1# @ajax/wasm-fuse
23Superinstructions for `@ajax/wasm-interp`. Over a function's lowered code (`@ajax/wasm-lower`), an
4operand-making instruction directly before a plain one becomes that instruction's operand:
5`local.get A` or a constant before an arithmetic, compare, conversion, load or store, and
6`local.get A; local.get B` as one instruction. In clang's -O2 wasm32 output `local.get` is about a quarter
7of all instructions and constants a fifth, and the commonest pairs are exactly these. The interpreter
8runs a fused instruction as its operand push plus a jump into the plain instruction's code, so each pair
9costs one dispatch instead of two.
1011Nothing is fused across a branch target (a jump must land on a whole instruction), and every target —
12branches, `if`, `br_table` entries — is remapped after the code shrinks.
1314Part of alpha-c-mesh's WebAssembly interpreter (it replaces wasmtime's JIT in the port of
15alpha-rust-mesh's `mesh-host/src/wasm.rs`; see `@ajax/wasm-interp` for the speed this buys).
1617Tests: `tests/fuse.c` (what fuses, what doesn't, targets remapped); the interpreter's spec,
18differential and fuzz tests run fused code.