pub struct Marker { /* private fields */ }Expand description
The marker manages the gray worklist and tri-color state.
Implementations§
Source§impl Marker
impl Marker
pub fn new() -> Self
Sourcepub fn start_marking(&mut self)
pub fn start_marking(&mut self)
Begin a new incremental marking cycle.
After calling this, the mutator should activate its SATB write barrier
(checking is_marking()).
Sourcepub fn finish_marking(&mut self)
pub fn finish_marking(&mut self)
Finish the marking cycle (called after termination + sweep).
Sourcepub fn is_marking(&self) -> bool
pub fn is_marking(&self) -> bool
Check whether a marking cycle is active.
This is the fast-path check used by the SATB write barrier.
Sourcepub fn mark_root(&mut self, ptr: *mut u8)
pub fn mark_root(&mut self, ptr: *mut u8)
Mark a root pointer: color it gray and add to worklist.
Sourcepub fn mark_gray(&mut self, ptr: *mut u8)
pub fn mark_gray(&mut self, ptr: *mut u8)
Mark a pointer as gray (add to worklist) if it is currently white.
Used during SATB termination to re-gray old references.
Sourcepub fn mark_child(&mut self, ptr: *mut u8)
pub fn mark_child(&mut self, ptr: *mut u8)
Mark a child pointer discovered during tracing. If it’s white, color it gray and add to the worklist.
Sourcepub fn mark_step(&mut self, budget: usize) -> bool
pub fn mark_step(&mut self, budget: usize) -> bool
Process up to budget gray objects.
Returns true if the worklist is empty (marking phase complete for
this step), false if more work remains.
Each processed object is colored black. In a full implementation the
trace_object callback would push the object’s children as gray via
mark_child; for now objects are treated as opaque blobs and simply
colored black.
Sourcepub fn terminate_marking(&mut self, satb: &mut SatbBuffer) -> bool
pub fn terminate_marking(&mut self, satb: &mut SatbBuffer) -> bool
Terminate the marking cycle by draining the SATB buffer and processing any remaining gray objects.
This should be called in a short STW pause after incremental marking reports the worklist as empty.
Returns true if marking is truly complete (gray set empty AND SATB
buffer empty), false if new work was discovered (caller should loop).
Sourcepub fn is_marked(&self, ptr: *const u8) -> bool
pub fn is_marked(&self, ptr: *const u8) -> bool
Check if a pointer was marked live in this cycle.
Sourcepub fn is_live(&self, ptr: *const u8) -> bool
pub fn is_live(&self, ptr: *const u8) -> bool
Alias for is_marked — consistent naming with the public API.
Sourcepub fn gray_count(&self) -> usize
pub fn gray_count(&self) -> usize
Get the number of objects currently in the gray worklist.
Sourcepub fn live_count(&self) -> usize
pub fn live_count(&self) -> usize
Get the number of objects marked live.
Sourcepub fn clear_mark(&self, ptr: *mut u8)
pub fn clear_mark(&self, ptr: *mut u8)
Clear the mark bit (reset to White) for a specific pointer.
Used during sweep to prepare objects for the next cycle.