Hi Eliot, hi John, This is what I do: - create a class var in SystemDictionary - accessors (wordSize and wordSize:), the first one can initialize the variable if nil, the second is to modify the value in case of 64bits image. Maybe the second one could be integrated in System-Tracing file. - in CompiledMethod, initialPC use it. Maybe we could integrate it in pharoCore. Cheers, Jannik ======= 'From PharoCore1.1ALPHA of ''19 October 2009'' [Latest update: #11088] on 16 December 2009 at 11:06:21 pm'! IdentityDictionary subclass: #SystemDictionary instanceVariableNames: 'cachedClassNames ' classVariableNames: 'LastImageName LastQuitLogPosition LowSpaceProcess LowSpaceSemaphore MemoryHogs ShutDownList SpecialSelectors StartUpList StartupStamp SystemChanges WordSize ' poolDictionaries: '' category: 'System-Support'! !SystemDictionary class methodsFor: 'initialization' stamp: 'jannik.laval 12/16/2009 22:40'! wordSize WordSize ifNil: [WordSize := [SmalltalkImage current vmParameterAt: 40] on: Error do: [4]]. ^WordSize! ! !SystemDictionary class methodsFor: 'initialization' stamp: 'jannik.laval 12/16/2009 22:40'! wordSize: aNumber WordSize := aNumber! ! IdentityDictionary subclass: #SystemDictionary instanceVariableNames: 'cachedClassNames' classVariableNames: 'LastImageName LastQuitLogPosition LowSpaceProcess LowSpaceSemaphore MemoryHogs ShutDownList SpecialSelectors StartUpList StartupStamp SystemChanges WordSize' poolDictionaries: '' category: 'System-Support'! !CompiledMethod methodsFor: 'accessing' stamp: 'jannik.laval 12/16/2009 22:41'! initialPC "Answer the program counter for the receiver's first bytecode." ^ (self numLiterals + 1) * SystemDictionary wordSize + 1! ! ======= On Dec 16, 2009, at 18:32 , Eliot Miranda wrote:
Um, I'm _quite_ serious on insisting that 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.
On Wed, Dec 16, 2009 at 12:48 AM, John M McIntosh <johnmci@smalltalkconsulting.com> wrote:
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.
CompiledMethod>>initialPC "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"
SystemDictionary>>wordSize "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@smalltalkconsulting.com> Twitter: squeaker68882 Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com ===========================================================================