Pie Squared <PieSquared@[EMAIL PROTECTED]
> writes:
> Is it possible to make a conservative moving GC?
> [...]
> So, is there some way to have a conservative GC which moves it's
> objects around?
A moving GC changes the value of pointers, which is fine as long as
the new pointer value points to (a copy of) the same object as the old
pointer value.
A conservative GC is a GC that does not know which values in memory
are pointers. So if the GC has a value that it is unsure is a pointer
or an integer (or real, character or anything other than a pointer to
the heap), it can not change it. The traditional approach is let the
GC do something that is safe regardless of whether the value is a
pointer or an integer, i.e., keep the value unchanged and keep the
heap structure it points to live. This precludes moving the heap
structure to another address, unless you leave a forwarding pointer
(and make the program transparently follow such forwarding pointers,
which sup****t from the compiler). But if you leave forwarding
pointers, the advantage of moving objects (better locality, freeing up
the old heap space) is lost.
The way a conservative GC recognise a non-pointer is usually by its
value: If the value seen as a pointer points outside the heap or is
not aligned to whatever alignment the heap enforces, then it can not
be a heap pointer.
Recognising something that is definitely a heap pointer is more
difficult, as an integer can take any value. So a GC needs extra
information to identify pointers. Non-conservative GCs have the
compiler mark values as pointers or non-pointers, but conservative GCs
don't have that option (if they did, they would not be conservative).
Torben


|