Hacker News new | past | comments | ask | show | jobs | submit login

  Some accounting only needs to happen when visiting the
  object for the first time. The complete barrier is simply:

     object->field = newValue;
     if (object->cellState == Old)
       remember(object);
This surely elides some synchronization? One would think that either this has to communicate with the collector (to prevent a racing concurrent collection from missing the referent), or happen in the opposite order.

Or perhaps it is relying on the calling mutator thread necessarily holding a reference to the young object in question? Even then there is some non-trivial ordering work to be done here (in particular on weakly ordered architectures.)

I'm sure this is well handled but as this is one of the main difficulties in implementing good write barriers I am curious what they did.




The barrier code you quote is for our old generational GC. Keep reading to see what the riptide barrier looks like. See the section on retreating wavefront.


Aha, thanks; I didn't realize the first generational section was for an older version.

However, the riptide barrier description still isn't 100% clear how it avoids terminating a sweep (I believe "drain" in your termination) in the middle of a barrier execution; in particular I'm not concerned about the data race between the field write and the mark bit, but the GC reading mark bits, believing the drain has terminated, and freeing memory while a mutator thread has written a field but not written the mark bit.

Are you just relying on the stop-the-world behavior relative to roots that you mention briefly?


The collector can only flip at safepoints. Safepoints cannot happen inside the barrier or in between the store the barrier protects and the barrier itself.

Flip = term of art for when the GC terminates and decides which objects are free.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: