[Vm-dev] VM Maker: VMMaker.oscog-eem.1111.mcz
commits at source.squeak.org
commits at source.squeak.org
Mon Mar 23 01:40:24 UTC 2015
Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1111.mcz
==================== Summary ====================
Name: VMMaker.oscog-eem.1111
Author: eem
Time: 22 March 2015, 6:38:13.789 pm
UUID: d49aabf6-9652-4eaf-b08d-0ccddc9c9146
Ancestors: VMMaker.oscog-eem.1110
Fix misgeneration of saveAndRestoreLinkRegAround:
by not marking as required <inline: true> methods
in CogAbstractInstruction. Has the nice side-effect
of deleting ~ 2000 lines of dead code from cogit.c.
Revert the bogus fix to preGenerationHook:.
Fix type coercion in propagateReturnIn: to not
generate unnecessary casts.
Fix baseTypeForType: to remove the function name
from function types that include a function name.
=============== Diff against VMMaker.oscog-eem.1110 ===============
Item was changed:
----- Method: CCodeGenerator>>baseTypeForType: (in category 'utilities') -----
baseTypeForType: aCType
"Reduce various declarations to the most basic type we can determine."
| type fpIndex closeidx openidx |
type := aCType.
((openidx := type indexOfSubCollection: 'const ') > 0
and: [openidx = 1 or: [(type at: openidx) isSeparator]]) ifTrue:
[type := type copyReplaceFrom: openidx to: openidx + 5 with: ''].
((type beginsWith: 'unsigned') and: [(type includes: $:) and: [type last isDigit]]) ifTrue:
[^#usqInt].
+ "collapse e.g. void (*foo(int bar))(void) to void (*)(void)"
(fpIndex := type indexOfSubCollection: '(*') > 0 ifTrue:
+ ["elide the function arguments after *, if there are any"
+ type := type copyReplaceFrom: (type indexOf: $( startingAt: fpIndex + 1)
- [type := type copyReplaceFrom: (type indexOf: $( startingAt: fpIndex + 1)
to: (type indexOf: $) startingAt: fpIndex + 1)
+ with: ''.
+ "elide the function name after *, if there is one"
+ type := type copyReplaceFrom: fpIndex + 2
+ to: (type indexOf: $) startingAt: fpIndex + 1)
+ with: ')'].
- with: ''].
"collapse [size] to *"
openidx := 0.
[(openidx := type indexOf: $[ startingAt: openidx + 1) > 0
and: [(closeidx := type indexOf: $] startingAt: openidx + 1) > 0]] whileTrue:
[type := type copyReplaceFrom: openidx to: closeidx with: '*'].
^type withBlanksTrimmed!
Item was changed:
----- Method: CogAbstractInstruction class>>requiredMethodNames: (in category 'translation') -----
requiredMethodNames: options
^self selectors reject:
[:s|
(self isAccessor: s)
+ or: [((self compiledMethodAt: s) pragmaAt: #doNotGenerate) notNil
+ or: [((self compiledMethodAt: s) pragmaAt: #inline:) notNil
+ and: [((self compiledMethodAt: s) pragmaAt: #inline:) arguments first == true]]]]!
- or: [((self compiledMethodAt: s) pragmaAt: #doNotGenerate) notNil]]!
Item was changed:
----- Method: Cogit class>>preGenerationHook: (in category 'translation') -----
preGenerationHook: aCCodeGenerator
"Perform any last-minute changes to the code generator immediately
before it performs code analysis and generation. In this case, make
all non-exported methods private."
| exportAPISelectors |
exportAPISelectors := self exportAPISelectors: aCCodeGenerator options.
aCCodeGenerator selectorsAndMethodsDo:
[:s :m|
(exportAPISelectors includes: s)
ifTrue: [m static: false]
ifFalse:
[m export ifFalse:
+ [m static: true]]]!
- [m static: true]]].
- aCCodeGenerator pruneMethods: #(saveAndRestoreLinkRegAround:)!
Item was changed:
----- Method: Cogit>>genEnilopmartFor:and:and:forCall:called: (in category 'initialization') -----
genEnilopmartFor: regArg1 and: regArg2 and: regArg3 forCall: forCall called: trampolineName
"An enilopmart (the reverse of a trampoline) is a piece of code that makes
the system-call-like transition from the C runtime into generated machine
code. The desired arguments and entry-point are pushed on a stackPage's
stack. The enilopmart pops off the values to be loaded into registers and
then executes a return instruction to pop off the entry-point and jump to it.
BEFORE AFTER (stacks grow down)
whatever stackPointer -> whatever
target address => reg1 = reg1val, etc
reg1val pc = target address
reg2val
stackPointer -> reg3val"
+ <returnTypeC: #'void (*genEnilopmartForandandforCallcalled(sqInt regArg1, sqInt regArg2, sqInt regArg3, sqInt forCall, sqInt trampolineName))(void)'>
- <returnTypeC: #'void (*)(void)'>
| size endAddress enilopmart |
opcodeIndex := 0.
backEnd genLoadStackPointers.
regArg3 ifNotNil: [self PopR: regArg3].
regArg2 ifNotNil: [self PopR: regArg2].
self PopR: regArg1.
self genEnilopmartReturn: forCall.
self computeMaximumSizes.
size := self generateInstructionsAt: methodZoneBase.
endAddress := self outputInstructionsAt: methodZoneBase.
self assert: methodZoneBase + size = endAddress.
enilopmart := methodZoneBase.
methodZoneBase := self alignUptoRoutineBoundary: endAddress.
backEnd nopsFrom: endAddress to: methodZoneBase - 1.
self recordGeneratedRunTime: trampolineName address: enilopmart.
^self cCoerceSimple: enilopmart to: #'void (*)(void)'!
Item was changed:
----- Method: TMethod>>propagateReturnIn: (in category 'inlining support') -----
propagateReturnIn: aCodeGen
"Propagate the return type to all return nodes"
| map coercionType |
returnType = #void ifTrue:
[^self].
"The following is necessary for functions returning functions, which have problematic syntax"
coercionType := aCodeGen
extractTypeFor: (aCodeGen cFunctionNameFor: self selector)
fromDeclaration: returnType.
map := IdentityDictionary new.
parseTree nodesDo:[:node|
+ (node isReturn
+ and: [(aCodeGen typeFor: node expression in: self) ~= coercionType]) ifTrue:
+ [map at: node expression put: (TSendNode new
- node isReturn ifTrue:[
- map at: node expression put: (TSendNode new
setSelector: #cCoerce:to:
receiver: (TVariableNode new setName: 'self')
arguments: {node expression.
TConstantNode new setValue: coercionType})]].
self replaceNodesIn: map!
More information about the Vm-dev
mailing list