pub struct DeterministicStackLimit {
pub logical_max: u32,
pub native_stack_max: u32,
}
Expand description
Knobs for deterministic stack height limiting.
The WebAssembly standard defines a call/value stack but it doesn’t say anything about its size except that it has to be finite. The implementations are free to choose their own notion of limit: some may count the number of calls or values, others would rely on the host machine stack and trap on reaching a guard page.
This obviously is a source of non-determinism during execution. This feature can be used to instrument the code so that it will count the depth of execution in some deterministic way (the machine stack limit should be so high that the deterministic limit always triggers first).
The deterministic stack height limiting feature allows to instrument the code so that it will count the number of items that may be on the stack. This counting will only act as an rough estimate of the actual stack limit in wasmtime. This is because wasmtime measures it’s stack usage in bytes.
The actual number of bytes consumed by a function is not trivial to compute without going
through full compilation. Therefore, it’s expected that native_stack_max
is greatly
overestimated and thus never reached in practice. The stack overflow check introduced by the
instrumentation and that relies on the logical item count should be reached first.
See here for more details of the instrumentation
Fields§
§logical_max: u32
A number of logical “values” that can be pushed on the wasm stack. A trap will be triggered if exceeded.
A logical value is a local, an argument or a value pushed on operand stack.
native_stack_max: u32
The maximum number of bytes for stack used by wasmtime JITed code.
It’s not specified how much bytes will be consumed by a stack frame for a given wasm function after translation into machine code. It is also not quite trivial.
Therefore, this number should be chosen conservatively. It must be so large so that it can
fit the logical_max
logical values on the stack, according to the
current instrumentation algorithm.
This value cannot be 0.
Trait Implementations§
source§impl Clone for DeterministicStackLimit
impl Clone for DeterministicStackLimit
source§fn clone(&self) -> DeterministicStackLimit
fn clone(&self) -> DeterministicStackLimit
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl RefUnwindSafe for DeterministicStackLimit
impl Send for DeterministicStackLimit
impl Sync for DeterministicStackLimit
impl Unpin for DeterministicStackLimit
impl UnwindSafe for DeterministicStackLimit
Blanket Implementations§
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.