Stack

Struct Stack 

pub struct Stack { /* private fields */ }
Expand description

Represents the currently active stack.

§Stack painting

Stack allows to measure the amount of stack effectively used through a technique called stack painting:

  1. When initializing the memory stack, it is filled with a sequence of bytes of known values: the paint.
  2. This paint gets covered during execution with the values stored on stack.
  3. When requested, the amount of covered paint is measured to estimate the amount of stack used during execution.

Note that this technique only provides a lower bound of stack usage, as the values stored in the stack may “collide” with the paint values. In the current implementation, and assuming the stack data follows a uniform distribution, this is unlikely to result in an underestimation of more than one byte.

§Note

On native, the stack modeled by this type is currently empty, so its usage and free space will both be reported as zero.

Implementations§

§

impl Stack

pub fn get() -> Stack

Returns a handle for the currently active stack.

§Panics

Panics when the world is on fire (e.g., when the limits returned by the architecture-dependent code don’t make sense).

pub fn size(&self) -> usize

Returns the total size of the current stack.

pub fn current_free_space(&self) -> usize

Returns the amount of currently free stack space.

pub fn current_usage(&self) -> usize

Returns the amount of currently used stack space.

pub fn peak_usage(&self) -> usize

Returns the peak amount of stack used since last repaint.

This re-calculates and thus runs in O(n)!

pub fn repaint(&self)

Repaints the stack.

§Panics

Only panics if its internal sanity check fails, which would point to a bug.

pub fn highest(&self) -> usize

Returns the highest address of the underlying stack.

Note: this is currently intended for debugging only. The address may be off by one word, and no guarantees are provided regarding its value across executions.

pub fn lowest(&self) -> usize

Returns the lowest address of the underlying stack.

Note: this is currently intended for debugging only. The address may be off by one word, and no guarantees are provided regarding its value across executions.

Trait Implementations§

§

impl Debug for Stack

§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Stack

§

impl RefUnwindSafe for Stack

§

impl !Send for Stack

§

impl !Sync for Stack

§

impl Unpin for Stack

§

impl UnwindSafe for Stack

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.

§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

§

const WITNESS: W = W::MAKE

A constant of the type witness
§

impl<T> Identity for T
where T: ?Sized,

§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
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, 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V