[Vm-dev] VM Maker: VMMaker.oscog-eem.1312.mcz
commits at source.squeak.org
commits at source.squeak.org
Mon May 18 00:43:05 UTC 2015
Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1312.mcz
==================== Summary ====================
Name: VMMaker.oscog-eem.1312
Author: eem
Time: 17 May 2015, 5:41:05.845 pm
UUID: f2ba142e-f4e1-43de-9f3e-b33fa10e5e45
Ancestors: VMMaker.oscog-eem.1311
Make accessor depth calculation more accurate by
not considering fetchInteger:ofObject: and arraySize:
et al as object accessors.
Make the read-before-written initializer safer, only
initialzing simple types (integers and pointers).
Be prepared to answer the size of usqInt.
=============== Diff against VMMaker.oscog-eem.1311 ===============
Item was changed:
----- Method: CCodeGenerator>>accessorDepthForChain: (in category 'spur primitive compilation') -----
accessorDepthForChain: chain "OrderedCollection"
"Answer the actual number of accessors in the access chain, filtering out assignments of variables to variables."
| accessorDepth |
accessorDepth := 0.
chain do:
[:node|
+ ((node isAssignment and: [node expression isVariable])
+ or: [node isSend and: [SpurMemoryManager isSameLevelObjectAccessor: node selector]]) ifFalse:
- (node isAssignment and: [node expression isVariable]) ifFalse:
[accessorDepth := accessorDepth + 1]].
^accessorDepth!
Item was changed:
----- Method: CCodeGenerator>>accessorsAndAssignmentsForMethod:actuals:depth:interpreterClass:into: (in category 'spur primitive compilation') -----
accessorsAndAssignmentsForMethod: method actuals: actualParameters depth: depth interpreterClass: interpreterClass into: aTrinaryBlock
"Evaluate aTrinaryBlock with the root accessor sends, accessor sends and assignments in the method."
| accessors assignments roots |
accessors := Set new.
assignments := Set new.
roots := Set new.
actualParameters with: method args do:
[:actual :argName|
(actual isVariable or: [actual isSend]) ifTrue:
[(actual isSend and: [self isStackAccessor: actual selector given: interpreterClass]) ifTrue:
[roots add: actual].
assignments add: (TAssignmentNode new
setVariable: (TVariableNode new setName: argName)
expression: actual)]].
method parseTree nodesDo:
[:node|
node isSend ifTrue:
[(self isStackAccessor: node selector given: interpreterClass) ifTrue:
[roots add: node].
(self isObjectAccessor: node selector given: interpreterClass) ifTrue:
[accessors add: node].
(self accessorDepthDeterminationFollowsSelfSends
and: [node receiver isVariable
and: [node receiver name = 'self'
and: [roots isEmpty
or: [node args anySatisfy:
[:arg|
(roots includes: arg)
or: [(accessors includes: arg)
or: [assignments anySatisfy: [:assignment| assignment variable isSameAs: arg]]]]]]]]) ifTrue:
[self accessorsAndAssignmentsForSubMethodNamed: node selector
actuals: node args
depth: depth + 1
interpreterClass: interpreterClass
into: [:subRoots :subAccessors :subAssignments|
(subRoots isEmpty and: [subAccessors isEmpty and: [subAssignments isEmpty]]) ifFalse:
[roots addAll: subRoots.
accessors add: node.
accessors addAll: subAccessors.
assignments addAll: subAssignments]]]].
(node isAssignment
+ and: [(node expression isSend and: [SpurMemoryManager isTerminalObjectAccessor: node expression selector]) not
and: [(roots includes: node expression)
or: [(accessors includes: node expression)
+ or: [node expression isVariable and: [node expression name ~= 'nil']]]]]) ifTrue:
- or: [node expression isVariable and: [node expression name ~= 'nil']]]]) ifTrue:
[assignments add: node]].
^aTrinaryBlock
value: roots
value: accessors
value: assignments!
Item was added:
+ ----- Method: CCodeGenerator>>isSimpleType: (in category 'type inference') -----
+ isSimpleType: aType
+ "For the purposes of the read-before-written initializer, answer if
+ aType is simple, e.g. not a structure, and array or an opaque type."
+ ^aType last = $*
+ or: [#( sqInt usqInt sqLong usqLong
+ int #'unsigned int' double float
+ short #'unsigned short'
+ char #'unsigned char' #'signed char') includes: aType]!
Item was added:
+ ----- Method: SpurMemoryManager class>>isSameLevelObjectAccessor: (in category 'translation') -----
+ isSameLevelObjectAccessor: selector
+ "For accessor depth calculation, answer if selector doesn't traverse into an object, merely deriving a pointer from it."
+ ^#(arrayValueOf: firstFixedField: firstIndexableField:) includes: selector!
Item was added:
+ ----- Method: SpurMemoryManager class>>isTerminalObjectAccessor: (in category 'translation') -----
+ isTerminalObjectAccessor: selector
+ "For accessor depth calculation, answer if selector doesn't answer another object object; merely a value."
+ ^#(byteSizeOf: fetchFloat:ofObject: fetchInteger:ofObject: fetchLong32:ofObject: instanceSizeOf: slotSizeOf: stSizeOf:) includes: selector!
Item was changed:
----- Method: TMethod>>removeUnusedTempsAndNilIfRequiredIn: (in category 'utilities') -----
removeUnusedTempsAndNilIfRequiredIn: aCodeGen
"Remove all of the unused temps in this method. Answer a set of the references.
As a side-effect introduce explicit temp := nil statements for temps that are
tested for nil before necessarily being assigned."
| refs readBeforeAssigned |
refs := self removeUnusedTempsIn: aCodeGen.
"reset the locals to be only those still referred to"
locals := locals select: [:e| refs includes: e].
(locals notEmpty
and: [aCodeGen
pushScope: declarations
+ while: [(readBeforeAssigned := (self findReadBeforeAssignedIn: (locals select: [:ea| aCodeGen isSimpleType: (self typeFor: ea in: aCodeGen)])
+ in: aCodeGen)) notEmpty]]) ifTrue:
- while: [(readBeforeAssigned := (self findReadBeforeAssignedIn: locals in: aCodeGen)) notEmpty]]) ifTrue:
[readBeforeAssigned := readBeforeAssigned reject:
[:v| | d | "don't initialize externs, arrays or the explicitly initialized."
d := self declarationAt: v.
(d beginsWith: 'extern') or: [(d includes: $[) or: [d includes: $=]]].
parseTree statements addAllFirst:
(readBeforeAssigned asSortedCollection collect:
[:var|
TAssignmentNode new
setVariable: (TVariableNode new setName: var; yourself)
expression: (TConstantNode new setValue: 0; yourself)])].
^refs!
Item was changed:
----- Method: VMClass>>sizeof: (in category 'translation support') -----
sizeof: objectSymbolOrClass
<doNotGenerate>
| index |
objectSymbolOrClass isInteger ifTrue:
[^self class objectMemoryClass wordSize].
objectSymbolOrClass isSymbol ifTrue:
[(objectSymbolOrClass last == $*
or: [#long == objectSymbolOrClass
or: [#'unsigned long' == objectSymbolOrClass]]) ifTrue:
[^self class objectMemoryClass wordSize].
index := #( #sqLong #usqLong #double
#int #'unsigned int' #float
#short #'unsigned short'
#char #'unsigned char' #'signed char')
indexOf: objectSymbolOrClass
ifAbsent:
+ [(#(usqInt sqInt) includes: objectSymbolOrClass) ifTrue: [^self class objectMemoryClass bytesPerOop].
- [objectSymbolOrClass = #sqInt ifTrue: [^self class objectMemoryClass bytesPerOop].
self error: 'unrecognized C type name'].
^#(8 8 8
4 4 4
2 2
1 1 1) at: index].
^(objectSymbolOrClass isBehavior
ifTrue: [objectSymbolOrClass]
ifFalse: [objectSymbolOrClass class])
alignedByteSizeOf: objectSymbolOrClass
forClient: self!
More information about the Vm-dev
mailing list