Re: [Pharo-project] [Vm-dev] Re: squeak VM 5.0
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 ===========================================================================
Ok, well I created Mantis http://bugs.squeak.org/view.php?id=7430 to document. Personally I would do Smalltalk wordSize versus SystemDictionary wordSize Also the issue is when to change the WordSize variable. I think in SmalltalkImage>>snapshot: andQuit: embedded: right at the ifTrue: [self quitPrimitive]. Cursor normal show. you want to set things so that wordSize is reset. At quit time you could do the reset before the "self quitPrimitive" then you know the value is reset and needs to be recalculated at startup time. or you can reset it before the Cursor normal show. which runs after startup time Somehow I think there is more risk resetting it after startup since I'm not sure when something could leap in wanting a valid value. On 2009-12-16, at 2:44 PM, Laval Jannik wrote:
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.
-- =========================================================================== John M. McIntosh <johnmci@smalltalkconsulting.com> Twitter: squeaker68882 Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com ===========================================================================
Hi, I modify the variable in the method "clonePreStartup". So, it works fine. ===== !SystemTracer2 methodsFor: 'clone startup' stamp: 'ajh 8/22/2002 11:15'! clonePreStartup "This will be executed right away when the new clone starts up, before processStartup. Subclasses may want to rehash all objects or something" SystemDictionary wordSize: self wordSize.! ! ===== Now, there are some tests which does not pass. So, I will publish the code and the pharoImage64, and with the community, we can check this. Cheers, Jannik On Dec 17, 2009, at 02:32 , John M McIntosh wrote:
Ok, well I created Mantis http://bugs.squeak.org/view.php?id=7430 to document.
Personally I would do Smalltalk wordSize versus SystemDictionary wordSize
Also the issue is when to change the WordSize variable.
I think in SmalltalkImage>>snapshot: andQuit: embedded: right at the ifTrue: [self quitPrimitive]. Cursor normal show. you want to set things so that wordSize is reset.
At quit time you could do the reset before the "self quitPrimitive" then you know the value is reset and needs to be recalculated at startup time. or you can reset it before the Cursor normal show. which runs after startup time
Somehow I think there is more risk resetting it after startup since I'm not sure when something could leap in wanting a valid value.
On 2009-12-16, at 2:44 PM, Laval Jannik wrote:
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.
-- =========================================================================== John M. McIntosh <johnmci@smalltalkconsulting.com> Twitter: squeaker68882 Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com ===========================================================================
participants (2)
-
John M McIntosh -
Laval Jannik