Skip to main content

NativeRootStore

Struct NativeRootStore 

Source
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

Source

pub fn new() -> NativeRootStore

A store with NATIVE_ROOT_RESERVATION roots’ worth of capacity.

Source

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.

Source

pub fn is_empty(&self) -> bool

True iff no scope holds anything.

Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for NativeRootStore

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl RootSet for NativeRootStore

Source§

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.

Auto Trait Implementations§

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

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.