Crate wasmtime_internal_unwinder

Crate wasmtime_internal_unwinder 

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

ExceptionTable
ExceptionTable deserialized from a serialized slice.
ExceptionTableBuilder
Collector struct for exception handlers per call site.
Frame
A stack frame within a Wasm stack trace.
UnwindHost
If we have the above host-specific implementations, we can implement Unwind.

Enums§

ThrowAction
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 fp is 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.