Skip to main content

Marker

Struct Marker 

Source
pub struct Marker { /* private fields */ }
Expand description

The marker manages the gray worklist and tri-color state.

Implementations§

Source§

impl Marker

Source

pub fn new() -> Self

Source

pub fn reset(&mut self)

Reset the marker for a new GC cycle.

Source

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()).

Source

pub fn finish_marking(&mut self)

Finish the marking cycle (called after termination + sweep).

Source

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.

Source

pub fn phase(&self) -> MarkPhase

Get the current mark phase.

Source

pub fn mark_root(&mut self, ptr: *mut u8)

Mark a root pointer: color it gray and add to worklist.

Source

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.

Source

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.

Source

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.

Source

pub fn mark_all(&mut self)

Process all remaining gray objects until the worklist is empty.

Source

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).

Source

pub fn is_marked(&self, ptr: *const u8) -> bool

Check if a pointer was marked live in this cycle.

Source

pub fn is_live(&self, ptr: *const u8) -> bool

Alias for is_marked — consistent naming with the public API.

Source

pub fn gray_count(&self) -> usize

Get the number of objects currently in the gray worklist.

Source

pub fn live_count(&self) -> usize

Get the number of objects marked live.

Source

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.

Trait Implementations§

Source§

impl Default for Marker

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Send for Marker

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.