Skip to main content

Module roots

Module roots 

Source
Expand description

Explicit root frames (§12.3, ADR-012) and the composite runtime root set.

§12.3 offers “compiler-managed shadow-stack frames or explicit root frames”; this runtime takes explicit root frames (ADR-012): a RootSet is anything that can enumerate the GcRefs it keeps alive, and a RAII RootScope holds a Vec<GcRef> and chains to an optional parent.

RuntimeRoots closes the collector’s root set: it is the only thing Heap::collect accepts, it is constructible only from a *mut RuntimeContext, and it is exhaustive over its six arms — five strong, enumerated by its RootSet impl, and one weak, cleared by its WeakSet impl. ctx.shadow, input_source, a parse failure’s partial value, a runtime-owned crash snapshot and everything native code holds in a Rust local are all arms of it, so “collect against a partial root set” has no representation.

NativeScope is the fifth strong arm. Native code that builds a value across an allocation — the grid helpers assembling a Vec of points, the parser interpreter assembling a record — holds it in a Rooted, which is the only input the &mut Payload accessors take. Holding a payload reference across a safepoint without rooting its owner does not type-check. The references themselves live in one contiguous NativeRootStore the runtime owns (ADR-114); a scope is the run of entries above the watermark it found, not an object.

The sixth arm is the crash debugger’s frames, and it is weak (ADR-106): the collector never traces it — tracing it would re-merge the two sets ADR-044 split — but it does scan it, once per collection, immediately after the sweep, marking every debug slot whose object that sweep reclaimed. A debug value is therefore always a live object or a stated absence, never a dangling reference — and the absence says which absence it is (crate::debug::RECLAIMED_WORD): a slot the collector emptied is not a slot nothing was ever written into.

Structs§

NativeRootStore
Every GcRef the runtime’s own Rust code is holding across an allocation, in one contiguous array (ADR-114).
NativeScope
A RAII claim on the tail of NativeRootStore: records the store’s length on construction and truncates back to it on Drop.
RootScope
A RAII frame that roots a set of GcRefs and optionally chains to a parent RootSet.
Rooted
A GcRef proven rooted for 's — the only input to a &mut Payload accessor.
RuntimeRoots
Everything the runtime owns that names a GcRef — five arms that keep one alive, and one that only has to keep one valid.

Constants§

NATIVE_ROOT_RESERVATION
How many roots the store reserves at Runtime::new.

Traits§

RootSet
Anything that can enumerate the GC references it keeps alive (§12.3).
WeakSet
A set the collector keeps valid without keeping alive (ADR-106).