Struct HeapSpec

Source
pub struct HeapSpec {
    pub reserved_size: u64,
    pub guard_size: u64,
    pub initial_size: u64,
    pub max_size: Option<u64>,
}
Expand description

Specifications about the heap of a Lucet module.

Fields§

§reserved_size: u64

Total bytes of memory for the heap to possibly expand into, as configured for Cranelift codegen.

All of this memory is addressable. Only some part of it is accessible - from 0 to the initial size, guaranteed, and up to the max_size. This size allows Cranelift to elide checks of the base pointer. At the moment that just means checking if it is greater than 4gb, in which case it can elide the base pointer check completely. In the future, Cranelift could use a solver to elide more base pointer checks if it can prove the calculation will always be less than this bound.

Specified in bytes, and must be evenly divisible by the host page size (4K).

§guard_size: u64

Total bytes of memory after the reserved area, as configured for Cranelift codegen.

All of this memory is addressable, but it is never accessible - it is guaranteed to trap if an access happens in this region. This size allows Cranelift to use common subexpression elimination to reduce checks of the sum of base pointer and offset (where the offset is always rounded up to a multiple of the guard size, to be friendly to CSE).

Specified in bytes, and must be evenly divisible by the host page size (4K).

§initial_size: u64

Total bytes of memory for the WebAssembly program’s linear memory upon initialization.

Specified in bytes, must be evenly divisible by the WebAssembly page size (64K), and must be less than or equal to reserved_size.

§max_size: Option<u64>

Maximum bytes of memory for the WebAssembly program’s linear memory at any time.

This is not necessarily the same as reserved_size - we want to be able to tune the check bound there separately than the declaration of a max size in the client program.

The program may optionally define this value. If it does, it must be less than the reserved_size. If it does not, the max size is left up to the runtime, and is allowed to be less than reserved_size.

Implementations§

Source§

impl HeapSpec

Source

pub fn new( reserved_size: u64, guard_size: u64, initial_size: u64, max_size: Option<u64>, ) -> Self

Source

pub fn empty() -> Self

Some very small test programs dont specify a memory import or definition.

Trait Implementations§

Source§

impl Clone for HeapSpec

Source§

fn clone(&self) -> HeapSpec

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for HeapSpec

Source§

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

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

impl Default for HeapSpec

Source§

fn default() -> HeapSpec

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

impl<'de> Deserialize<'de> for HeapSpec

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for HeapSpec

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 Serialize for HeapSpec

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for HeapSpec

Source§

impl StructuralPartialEq for HeapSpec

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
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> 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,