Description
Traps
Find a solution to handle traps in wasm execution
Keywords
frame_info
look_up_frame_info
look_up_trap_info
Issues
Under some conditions, certain instructions may produce a trap, which immediately aborts execution. Traps cannot be handled by WebAssembly code, but are reported to the outside environment, where they typically can be caught.
#Traps concept in WebAssembly Overview
Administrative Instructions in WebAssembly Execution
In order to express the reduction of traps, calls, and control instructions, the syntax of instructions is extended to include the following administrative instructions:
instr ::= ...
| trap
| invoke funcaddr
| init_elem tabbleaddr u32 funcidx*
| init_data memaddr u32 byte*
| labe𝑛 { instr* } instr* end
| frame𝑛 { frame } instr* end
The trap instruction represents the occurrence of a trap. Traps are bubbled up through nested instruction sequences, ultimately reducing the entire program to a single 𝗍𝗋𝖺𝗉 instruction, signaling abrupt termination.
Runtime Result
A result is the outcome of a computation. It is either a sequence of values or a trap.
result ::= val*
trap