Struct sc_executor_wasmtime::DeterministicStackLimit[][src]

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 grealy 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 choosen 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.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Get a reference to the inner from the outer.

Get a mutable reference to the inner from the outer.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The counterpart to unchecked_from.