pub struct NativeRootStore { /* private fields */ }Expand description
Every GcRef the runtime’s own Rust code is holding across an allocation,
in one contiguous array (ADR-114).
The runtime’s own wrappers build values in Rust locals — a result Vec that
is filled by repeatedly allocating points, a record assembled field by
field. Those locals are invisible to the shadow stack, which only generated
code writes. There is exactly one store per Runtime, it
is reachable through RuntimeContext::native_roots, and it is the fifth
strong arm of RuntimeRoots.
A frame is not an object. A NativeScope is the run of entries above
the watermark it found on entry, exactly as ADR-101 made a shadow frame the
run of slots above the top a prologue found, so opening one allocates
nothing — which matters because it sits on the path of praxis_vec_push,
praxis_map_insert and every other mutating collection primitive in the
language.
Roots are held behind a RefCell so NativeScope::root can take &self
and several Rooted values can be live at once — the common shape, since a
helper usually roots its result and then roots each intermediate it builds.
Nothing can collect inside the borrow_mut: the only thing a push can call
is the system allocator, on a growth, and that is not a safepoint.
Implementations§
Source§impl NativeRootStore
impl NativeRootStore
Sourcepub fn new() -> NativeRootStore
pub fn new() -> NativeRootStore
A store with NATIVE_ROOT_RESERVATION roots’ worth of capacity.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
How many roots are currently held, across every live scope. Zero between
runs, if every scope was balanced by its Drop.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
The reservation’s current capacity, in roots.
Exposed because it is the observable form of “this program forced the
store to grow”: the capacity only ever rises, so a value above
NATIVE_ROOT_RESERVATION is a realloc that happened, and the growth
path is the one a pointer-shaped watermark would have died on.
Trait Implementations§
Source§impl Debug for NativeRootStore
impl Debug for NativeRootStore
Source§impl Default for NativeRootStore
impl Default for NativeRootStore
Source§impl RootSet for NativeRootStore
impl RootSet for NativeRootStore
Source§fn push_roots(&self, out: &mut Vec<GcRef>)
fn push_roots(&self, out: &mut Vec<GcRef>)
One extend_from_slice over every live scope’s roots at once.
One copy yields every live scope’s roots, for ADR-101’s reason applied
to this chain: scopes nest with the Rust stack, each occupies exactly the
run between its own watermark and the next one’s, and the runs partition
[0, len). There is no per-frame walk, which matters because the parser
interpreter’s own recursion can stack dozens of scopes in front of a
collection taken inside a parse.