[Gc] How can I advise the mark phase?
Richard A. O'Keefe
ok at cs.otago.ac.nz
Wed May 18 17:58:47 PDT 2005
I want to use this GC in the runtime for a compiler I'm writing.
The representation I am using is
immediate integer: true value shifted left 2, 00
immediate character: Unicode value shift left 2, 10
pointer to object: pointer to class number | 01
Characters are immediate because with more than a million possible
Unicode characters, I really don't want to allocate an object for each.
The use of 00 for integers simplifies integer arithmetic a lot.
The layout of each object is low addresses
start of block: instance variables |
instance variables |
(coded pointer -1): (class number << 2, 00) V
start of block: instance variables
(coded pointer -1): (class number << 2, 00)
(number of indexed elements << 2, 00)
This representation is chosen so that arrays can be passed to C as
C arrays and so that it is easy to find the array size no matter how
many instance variables there are.
So any valid pointer
(1) must end in 01, so points "into the middle"
(2) must point to a word (0..n)*4 where the number of classes n is known
(3) provides, in the class number, an index into a table that says
(a) how many slots precede the class number, which can
used to check that the pointer is valid
(b) whether the elements are pointers, floats, bytes, &c,
which can be used to avoid scanning binary data.
The thing that's not clear to me is how to tell the collector about this.
I suspect that I may have to modify the collector myself; where should I
More information about the Gc