Skip to main content

Module marker

Module marker 

Source
Expand description

Tri-color mark phase for the GC.

Colors:

  • White: Unmarked, potentially reclaimable after marking completes.
  • Gray: Reachable, but children not yet scanned.
  • Black: Reachable, all children scanned.

Algorithm:

  1. All objects start white.
  2. Root objects are colored gray and pushed to the worklist.
  3. Process gray objects: for each, trace children (color white->gray), color self black.
  4. After worklist is empty, all white objects are garbage.

§Incremental marking

Instead of processing the entire gray worklist in one STW pause, the marker exposes mark_step(budget) which processes a bounded number of objects per mutator safepoint. An SATB write barrier (see barrier.rs) records references overwritten by the mutator during marking. Mark termination is a short STW pause that drains the SATB buffers and re-processes any new grays until convergence.

Structs§

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

Enums§

MarkPhase
Marker phase state.