Skip to main content

ValueHeap

Struct ValueHeap 

Source
pub struct ValueHeap { /* private fields */ }

Implementations§

Source§

impl ValueHeap

Source

pub fn new() -> Self

Source

pub fn alloc(&mut self, len: u32, room: &mut Room) -> Range

Allocates a range of at least len slots, filled with Value::EMPTY. The returned length is rounded up to the class size. A growth step is charged to room.

Source

pub fn alloc_slots(&mut self, len: u32, room: &mut Room) -> Range

ValueHeap::alloc rounded to a power of two: an object’s named property slots, which the header decodes with one shift.

Source

pub fn growth_bytes(&self, len: u32) -> usize

Bytes the backing vector grows by if a range of len is allocated now.

Source

pub fn grow(&mut self, range: Range, new_len: u32, room: &mut Room) -> Range

Returns a range of at least new_len holding range’s values: the same range when it is already large enough, otherwise a new one (alloc, copy, free).

Source

pub fn grow_slots( &mut self, range: Range, new_len: u32, room: &mut Room, ) -> Range

ValueHeap::grow for named property slots, to a power of two.

Source

pub fn free(&mut self, range: Range)

Returns a range to its class. The slots are poisoned with EMPTY.

Source

pub fn begin_sweep(&mut self)

Starts a collection’s sweep: the free space moves into the bitmap of free slots, where ValueHeap::release records the ranges the sweep frees, and ValueHeap::finish_sweep rebuilds it from the bitmap.

Source

pub fn release(&mut self, range: Range)

Frees a range during the sweep: poisons it with EMPTY and records it in the bitmap of free slots.

Source

pub fn finish_sweep(&mut self)

Ends the sweep: rebuilds the free space from the maximal runs of free slots. A run shorter than [SHORT_RUN] goes on the class lists, cut from its start into the largest class ranges that fit (a run of seven becomes ranges of six and one); a longer one becomes a free run. A run that ends the heap and spans more than a quarter of its capacity is cut off instead, and the capacity past one growth step goes back to the allocator. Lower ranges and runs are reused first.

Source

pub fn get(&self, range: Range, slot: u32) -> Value

Source

pub fn set(&mut self, range: Range, slot: u32, value: Value)

Source

pub fn get_or_empty(&self, range: Range, slot: u32) -> Value

The value at slot of range, or Value::EMPTY past its end.

Source

pub fn get_at(&self, index: u32) -> Value

An absolute slot; callers check the range in debug builds.

Source

pub fn set_at(&mut self, index: u32, value: Value)

Source

pub fn slice(&self, range: Range) -> &[Value]

Source

pub fn slice_mut(&mut self, range: Range) -> &mut [Value]

Source

pub fn total_slots(&self) -> usize

Slots handed out, free or in use.

Source

pub fn free_slots(&self) -> usize

Slots sitting in free lists.

Source

pub fn used_slots(&self) -> usize

Slots held by live ranges.

Source

pub fn fragmentation(&self) -> f64

Free-list slots over all handed-out slots.

Source

pub fn bytes(&self) -> usize

Source

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

Every free range of the class lists.

Source

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

The free runs, the current one first, for the stress-mode verifier.

Trait Implementations§

Source§

impl Default for ValueHeap

Source§

fn default() -> Self

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

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

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.