Um, I&#39;m _quite_ serious on insisting that <span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">Smalltalk wordSize be implemented in some way that caches the value in e.g. a class variable (or class inst var for max speed) that is reevaluated on startup.  initialPC is evaluated a lot, e.g. once for every method in a &quot;browse inst var refs&quot;.  This is performance-critical, and going to a slow primitive to access something that can only change at startup is not a good idea.  Please arrange that e.g. SystemDictionary gains a class var that caches the word size.</span><div>
<br><div class="gmail_quote">On Wed, Dec 16, 2009 at 12:48 AM, John M McIntosh <span dir="ltr">&lt;<a href="mailto:johnmci@smalltalkconsulting.com">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>
RIght and it&#39;s 12:30 am again,<br>
<br>
So the MAGIC fixes for the tracer to let you build a 64bit Pharo image are below.<br>
No doubt they apply to closure based squeak trunk images.<br>
<br>
Could someone can be kind enough to integrate them into the current System-Tracing.2forPharo.cs ?<br>
Then some people in Europe? can grab the current Pharo/Trunk image and convert it, and run some smoke tests.<br>
BTW you need to use the Squeak.5.0.0.b9.64*64.app.zip to run a 64bit image<br>
<br>
Don&#39;t forget to convert you have to use a powerpc, or a  squeak VM that is running as powerpc (via get info settings) on your macintel machine.<br>
Still need someone to *fix* the systemtracer so it will run on intel machines.  (Hint watch how it writes out integer data). ...<br>
<br>
Changes below:<br>
<br>
&quot;This is the magic change, it&#39;s not the conversion of the image that is bad. It&#39;s the Smalltalk code assumption of is that 4 or 8 bytes? &quot;<br>
&quot;There likely should be a Pharo/Squeak bug for this since it should be using wordSize not a magic number of 4&quot;<br>
<br>
Eliot notes  &quot;Bravo!  But Smalltalk wordSize has to be implemented in some way that caches the value in e.g. a class variable (or class inst var for max speed) that is reevaluated on startup.&quot;<br>
<br>
So I&#39;ll let someone propose/write a clever solution since the Smalltalk wordSize is computational heavy.<br>
<br>
CompiledMethod&gt;&gt;initialPC<br>
        &quot;Answer the program counter for the receiver&#39;s first bytecode.&quot;<br>
<br>
        ^ (self numLiterals + 1) * (Smalltalk wordSize) + 1<br>
<br>
<br>
&quot;This next method  isn&#39;t used much, should be. But the System-Tracing.2forPharo.cs trashes it with a ancient version.<br>
This is the correct version&quot;<br>
<br>
SystemDictionary&gt;&gt;wordSize<br>
 &quot;Answer the size (in bytes) of an object pointer.&quot;<br>
 &quot;Smalltalk wordSize&quot;<br>
 ^[SmalltalkImage current vmParameterAt: 40] on: Error do: [4]<br>
<br>
&quot;Changes to properly fix up BlockClosure in the SystemTracer2&quot;<br>
<br>
SystemTracer2&gt;&gt;object: object allFieldsWithIndex: block collect: sequenceableCollectionClass<br>
        &quot;Evaluate block against each of the pointer fields with index, and collect the results in an instance of sequenceableCollectionClass&quot;<br>
<br>
        | fixedSize results varSize nilResults blockvalue |<br>
        object isCompiledMethod ifTrue:<br>
                [results := sequenceableCollectionClass new: 1 + object numLiterals.<br>
                1 to: 1 + object numLiterals do:<br>
                        [:j | results at: j put: (block value: (object objectAt: j) value: j)].<br>
                ^ results].<br>
<br>
        fixedSize := object class instSize.<br>
        varSize := object basicSize.<br>
        results := sequenceableCollectionClass new: fixedSize + varSize.<br>
        1 to: fixedSize do:<br>
                [:j | results at: j put: (block value: (object instVarAt: j) value: j)].<br>
        1 to: varSize do:<br>
                [:j |<br>
                results at: fixedSize + j put: (block value: (object basicAt: j) value: fixedSize + j)].<br>
<br>
        object isContextPart ifTrue:<br>
<div class="im">                [(object instVarAt: 2) ifNotNil:<br>
                        [&quot;May need to adjust PC and startPC if changing wordSize...&quot;<br>
</div>                        blockvalue := (object instVarAt: 2)+(self pcDeltaForMethod: object method).<br>
                results at: 2 put: (block value: blockvalue value: 2)].<br>
                ((object isMemberOf: BlockContext) and: [object home notNil]) ifTrue:<br>
                                [results at: 5 put: (block value: (object instVarAt: 5)+(self pcDeltaForMethod: object method) value: 5)].<br>
                &quot;Need to fill out the nils beyond the knowable end of stack&quot;<br>
                nilResults := sequenceableCollectionClass new: object frameSize - object basicSize.<br>
                1 to: nilResults size do:<br>
                        [:j | nilResults at: j put: (block value: nil value: j)].<br>
                ^ results , nilResults].<br>
<div class="im">        object class = BlockClosure ifTrue:<br>
                [&quot;May need to adjust PC and startPC if changing wordSize...&quot;<br>
</div>                blockvalue := (object instVarAt: 2)+(self pcDeltaForMethod: object method).<br>
                results at: 2 put: (block value: blockvalue value: 2)].<br>
                ^ results<br>
<br>
<br>
&gt;&gt; Eliot and I spent 30 minutes chatting about what is wrong. The conclusion is we *think* we are doing the right thing,<br>
&gt;&gt; yet the Virtual Machine says the image is busted.   So a quick fix is not apparent, and we&#39;ll dig more.<br>
<font color="#888888"><br>
--<br>
===========================================================================<br>
John M. McIntosh &lt;<a href="mailto:johnmci@smalltalkconsulting.com">johnmci@smalltalkconsulting.com</a>&gt;   Twitter:  squeaker68882<br>
Corporate Smalltalk Consulting Ltd.  <a href="http://www.smalltalkconsulting.com" target="_blank">http://www.smalltalkconsulting.com</a><br>
===========================================================================<br>
<br>
<br>
<br>
<br>
</font></blockquote></div><br></div>