Module traphandlers

Module traphandlers 

Source
Expand description

WebAssembly trap handling, which is built on top of the lower-level signalhandling mechanisms.

Structsยง

StackCache ๐Ÿ”’
Per-thread cache holding a single ready-to-use coroutine stack. The hot path of on_wasm_stack pops from here without touching the global STACK_POOLโ€™s atomics; only the first call on a thread or re-entrant nested calls fall back to the pool.
TrapHandlerContext ๐Ÿ”’
Read-only information that is used by signal handlers to handle and recover from traps.
TrapHandlerContextInner ๐Ÿ”’
VMConfig
Configuration for the runtime VM Currently only the stack size is configurable

Constantsยง

MAX_STACK_SIZE
Maximum allowed default stack size (100 MiB) for the process-wide configuration set via set_stack_size.
TLS_STACK ๐Ÿ”’
TRAP_HANDLER ๐Ÿ”’
YIELDER ๐Ÿ”’

Staticsยง

DEFAULT_STACK_SIZE ๐Ÿ”’
MAGIC ๐Ÿ”’
PREV_SIGBUS ๐Ÿ”’
PREV_SIGFPE ๐Ÿ”’
PREV_SIGILL ๐Ÿ”’
PREV_SIGSEGV ๐Ÿ”’
PREV_SIGUSR1 ๐Ÿ”’
STACK_POOL ๐Ÿ”’
Pool of pre-allocated coroutine stacks to avoid repeated mmap syscalls. Acts as the cross-thread overflow store; per-thread reuse is served by TLS_STACK to keep the hot path atomic-free.

Traitsยง

StackExt ๐Ÿ”’
Convenience extension for [Stack] that exposes the total mapped size.

Functionsยง

acquire_stack ๐Ÿ”’
Acquire a coroutine stack large enough for min_size. Prefers the thread-local cache (no atomics), falls back to the global STACK_POOL, then allocates a fresh stack.
catch_trapsโš 
Catches any wasm traps that happen within the execution of closure, returning them as a Result.
drain_stack_pool
Drains the coroutine stack pool at the moment it runs.
get_pc_sp ๐Ÿ”’ โš 
get_stack_size
Returns the process-wide default stack size in bytes.
init_traps
This function is required to be called before any WebAssembly is entered. This will configure global state such as signal handlers to prepare the process to receive wasm traps.
lazy_per_thread_init
A module for registering a custom alternate signal stack (sigaltstack).
on_host_stack
When executing on the Wasm stack, temporarily switch back to the host stack to perform an operation that should not be constrained by the Wasm stack limits.
on_wasm_stack ๐Ÿ”’
Runs the given function on a separate stack so that its stack usage can be bounded. Stack overflows and other traps can be caught and execution returned to the root of the stack.
platform_init ๐Ÿ”’ โš 
process_illegal_op ๐Ÿ”’ โš 
raise_lib_trapโš 
Raises a trap from inside library code immediately.
raise_user_trapโš 
Raises a user-defined trap immediately.
release_stack ๐Ÿ”’
Release a coroutine stack. Prefers the thread-local slot if empty (no atomics); otherwise pushes to the global STACK_POOL so the stack is still reusable by other threads.
resume_panicโš 
Carries a Rust panic across wasm code and resumes the panic on the other side.
set_stack_size
Sets the process-wide default stack size for new Wasmer coroutines. The value is clamped to [8 KiB, MAX_STACK_SIZE].
trap_handler ๐Ÿ”’ โš 
unwind_with ๐Ÿ”’ โš 
update_context ๐Ÿ”’ โš 

Type Aliasesยง

TrapHandlerFn
Function which may handle custom signals while processing traps.