Skip to main content

RefMap

Struct RefMap 

Source
pub struct RefMap { /* private fields */ }
Expand description

Which slots of a frame are Repr::Ref, as one bit each.

A frame’s roots are a static fact here rather than a program-counter dependent one, and that is the point of the register machine: a stack machine’s live-reference set changes as operands are pushed and popped, so its map has to be indexed by pc. Here the answer does not change between the first instruction of a function and the last.

The lowering guarantees the one fact this relies on: a slot’s Repr is fixed for the whole function. A slot may be reused by a later value of the same Repr — that is what keeps a frame from growing with every temporary a long body mentions — but never by one of a different Repr, because then no single bit would be right at every program counter.

A static map says which slots the collector reads. It cannot say when the value in one stopped being needed, because that is a fact about a program point. The lowering answers that in the data instead: it emits Clear at a reference’s last use, so a dead slot holds null and the collector traces nothing from it.

Implementations§

Source§

impl RefMap

Source

pub fn of(reprs: &[Repr]) -> RefMap

The map for a frame of slots words, with reprs[i] at slot i.

Source

pub fn slots(&self) -> u32

How many slots the map covers.

Source

pub fn is_ref(&self, slot: u32) -> bool

Whether slot slot holds a reference.

Out of range answers false rather than panicking: the collector walks a frame whose size it took from the same crate::Function as this map, so a disagreement is a bug in the lowering, and a collection is the worst place to discover one by unwinding.

Source

pub fn iter(&self) -> impl Iterator<Item = u32> + '_

Every reference slot, ascending.

Iterating the set bits rather than every slot is what makes a frame of mostly scalars cheap to scan: a frame with no references at all costs one word read per 64 slots.

Source

pub fn is_empty(&self) -> bool

Whether the frame holds no references at all.

Trait Implementations§

Source§

impl Clone for RefMap

Source§

fn clone(&self) -> RefMap

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RefMap

Source§

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

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

impl Default for RefMap

Source§

fn default() -> RefMap

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

impl Eq for RefMap

Source§

impl PartialEq for RefMap

Source§

fn eq(&self, other: &RefMap) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for RefMap

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.