Garbage Collection
Thursday, January 15, 2009 Garbage collection is a pretty critical decision when building a virtual machine. It determines a bunch of other decisions such as object layout in memory. For a good overview of different garbage collection techniques checkout wikipedia. To see some of the other issues that you face when actually building a GC, there is a really good FAQ on the I.E.C.C GC List FAQ.
Normal binary would be:
0000 0100
SquirrelFish internal representation:
0000 1001
There are other tags in SquirrelFish as well. The implementation details as well as the other comments are in JSImmediate.h..
* Tip from Aaron. Pointers are guaranteed to point to aligned word boundaries.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 00
[ high 30 bits: pointer address ] [ low 2 bits -- always 0 ]XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 1
[ high 31 bits: signed integer ] [ lowest bit -- always 1 ]
000000000000000000000000000 01 10
[ boolean value ] [ bool ] [ tag 'other' ]000000000000000000000000000 10 10
[ zero ] [ undefined ] [ tag 'other' ]000000000000000000000000000 00 10
[ zero ] [ zero ] [ tag 'other' ]

Reader Comments (2)
it's worth noting here that this trick works because the things to which the pointers point are guaranteed to be aligned to word boundaries, thus the bottom two bits of the pointer would be zero anyway.
This is a fairly old trick and is used by many programming language implementations (off the top of my head Matz's Ruby, OCaml, and a handful of lisps all do this).
Hi Aaron,
Thanks for the tip, it's a pretty cool trick.