[squeak-dev] Re: [Pharo-project] squeak VM 5.0

John M McIntosh johnmci at smalltalkconsulting.com
Wed Dec 16 08:48:18 UTC 2009

RIght and it's 12:30 am again, 

So the MAGIC fixes for the tracer to let you build a 64bit Pharo image are below. 
No doubt they apply to closure based squeak trunk images. 

Could someone can be kind enough to integrate them into the current System-Tracing.2forPharo.cs ? 
Then some people in Europe? can grab the current Pharo/Trunk image and convert it, and run some smoke tests. 
BTW you need to use the Squeak.5.0.0.b9.64*64.app.zip to run a 64bit image

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. 
Still need someone to *fix* the systemtracer so it will run on intel machines.  (Hint watch how it writes out integer data). ... 
Changes below:

"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? "
"There likely should be a Pharo/Squeak bug for this since it should be using wordSize not a magic number of 4"

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."

So I'll let someone propose/write a clever solution since the Smalltalk wordSize is computational heavy.

	"Answer the program counter for the receiver's first bytecode."

	^ (self numLiterals + 1) * (Smalltalk wordSize) + 1  

"This next method  isn't used much, should be. But the System-Tracing.2forPharo.cs trashes it with a ancient version. 
This is the correct version"

 "Answer the size (in bytes) of an object pointer." 
 "Smalltalk wordSize" 
 ^[SmalltalkImage current vmParameterAt: 40] on: Error do: [4]

"Changes to properly fix up BlockClosure in the SystemTracer2" 

SystemTracer2>>object: object allFieldsWithIndex: block collect: sequenceableCollectionClass
	"Evaluate block against each of the pointer fields with index, and collect the results in an instance of sequenceableCollectionClass"

	| fixedSize results varSize nilResults blockvalue |
	object isCompiledMethod ifTrue:
		[results := sequenceableCollectionClass new: 1 + object numLiterals.
		1 to: 1 + object numLiterals do:
			[:j | results at: j put: (block value: (object objectAt: j) value: j)].
		^ results].
	fixedSize := object class instSize.
	varSize := object basicSize.
	results := sequenceableCollectionClass new: fixedSize + varSize.
	1 to: fixedSize do:
		[:j | results at: j put: (block value: (object instVarAt: j) value: j)].
	1 to: varSize do:
		[:j | 
		results at: fixedSize + j put: (block value: (object basicAt: j) value: fixedSize + j)].

	object isContextPart ifTrue:
		[(object instVarAt: 2) ifNotNil:
			["May need to adjust PC and startPC if changing wordSize..."
			blockvalue := (object instVarAt: 2)+(self pcDeltaForMethod: object method).
		results at: 2 put: (block value: blockvalue value: 2)].
		((object isMemberOf: BlockContext) and: [object home notNil]) ifTrue:
				[results at: 5 put: (block value: (object instVarAt: 5)+(self pcDeltaForMethod: object method) value: 5)].
		"Need to fill out the nils beyond the knowable end of stack"
		nilResults := sequenceableCollectionClass new: object frameSize - object basicSize.
		1 to: nilResults size do:
			[:j | nilResults at: j put: (block value: nil value: j)].
		^ results , nilResults].
	object class = BlockClosure ifTrue: 
		["May need to adjust PC and startPC if changing wordSize..."
		blockvalue := (object instVarAt: 2)+(self pcDeltaForMethod: object method).
		results at: 2 put: (block value: blockvalue value: 2)].
		^ results 

>> Eliot and I spent 30 minutes chatting about what is wrong. The conclusion is we *think* we are doing the right thing, 
>> yet the Virtual Machine says the image is busted.   So a quick fix is not apparent, and we'll dig more. 

John M. McIntosh <johnmci at smalltalkconsulting.com>   Twitter:  squeaker68882
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com

More information about the Squeak-dev mailing list