[Vm-dev] VM Maker: VMMaker.oscog-sk.2261.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Aug 10 09:05:01 UTC 2017
Sophie Kaleba uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-sk.2261.mcz
==================== Summary ====================
Name: VMMaker.oscog-sk.2261
Author: sk
Time: 10 August 2017, 11:03:27.62493 am
UUID: 2502e8bf-7a6c-4656-ab61-b3da8e6f5199
Ancestors: VMMaker.oscog-eem.2260
Modify the profiling primitive cogCodeConstituents: to be able to differentiate the closedPICs from the openPICs in the profiling report
=============== Diff against VMMaker.oscog-eem.2260 ===============
Item was changed:
----- Method: Cogit>>cogCodeConstituents: (in category 'profiling primitives') -----
cogCodeConstituents: withDetails
"Answer the contents of the code zone as an array of pair-wise element, address in ascending address order.
Answer a string for a runtime routine or abstract label (beginning, end, etc), a CompiledMethod for a CMMethod,
or a selector (presumably a Symbol) for a PIC."
<api>
| count cogMethod constituents label value |
<var: #cogMethod type: #'CogMethod *'>
count := trampolineTableIndex / 2 + 3. "+ 3 for start, freeStart and end"
cogMethod := self cCoerceSimple: methodZoneBase to: #'CogMethod *'.
[cogMethod < methodZone limitZony] whileTrue:
[cogMethod cmType ~= CMFree ifTrue:
[count := count + 1].
cogMethod := methodZone methodAfter: cogMethod].
constituents := coInterpreter instantiateClass: coInterpreter classArray indexableSize: count * 2.
constituents ifNil:
[^constituents].
coInterpreter pushRemappableOop: constituents.
((label := objectMemory stringForCString: 'CogCode') isNil
or: [(value := self positiveMachineIntegerFor: codeBase) isNil]) ifTrue:
[^nil].
coInterpreter
storePointerUnchecked: 0 ofObject: coInterpreter topRemappableOop withValue: label;
storePointerUnchecked: 1 ofObject: coInterpreter topRemappableOop withValue: value.
0 to: trampolineTableIndex - 1 by: 2 do:
[:i|
((label := objectMemory stringForCString: (trampolineAddresses at: i)) isNil
or: [(value := self positiveMachineIntegerFor: (trampolineAddresses at: i + 1) asUnsignedInteger) isNil]) ifTrue:
[coInterpreter popRemappableOop.
^nil].
coInterpreter
storePointerUnchecked: 2 + i ofObject: coInterpreter topRemappableOop withValue: label;
storePointerUnchecked: 3 + i ofObject: coInterpreter topRemappableOop withValue: value].
count := trampolineTableIndex + 2.
cogMethod := self cCoerceSimple: methodZoneBase to: #'CogMethod *'.
[cogMethod < methodZone limitZony] whileTrue:
[cogMethod cmType ~= CMFree ifTrue:
[coInterpreter
storePointerUnchecked: count
ofObject: coInterpreter topRemappableOop
+ withValue: (self valueOf: cogMethod).
- withValue: (cogMethod cmType = CMMethod
- ifTrue: [cogMethod methodObject]
- ifFalse: [cogMethod selector]).
value := withDetails
ifFalse: [self positiveMachineIntegerFor: cogMethod asUnsignedInteger]
ifTrue: [self collectCogMethodConstituent: cogMethod].
value ifNil: [coInterpreter popRemappableOop. ^nil].
coInterpreter
storePointerUnchecked: count + 1
ofObject: coInterpreter topRemappableOop
withValue: value.
count := count + 2].
cogMethod := methodZone methodAfter: cogMethod].
((label := objectMemory stringForCString: 'CCFree') isNil
or: [(value := self positiveMachineIntegerFor: methodZone zoneFree) isNil]) ifTrue:
[coInterpreter popRemappableOop.
^nil].
coInterpreter
storePointerUnchecked: count ofObject: coInterpreter topRemappableOop withValue: label;
storePointerUnchecked: count + 1 ofObject: coInterpreter topRemappableOop withValue: value.
((label := objectMemory stringForCString: 'CCEnd') isNil
or: [(value := self positiveMachineIntegerFor: methodZone zoneEnd) isNil]) ifTrue:
[coInterpreter popRemappableOop.
^nil].
coInterpreter
storePointerUnchecked: count + 2 ofObject: coInterpreter topRemappableOop withValue: label;
storePointerUnchecked: count + 3 ofObject: coInterpreter topRemappableOop withValue: value.
constituents := coInterpreter popRemappableOop.
coInterpreter beRootIfOld: constituents.
^constituents!
Item was added:
+ ----- Method: Cogit>>createCPICData: (in category 'profiling primitives') -----
+ createCPICData: cPIC
+ <var: #cPIC type: #'CogMethod *'>
+ | pc entryPoint targetMethod value array |
+ <var: #targetMethod type: #'CogMethod *'>
+ array := 1.
+ array := objectMemory instantiateClass: objectMemory classArray indexableSize: 1 + cPIC cPICNumCases.
+ objectMemory storePointerUnchecked: 0 ofObject: array withValue: cPIC selector.
+ 1 to: cPIC cPICNumCases do:
+ [:i|
+ pc := self addressOfEndOfCase: i inCPIC: cPIC.
+ entryPoint := i = 1
+ ifTrue: [backEnd jumpLongTargetBeforeFollowingAddress: pc]
+ ifFalse: [backEnd jumpLongConditionalTargetBeforeFollowingAddress: pc].
+ "Find target from jump. A jump to the MNU entry-point should collect #doesNotUnderstand:"
+ (cPIC containsAddress: entryPoint)
+ ifTrue:
+ [value := objectMemory splObj: SelectorDoesNotUnderstand]
+ ifFalse:
+ [targetMethod := self cCoerceSimple: entryPoint - cmNoCheckEntryOffset to: #'CogMethod *'.
+ self assert: targetMethod cmType = CMMethod.
+ value := targetMethod methodObject].
+ objectMemory storePointer: i ofObject: array withValue: value].
+ ^ array!
Item was added:
+ ----- Method: Cogit>>valueOf: (in category 'profiling primitives') -----
+ valueOf: cogMethod
+ "gives the type of the cogMethod and returns a CompiledMethod for a compiled method, a selector for an openPIC or an array containing a selector followed by the methods present in the closedPIC for a closedPIC"
+
+ <var: #cogMethod type: #'CogMethod *'>
+ ^cogMethod cmType = CMMethod
+ ifTrue: [cogMethod methodObject]
+ ifFalse: [cogMethod cmType = CMClosedPIC
+ ifTrue: [self createCPICData: cogMethod.]
+ ifFalse: [cogMethod selector]]
+ !
More information about the Vm-dev
mailing list