[gclist] Precise GC's performance

John Jannotti jjannott@goober.mit.edu
Fri, 8 Mar 1996 19:31:03 -0500



Darius Blasband wrote:
>>"When the YAFL GC is started, a first mark pass is performed. Then, on all
>>objects which have been found not to be reachable anymore from the root sets,
>>the KILL method is applied if defined. No deallocation is performed
>>yet. Hence, no cycle problem.

>>Then, a brand new mark pass is performed, and all objects which have been
>>found unreachable on both of these passes are deallocated. This allows for
>>"last chance rescue": when a given object is being killed, it can rescue
>>itself from deallocation by setting an external reference to itself as part
>>of its KILL method.

>>I don't know whether such a scheme can be implemented on top of Boehm's
>>GC. Any clue ?"

Hans Boehm responded
> I think there's currently no may to implement this on top of our collector
> without making copies of objects.  Adding it would involve a very local and
> fairly simple change to the collector code.  (Actually there may be
> an obscure way to do it, but modifying the collector would be cleaner.)

Obviously, you're the expert here, but why not just add a bit to
objects with finalizers?  The bit would mean, "finalizer must be
called".  If the bit is *on*, a collection would cause the object's
finalizer to be called, and the bit flipped *off*.  Then, instead of
having a second pass, just wait for the next collection.  If the bit
is *off* during a collection, the object is just collected as normal
(no call to the finalizer).  To handle the "rescue from deallocation",
if such an object is reachable in a collection, the bit is always
turned back *on*.

I don't know enough of the details of the collector to know if this is
definately doable this way, but it seems so.

John Jannotti