hashing behaviors for the system archive

Craig Latta craig at netjam.org
Wed Jun 6 00:49:04 UTC 2007


Hi all--

     I'm working on the system archive for Spoon (see [1]). I'll be
storing "records" in it which have suitable information for
reconstructing past versions of classes and methods (e.g., the format of
a class, or a method's instructions, amongst several other things).

     A common operation is looking up the record for a
currently-installed class or method. I'd like for each class and method
to be able to provide a key for looking up the corresponding record,
effectively a hash (what I call a "storage hash"). I think it would be
fine to use the identity hash of a method (along with the normal hash,
for additional range, in 28-bit space via hashMultiply), since methods
change identity completely from version to version. When you recompile
the source for an existing method, the system makes a completely new
compiled method, it doesn't modify the old one.

     However, a behavior's state can change in ways that result in a new
version of the behavior as far as the archive is concerned, without
changing the identity of the class object itself (e.g., changing class
name). There are several such state changes, and some of the pieces of
state can refer back to the class itself. Rather than have to perform an
expensive and possibly circular storage hash calculation, I wonder if it
would be reasonable to use the identity hashes of the class and its
superclass, and just have the class change its own identity hash
whenever one of those state changes occurs. It's easy enough to add a
primitive to change the hash bits of an object to the next pseudo-random
hash value.

     This brings me to the gazillionth recitation of the classic
Smalltalk hacker's question: Will something bad happen if I do this? :)
(The corollary is that I have indeed already done it and nothing bad
seems to have happened *yet* :). Is there some part of the system I've
overlooked that depends critically on the identity hashes of classes
remaining consistent over some period of time, or can I feel free to
swizzle the hash bits and then just rehash whatever hashed collections
might be using them?


     thanks!

-C

[1] http://tinyurl.com/2zvv8o (lists.squeakfoundation.org)

-- 
Craig Latta
improvisational musical informaticist
www.netjam.org
Smalltalkers do: [:it | All with: Class, (And love: it)]



More information about the Spoon mailing list