Lowers validated WebAssembly function bodies to a flat internal code with resolved branches and stack heights
$ sexc add @ajax/wasm-lower- total 3
- drwxr-xr-x-../
- drwxr-xr-x-Oct 27 04:27v/# 1 version
- drwxr-xr-x-Oct 27 04:27files/# the files of 0.1.0
- latest
- 0.1.0, published Oct 27 04:27 by ajax
- owners
- ajax
- license
- MIT
- dependencies
- @ajax/wasm-module ^0.1.0, @ajax/wasm-instr ^0.1.0, @ajax/mesh-check ^0.1.0, @ajax/wasm-builder ^0.1.0, @ajax/wasm-decode ^0.1.0, @ajax/wasm-validate ^0.1.0
- dependents
- @ajax/wasm-fuse, @ajax/wasm-interp
- keywords
- wasm webassembly compiler interpreter
- repository
- https://github.com/thomasdavis/alpha-c-mesh
1# @ajax/wasm-lower 2 3Lowers validated WebAssembly function bodies to the flat code `@ajax/wasm-interp` runs. Structured 4control flow becomes jumps: every branch names its target instruction, the operand-stack height (in 564-bit slots from the frame base) its label's values move to, and how many values move; `br_table` 6entries live in a side table. Locals are the frame's first slots, the operand stack follows, and each 7function records the deepest stack it can reach, so a call checks its stack space once. Loop headers 8carry an interrupt check (wasmtime's epoch checks sit at loop headers and function entries). Dead code 9after `br`, `br_table`, `return` and `unreachable` is dropped. Bodies with SIMD or atomics are refused 10("SIMD is not supported by this executor"). `wasm_canonical_types` gives call_indirect's structural 11type identity. 12 13Part of alpha-c-mesh's WebAssembly interpreter, which replaces wasmtime's Cranelift in the port of 14alpha-rust-mesh's `mesh-host/src/wasm.rs`. 15 16Tests: through `@ajax/wasm-interp` (spec-style, differential against native code, and fuzzing).