Re: [Pharo-project] squeak VM 5.0

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-project] squeak VM 5.0

johnmci

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 <[hidden email]>   Twitter:  squeaker68882
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================




Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-project] squeak VM 5.0

johnmci

Obviously some bored developer should take one of these handy 64bit images and with a 64bit vm
fire it up and create oh mmm let's say a 10GB image?  Just to see, don't forget to save it and reopen,
do a garbage collect all...

Can't recall hearing of anyone trying an image greater than 2 GB...

If you show proof of a 100GB image, then I'll buy you a beer at the next ESUG.

On 2009-12-16, at 12:48 AM, John M McIntosh wrote:

> So the MAGIC fixes for the tracer to let you build a 64bit Pharo image are below.

--
===========================================================================
John M. McIntosh <[hidden email]>   Twitter:  squeaker68882
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================




Reply | Threaded
Open this post in threaded view
|

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

Eliot Miranda-2
In reply to this post by johnmci
 
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 <[hidden email]> 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 <[hidden email]>   Twitter:  squeaker68882
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================





Reply | Threaded
Open this post in threaded view
|

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

johnmci
 
Ok, well I created Mantis 
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 <[hidden email]>   Twitter:  squeaker68882
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================




Reply | Threaded
Open this post in threaded view
|

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

David T. Lewis
 
On Wed, Dec 16, 2009 at 05:32:37PM -0800, John M McIntosh wrote:
>  
> Ok, well I created Mantis
> http://bugs.squeak.org/view.php?id=7430
> to document.

Good idea, thanks.

> Personally I would do
> Smalltalk wordSize
> versus
> SystemDictionary wordSize

I gather from Eliot's comment about using a class instance variable that
"SystemDictionary wordSize" would be preferred for performance.  But
"Smalltalk wordSize" reads well and is easier to understand.

Ideally, I would view the word size as an attribute of the object memory,
hence "ObjectMemory wordSize". However, most images do not have class
ObjectMemory loaded, so perhaps

  Object wordSize

to convey the intended meaning without requiring a dictionary lookup?

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

I would think that doing it immediately after the quitPrimitive would
be more reliable overall. It's simple, and if something did not work
you would know exactly where to look for the problem.

Dave

Reply | Threaded
Open this post in threaded view
|

Re: squeak VM 5.0

Bert Freudenberg
In reply to this post by johnmci
 
On 17.12.2009, at 07:44, Laval Jannik wrote:
Hi,

I modify the variable in the method "clonePreStartup".
So, it works fine.


Given that this won't change on any further startup I'd think this is a better solution than putting it in the snapshot code. Since there won't be a sender of #wordSize: in the resulting image, I'd add a comment explaining why. Also, I'd take out the lazy init code in #wordSize, no need to be lazy here ;)

- Bert -

=====
!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 
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.