Mantis - Squeak
Viewing Issue Advanced Details
7430 Squeak 64 bit crash always 12-17-09 00:52 04-18-10 21:59
johnmci  
lewis  
urgent  
closed trunk  
fixed  
none    
none  
0007430: CompiledMethod>> initialPC calculation is wrong for 64bit images
Needs to consider Smalltalk wordsize (cached value) versus the hard coded 4, because on a 64bit image it's 8.

related to 0005239closed lewis Need a re-traced 64 bit image for current VM 
 CompiledMethod-initialPC.st [^] (306 bytes) 12-17-09 13:12
 Smalltalk-wordSize-dtl-M7430.1.cs [^] (3,629 bytes) 12-18-09 05:44
 Smalltalk-wordSize-dtl-M7430.2.cs [^] (1,172 bytes) 12-18-09 23:14

Notes
(0013436)
lewis   
12-17-09 13:16   
For reference, I uploaded CompiledMethod-initialPC.st, which contains the version of this method from the original "dist 3" 64-bit image. This uses "Smalltalk wordSize", which is correct (but slow). Presumably this version of the method was added to the 32-bit image prior to tracing the 64-bit image. See discussion on Squeak/Pharo lists concerning the best way to do this without impacting performance.
(0013437)
lewis   
12-18-09 05:49   
Laval Jannik posted fixes on vm-dev and pharo lists. The attached Smalltalk-wordSize-dtl-M7430.1.cs is a variation on Laval's proposal.

This uses "Smalltalk wordSize" (not "SystemDictionary wordSize"), and clears the cached value immediately prior to a snapshot.

Cache Smalltalk wordSize in class var in SystemDictionary. Clear the cached value prior to an image snapshot, and initialize it on image restart.

Update CompiledMethod>>initialPC to use #wordSize. This is the method as implemented in the original 64-bit image (author di)."
(0013438)
johnmci   
12-18-09 06:24   
I don't think we need the Smalltalk clearWordSize in snapshot: save andQuit: quit embedded: embeddedFlag. Based on the discussion of what is going on, all existing images start out as 32bit images so they need the WordSize on SystemDictionary, which will get set to 4, and of course the change to CompiledMethod>> initialPC

 But as pointed out when the SystemTracer2 converts it to a 64bit image we then change the value to 8 as part of the bootstrapping. Now there is no need to nill or swap back to 4, because 8 is the only correct answer for a 64bit image so there is no need to nil and reload 8 back into the class var.
(0013439)
lewis   
12-18-09 23:18   
Agreed, setting WordSize should be done only by system trace as per Bert's suggestion. Corrected change set attached (Smalltalk-wordSize-dtl-M7430.2.cs), which caches #wordSize but does not affect snapshot/resume. Need to confirm that this matches changes for Pharo by Laval Jannik <jannik.laval@inria.fr>, or just use Laval's changes directly (I don't have the change set).
(0013455)
lewis   
01-05-10 02:54   
Smalltalk-wordSize-dtl-M7430.2.cs has been added to Squeak trunk. I also updated the method comment for #wordSize to explain:

"Answer the size in bytes of an object pointer or word in the object memory. The value does not change for a given image, but may be modified by a SystemTracer when converting the image to another format. The value is cached in WordSize to avoid the performance overhead of repeatedly consulting the VM."

(0013484)
lewis   
01-16-10 18:55   
Fixed in Squeak trunk and Pharo