[gclist] write barrier
Charles Fiterman
cef@geode.geodesic.com
Fri, 8 Mar 1996 08:37:04 -0600
> Dear GC'ers,
>
> A dumb question from a novice but very interested reader of this list:
> what's a "write barrier" and what role does it play in a GC?
Dumb questions are better than dumb mistakes. It means that when you
write something to a pointer the collector gets notified. This
is a vital notion in incremental collectors, that is collectors which
run a little, let the mutator run a little etc.
Consider the Baker four color algorithm. Suppose an object is on
the Black queue meaning it is used and the collector has already
marked any objects it points to. Now suppose the mutator changes
a pointer in that object to point to an object in the white queue,
objects that are being classified by the collector. Now that object
will never go to the Grey queue, objects that are used but not
examined yet. So there is a write barrier which says if a pointer
is changed to point to an object on the white queue move it to the
grey queue.
An alternative notion in conservative collectors are dirty bits. The
collector will scan a page of memory and mark it clean. If the page
is modified the operating system will mark the page dirty and the
collector will have to rescan it.