pub struct Marker { /* private fields */ }Expand description
Holds the gray queue during a mark phase. Passed to Trace::trace.
Implementations§
Source§impl Marker
impl Marker
Sourcepub fn mark<T: Trace + 'static>(&mut self, gc: Gc<T>)
pub fn mark<T: Trace + 'static>(&mut self, gc: Gc<T>)
Mark a Gc<T> as gray (reachable, but its outgoing edges not yet
traced). Called by Trace::trace implementations.
Per-cycle dedup uses visited (a HashSet of box identities) rather
than the color flag. Color-based dedup would silently skip
new_uncollected boxes left Black by the previous cycle — those
allocations are NOT on the heap’s allgc chain, so the start-of-mark
“reset all allgc to White” loop does not reach them, and a Black
uncollected box would be skipped without re-tracing its children
(causing reachable allgc descendants to be swept). The visited set
is rebuilt every full_collect (Marker::new), so this dedup is
always per-cycle.
Sourcepub fn try_visit(&mut self, addr: usize) -> bool
pub fn try_visit(&mut self, addr: usize) -> bool
Record that an Rc-backed object (GcRef<T> in Phase A-D-0) has been
visited and return whether this is the first visit. Used by recursive
Trace impls to break cycles while the real Gc<T> gray-queue path is
not yet wired (e.g. _G._G == _G would otherwise infinitely recurse).
Sourcepub fn is_visited(&self, id: usize) -> bool
pub fn is_visited(&self, id: usize) -> bool
True iff id was reached during the mark phase. Used by the
post-mark hook (Heap::full_collect_with_post_mark) to decide whether
a weak-table entry’s target is still strongly reachable. Read-only —
callers cannot add entries.
Sourcepub fn visited_count(&self) -> usize
pub fn visited_count(&self) -> usize
Number of objects marked so far. Used by the post-mark hook’s ephemeron-convergence fixed-point loop to detect when an iteration added no new reachable objects and the loop can terminate.
Sourcepub fn drain_gray_queue(&mut self)
pub fn drain_gray_queue(&mut self)
Drain the gray queue, transitively marking children. Each gray box
becomes black; its Trace::trace is called so the children it points
at get pushed onto the queue. Repeats until the queue is empty.
Exposed for the post-mark hook so it can run ephemeron convergence:
after marking new values via Marker::mark (or value.trace(self)),
the hook calls drain_gray_queue to propagate the new reachability,
then re-checks for fixed-point.