skip to content
[readonly]

Validates a decoded WebAssembly module: module-level rules and full type checking of every function body, per enabled proposals

sh
$ sexc add @ajax/wasm-validate
  • 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/wasm-decode ^0.1.0, @ajax/mesh-check ^0.1.0, @ajax/wasm-builder ^0.1.0
dependents
@ajax/wasm-float-guard, @ajax/wasm-fuse, @ajax/wasm-interp, @ajax/wasm-lower
keywords
wasm webassembly validator type-checker
repository
https://github.com/thomasdavis/alpha-c-mesh
==> 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.