Hi In CoInterpreter we can find initializePrimitiveTable super initializePrimitiveTable. PrimNumberHashMultiply := 159. self assert: (PrimitiveTable at: PrimNumberHashMultiply + 1) = #primitiveHashMultiply. #(216 253) do: [:pidx| self assert: (PrimitiveTable at: pidx + 1) = #primitiveFail]. self assert: (PrimitiveTable at: 215 + 1) = #primitiveFlushCacheByMethod. PrimitiveTable at: 253 + 1 put: #primitiveCollectCogCodeConstituents; at: 215 + 1 put: #primitiveVoidVMStateForMethod; at: 216 + 1 put: #primitiveMethodXray There is a primitive primitiveMethodXray :) primitiveMethodXray "Lift the veil from a method and answer an integer describing the interior state of its machine code. Used for e.g. VM tests so they can verify they're testing what they think they're testing. 0 implies a vanilla method. Bit 0 = method might be compiled to machine code Bit 1 = method is currently compiled to machine code Bit 2 = is compiled frameless. Bit 3 = method refers to young object. Bit 4 = method too big to be jitted (more than 64k of code, or needs more than 1.5Mb of stack space to compile) Bit 5 = method contains unknown/unjittable bytecode Bit 6 = method should not be jitted because it contains a primitive not to be called from machine code (unused)" | alreadyCogged flags cogMethod | <var: #cogMethod type: #'CogMethod *'> (self methodWithHeaderShouldBeCogged: (objectMemory methodHeaderOf: self stackTop)) ifTrue: [alreadyCogged := self maybeMethodHasCogMethod: self stackTop. flags := 1. alreadyCogged ifFalse: [cogMethod := cogit cog: self stackTop selector: objectMemory nilObject. (cogMethod = nil and: [cogCompiledCodeCompactionCalledFor]) ifTrue: [self commenceCogCompiledCodeCompaction. cogMethod := cogit cog: self stackTop selector: objectMemory nilObject]. cogMethod asInteger caseOf: { [MethodTooBig] -> [flags := 1 + 16]. [EncounteredUnknownBytecode] -> [flags := 1 + 32]. [ShouldNotJIT] -> [flags := 1 + 64] } otherwise: [self deny: (cogMethod asInteger between: MaxNegativeErrorCode and: NotFullyInitialized)]]. (flags = 1 and: [self maybeMethodHasCogMethod: self stackTop]) ifTrue: [cogMethod := self cogMethodOf: self stackTop. flags := cogMethod stackCheckOffset = 0 ifTrue: [7] ifFalse: [3]. cogMethod cmRefersToYoung ifTrue: [flags := flags + 8]. alreadyCogged ifFalse: [cogit freeMethod: cogMethod]]] ifFalse: [flags := 0]. self pop: 1 thenPush: (objectMemory integerObjectOf: flags) and I wanted to execute it. So on compiledMethod I defined a method CompiledMethod >> xray <primitive: 216> and I did (Point>>#degrees) xray but when I execute I get a compiled method and not an integer. So I probably do something silly. But I would like to understand what. Tx
Just as a follow-up, last week we did together with Jean Privat and Stef a pass on this primitive, and the primitive that exposes method pic information. The work we did can be found in the following PR https://github.com/pharo-project/pharo-vm/pull/463 The PR includes a couple of fixes, tests, and cleanups. The mashed log is Fixes on primitiveMethodXray <https://github.com/pharo-project/pharo-vm/pull/463/commits/67780af2e454a348f...>: fixing flags + tests use externalWriteBackHeadFramePointers before code compaction to ensure stacks are in sync declare it as maycallback to ensure call is made through a trampoline and the return address remains correct after compacting jit code Protect method freeing in xray primitive <https://github.com/pharo-project/pharo-vm/commit/8a4b4b4ee93ea6ff71ca5671ae6...> Expose method profiling data (PICs and linked sends type information): Expose method profiling data <https://github.com/pharo-project/pharo-vm/commit/dbf4154e553109ff17757f4565c...> rename picData -> profilingData as it may yield also execution counters do not expose counters if not available Fix type of methodClassIfSuper, restore array shrinking <https://github.com/pharo-project/pharo-vm/commit/903ba641446c591412b59ff4f25...> Rename dollowing the literature <https://github.com/pharo-project/pharo-vm/pull/463/commits/10aba4ad1d6db0460...>: OpenPIC -> MegamorphicIC ClosedPIC -> PolymorphicIC Cleanups: Adding notYetImplemented with message parameter <https://github.com/pharo-project/pharo-vm/commit/75be0cddfe3037aa5f574c6a379...> Remove old block compilation related methods <https://github.com/pharo-project/pharo-vm/commit/a806e2f7811973cdfca76f47ee6...> Remove SistaCogitClone <https://github.com/pharo-project/pharo-vm/commit/7ea5b11e031707b83b1b6ca0371...> Cleaning morphic related method <https://github.com/pharo-project/pharo-vm/commit/1ee56c2528503f6380415085a11...> Cheers, G
El 15 sept 2022, a las 21:15, stephane ducasse <stephane.ducasse@inria.fr> escribió:
Hi
In CoInterpreter we can find
initializePrimitiveTable super initializePrimitiveTable. PrimNumberHashMultiply := 159. self assert: (PrimitiveTable at: PrimNumberHashMultiply + 1) = #primitiveHashMultiply.
#(216 253) do: [:pidx| self assert: (PrimitiveTable at: pidx + 1) = #primitiveFail]. self assert: (PrimitiveTable at: 215 + 1) = #primitiveFlushCacheByMethod. PrimitiveTable at: 253 + 1 put: #primitiveCollectCogCodeConstituents; at: 215 + 1 put: #primitiveVoidVMStateForMethod; at: 216 + 1 put: #primitiveMethodXray
There is a primitive primitiveMethodXray :)
primitiveMethodXray "Lift the veil from a method and answer an integer describing the interior state of its machine code. Used for e.g. VM tests so they can verify they're testing what they think they're testing. 0 implies a vanilla method. Bit 0 = method might be compiled to machine code Bit 1 = method is currently compiled to machine code Bit 2 = is compiled frameless. Bit 3 = method refers to young object. Bit 4 = method too big to be jitted (more than 64k of code, or needs more than 1.5Mb of stack space to compile) Bit 5 = method contains unknown/unjittable bytecode Bit 6 = method should not be jitted because it contains a primitive not to be called from machine code (unused)" | alreadyCogged flags cogMethod | <var: #cogMethod type: #'CogMethod *'> (self methodWithHeaderShouldBeCogged: (objectMemory methodHeaderOf: self stackTop)) ifTrue: [alreadyCogged := self maybeMethodHasCogMethod: self stackTop. flags := 1. alreadyCogged ifFalse: [cogMethod := cogit cog: self stackTop selector: objectMemory nilObject. (cogMethod = nil and: [cogCompiledCodeCompactionCalledFor]) ifTrue: [self commenceCogCompiledCodeCompaction. cogMethod := cogit cog: self stackTop selector: objectMemory nilObject]. cogMethod asInteger caseOf: { [MethodTooBig] -> [flags := 1 + 16]. [EncounteredUnknownBytecode] -> [flags := 1 + 32]. [ShouldNotJIT] -> [flags := 1 + 64] } otherwise: [self deny: (cogMethod asInteger between: MaxNegativeErrorCode and: NotFullyInitialized)]]. (flags = 1 and: [self maybeMethodHasCogMethod: self stackTop]) ifTrue: [cogMethod := self cogMethodOf: self stackTop. flags := cogMethod stackCheckOffset = 0 ifTrue: [7] ifFalse: [3]. cogMethod cmRefersToYoung ifTrue: [flags := flags + 8]. alreadyCogged ifFalse: [cogit freeMethod: cogMethod]]] ifFalse: [flags := 0]. self pop: 1 thenPush: (objectMemory integerObjectOf: flags)
and I wanted to execute it.
So on compiledMethod I defined a method
CompiledMethod >> xray
<primitive: 216>
and I did (Point>>#degrees) xray but when I execute I get a compiled method and not an integer.
So I probably do something silly. But I would like to understand what.
Tx
_______________________________________________ Pharo-vm mailing list -- pharo-vm@lists.pharo.org To unsubscribe send an email to pharo-vm-leave@lists.pharo.org
Thanks guille for the recap. It was a cool session and we learned a lot from you. S
On 24 Sep 2022, at 22:19, Guillermo Polito <guillermopolito@gmail.com> wrote:
Just as a follow-up, last week we did together with Jean Privat and Stef a pass on this primitive, and the primitive that exposes method pic information. The work we did can be found in the following PR
https://github.com/pharo-project/pharo-vm/pull/463 <https://github.com/pharo-project/pharo-vm/pull/463>
The PR includes a couple of fixes, tests, and cleanups. The mashed log is
Fixes on primitiveMethodXray <https://github.com/pharo-project/pharo-vm/pull/463/commits/67780af2e454a348f...>:
fixing flags + tests use externalWriteBackHeadFramePointers before code compaction to ensure stacks are in sync declare it as maycallback to ensure call is made through a trampoline and the return address remains correct after compacting jit code Protect method freeing in xray primitive <https://github.com/pharo-project/pharo-vm/commit/8a4b4b4ee93ea6ff71ca5671ae6...> Expose method profiling data (PICs and linked sends type information):
Expose method profiling data <https://github.com/pharo-project/pharo-vm/commit/dbf4154e553109ff17757f4565c...> rename picData -> profilingData as it may yield also execution counters do not expose counters if not available Fix type of methodClassIfSuper, restore array shrinking <https://github.com/pharo-project/pharo-vm/commit/903ba641446c591412b59ff4f25...> Rename dollowing the literature <https://github.com/pharo-project/pharo-vm/pull/463/commits/10aba4ad1d6db0460...>:
OpenPIC -> MegamorphicIC ClosedPIC -> PolymorphicIC Cleanups:
Adding notYetImplemented with message parameter <https://github.com/pharo-project/pharo-vm/commit/75be0cddfe3037aa5f574c6a379...> Remove old block compilation related methods <https://github.com/pharo-project/pharo-vm/commit/a806e2f7811973cdfca76f47ee6...> Remove SistaCogitClone <https://github.com/pharo-project/pharo-vm/commit/7ea5b11e031707b83b1b6ca0371...> Cleaning morphic related method <https://github.com/pharo-project/pharo-vm/commit/1ee56c2528503f6380415085a11...> Cheers, G
El 15 sept 2022, a las 21:15, stephane ducasse <stephane.ducasse@inria.fr <mailto:stephane.ducasse@inria.fr>> escribió:
Hi
In CoInterpreter we can find
initializePrimitiveTable super initializePrimitiveTable. PrimNumberHashMultiply := 159. self assert: (PrimitiveTable at: PrimNumberHashMultiply + 1) = #primitiveHashMultiply.
#(216 253) do: [:pidx| self assert: (PrimitiveTable at: pidx + 1) = #primitiveFail]. self assert: (PrimitiveTable at: 215 + 1) = #primitiveFlushCacheByMethod. PrimitiveTable at: 253 + 1 put: #primitiveCollectCogCodeConstituents; at: 215 + 1 put: #primitiveVoidVMStateForMethod; at: 216 + 1 put: #primitiveMethodXray
There is a primitive primitiveMethodXray :)
primitiveMethodXray "Lift the veil from a method and answer an integer describing the interior state of its machine code. Used for e.g. VM tests so they can verify they're testing what they think they're testing. 0 implies a vanilla method. Bit 0 = method might be compiled to machine code Bit 1 = method is currently compiled to machine code Bit 2 = is compiled frameless. Bit 3 = method refers to young object. Bit 4 = method too big to be jitted (more than 64k of code, or needs more than 1.5Mb of stack space to compile) Bit 5 = method contains unknown/unjittable bytecode Bit 6 = method should not be jitted because it contains a primitive not to be called from machine code (unused)" | alreadyCogged flags cogMethod | <var: #cogMethod type: #'CogMethod *'> (self methodWithHeaderShouldBeCogged: (objectMemory methodHeaderOf: self stackTop)) ifTrue: [alreadyCogged := self maybeMethodHasCogMethod: self stackTop. flags := 1. alreadyCogged ifFalse: [cogMethod := cogit cog: self stackTop selector: objectMemory nilObject. (cogMethod = nil and: [cogCompiledCodeCompactionCalledFor]) ifTrue: [self commenceCogCompiledCodeCompaction. cogMethod := cogit cog: self stackTop selector: objectMemory nilObject]. cogMethod asInteger caseOf: { [MethodTooBig] -> [flags := 1 + 16]. [EncounteredUnknownBytecode] -> [flags := 1 + 32]. [ShouldNotJIT] -> [flags := 1 + 64] } otherwise: [self deny: (cogMethod asInteger between: MaxNegativeErrorCode and: NotFullyInitialized)]]. (flags = 1 and: [self maybeMethodHasCogMethod: self stackTop]) ifTrue: [cogMethod := self cogMethodOf: self stackTop. flags := cogMethod stackCheckOffset = 0 ifTrue: [7] ifFalse: [3]. cogMethod cmRefersToYoung ifTrue: [flags := flags + 8]. alreadyCogged ifFalse: [cogit freeMethod: cogMethod]]] ifFalse: [flags := 0]. self pop: 1 thenPush: (objectMemory integerObjectOf: flags)
and I wanted to execute it.
So on compiledMethod I defined a method
CompiledMethod >> xray
<primitive: 216>
and I did (Point>>#degrees) xray but when I execute I get a compiled method and not an integer.
So I probably do something silly. But I would like to understand what.
Tx
_______________________________________________ Pharo-vm mailing list -- pharo-vm@lists.pharo.org <mailto:pharo-vm@lists.pharo.org> To unsubscribe send an email to pharo-vm-leave@lists.pharo.org <mailto:pharo-vm-leave@lists.pharo.org>
Wwoooooo this is very nice!!! Congrats ð
On 25 Sep 2022, at 08:31, stephane ducasse <stephane.ducasse@inria.fr> wrote:
Thanks guille for the recap. It was a cool session and we learned a lot from you.
S
On 24 Sep 2022, at 22:19, Guillermo Polito <guillermopolito@gmail.com <mailto:guillermopolito@gmail.com>> wrote:
Just as a follow-up, last week we did together with Jean Privat and Stef a pass on this primitive, and the primitive that exposes method pic information. The work we did can be found in the following PR
https://github.com/pharo-project/pharo-vm/pull/463 <https://github.com/pharo-project/pharo-vm/pull/463>
The PR includes a couple of fixes, tests, and cleanups. The mashed log is
Fixes on primitiveMethodXray <https://github.com/pharo-project/pharo-vm/pull/463/commits/67780af2e454a348f...>:
fixing flags + tests use externalWriteBackHeadFramePointers before code compaction to ensure stacks are in sync declare it as maycallback to ensure call is made through a trampoline and the return address remains correct after compacting jit code Protect method freeing in xray primitive <https://github.com/pharo-project/pharo-vm/commit/8a4b4b4ee93ea6ff71ca5671ae6...> Expose method profiling data (PICs and linked sends type information):
Expose method profiling data <https://github.com/pharo-project/pharo-vm/commit/dbf4154e553109ff17757f4565c...> rename picData -> profilingData as it may yield also execution counters do not expose counters if not available Fix type of methodClassIfSuper, restore array shrinking <https://github.com/pharo-project/pharo-vm/commit/903ba641446c591412b59ff4f25...> Rename dollowing the literature <https://github.com/pharo-project/pharo-vm/pull/463/commits/10aba4ad1d6db0460...>:
OpenPIC -> MegamorphicIC ClosedPIC -> PolymorphicIC Cleanups:
Adding notYetImplemented with message parameter <https://github.com/pharo-project/pharo-vm/commit/75be0cddfe3037aa5f574c6a379...> Remove old block compilation related methods <https://github.com/pharo-project/pharo-vm/commit/a806e2f7811973cdfca76f47ee6...> Remove SistaCogitClone <https://github.com/pharo-project/pharo-vm/commit/7ea5b11e031707b83b1b6ca0371...> Cleaning morphic related method <https://github.com/pharo-project/pharo-vm/commit/1ee56c2528503f6380415085a11...> Cheers, G
El 15 sept 2022, a las 21:15, stephane ducasse <stephane.ducasse@inria.fr <mailto:stephane.ducasse@inria.fr>> escribió:
Hi
In CoInterpreter we can find
initializePrimitiveTable super initializePrimitiveTable. PrimNumberHashMultiply := 159. self assert: (PrimitiveTable at: PrimNumberHashMultiply + 1) = #primitiveHashMultiply.
#(216 253) do: [:pidx| self assert: (PrimitiveTable at: pidx + 1) = #primitiveFail]. self assert: (PrimitiveTable at: 215 + 1) = #primitiveFlushCacheByMethod. PrimitiveTable at: 253 + 1 put: #primitiveCollectCogCodeConstituents; at: 215 + 1 put: #primitiveVoidVMStateForMethod; at: 216 + 1 put: #primitiveMethodXray
There is a primitive primitiveMethodXray :)
primitiveMethodXray "Lift the veil from a method and answer an integer describing the interior state of its machine code. Used for e.g. VM tests so they can verify they're testing what they think they're testing. 0 implies a vanilla method. Bit 0 = method might be compiled to machine code Bit 1 = method is currently compiled to machine code Bit 2 = is compiled frameless. Bit 3 = method refers to young object. Bit 4 = method too big to be jitted (more than 64k of code, or needs more than 1.5Mb of stack space to compile) Bit 5 = method contains unknown/unjittable bytecode Bit 6 = method should not be jitted because it contains a primitive not to be called from machine code (unused)" | alreadyCogged flags cogMethod | <var: #cogMethod type: #'CogMethod *'> (self methodWithHeaderShouldBeCogged: (objectMemory methodHeaderOf: self stackTop)) ifTrue: [alreadyCogged := self maybeMethodHasCogMethod: self stackTop. flags := 1. alreadyCogged ifFalse: [cogMethod := cogit cog: self stackTop selector: objectMemory nilObject. (cogMethod = nil and: [cogCompiledCodeCompactionCalledFor]) ifTrue: [self commenceCogCompiledCodeCompaction. cogMethod := cogit cog: self stackTop selector: objectMemory nilObject]. cogMethod asInteger caseOf: { [MethodTooBig] -> [flags := 1 + 16]. [EncounteredUnknownBytecode] -> [flags := 1 + 32]. [ShouldNotJIT] -> [flags := 1 + 64] } otherwise: [self deny: (cogMethod asInteger between: MaxNegativeErrorCode and: NotFullyInitialized)]]. (flags = 1 and: [self maybeMethodHasCogMethod: self stackTop]) ifTrue: [cogMethod := self cogMethodOf: self stackTop. flags := cogMethod stackCheckOffset = 0 ifTrue: [7] ifFalse: [3]. cogMethod cmRefersToYoung ifTrue: [flags := flags + 8]. alreadyCogged ifFalse: [cogit freeMethod: cogMethod]]] ifFalse: [flags := 0]. self pop: 1 thenPush: (objectMemory integerObjectOf: flags)
and I wanted to execute it.
So on compiledMethod I defined a method
CompiledMethod >> xray
<primitive: 216>
and I did (Point>>#degrees) xray but when I execute I get a compiled method and not an integer.
So I probably do something silly. But I would like to understand what.
Tx
_______________________________________________ Pharo-vm mailing list -- pharo-vm@lists.pharo.org <mailto:pharo-vm@lists.pharo.org> To unsubscribe send an email to pharo-vm-leave@lists.pharo.org <mailto:pharo-vm-leave@lists.pharo.org>
_______________________________________________ Pharo-vm mailing list -- pharo-vm@lists.pharo.org To unsubscribe send an email to pharo-vm-leave@lists.pharo.org
participants (3)
-
Guillermo Polito -
Nahuel -
stephane ducasse