<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 17, 2014 at 6:24 AM, Guillermo Polito <span dir="ltr">&lt;<a href="mailto:guillermopolito@gmail.com" target="_blank">guillermopolito@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"> <br><div dir="ltr">Hi Eliot, guys,<div><br></div><div>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 :).</div></div></blockquote><div><br></div><div>StackInterpreterSimulator newWithOptions: anArray</div><div>CogVMSimulator newWithOptions: anArray</div><div><br></div><div>The arguments of the array are symbol,value pairs that define the options, e.g.</div><div><br></div><div>StackInterpreterSimulator newWithOptions: #(ObjectMemory Spur32BitMemoryManager</div><div><span class="" style="white-space:pre">                                                                        </span>NewspeakVM true MULTIPLEBYTECODESETS true).</div><div><br></div><div>The key,value pairs are</div><div><br></div><div>ObjectMemory<span style="white-space:pre">        </span><span style="white-space:pre">        </span><span style="white-space:pre">        </span><span style="white-space:pre">        </span><span style="white-space:pre">New</span>ObjectMemory (default) <span style="white-space:pre">NewCo</span>ObjectMemory Spur32BitMemoryManager Spur32BitCoMemoryManager</div><span style="white-space:pre"><div class="gmail_quote"><span style="white-space:pre"><br></span></div><div class="gmail_quote"><span style="white-space:normal">NewspeakVM</span>                                false (default)<span style="white-space:normal"><br class="">SistaVM</span>                                        false (default)</div></span>MULTIPLEBYTECODESETS<span style="white-space:pre">        false (default)</span><span style="white-space:pre"><div class="gmail_quote">bytecodeTableInitializer                initializeBytecodeTableForSqueakV3PlusClosures et al<span style="white-space:pre"><br></span></div></span></div><div class="gmail_quote"><span style="white-space:pre"><br></span><div>Cogit<span style="white-space:pre">        </span><span style="white-space:pre">        </span><span style="white-space:pre">        </span><span style="white-space:pre">        </span><span style="white-space:pre">        Simple</span>StackBasedCogit (default) StackToRegisterMappingCogit (production version) SistaStackToRegisterMappingCogit</div><div>MaxLiteralCountForCompile<span style="white-space:pre">        60 (default)</span><br></div><div>COGMTVM<span style="white-space:pre">        </span><span style="white-space:pre">        </span><span style="white-space:pre">        </span><span style="white-space:pre">        false (default) true</span></div>ISA<span style="white-space:pre">        </span><span style="white-space:pre">        </span><span style="white-space:pre">        </span><span style="white-space:pre">        </span><span style="white-space:pre">        </span><span style="white-space:pre">        </span><span style="white-space:pre">IA32 (default) ARMv5 etc</span></div><div class="gmail_quote"><div><span style="white-space:pre">EagerInstructionDecoration</span><span style="white-space:pre">        false (true) true</span><br></div><div><span style="white-space:pre"><br></span></div><div>Choosing these values merey gives you a simulator with the right classes and basic values.  As you note below it doesn&#39;t initialize a heap.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>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.<br></div></div></blockquote><div><br></div><div>No, I don&#39;t.  I start with an image and transform it.  But see below.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div></div><div><br></div><div>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:</div><div><br></div><div><div><span style="white-space:pre-wrap">        </span>simulator := StackInterpreterSimulator new.<span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">        </span>simulator objectMemory setEndOfMemory: 0.</div><div><span style="white-space:pre-wrap">        </span>simulator objectMemory edenBytes: simulator objectMemory defaultEdenBytes.</div><div><span style="white-space:pre-wrap">        </span>simulator objectMemory specialObjectsOop: 0. &quot;We don&#39;t have one yet&quot;</div><div><span style="white-space:pre-wrap">        </span>simulator objectMemory allocateMemoryOfSize: 25000000. &quot;Extra bytes&quot;</div><div><span style="white-space:pre-wrap">        </span>simulator objectMemory initialize.<span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">        </span>simulator initializeOzInterpreter: 0. &quot;its initializeInterpreter: but a bit tweeked&quot;</div></div><div><br></div><div>But it stops in an assert because firstFree = end of memory... Which is wrong as we have an empty memory :D. And i&#39;m a bit lost in this one...</div></div></blockquote><div><br></div><div>Yes.  You need to start by looking at the implementations of openOn:extraMemory: and see how the object memory is initalized.  You&#39;ll probably want to create your own method, e.g. initializeHeapOfSize:.  The key message is</div><div><br></div><div><div><span class="" style="white-space:pre">        </span>objectMemory<br></div><div><span class="" style="white-space:pre">                </span>setHeapBase: heapBase</div><div><span class="" style="white-space:pre">                </span>memoryLimit: heapBase + heapSize</div><div><span class="" style="white-space:pre">                </span>endOfMemory: heapBase + dataSize. &quot;bogus for Spur&quot;</div></div><div><br></div><div>As you know, it&#39;s a really useful thing to do, but the thing to remember is that IFAIA no one has done this before.  Don&#39;t expect it to just work.  But I&#39;m here to answer any questions I can.  Good luck!!</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>I was looking at how the Spur bootstrap was doing it</div><div><br></div><div><div>on: imageName</div><div><span style="white-space:pre-wrap">        </span>StackInterpreter initializeWithOptions: Dictionary new.</div><div><span style="white-space:pre-wrap">        </span>(oldInterpreter := StackInterpreterSimulator new)</div><div><span style="white-space:pre-wrap">                </span>openOn: imageName extraMemory: 0;</div><div><span style="white-space:pre-wrap">                </span>assertValidExecutionPointersAtEachStep: false.</div><div><span style="white-space:pre-wrap">        </span>oldHeap := oldInterpreter objectMemory.</div><div><span style="white-space:pre-wrap">        </span>newHeap := Spur32BitMMLESimulator new.</div><div><span style="white-space:pre-wrap">        </span>newHeap</div><div><span style="white-space:pre-wrap">                </span>allocateMemoryOfSize: (oldHeap youngStart * 3 / 2 roundUpTo: 1024 * 1024)</div><div><span style="white-space:pre-wrap">                </span>newSpaceSize: 2 * 1024 * 1024</div><div><span style="white-space:pre-wrap">                </span>stackSize: 1024 * 1024</div><div><span style="white-space:pre-wrap">                </span>codeSize: 0.</div><div><span style="white-space:pre-wrap">        </span>newHeap setCheckForLeaks: 15 - 6. &quot;don&#39;t check become; or newSpace; soooo many rehashes in bootstrap&quot;</div><div><span style="white-space:pre-wrap">        </span>newHeap bootstrapping: true.</div><div><span style="white-space:pre-wrap">        </span>self initMaps</div></div><div><br></div><div>But well, the NewObjectMemory does not have the same API as SpurMemoryManager.</div><div><br></div><div>I&#39;d appreciate any hints on it!</div><div>Thanks and cheers,</div><div>Guille</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">best,<div>Eliot</div></div>
</div></div>