WebAssembly

application/wasm, read and written in FunctionalScript: an AST of a module's sections, a binary parser, a binary writer and a WAT writer. The WASM demo pages' publisher is their first user, and none of them depends on it.

ModuleWhat it does
types.tsThe AST
instructionThe opcode table every module below reads
binary/parseBytes to the AST, or an error naming the byte
binary/writeThe AST to bytes
watThe AST to text, laid out as wasmprinter lays it out, and its functions as marked text, each word with its kind

Scope

The WebAssembly 2.0 core instruction set without the vector (SIMD) instructions, which holds every instruction Rust 1.99.1 emits into the demo module. Anything outside it is refused, never skipped.

Round trip

parse(write(m)) is m, and write depends on the module alone. The bytes need not survive write(parse(bytes)): the writer is canonical (shortest LEB128, shortest element encoding, and no empty section unless a custom section follows it) and wasm-ld is not, so the 1,007,871-byte demo module comes back as 962,789 bytes that wasmprinter prints identically. The demo module of these figures is the one Rust 1.99.1 built from de6cb93.

WAT

The text is wasmprinter's, line for line: on the whole demo module of Round trip, 328,525 lines, the two differ only in the producers custom section, which wasmprinter prints in a syntax of its own and this prints as bytes, as any other custom section. Matching it kept the demo pages' disassembly the same when the Rust publisher was replaced, and gave that replacement a check: a diff of every sample's WAT.

Emergent Testing

Idle. Press Run to start the suite.

  • ./binary/parse/proof.f.mjs
  • ./binary/write/proof.f.mjs
  • ./instruction/proof.f.mjs
  • ./wat/proof.f.mjs