<br><br><div class="gmail_quote">On Mon, Apr 13, 2009 at 2:08 PM, Eliot Miranda <span dir="ltr">&lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br><br><div class="gmail_quote"><div class="im">On Sat, Apr 11, 2009 at 11:55 PM, John M McIntosh <span dir="ltr">&lt;<a href="mailto:johnmci@smalltalkconsulting.com" target="_blank">johnmci@smalltalkconsulting.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Ok, I&#39;m confused about the comments in initialCleanup, since in testing with a Pharo image from feb it DOES call the flushExternalPrimitives, but the comments imply a 3.8 or later image shouldn&#39;t have the root bit set.<br>


<br>
Also then the flushExternalPrimitiveOf: seems to be invoked by the snapshotCleanUp.<br>
<br>
So is the comment in initialCleanup wrong?<br>
<br>
Could in the Closure VM could we skip flushExternalPrimitives for the new image type, since we *know* any closure image would have been processed by snapshotCleanUp, versus being a 3.2 image?<br></blockquote><div><br></div>

</div><div>Good point.  So initialCleanup would then become</div><div><br></div><div><div>flushExternalPrimitives</div><div><span style="white-space:pre">        </span>self flushMethodCache.</div><div><span style="white-space:pre">        </span>self flushAtCache.</div>

<div><span style="white-space:pre">        </span>self flushExternalPrimitiveTable</div></div></div></blockquote><div><br></div><div>Oops; copy paste error.  I meant of course </div><div><br></div><div>initialCleanup<br></div><div>
<span style="white-space: pre; ">        </span>self flushMethodCache.</div><div><span style="white-space: pre; ">        </span>self flushAtCache.</div><div><span style="white-space: pre; ">        </span>self flushExternalPrimitiveTable</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote"><div><div></div></div><div><div></div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

initialCleanup<br>
        &quot;Images written by VMs earlier than 3.6/3.7 will wrongly have the root bit set on the active context. Besides clearing the root bit, we treat this as a marker that these images also lack a cleanup of external primitives (which has been introduced at the same time when the root bit problem was fixed). In this case, we merely flush them from here.&quot;<br>


<br>
        ((self longAt: activeContext) bitAnd: RootBit) = 0 ifTrue:[^nil]. &quot;root bit is clean&quot;<br>
        &quot;Clean root bit of activeContext&quot;<br>
        self longAt: activeContext put: ((self longAt: activeContext) bitAnd: AllButRootBit).<br>
        &quot;Clean external primitives&quot;<br>
        self flushExternalPrimitives.<br>
<br>
<br>
then<br>
<br>
<br>
flushExternalPrimitives<br>
        &quot;Flush the references to external functions from plugin<br>
        primitives. This will force a reload of those primitives when<br>
        accessed next.<br>
        Note: We must flush the method cache here so that any<br>
        failed primitives are looked up again.&quot;<br>
        | oop primIdx |<br>
        oop := self firstObject.<br>
        [self oop: oop isLessThan: endOfMemory]<br>
                whileTrue: [(self isFreeObject: oop)<br>
                                ifFalse: [(self isCompiledMethod: oop)<br>
                                                ifTrue: [&quot;This is a compiled method&quot;<br>
                                                        primIdx := self primitiveIndexOf: oop.<br>
                                                        primIdx = PrimitiveExternalCallIndex<br>
                                                                ifTrue: [&quot;It&#39;s primitiveExternalCall&quot;<br>
                                                                        self flushExternalPrimitiveOf: oop]]].<br>
                        oop := self objectAfter: oop].<br>
        self flushMethodCache.<br>
        self flushObsoleteIndexedPrimitives.<br>
        self flushExternalPrimitiveTable<br>
<br>
<br>
snapshotCleanUp<br>
        &quot;Clean up right before saving an image, sweeping memory and:<br>
        * nilling out all fields of contexts above the stack pointer.<br>
        * flushing external primitives<br>
        * clearing the root bit of any object in the root table &quot;<br>
        | oop header fmt sz |<br>
        oop := self firstObject.<br>
        [self oop: oop isLessThan: endOfMemory]<br>
                whileTrue: [(self isFreeObject: oop)<br>
                                ifFalse: [header := self longAt: oop.<br>
                                        fmt := header &gt;&gt; 8 bitAnd: 15.<br>
                                        &quot;Clean out context&quot;<br>
                                        (fmt = 3 and: [self isContextHeader: header])<br>
                                                ifTrue: [sz := self sizeBitsOf: oop.<br>
                                                        (self lastPointerOf: oop) + BytesPerWord<br>
                                                                to: sz - BaseHeaderSize by: BytesPerWord<br>
                                                                do: [:i | self longAt: oop + i put: nilObj]].<br>
                                        &quot;Clean out external functions&quot;<br>
                                        fmt &gt;= 12<br>
                                                ifTrue: [&quot;This is a compiled method&quot;<br>
                                                        (self primitiveIndexOf: oop) = PrimitiveExternalCallIndex<br>
                                                                ifTrue: [&quot;It&#39;s primitiveExternalCall&quot;<br>
                                                                        self flushExternalPrimitiveOf: oop]]].<br>
                        oop := self objectAfter: oop].<br>
        self clearRootsTable<br><font color="#888888">
<br>
<br>
--<br>
===========================================================================<br>
John M. McIntosh &lt;<a href="mailto:johnmci@smalltalkconsulting.com" target="_blank">johnmci@smalltalkconsulting.com</a>&gt;<br>
Corporate Smalltalk Consulting Ltd.  <a href="http://www.smalltalkconsulting.com" target="_blank">http://www.smalltalkconsulting.com</a><br>
===========================================================================<br>
<br>
<br>
<br>
</font></blockquote></div></div></div><br>
</blockquote></div><br>