[Vm-dev] Initializing the simulator without an image
eliot.miranda at gmail.com
Mon Nov 17 17:04:21 UTC 2014
On Mon, Nov 17, 2014 at 6:24 AM, Guillermo Polito <guillermopolito at gmail.com
> Hi Eliot, guys,
> Does anybody know what is the right way to initialize the simulator when I
> have no image (yet) ? That means: I have no contexts, no processes, no
> special objects array, no nil. Nothing :).
StackInterpreterSimulator newWithOptions: anArray
CogVMSimulator newWithOptions: anArray
The arguments of the array are symbol,value pairs that define the options,
StackInterpreterSimulator newWithOptions: #(ObjectMemory
NewspeakVM true MULTIPLEBYTECODESETS true).
The key,value pairs are
ObjectMemory NewObjectMemory (default) NewCoObjectMemory
NewspeakVM false (default)
SistaVM false (default)
MULTIPLEBYTECODESETS false (default)
bytecodeTableInitializer initializeBytecodeTableForSqueakV3PlusClosures et
Cogit SimpleStackBasedCogit (default) StackToRegisterMappingCogit
(production version) SistaStackToRegisterMappingCogit
MaxLiteralCountForCompile 60 (default)
COGMTVM false (default) true
ISA IA32 (default) ARMv5 etc
EagerInstructionDecoration false (true) true
Choosing these values merey gives you a simulator with the right classes
and basic values. As you note below it doesn't initialize a heap.
I want to create an empty simulator that I will fill with objects later,
> with bootstrapping purposes. And I know Eliot is doing something like that
> to initialize the Spur bootstrap.
No, I don't. I start with an image and transform it. But see below.
> I tried to get that working by myself, but when I updated to the latest VM
> code everything went bananas. My code was something like:
> simulator := StackInterpreterSimulator new.
> simulator objectMemory setEndOfMemory: 0.
> simulator objectMemory edenBytes: simulator objectMemory defaultEdenBytes.
> simulator objectMemory specialObjectsOop: 0. "We don't have one yet"
> simulator objectMemory allocateMemoryOfSize: 25000000. "Extra bytes"
> simulator objectMemory initialize.
> simulator initializeOzInterpreter: 0. "its initializeInterpreter: but a
> bit tweeked"
> But it stops in an assert because firstFree = end of memory... Which is
> wrong as we have an empty memory :D. And i'm a bit lost in this one...
Yes. You need to start by looking at the implementations of
openOn:extraMemory: and see how the object memory is initalized. You'll
probably want to create your own method, e.g. initializeHeapOfSize:. The
key message is
memoryLimit: heapBase + heapSize
endOfMemory: heapBase + dataSize. "bogus for Spur"
As you know, it's a really useful thing to do, but the thing to remember is
that IFAIA no one has done this before. Don't expect it to just work. But
I'm here to answer any questions I can. Good luck!!
I was looking at how the Spur bootstrap was doing it
> on: imageName
> StackInterpreter initializeWithOptions: Dictionary new.
> (oldInterpreter := StackInterpreterSimulator new)
> openOn: imageName extraMemory: 0;
> assertValidExecutionPointersAtEachStep: false.
> oldHeap := oldInterpreter objectMemory.
> newHeap := Spur32BitMMLESimulator new.
> allocateMemoryOfSize: (oldHeap youngStart * 3 / 2 roundUpTo: 1024 * 1024)
> newSpaceSize: 2 * 1024 * 1024
> stackSize: 1024 * 1024
> codeSize: 0.
> newHeap setCheckForLeaks: 15 - 6. "don't check become; or newSpace; soooo
> many rehashes in bootstrap"
> newHeap bootstrapping: true.
> self initMaps
> But well, the NewObjectMemory does not have the same API as
> I'd appreciate any hints on it!
> Thanks and cheers,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Vm-dev