Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

CLI Usage

# Compile WAT or WASM to JAM
wasm-pvm compile input.wat -o output.jam
wasm-pvm compile input.wasm -o output.jam

# With import resolution
wasm-pvm compile input.wasm -o output.jam \
  --imports imports.txt \
  --adapter adapter.wat

# Disable specific optimizations
wasm-pvm compile input.wasm -o output.jam --no-inline --no-peephole

# Disable all optimizations
wasm-pvm compile input.wasm -o output.jam \
  --no-peephole --no-register-cache \
  --no-icmp-fusion --no-shrink-wrap --no-dead-store-elim \
  --no-const-prop --no-inline --no-cross-block-cache \
  --no-register-alloc --no-fallthrough-jumps

--debug-skip-llvm-passes is not included above: it disables mem2reg and therefore breaks PVM lowering on any non-trivial input. See Diagnostic & Triage Flags.

Optimization Flags

All non-trivial optimizations are enabled by default. Each can be individually disabled:

FlagWhat it controls
--no-peepholePost-codegen peephole optimizer
--no-register-cachePer-block store-load forwarding
--no-icmp-fusionFuse ICmp+Branch into single PVM branch
--no-shrink-wrapOnly save/restore used callee-saved regs
--no-dead-store-elimRemove SP-relative stores never loaded from
--no-const-propSkip redundant LoadImm when register already holds the constant
--no-inlineLLVM function inlining for small callees
--no-cross-block-cachePropagate register cache across single-predecessor block boundaries
--no-register-allocLinear-scan register allocation for loop values
--no-fallthrough-jumpsSkip redundant Jump when target is next block

See the Optimizations chapter for details on each.

Diagnostic & Triage Flags

These flags affect what the compiler accepts or how it reports failures. They are not optimizations.

FlagWhat it does
--trap-floatsReplace every f32/f64 operator with a runtime trap instead of failing compilation. See Trap Floats Mode.
--debug-skip-llvm-passesDebug only. Skip the entire LLVM pass pipeline (including mem2reg). The PVM backend cannot lower the resulting alloca / unpromoted SSA, so non-trivial WASM will fail to compile. Use only to inspect raw frontend IR.

When compilation fails on an unsupported operator, the error message includes the function index, the function’s display name (from the WASM name custom section, falling back to the export name, then wasm_func_<idx>), and the operator’s byte offset within the function body. Example:

Error: Compilation failed

Caused by:
    Unsupported WASM feature: F64Load { memarg: ... } (in function #42 'compute_score' at byte offset 0x1a3)

This makes it possible to grep into the WASM disassembly (wasm-tools dump) or anan-as source to find the offending site without bisecting the module.