Pharo-vm
By thread
pharo-vm@lists.pharo.org
By month
Messages by month
- ----- 2026 -----
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
September 2022
- 7 participants
- 15 messages
Re: JIT Code Zone
by Guille Polito
Hi,
> El 26 sept 2022, a las 20:09, stephane ducasse <stephane.ducasse(a)inria.fr> escribió:
>
>
> Hello,
> I am wondering how the Pharo VM and Cogit manage the JIT code zone and have several questions related to that! I will ask my questions and what could be the answers, feel free to correct me!
>
> Context: I would like to secure this part of the VM, instrument accesses to it and experiment with changes in its layout/location!
>
> Initialization:
>
> When and how is the code zone memory allocated? And initialized?
> The allocation is made through the succession of: allocateMemoryForImage:withHeader: then allocateMemory:desiredPosition:. The initialization is made through initializeCodeZoneFrom:upTo: where trampolines, PIC prototypes and offsets are generated/computed.
Yes, take a look at the following line in #allocateMemoryForImage:withHeader:
cogCodeBase := self
allocateJITMemory: cogCodeSize
desiredPosition: header oldBaseAddr - cogCodeSize.
That method is defined only for the simulation as follows (see there is a <doNotGenerate> pragma)
allocateJITMemory: desiredSize _: desiredPosition
<doNotGenerate>
^ memoryManager allocate: desiredSize desiredPosition: desiredPosition
And then there are native implementations of allocateJITMemory() in the C code of the repository. E.g.,
void* allocateJITMemory(usqInt desiredSize, usqInt desiredPosition){
char *address, *alloc;
usqIntptr_t alignment;
sqInt allocBytes;
SYSTEM_INFO sysInfo;
/* determine page boundaries & available address space */
GetSystemInfo(&sysInfo);
pageSize = sysInfo.dwPageSize;
pageMask = ~(pageSize - 1);
minAppAddr = sysInfo.lpMinimumApplicationAddress;
maxAppAddr = sysInfo.lpMaximumApplicationAddress;
alignment = max(pageSize,1024*1024);
address = (char *)(((usqInt)desiredPosition + alignment - 1) & ~(alignment - 1));
alloc = sqAllocateMemorySegmentOfSizeAboveAllocatedSizeInto(roundUpToPage(desiredSize), address, &allocBytes);
if (!alloc) {
logErrorFromErrno("Could not allocate JIT memory");
exit(1);
}
return alloc;
}
> What is the layout of the different components of the code zone?
> Trampolines and methods/inline caches coexist, trampolines being the first thing generated.
The JIT code cache has two main spaces, delimited by the methodZoneBase.
The lower part of the JIT code cache (before the methodZoneBase) is the âTrampolineâ region, but it not only contains trampolines.
It contains also other reusable machine code routines for the runtime (for example, there is the routine that reifies the stack frames).
This part of the JIT code cache is fixed on VM initialization. Routines inside this part are not collected and are not moved/relocated.
The upper part of the JIT code cache contains methods, polymorphic inline caches and megamorphic inline caches.
This part is collected/compacted from time to time, here methods can move!
>
> Runtime:
> JIT compilation - What is the granularity of a JIT compilation? When does it write to machine code?
> The compiler processes bytecodes at the granularity of a method, using outputInstructionsForGeneratedRuntimeAt: or outputInstructionsAt:. It instruments the actual write with enableCodeZoneWriteDuring:flushingCacheWith:.
The core of the compilation is in the last three lines of compileCogMethod:
(result := self compileEntireMethod) < 0 ifTrue:
[^coInterpreter cCoerceSimple: result to: #'CogMethod *'].
^self generateCogMethod: selector
The first line generated the IR using a temporary memory buffer.
The last line generates the machine code from the IR.
If the question is how âatomicâ is the writing to the JIT code cache, my answer would be âit could be more atomicâ :).
Inside the machine code generation, the machine code for all instructions is written by outputInstructionsAt: as you say.
But the JIT does not only write instructions but also some metadata method header and a footer with machine code annotations.
> This step only needs write accesses to the method zone region (after the trampolines).
Yes, the move to ARMv8 and the new W^X restrictions forced us to explicitly identify in the code when the code cache is being modified.
That probably could help you.
If you want to know when the code cache is being written, just follow the senders of enableCodeZoneWriteDuring:flushingCacheWith:
> Garbage collection - When is the GC interfering with machine code? For rewriting and compaction?
> Marking with mapMachineCode: and compaction compactCogCompiledCode are the two ways the GC temper with machine code. While the first one only needs to read data, the second needs both read and write accesses.
Hmm, there are two aspects here.
The JIT code cache will get compacted when it reaches a threshold, by calling compactCogCompiledCode
The compaction will remove methods from the cache, and relink linked sends, so it requires some code patching.
On a second note, the heap GC will traverse the code cache to find roots.
The GC does only need read permissions to extract meta-data, disassemble some machine code and extract object references from the code cache.
So it does not need write nor execute permissoins.
>
> Interaction between interpreter and machine code - How is forward execution (interpreter - machine code) control flow performed? How is backward execution (machine code - interpreter) performed?
> I guess the trampolines ceEnterCogCodePopReceiverReg and ceReturnToInterpreter: are the main bridges between both worlds.
Yes, there is ceEnterCogCodePopReceiverReg and ceCallCogCodePopReceiverReg. The calling convention is that the interpreter puts the things required for the activation on the stack and call the enilopmarts.
The enilopmarts will then extract the info from the stack, put them into registers and call the machine code method.
The return is a bit more tricky.
What happens is that when an interpreter method calls a JIT method, we do not push to the stack the bytecode program counter (which will be useless for the machine code).
Instead, we push the address to a trampoline that knows how to return.
The machine returns normally using a ret instruction and jumps to the trampoline, which will massage the stack and let the interpreter continue.
> Bonus: What is the difference between Cogit and the CoInterpreter?
>
Cogit is the compiler.
CoInterpreter is a subclass of the interpreter that has the glue code between the interpreter and the compiler.
:)
G
>
> Thanks in advance for the answers!
> <https://www.ensta-bretagne.fr/> <https://www.labsticc.fr/en/index/>
> Quentin Ducasse
> Doctorant / PhD Student
> Lab-STICC â UMR CNRS 6285
> www.labsticc.fr <http://www.labsticc.fr/>
>
> ENSTA Bretagne
> Grande école d'ingénieurs et centre de recherche
> French State Graduate, Post-Graduate and Research Institute
> 2 rue François Verny - 29806 Brest Cedex 9 - France
> www.ensta-bretagne.fr <https://www.ensta-bretagne.fr/>
>
> _______________________________________________
> Pharo-vm mailing list -- pharo-vm(a)lists.pharo.org
> To unsubscribe send an email to pharo-vm-leave(a)lists.pharo.org
Sept. 28, 2022
JIT Code Zone
by stephane ducasse
Hello,
I am wondering how the Pharo VM and Cogit manage the JIT code zone and have several questions related to that! I will ask my questions and what could be the answers, feel free to correct me!
Context: I would like to secure this part of the VM, instrument accesses to it and experiment with changes in its layout/location!
Initialization:
When and how is the code zone memory allocated? And initialized?
The allocation is made through the succession of: allocateMemoryForImage:withHeader: then allocateMemory:desiredPosition:. The initialization is made through initializeCodeZoneFrom:upTo: where trampolines, PIC prototypes and offsets are generated/computed.
What is the layout of the different components of the code zone?
Trampolines and methods/inline caches coexist, trampolines being the first thing generated.
Runtime:
JIT compilation - What is the granularity of a JIT compilation? When does it write to machine code?
The compiler processes bytecodes at the granularity of a method, using outputInstructionsForGeneratedRuntimeAt: or outputInstructionsAt:. It instruments the actual write with enableCodeZoneWriteDuring:flushingCacheWith:. This step only needs write accesses to the method zone region (after the trampolines).
Garbage collection - When is the GC interfering with machine code? For rewriting and compaction?
Marking with mapMachineCode: and compaction compactCogCompiledCode are the two ways the GC temper with machine code. While the first one only needs to read data, the second needs both read and write accesses.
Interaction between interpreter and machine code - How is forward execution (interpreter - machine code) control flow performed? How is backward execution (machine code - interpreter) performed?
I guess the trampolines ceEnterCogCodePopReceiverReg and ceReturnToInterpreter: are the main bridges between both worlds.
Bonus: What is the difference between Cogit and the CoInterpreter?
Thanks in advance for the answers!
<https://www.ensta-bretagne.fr/> <https://www.labsticc.fr/en/index/>
Quentin Ducasse
Doctorant / PhD Student
Lab-STICC â UMR CNRS 6285
www.labsticc.fr
ENSTA Bretagne
Grande école d'ingénieurs et centre de recherche
French State Graduate, Post-Graduate and Research Institute
2 rue François Verny - 29806 Brest Cedex 9 - France
www.ensta-bretagne.fr <https://www.ensta-bretagne.fr/>
Sept. 26, 2022
Re: About primitiveMethodXray
by Nahuel
Wwoooooo this is very nice!!! Congrats ð
> On 25 Sep 2022, at 08:31, stephane ducasse <stephane.ducasse(a)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(a)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/67780af2e454a348…>:
>>
>> 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/8a4b4b4ee93ea6ff71ca5671ae…>
>> Expose method profiling data (PICs and linked sends type information):
>>
>> Expose method profiling data <https://github.com/pharo-project/pharo-vm/commit/dbf4154e553109ff17757f4565…>
>> 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/903ba641446c591412b59ff4f2…>
>> Rename dollowing the literature <https://github.com/pharo-project/pharo-vm/pull/463/commits/10aba4ad1d6db046…>:
>>
>> OpenPIC -> MegamorphicIC
>> ClosedPIC -> PolymorphicIC
>> Cleanups:
>>
>> Adding notYetImplemented with message parameter <https://github.com/pharo-project/pharo-vm/commit/75be0cddfe3037aa5f574c6a37…>
>> Remove old block compilation related methods <https://github.com/pharo-project/pharo-vm/commit/a806e2f7811973cdfca76f47ee…>
>> Remove SistaCogitClone <https://github.com/pharo-project/pharo-vm/commit/7ea5b11e031707b83b1b6ca037…>
>> Cleaning morphic related method <https://github.com/pharo-project/pharo-vm/commit/1ee56c2528503f6380415085a1…>
>> Cheers,
>> G
>>
>>> El 15 sept 2022, a las 21:15, stephane ducasse <stephane.ducasse(a)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(a)lists.pharo.org <mailto:pharo-vm@lists.pharo.org>
>>> To unsubscribe send an email to pharo-vm-leave(a)lists.pharo.org <mailto:pharo-vm-leave@lists.pharo.org>
>>
>
> _______________________________________________
> Pharo-vm mailing list -- pharo-vm(a)lists.pharo.org
> To unsubscribe send an email to pharo-vm-leave(a)lists.pharo.org
Sept. 25, 2022
Re: About primitiveMethodXray
by stephane ducasse
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(a)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/67780af2e454a348…>:
>
> 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/8a4b4b4ee93ea6ff71ca5671ae…>
> Expose method profiling data (PICs and linked sends type information):
>
> Expose method profiling data <https://github.com/pharo-project/pharo-vm/commit/dbf4154e553109ff17757f4565…>
> 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/903ba641446c591412b59ff4f2…>
> Rename dollowing the literature <https://github.com/pharo-project/pharo-vm/pull/463/commits/10aba4ad1d6db046…>:
>
> OpenPIC -> MegamorphicIC
> ClosedPIC -> PolymorphicIC
> Cleanups:
>
> Adding notYetImplemented with message parameter <https://github.com/pharo-project/pharo-vm/commit/75be0cddfe3037aa5f574c6a37…>
> Remove old block compilation related methods <https://github.com/pharo-project/pharo-vm/commit/a806e2f7811973cdfca76f47ee…>
> Remove SistaCogitClone <https://github.com/pharo-project/pharo-vm/commit/7ea5b11e031707b83b1b6ca037…>
> Cleaning morphic related method <https://github.com/pharo-project/pharo-vm/commit/1ee56c2528503f6380415085a1…>
> Cheers,
> G
>
>> El 15 sept 2022, a las 21:15, stephane ducasse <stephane.ducasse(a)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(a)lists.pharo.org <mailto:pharo-vm@lists.pharo.org>
>> To unsubscribe send an email to pharo-vm-leave(a)lists.pharo.org <mailto:pharo-vm-leave@lists.pharo.org>
>
Sept. 25, 2022
Re: About primitiveMethodXray
by Guillermo Polito
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/67780af2e454a348…>:
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/8a4b4b4ee93ea6ff71ca5671ae…>
Expose method profiling data (PICs and linked sends type information):
Expose method profiling data <https://github.com/pharo-project/pharo-vm/commit/dbf4154e553109ff17757f4565…>
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/903ba641446c591412b59ff4f2…>
Rename dollowing the literature <https://github.com/pharo-project/pharo-vm/pull/463/commits/10aba4ad1d6db046…>:
OpenPIC -> MegamorphicIC
ClosedPIC -> PolymorphicIC
Cleanups:
Adding notYetImplemented with message parameter <https://github.com/pharo-project/pharo-vm/commit/75be0cddfe3037aa5f574c6a37…>
Remove old block compilation related methods <https://github.com/pharo-project/pharo-vm/commit/a806e2f7811973cdfca76f47ee…>
Remove SistaCogitClone <https://github.com/pharo-project/pharo-vm/commit/7ea5b11e031707b83b1b6ca037…>
Cleaning morphic related method <https://github.com/pharo-project/pharo-vm/commit/1ee56c2528503f6380415085a1…>
Cheers,
G
> El 15 sept 2022, a las 21:15, stephane ducasse <stephane.ducasse(a)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(a)lists.pharo.org
> To unsubscribe send an email to pharo-vm-leave(a)lists.pharo.org
Sept. 24, 2022
Updated plugin compilation info?
by Hernán Morales Durand
Dear all,
I wrote a stupid debugger plugin and generated the C code using:
ProtoDebugInterpreterPlugin
translateInDirectory: 'ProtoDebug' asFileReference
doInlining: false.
I remember time ago I modified a plugins.ext file and then copied necessary
C headers to a directory (along with my generated .c from Slang) etc etc.
Now where should I put my new .c file?
Which command/script do you use to compile the VM with a new plugin?
Cheers,
Hernán
Sept. 23, 2022
Re: Nooby questio - getting hello world out of a headless vm
by Luc Fabresse
Hi Dave,
I have no clue what this small (204K) file
build/dist/pharo-vm/resources/img.image is.
Anyone knows?
Regarding you libgit issue, I guess this is because
build/dist/lib/libgit2.so.1.4.4 is not there.
On my side, if I use (as Guille wrote):
$ cmake --build vmbuild --target install
external libs are there.
I agree that "install" is confusing here or I misunderstood.
Luc
Le jeu. 15 sept. 2022 à 16:27, David Mason <dmason(a)ryerson.ca> a écrit :
> Thanks! That worked.
>
> I guess the build/dist/pharo-vm/resources/img.image - which I thought
> would be a minimal functional image - isnât. I was trying to get the
> startup .st code working first, and didnât try any other image.
>
> I get a bunch of stderr log messages about
> Cannot locate any of #('libgit2.1.4.4.dylib' 'libgit2.1.0.1.dylib'
> 'libgit2.1.0.0.dylib' 'libgit2.0.25.1.dylib'). Please check if it installed
> on your system
>
> but I can ignore those easily enough.
>
> Thanks, now I can get to my experiment.
>
> ../Dave
> On Sep 15, 2022, 9:40 AM -0400, Guillermo Polito <
> guillermopolito(a)gmail.com>, wrote:
>
> Sure, but Iâd need a bit more of information from your side, because from
> my side, I just compiled latest version and did:
>
> # Compile VM
> $ git clone ⦠repo
> $ cmake -B vmbuild -S repo
> $ cmake âbuild vmbuild âtarget install
>
> #Download a pharo 10 image
> $ wget -O- https://get.pharo.org/100 | bash
>
> #Create your script
>
> $ tee -a hello.st << EOF
> Transcript show: 'hello world!!';cr.
> EOF
>
> $ ./build/build/dist/Pharo.app/Contents/MacOS/Pharo Pharo.image st
> hello.st --save --quit
> hello world!
>
> G
>
> El 15 sept 2022, a las 15:19, David Mason <dmason(a)ryerson.ca> escribió:
>
> Hi Guille,
>
> Iâm just trying to run the img.image that comes with the pharo-project
> install.
>
> All I want at this stage is to execute `Transcript show: âhello
> worldâ;cr.` (and have that show on std-out or std-err) and exit.
>
> ../Dave
> On Sep 15, 2022, 8:53 AM -0400, Guillermo Polito <
> guillermopolito(a)gmail.com>, wrote:
>
> Hi Dave,
>
> a couple of quick hints that could lead us to a solution:
>
> - what image are you running on top? what version?
> - is the image source file close to the image/VM?
> - if the process seems frozen, you can send it the SIGUSR1 signal so it
> dumps a log of the execution
> kill -SIGUSR1 pid
>
> That dumps
> - the native stack
> - the smalltalk stacks
>
> That would show you quickly where the problem is, very probably there is
> an infinite recursion in pharo code.
>
> G
>
> El 14 sept 2022, a las 20:16, David Mason <dmason(a)ryerson.ca> escribió:
>
> Hi,
>
> Iâve built a stackVM straight out of the box from the instructions at
> https://github.com/pharo-project/pharo-vm to run some experiments. So Iâm
> trying for a simple Hello world on stdout/stderr. I assumed on headless
> Transcript would go to some useful place, so I tried,
>
> I have a hello.st
> -----
> Transcript show: 'hello world!';cr.
> "(Smalltalk at: #Transcript) show: 'hello world!';cr."
> -----
> and run-test:
> -----
> #! /bin/sh
> #
> # Run it with a headless Pharo:
> #
> DIR=~/git/pharo-project/stackVM/build
> VM=$DIR/vm/Debug/Pharo.app/Contents/MacOS/Pharo
> #IMAGE=$DIR/dist/pharo-vm/resources/img.image
> IMAGE=img.image
> ls -l $VM $IMAGE
> grep . "$@" /dev/null
> set -x
> $VM -vm-display-null -headless --logLevel=4 $IMAGE "$@" --save --quit
> -----
>
> and I get:
> : Sep14 ; date;./run-test hello.st ;date
> Wed 14 Sep 2022 14:09:17 EDT
> -rwxr-xr-x 1 dmason staff 50226 9 Sep 14:08
> /Users/dmason/git/pharo-project/stackVM/build/vm/Debug/Pharo.app/Contents/MacOS/Pharo
> -rw-r--r-- 1 dmason staff 206336 13 Sep 23:21 img.image
> hello.st:Transcript show: 'hello world!';cr.
> hello.st:"(Smalltalk at: #Transcript) show: 'hello world!';cr."
> +
> /Users/dmason/git/pharo-project/stackVM/build/vm/Debug/Pharo.app/Contents/MacOS/Pharo
> -vm-display-null -headless --logLevel=4 img.image hello.st --save --quit
> [DEBUG] 2022-09-14 14:09:17.000 logParameters
> (src/parameters/parameters.c:341):Image file name: img.image
> [DEBUG] 2022-09-14 14:09:17.000 logParameters
> (src/parameters/parameters.c:342):Is default Image: no
> [DEBUG] 2022-09-14 14:09:17.000 logParameters
> (src/parameters/parameters.c:343):Is interactive session: no
> [DEBUG] 2022-09-14 14:09:17.000 logParameterVector
> (src/parameters/parameters.c:331):vmParameters [count = 5]:
> [DEBUG] 2022-09-14 14:09:17.000 logParameterVector
> (src/parameters/parameters.c:334):
> /Users/dmason/git/pharo-project/stackVM/build/vm/Debug/Pharo.app/Contents/MacOS/Pharo
> [DEBUG] 2022-09-14 14:09:17.000 logParameterVector
> (src/parameters/parameters.c:334): -vm-display-null
> [DEBUG] 2022-09-14 14:09:17.000 logParameterVector
> (src/parameters/parameters.c:334): -headless
> [DEBUG] 2022-09-14 14:09:17.000 logParameterVector
> (src/parameters/parameters.c:334): --logLevel=4
> [DEBUG] 2022-09-14 14:09:17.000 logParameterVector
> (src/parameters/parameters.c:334): --headless
> [DEBUG] 2022-09-14 14:09:17.000 logParameterVector
> (src/parameters/parameters.c:331):imageParameters [count = 3]:
> [DEBUG] 2022-09-14 14:09:17.000 logParameterVector
> (src/parameters/parameters.c:334): hello.st
> [DEBUG] 2022-09-14 14:09:17.000 logParameterVector
> (src/parameters/parameters.c:334): --save
> [DEBUG] 2022-09-14 14:09:17.000 logParameterVector
> (src/parameters/parameters.c:334): --quit
> [INFO ] 2022-09-14 14:09:17.000 vm_main_with_parameters
> (src/client.c:113):Opening Image: img.image
> [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters
> (src/client.c:135):Working Directory /Users/dmason/git/AST-Smalltalk/testing
> [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters
> (src/client.c:137):sizeof(int): 4
> [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters
> (src/client.c:138):sizeof(long): 8
> [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters
> (src/client.c:139):sizeof(long long): 8
> [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters
> (src/client.c:140):sizeof(void*): 8
> [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters
> (src/client.c:141):sizeof(sqInt): 8
> [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters
> (src/client.c:142):sizeof(sqLong): 8
> [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters
> (src/client.c:143):sizeof(float): 4
> [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters
> (src/client.c:144):sizeof(double): 8
> [DEBUG] 2022-09-14 14:09:17.000 runOnMainThread (src/client.c:254):Running
> VM on main thread
> [DEBUG] 2022-09-14 14:09:17.000 sqAllocateMemory
> (src/memoryUnix.c:139):Trying to load the image in 0x804000
> [DEBUG] 2022-09-14 14:09:17.000 sqAllocateMemory
> (src/memoryUnix.c:181):Loading the image in 0x106fa4000
> [WARN ] 2022-09-14 14:09:17.000 ioLoadModule
> (src/externalPrimitives.c:102):Failed to load module: SecurityPlugin
>
> and 40 minutes later it exits having been kill -9âed
>
> Once, it exited quickly, but I have no idea what was different that time.
> Also âsave does seem to do anything.
>
> If it reliably exited, I could experiment, but I have no idea whatâs
> happening.
>
> Help! (and Thanks in advance)
>
> ../Dave
> _______________________________________________
> Pharo-vm mailing list -- pharo-vm(a)lists.pharo.org
> To unsubscribe send an email to pharo-vm-leave(a)lists.pharo.org
>
>
>
> _______________________________________________
> Pharo-vm mailing list -- pharo-vm(a)lists.pharo.org
> To unsubscribe send an email to pharo-vm-leave(a)lists.pharo.org
>
> _______________________________________________
> Pharo-vm mailing list -- pharo-vm(a)lists.pharo.org
> To unsubscribe send an email to pharo-vm-leave(a)lists.pharo.org
>
Sept. 16, 2022
About primitiveMethodXray
by stephane ducasse
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
Sept. 15, 2022
Re: Nooby questio - getting hello world out of a headless vm
by David Mason
Thanks! That worked.
I guess the build/dist/pharo-vm/resources/img.image - which I thought would be a minimal functional image - isnât. I was trying to get the startup .st code working first, and didnât try any other image.
I get a bunch of stderr log messages about
 Cannot locate any of #('libgit2.1.4.4.dylib' 'libgit2.1.0.1.dylib' 'libgit2.1.0.0.dylib' 'libgit2.0.25.1.dylib'). Please check if it installed on your system
but I can ignore those easily enough.
Thanks, now I can get to my experiment.
../Dave
On Sep 15, 2022, 9:40 AM -0400, Guillermo Polito <guillermopolito(a)gmail.com>, wrote:
> Sure, but Iâd need a bit more of information from your side, because from my side, I just compiled latest version and did:
>
> # Compile VM
> $ git clone ⦠repo
> $ cmake -B vmbuild -S repo
> $ cmake âbuild vmbuild âtarget install
>
> #Download a pharo 10 image
> $ wget -O- https://get.pharo.org/100 | bash
>
> #Create your script
>
> $ tee -a hello.st << EOF
> Transcript show: 'hello world!!';cr.
> EOF
>
> $Â ./build/build/dist/Pharo.app/Contents/MacOS/Pharo Pharo.image st hello.st --save --quit
> hello world!
>
> G
>
> > El 15 sept 2022, a las 15:19, David Mason <dmason(a)ryerson.ca> escribió:
> >
> > Hi Guille,
> >
> > Iâm just trying to run the img.image that comes with the pharo-project install.
> >
> > All I want at this stage is to execute `Transcript show: âhello worldâ;cr.` (and have that show on std-out or std-err) and exit.
> >
> > ../Dave
> > On Sep 15, 2022, 8:53 AM -0400, Guillermo Polito <guillermopolito(a)gmail.com>, wrote:
> > > Hi Dave,
> > >
> > > a couple of quick hints that could lead us to a solution:
> > >
> > > - what image are you running on top? what version?
> > > - is the image source file close to the image/VM?
> > > - if the process seems frozen, you can send it the SIGUSR1 signal so it dumps a log of the execution
> > > Â Â kill -SIGUSR1 pid
> > >
> > > That dumps
> > > Â - the native stack
> > > Â - the smalltalk stacks
> > >
> > > That would show you quickly where the problem is, very probably there is an infinite recursion in pharo code.
> > >
> > > G
> > >
> > > > El 14 sept 2022, a las 20:16, David Mason <dmason(a)ryerson.ca> escribió:
> > > >
> > > > Hi,
> > > >
> > > > Iâve built a stackVM straight out of the box from the instructions at https://github.com/pharo-project/pharo-vm to run some experiments. So Iâm trying for a simple Hello world on stdout/stderr. I assumed on headless Transcript would go to some useful place, so I tried,
> > > >
> > > > I have a hello.st
> > > > -----
> > > > Transcript show: 'hello world!';cr.
> > > > "(Smalltalk at: #Transcript) show: 'hello world!';cr."
> > > > -----
> > > > and run-test:
> > > > -----
> > > > #! /bin/sh
> > > > #
> > > > # Run it with a headless Pharo:
> > > > #
> > > > DIR=~/git/pharo-project/stackVM/build
> > > > VM=$DIR/vm/Debug/Pharo.app/Contents/MacOS/Pharo
> > > > #IMAGE=$DIR/dist/pharo-vm/resources/img.image
> > > > IMAGE=img.image
> > > > ls -l $VM $IMAGE
> > > > grep . "$@" /dev/null
> > > > set -x
> > > > $VM -vm-display-null -headless --logLevel=4 $IMAGE "$@" --save --quit
> > > > -----
> > > >
> > > > and I get:
> > > > : Sep14 ; date;./run-test hello.st ;date
> > > > Wed 14 Sep 2022 14:09:17 EDT
> > > > -rwxr-xr-x 1 dmason staff 50226 9 Sep 14:08 /Users/dmason/git/pharo-project/stackVM/build/vm/Debug/Pharo.app/Contents/MacOS/Pharo
> > > > -rw-r--r-- 1 dmason staff 206336 13 Sep 23:21 img.image
> > > > hello.st:Transcript show: 'hello world!';cr.
> > > > hello.st:"(Smalltalk at: #Transcript) show: 'hello world!';cr."
> > > > + /Users/dmason/git/pharo-project/stackVM/build/vm/Debug/Pharo.app/Contents/MacOS/Pharo -vm-display-null -headless --logLevel=4 img.image hello.st --save --quit
> > > > [DEBUG] 2022-09-14 14:09:17.000 logParameters (src/parameters/parameters.c:341):Image file name: img.image
> > > > [DEBUG] 2022-09-14 14:09:17.000 logParameters (src/parameters/parameters.c:342):Is default Image: no
> > > > [DEBUG] 2022-09-14 14:09:17.000 logParameters (src/parameters/parameters.c:343):Is interactive session: no
> > > > [DEBUG] 2022-09-14 14:09:17.000 logParameterVector (src/parameters/parameters.c:331):vmParameters [count = 5]:
> > > > [DEBUG] 2022-09-14 14:09:17.000 logParameterVector (src/parameters/parameters.c:334): /Users/dmason/git/pharo-project/stackVM/build/vm/Debug/Pharo.app/Contents/MacOS/Pharo
> > > > [DEBUG] 2022-09-14 14:09:17.000 logParameterVector (src/parameters/parameters.c:334): -vm-display-null
> > > > [DEBUG] 2022-09-14 14:09:17.000 logParameterVector (src/parameters/parameters.c:334): -headless
> > > > [DEBUG] 2022-09-14 14:09:17.000 logParameterVector (src/parameters/parameters.c:334): --logLevel=4
> > > > [DEBUG] 2022-09-14 14:09:17.000 logParameterVector (src/parameters/parameters.c:334): --headless
> > > > [DEBUG] 2022-09-14 14:09:17.000 logParameterVector (src/parameters/parameters.c:331):imageParameters [count = 3]:
> > > > [DEBUG] 2022-09-14 14:09:17.000 logParameterVector (src/parameters/parameters.c:334):Â hello.st
> > > > [DEBUG] 2022-09-14 14:09:17.000 logParameterVector (src/parameters/parameters.c:334): --save
> > > > [DEBUG] 2022-09-14 14:09:17.000 logParameterVector (src/parameters/parameters.c:334): --quit
> > > > [INFO ] 2022-09-14 14:09:17.000 vm_main_with_parameters (src/client.c:113):Opening Image: img.image
> > > > [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters (src/client.c:135):Working Directory /Users/dmason/git/AST-Smalltalk/testing
> > > > [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters (src/client.c:137):sizeof(int): 4
> > > > [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters (src/client.c:138):sizeof(long): 8
> > > > [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters (src/client.c:139):sizeof(long long): 8
> > > > [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters (src/client.c:140):sizeof(void*): 8
> > > > [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters (src/client.c:141):sizeof(sqInt): 8
> > > > [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters (src/client.c:142):sizeof(sqLong): 8
> > > > [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters (src/client.c:143):sizeof(float): 4
> > > > [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters (src/client.c:144):sizeof(double): 8
> > > > [DEBUG] 2022-09-14 14:09:17.000 runOnMainThread (src/client.c:254):Running VM on main thread
> > > > [DEBUG] 2022-09-14 14:09:17.000 sqAllocateMemory (src/memoryUnix.c:139):Trying to load the image in 0x804000
> > > > [DEBUG] 2022-09-14 14:09:17.000 sqAllocateMemory (src/memoryUnix.c:181):Loading the image in 0x106fa4000
> > > > [WARN ] 2022-09-14 14:09:17.000 ioLoadModule (src/externalPrimitives.c:102):Failed to load module: SecurityPlugin
> > > >
> > > > and 40 minutes later it exits having been kill -9âed
> > > >
> > > > Once, it exited quickly, but I have no idea what was different that time. Also âsave does seem to do anything.
> > > >
> > > > If it reliably exited, I could experiment, but I have no idea whatâs happening.
> > > >
> > > > Help! (and Thanks in advance)
> > > >
> > > > ../Dave
> > > > _______________________________________________
> > > > Pharo-vm mailing list -- pharo-vm(a)lists.pharo.org
> > > > To unsubscribe send an email to pharo-vm-leave(a)lists.pharo.org
> > >
>
> _______________________________________________
> Pharo-vm mailing list -- pharo-vm(a)lists.pharo.org
> To unsubscribe send an email to pharo-vm-leave(a)lists.pharo.org
Sept. 15, 2022
Re: Nooby questio - getting hello world out of a headless vm
by Guillermo Polito
Sure, but Iâd need a bit more of information from your side, because from my side, I just compiled latest version and did:
# Compile VM
$ git clone ⦠repo
$ cmake -B vmbuild -S repo
$ cmake âbuild vmbuild âtarget install
#Download a pharo 10 image
$ wget -O- https://get.pharo.org/100 | bash
#Create your script
$ tee -a hello.st << EOF
Transcript show: 'hello world!!';cr.
EOF
$ ./build/build/dist/Pharo.app/Contents/MacOS/Pharo Pharo.image st hello.st --save --quit
hello world!
G
> El 15 sept 2022, a las 15:19, David Mason <dmason(a)ryerson.ca> escribió:
>
> Hi Guille,
>
> Iâm just trying to run the img.image that comes with the pharo-project install.
>
> All I want at this stage is to execute `Transcript show: âhello worldâ;cr.` (and have that show on std-out or std-err) and exit.
>
> ../Dave
> On Sep 15, 2022, 8:53 AM -0400, Guillermo Polito <guillermopolito(a)gmail.com>, wrote:
>> Hi Dave,
>>
>> a couple of quick hints that could lead us to a solution:
>>
>> - what image are you running on top? what version?
>> - is the image source file close to the image/VM?
>> - if the process seems frozen, you can send it the SIGUSR1 signal so it dumps a log of the execution
>> kill -SIGUSR1 pid
>>
>> That dumps
>> - the native stack
>> - the smalltalk stacks
>>
>> That would show you quickly where the problem is, very probably there is an infinite recursion in pharo code.
>>
>> G
>>
>>> El 14 sept 2022, a las 20:16, David Mason <dmason(a)ryerson.ca <mailto:dmason@ryerson.ca>> escribió:
>>>
>>> Hi,
>>>
>>> Iâve built a stackVM straight out of the box from the instructions at https://github.com/pharo-project/pharo-vm <https://github.com/pharo-project/pharo-vm> to run some experiments. So Iâm trying for a simple Hello world on stdout/stderr. I assumed on headless Transcript would go to some useful place, so I tried,
>>>
>>> I have a hello.st <http://hello.st/>
>>> -----
>>> Transcript show: 'hello world!';cr.
>>> "(Smalltalk at: #Transcript) show: 'hello world!';cr."
>>> -----
>>> and run-test:
>>> -----
>>> #! /bin/sh
>>> #
>>> # Run it with a headless Pharo:
>>> #
>>> DIR=~/git/pharo-project/stackVM/build
>>> VM=$DIR/vm/Debug/Pharo.app/Contents/MacOS/Pharo
>>> #IMAGE=$DIR/dist/pharo-vm/resources/img.image
>>> IMAGE=img.image
>>> ls -l $VM $IMAGE
>>> grep . "$@" /dev/null
>>> set -x
>>> $VM -vm-display-null -headless --logLevel=4 $IMAGE "$@" --save --quit
>>> -----
>>>
>>> and I get:
>>> : Sep14 ; date;./run-test hello.st <http://hello.st/> ;date
>>> Wed 14 Sep 2022 14:09:17 EDT
>>> -rwxr-xr-x 1 dmason staff 50226 9 Sep 14:08 /Users/dmason/git/pharo-project/stackVM/build/vm/Debug/Pharo.app/Contents/MacOS/Pharo
>>> -rw-r--r-- 1 dmason staff 206336 13 Sep 23:21 img.image
>>> hello.st <http://hello.st/>:Transcript show: 'hello world!';cr.
>>> hello.st <http://hello.st/>:"(Smalltalk at: #Transcript) show: 'hello world!';cr."
>>> + /Users/dmason/git/pharo-project/stackVM/build/vm/Debug/Pharo.app/Contents/MacOS/Pharo -vm-display-null -headless --logLevel=4 img.image hello.st <http://hello.st/> --save --quit
>>> [DEBUG] 2022-09-14 14:09:17.000 logParameters (src/parameters/parameters.c:341):Image file name: img.image
>>> [DEBUG] 2022-09-14 14:09:17.000 logParameters (src/parameters/parameters.c:342):Is default Image: no
>>> [DEBUG] 2022-09-14 14:09:17.000 logParameters (src/parameters/parameters.c:343):Is interactive session: no
>>> [DEBUG] 2022-09-14 14:09:17.000 logParameterVector (src/parameters/parameters.c:331):vmParameters [count = 5]:
>>> [DEBUG] 2022-09-14 14:09:17.000 logParameterVector (src/parameters/parameters.c:334): /Users/dmason/git/pharo-project/stackVM/build/vm/Debug/Pharo.app/Contents/MacOS/Pharo
>>> [DEBUG] 2022-09-14 14:09:17.000 logParameterVector (src/parameters/parameters.c:334): -vm-display-null
>>> [DEBUG] 2022-09-14 14:09:17.000 logParameterVector (src/parameters/parameters.c:334): -headless
>>> [DEBUG] 2022-09-14 14:09:17.000 logParameterVector (src/parameters/parameters.c:334): --logLevel=4
>>> [DEBUG] 2022-09-14 14:09:17.000 logParameterVector (src/parameters/parameters.c:334): --headless
>>> [DEBUG] 2022-09-14 14:09:17.000 logParameterVector (src/parameters/parameters.c:331):imageParameters [count = 3]:
>>> [DEBUG] 2022-09-14 14:09:17.000 logParameterVector (src/parameters/parameters.c:334): hello.st <http://hello.st/>
>>> [DEBUG] 2022-09-14 14:09:17.000 logParameterVector (src/parameters/parameters.c:334): --save
>>> [DEBUG] 2022-09-14 14:09:17.000 logParameterVector (src/parameters/parameters.c:334): --quit
>>> [INFO ] 2022-09-14 14:09:17.000 vm_main_with_parameters (src/client.c:113):Opening Image: img.image
>>> [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters (src/client.c:135):Working Directory /Users/dmason/git/AST-Smalltalk/testing
>>> [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters (src/client.c:137):sizeof(int): 4
>>> [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters (src/client.c:138):sizeof(long): 8
>>> [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters (src/client.c:139):sizeof(long long): 8
>>> [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters (src/client.c:140):sizeof(void*): 8
>>> [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters (src/client.c:141):sizeof(sqInt): 8
>>> [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters (src/client.c:142):sizeof(sqLong): 8
>>> [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters (src/client.c:143):sizeof(float): 4
>>> [DEBUG] 2022-09-14 14:09:17.000 vm_main_with_parameters (src/client.c:144):sizeof(double): 8
>>> [DEBUG] 2022-09-14 14:09:17.000 runOnMainThread (src/client.c:254):Running VM on main thread
>>> [DEBUG] 2022-09-14 14:09:17.000 sqAllocateMemory (src/memoryUnix.c:139):Trying to load the image in 0x804000
>>> [DEBUG] 2022-09-14 14:09:17.000 sqAllocateMemory (src/memoryUnix.c:181):Loading the image in 0x106fa4000
>>> [WARN ] 2022-09-14 14:09:17.000 ioLoadModule (src/externalPrimitives.c:102):Failed to load module: SecurityPlugin
>>>
>>> and 40 minutes later it exits having been kill -9âed
>>>
>>> Once, it exited quickly, but I have no idea what was different that time. Also âsave does seem to do anything.
>>>
>>> If it reliably exited, I could experiment, but I have no idea whatâs happening.
>>>
>>> Help! (and Thanks in advance)
>>>
>>> ../Dave
>>> _______________________________________________
>>> Pharo-vm mailing list -- pharo-vm(a)lists.pharo.org <mailto:pharo-vm@lists.pharo.org>
>>> To unsubscribe send an email to pharo-vm-leave(a)lists.pharo.org <mailto:pharo-vm-leave@lists.pharo.org>
>>
Sept. 15, 2022