RRB - recording read barrier

RRB - the recording read barrier is a twist on classical read barriers for detecting pointer loads.
While all read barriers I came across are very precise, precise in that they know immediately if the pointer in question is tainted,
this barrier is in-precise in nature.
It is simply used to record, as the name suggest, the pointer in question in a temporary circular buffer.
In combination with page protection mechanisms, a load from a tainted pointer will SIGSEGV during the execution of normal application instructions.
When a SIGSEGV is detected, the fault hander then checks the circular buffer and processes all the tainted pointers in there.
Once done, it adjusts the execution context (ie update to the new pointer address) and resumes execution.

The advantage of this approach is performance.
Most pointer loads are non-tainted, but the recording of the pointer itself only uses very simple unconditional instructions (and, mov, inc).
By utilizing the RRB, the mutator threads do not have to incur a massive performance hit allowing much better concurrent garbage collections.

Early benchmarks in CMM showed about -2% to 6% overhead when using the recording read barrier, while allowing similar features as a conditional read barrier.


The RRB writes all the object pointers loaded by the mutators into a thread local circular buffer.
This buffer should be large enough to capture the most recent pointer loads (in CMM set to 128 elements).
During processing of mutator code, a tainted pointer might be loaded, and when accessing elements via that pointer, a SIGSEGV is raised.
The fault handler then processes all the relevant heap pages that need moving / compacting and also adjusts the bad pointer at the SIGSEGV site and resumes the mutator.
The RRB buffer is small, because only the most recent pointer accesses shall the handled by the mutator fault handler in order for the mutator to resume working normally ASAP.
Background GC threads also handle the compaction in parallel with the mutators.

RRB hotspot ASM