PANINI

W3C WebAssembly · stack machine · linear memory

WASM backend

ISO C on the interpreter is done. The next host is a universal sandboxed binary. Emitter is PANINI. Assembler is in-tree. No wabt.

PANINI.Frontend.C PANINI.Backend.Wasm wat2wasm goto skip = 1

Three hurdles

  1. Stack vs memory. Trees become postfix. x + 10 * 2 → get x; const 10; const 2; mul; add.
  2. Strict i32. The validator rejects C’s implicit casts. Lowering inserts typed ops.
  3. One linear memory. $heap bump is calloc. $sp grows down. Pointers are i32 offsets. i32.load / i32.store.

Maṇḍūkapluti (goto): a function without it stays on structured if/loop. A function with it lowers to a CFG and a br_table dispatcher. Peephole deletes jumps to the next block. Relooper is named, not this turn. WASM_MANDUKAPLUTI.md · wasm-cfg

Run WAT in this browser

The assembler is the same file the tests use. Instantiate is the W3C engine in your browser.

WAT

C source — live emitter (c.pni → wasm.pni)

Examples from the PANINI emitter

Ready.

Pipeline

C → c.pni AST → wasm.pni WAT → wat2wasm → .wasm → WebAssembly.instantiate

Hindi C and the other shailis flatten to this C, then to the same module. Representation stays independent of the binary.

WASM.md · wasm.pni · compute.c