Skip to main content

RuntimeRoots

Struct RuntimeRoots 

Source
pub struct RuntimeRoots<'a> { /* private fields */ }
Expand description

Everything the runtime owns that names a GcRef — five arms that keep one alive, and one that only has to keep one valid.

Sealed: the only constructor is RuntimeRoots::from_context, so a collection cannot be run against a hand-picked subset. The six arms are every documented owner of a reference:

armstrengthowner
shadowstrongctx.shadow — the generated shadow stack, scanned [base, top) (ADR-019, ADR-101)
inputstrongctx.input_source — the read-in buffer
parse_partialstrongParseDetail.fail.partial — the best partial parse
snapshotstrongthe runtime-owned CrashSnapshot’s copied locals
nativestrongNativeRootStore — what Rust helpers hold, scanned [0, len) (ADR-114)
debugweakctx.debug_frames + ctx.debug_values — the crash debugger’s live frames and the value slots they name (ADR-104, ADR-106)

abi::maybe_collect builds one of these and passes it whole, so a host-driven allocation and one taken inside the parser interpreter collect against the same arms generated code does.

§Why the sixth arm is weak

The debug slots are the over-approximate set: ADR-044 split them from the root set precisely so that making the root set exact would not make the debugger render <uninit> for a local the user can still see in their source. RootSlots::dead nulls a shadow slot at its local’s last use; the debug slot keeps the value, because a value that has been produced stays renderable.

Pushing debug in RootSet::push_roots would undo exactly that split. It is one line, it makes every dead local reachable again, and a_dead_local_stops_being_reachable_from_its_frame is the end-to-end gate that fails when someone writes it — deliberately, and it must keep failing. The arm’s whole content is therefore in WeakSet::clear_reclaimed: the collector decides what dies without consulting the debugger, and then tells the debugger what died.

Implementations§

Source§

impl<'a> RuntimeRoots<'a>

Source

pub unsafe fn from_context(ctx: *mut RuntimeContext) -> RuntimeRoots<'a>

Read every root arm out of ctx.

§Safety

ctx must be null, or point at a live RuntimeContext whose non-null shadow / parse_detail / crash_snapshot / native_roots / debug_frames / debug_values pointers reference live values for 'a. A non-null context’s input_source must be a valid GcRef (RuntimeContext::placeholder documents the same requirement).

Trait Implementations§

Source§

impl RootSet for RuntimeRoots<'_>

Source§

fn push_roots(&self, out: &mut Vec<GcRef>)

Push every root held by this set into out, in any order.
Source§

impl WeakSet for RuntimeRoots<'_>

Source§

fn clear_reclaimed(&self) -> usize

Null every debug value slot whose object the sweep just reclaimed.

The whole of the weak arm. Called by Heap::collect_inner between the sweep and the return to the allocator — see WeakSet for why nowhere else will do.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for RuntimeRoots<'a>

§

impl<'a> !Send for RuntimeRoots<'a>

§

impl<'a> !Sync for RuntimeRoots<'a>

§

impl<'a> !UnwindSafe for RuntimeRoots<'a>

§

impl<'a> Freeze for RuntimeRoots<'a>

§

impl<'a> Unpin for RuntimeRoots<'a>

§

impl<'a> UnsafeUnpin for RuntimeRoots<'a>

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 = !

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.