Skip to main content

ArrayStore

Struct ArrayStore 

Source
pub struct ArrayStore {
    pub entities: EntityTable,
    /* private fields */
}
Expand description

Storage for PostScript array element data.

Fields§

§entities: EntityTable

Implementations§

Source§

impl ArrayStore

Source

pub fn new() -> Self

Source

pub fn allocated_objects(&self) -> usize

Number of object slots handed out so far.

The backing arena only ever grows — nothing is reclaimed without a restore — so this doubles as the store’s high-water mark. Useful for asserting that a code path which evaluates PostScript repeatedly isn’t allocating a fresh array per evaluation.

Source

pub fn data_len(&self) -> usize

Release every object slot and entity from the given marks onward.

Used by restore to reclaim the objects a save level created. See crate::entity_table::EntityTable::truncate for the safety argument and the EntityId-reuse caveat. Number of PsObject slots currently held.

Used for VM accounting; see crate::context::Context::vm_bytes.

Source

pub fn data_capacity(&self) -> usize

Slots currently reserved, which is what the allocator actually holds.

VM accounting has to use this rather than the length. The backing Vec grows geometrically, so a store holding just under the ceiling by length asks the allocator for roughly twice that on its next growth — which is how { 1000000 string pop } loop still aborted with a 16 GB request after a length-based check had passed at 8 GB.

Source

pub fn truncate_to(&mut self, data_len: usize, entity_len: usize)

Source

pub fn allocate(&mut self, len: usize) -> EntityId

Allocate len null-filled slots, returning an EntityId.

Source

pub fn allocate_from(&mut self, items: &[PsObject]) -> EntityId

Allocate and copy items into the store.

Source

pub fn allocate_from_with( &mut self, items: &[PsObject], save_level: u16, global: bool, created_after_save: u32, ) -> EntityId

Allocate and copy items with a specific save level and global flag.

Source

pub fn allocate_with( &mut self, len: usize, save_level: u16, global: bool, created_after_save: u32, ) -> EntityId

Allocate with a specific save level and global flag.

Source

pub fn iter_entities(&self) -> impl Iterator<Item = (EntityId, &[PsObject])>

Iterate every allocated array in this store as (EntityId, elements).

Used by the VM audit (see crate::vm_audit) to sweep global VM for PLRM 3.7.2 violations. Sweeping the entity table rather than following references catches arrays written through ArrayStore::get_mut, which hands out &mut [PsObject] and so bypasses any per-store checkpoint.

Source

pub fn get(&self, entity: EntityId, start: u32, len: u32) -> &[PsObject]

Get a slice of array elements via entity table indirection.

Source

pub fn get_mut( &mut self, entity: EntityId, start: u32, len: u32, ) -> &mut [PsObject]

Get a mutable slice of array elements via entity table indirection.

Source

pub fn get_element(&self, entity: EntityId, index: u32) -> PsObject

Get a single element.

Source

pub fn set_element(&mut self, entity: EntityId, index: u32, obj: PsObject)

Set a single element.

Source

pub fn cow_copy(&mut self, entity: EntityId) -> EntityId

Copy entity data to a new region (for COW). Returns the new EntityId pointing at the backup. The original entity’s offset is updated to point at the fresh copy.

Source

pub fn swap_offsets(&mut self, a: EntityId, b: EntityId)

Swap offsets between two entities (used by restore).

Trait Implementations§

Source§

impl Default for ArrayStore

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

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.