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> 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


The PR includes a couple of fixes, tests, and cleanups.
The mashed log is

Fixes on primitiveMethodXray:

  • 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

Expose method profiling data (PICs and linked sends type information):

Rename dollowing the literature:

  • OpenPIC -> MegamorphicIC
  • ClosedPIC -> PolymorphicIC

Cleanups:

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


_______________________________________________
Pharo-vm mailing list -- pharo-vm@lists.pharo.org
To unsubscribe send an email to pharo-vm-leave@lists.pharo.org