[squeak-dev] true hash

David T. Lewis lewis at mail.msen.com
Wed May 9 23:06:43 UTC 2012


On Wed, May 09, 2012 at 09:57:16PM +0200, Bert Freudenberg wrote:
> On 09.05.2012, at 21:28, Chris Muller wrote:
> 
> > Where do true, false and nil obtain their hash value?  They inherit
> > #hash from Object, so it is their identityHash, but I noticed this is
> > consistent between images -- how?  It's great, but is there any danger
> > of that value ever changing?  That would be bad..
> 
> 
> The identity hash bits are stored in each object's header. And since true, false, nil are the same decades old instances, their hash did not change.
> 
> Depending on what the SystemTracer does, it may be different in an image derived by that though. E.g. you may want to check a 64 bit image.
> 
> - Bert -

FWIW, on a 32-bit image:

  ImageFormat thisImageFileFormat asInteger ==> 6504
  Smalltalk wordSize ==> 4
  nil identityHash ==> 3840
  true identityHash ==> 2950
  false identityHash ==> 3152

And on a 64-bit image:

  ImageFormat thisImageFileFormat asInteger ==> 68002
  Smalltalk wordSize ==> 8
  nil identityHash ==> 3840
  true identityHash ==> 2950
  false identityHash ==> 3152

Dave



More information about the Squeak-dev mailing list