[Gc] About "Disclaim" patch for BDWGC
urkedal at nbi.dk
Sat Aug 6 08:39:15 PDT 2011
On 2011-08-06, Petter Urkedal wrote:
> There is another change in mark.c to allow objects in an object kind to
> be treated as roots, to protect pointers which may be referenced by the
> finalizer. This is usually not needed by weak data-structures.
Correction: This is usually needed for weak data-structures. My
statement to the contrary was based on my experience with hash-consing
to which it applies. To see that, just notice that any algorithm which
constructs an object needs to first construct all referenced objects,
possibly resurrecting them in the process. There is however a subtlety
Suppose we have an object A pointing to B, say a tuple
A = (X, B, Y)
After a garbage collection, both A and B are unmarked. Then B is
reclaimed to construct a new object B'. Now, if we construct the object
A' = (X, B', Y)
before A is reclaimed, then A' will hash-cons to the same pointer as A.
No harm is done, since there are no longer any pointers around which are
meant to refer to A. We have merely re-used the bitwise representation.
More information about the Gc