[gclist] object identity & copying collection

David Chase chase@world.std.com
Wed, 10 Dec 1997 09:18:44 -0500


I saw what looked like a clever trick on the Squeak mailing list.
There, each option header has two bits reserved for storing one of
three states:

  1. no hash code computed
  2. hash code is address
  3. hash code follows object

The usual case is #1.  When Object.hashCode is requested, the object
is placed in state #2.  When the object is moved, it is placed in state
#3.

This can lead to objects with equal hashcodes, but nobody ever claimed
they would be unique, and this can be avoided somewhat by shuffling
newspaces around (if you use page-mapping tricks on Windows NT to get
zeroed pages, and give it its choice of pages, it does the shuffling
for you.  Not clear this is a system-level win, but it helps this
small problem).

David Chase
chase@world.std.com