Expand description
Wasmtime unwinder.
⚠️ Warning ⚠️: this crate is an internal-only crate for the Wasmtime project and is not intended for general use. APIs are not strictly reviewed for safety and usage outside of Wasmtime may have bugs. If you’re interested in using this feel free to file an issue on the Wasmtime repository to start a discussion about doing so, but otherwise be aware that your usage of this crate is not supported.
§wasmtime-unwinder
This crate implements an unwind info format, stack walking, and unwinding for Wasmtime. It includes logic that:
- Can walk the Wasmstack and visit each frame;
- Can find exception handlers using an efficient format serialized from Cranelift compilation metadata that can be mapped and used in-place from disk;
- Provides a “throw” helper that, when called from host code that has been invoked from Wasmcode, can find a handler; and a “resume” stub that can be invoked to transfer control to the corresponding handler.
Structs§
- Exception
Table - ExceptionTable deserialized from a serialized slice.
- Exception
Table Builder - Collector struct for exception handlers per call site.
- Frame
- A stack frame within a Wasm stack trace.
- Unwind
Host - If we have the above host-specific implementations, we can
implement
Unwind.
Enums§
- Throw
Action - Throw action to perform.
Constants§
- NEXT_
OLDER_ FP_ FROM_ FP_ OFFSET - The offset of the saved old-FP value in a frame, from the location pointed to by a given FP.
- NEXT_
OLDER_ SP_ FROM_ FP_ OFFSET - The offset of the next older SP value, from the value of a given FP.
Traits§
- Unwind
- Implementation necessary to unwind the stack, used by
Backtrace.
Functions§
- assert_
fp_ is_ aligned - Assert that the given
fpis aligned as expected by the host platform’s implementation of the Cranelift tail-call ABI. Frame pointers are aligned if they’re aligned to twice the size of a pointer. - compute_
throw_ ⚠action - Implementation of stack-walking to find a handler.
- get_
next_ ⚠older_ pc_ from_ fp - Get the return address in the function at the next-older frame from the given FP.
- get_
stack_ pointer - Get the current stack pointer (at the time this function is executing). This may be used to check, e.g., approximate space remaining on a stack, but cannot be relied upon for anything exact because the stack pointer from within this function is read and the frame is later popped.
- resume_
to_ ⚠exception_ handler - Resume execution at the given PC, SP, and FP, with the given payload values, according to the tail-call ABI’s exception scheme. Note that this scheme does not restore any other registers, so the given state is all that we need.
- visit_
frames ⚠ - Walk through a contiguous sequence of Wasm frames starting with
the frame at the given PC and FP and ending at
trampoline_fp. This FP should correspond to that of a trampoline that was used to enter the Wasm code.