[Gc] Newbie: collect non-pointers

Jan Wielemaker J.Wielemaker at vu.nl
Wed Dec 14 12:48:49 PST 2011


I've started studying the use of the Boehm collector for SWI-Prolog, as
it seems a great alternative to cleanly collect the various heap
objects. Now, Prolog already has a collector that does something
similar: the atom garbage collector. This thing walks along the Prolog
stacks of all threads and marks reachable atoms. Running both the
current atom-gc and Boehm GC worries me a bit. They are likely do do
double work and might start fighting over signals (atom-gc uses a
similar approach to suspend threads as Boehm-GC).

If I can replace atom-gc using the Boehm collector I avoid this and get
the benefits that the Boehm collector scans the C stacks and CPU
registers (safe references to atoms outside the Prolog stacks are
now the responsibility of the user, using reference counts).

But, atoms are not pointers. Instead, they are integers with the width
of a pointer (uintptr_t) and contain a (shifted) offset into an array in
addition to several housekeeping bits. This array contains pointers to
atom structures. This cannot be changed without a serious redesign of
the Prolog datastructures :-(

What I'm hoping is that I can provide a marker routine that will, along
with looking for pointers, look for atoms and allows me to clean the
unused ones.

Reading the slides and scanning through the headers and some googling
suggests this might be possible.  Can someone tell me whether this can
work, where to start looking and hopefully some example code?

	Thanks a lot --- Jan

More information about the Gc mailing list