Um, I'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 "browse inst var refs". 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"><<a href="mailto:johnmci@smalltalkconsulting.com">johnmci@smalltalkconsulting.com</a>></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'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'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>
"This is the magic change, it's not the conversion of the image that is bad. It's the Smalltalk code assumption of is that 4 or 8 bytes? "<br>
"There likely should be a Pharo/Squeak bug for this since it should be using wordSize not a magic number of 4"<br>
<br>
Eliot notes "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."<br>
<br>
So I'll let someone propose/write a clever solution since the Smalltalk wordSize is computational heavy.<br>
<br>
CompiledMethod>>initialPC<br>
"Answer the program counter for the receiver's first bytecode."<br>
<br>
^ (self numLiterals + 1) * (Smalltalk wordSize) + 1<br>
<br>
<br>
"This next method isn't used much, should be. But the System-Tracing.2forPharo.cs trashes it with a ancient version.<br>
This is the correct version"<br>
<br>
SystemDictionary>>wordSize<br>
"Answer the size (in bytes) of an object pointer."<br>
"Smalltalk wordSize"<br>
^[SmalltalkImage current vmParameterAt: 40] on: Error do: [4]<br>
<br>
"Changes to properly fix up BlockClosure in the SystemTracer2"<br>
<br>
SystemTracer2>>object: object allFieldsWithIndex: block collect: sequenceableCollectionClass<br>
"Evaluate block against each of the pointer fields with index, and collect the results in an instance of sequenceableCollectionClass"<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>
["May need to adjust PC and startPC if changing wordSize..."<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>
"Need to fill out the nils beyond the knowable end of stack"<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>
["May need to adjust PC and startPC if changing wordSize..."<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>
>> Eliot and I spent 30 minutes chatting about what is wrong. The conclusion is we *think* we are doing the right thing,<br>
>> yet the Virtual Machine says the image is busted. So a quick fix is not apparent, and we'll dig more.<br>
<font color="#888888"><br>
--<br>
===========================================================================<br>
John M. McIntosh <<a href="mailto:johnmci@smalltalkconsulting.com">johnmci@smalltalkconsulting.com</a>> 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>