Godmar Back gback at
Sat Aug 29 22:14:40 PDT 1998

> What does the soft_addreference() function do? And where is it?
> I can't seem to find it anywhere... is it obsolete? If so, then
> what about this macro in gc-incremental.h?
>   #if defined(GC_INCREMENTAL)
>   #define GC_WRITE(_o, _p)        soft_addreference(_o, _p)
>   #else   
>   #define GC_WRITE(_o, _p)
>   #endif                  
> Does that imply GC_WRITE() is obsolete also (and may be removed)?

 No.  Please don't remove it.

GC_WRITE is a write barrier.  Write barriers can be used for
incremental collection.  Tim attempted incremental collection at
some point (the name gc-incremental.c still witnesses this), but it never
worked for various reasons and was later removed---hence no soft_addreference.
 However, it is possible and probably desirable that somebody might attempt
incremental collection again in the future, in fact, a couple of people
sent me mail asking about information on how to do that.

My take is we should not only not remove the GC_WRITE macros, but
make sure we put them in where they're needed, in order to help that
task.  I can provide a version of System.arraycopy with GC_WRITEs, 
and I've also found several other places in the VM where GC_WRITEs were 
missing.  Also, make sure the GC_WRITE comes before the actual 
assignment, not after it.

To become familiar with write barriers etc., it is best to read the
literature, such as [Wilson].  In brief, if garbage collection
is to be done incrementally, concurrently with other running threads,
then these threads must notify the collector when they create a connection
between an object that the garbage collector has already scanned and
an object that the garbage collector hasn't seen yet.  For instance, if
the thread executes	a->x = b, then this creates a connection
from a to b.  If the collector has already scanned a, and b can't
be reached differently, then the collector must be told to consider
b.  This is what GC_WRITE(a, b) does.

	- Godmar

    AUTHOR = {Paul R. Wilson},
    TITLE = {Uniprocessor Garbage Collection Techniques},
    BOOKTITLE = {Proceedings of the International Workshop on
    	Memory Management},
    YEAR = {1992},
    PUBLISHER = {Springer-Verlag},
    ADDRESS = {St. Malo, France},
    MONTH = sep,
    notes = {Lecture Notes in Computer Science 637}

More information about the kaffe mailing list