skip to content
==> README.md <==
1# @ajax/wasm-validate
2
3Validates a decoded WebAssembly module (spec chapter 3) for a chosen set of proposals: the module's
4index spaces, limits, constant expressions (with extended constant expressions), exports (unique
5names), the start function, element and data segments, declared function references, and a type check
6of every function body with the spec's algorithm — an operand stack of types and a stack of control
7frames, polymorphic after `unreachable`, `br`, `br_table` and `return`. Instructions of a proposal that
8isn't enabled are refused as wasmparser refuses them (`SIMD support is not enabled (at offset 0x1f)`).
9
10SIMD instructions are decoded but not type-checked: where SIMD is enabled, a body's type check stops at
11its first SIMD instruction and the rest is walked for structure and disabled proposals only, and the
12report says SIMD is used. The interpreter (`@ajax/wasm-interp`) runs no SIMD, so such a function never
13runs; meshd's float guard needs only to know whether SIMD, threads or relaxed SIMD appear, which this
14gives exactly.
15
16Part of alpha-c-mesh's WebAssembly interpreter, which replaces wasmtime and wasmparser in the port of
17alpha-rust-mesh's `mesh-host/src/wasm.rs`.
18
19## Differences
20
21- wasmparser type-checks SIMD bodies; this doesn't (above).
22- Messages follow wasmparser's wording where it matters to callers (the proposal refusals, which
23  meshd's float guard reports); others are close but not always identical.
24
25Tests: `tests/validate.c` (valid bodies of every instruction kind; type, index and structure errors;
26each disabled proposal); clang-built guest programs in the wasm executor's tests.