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-llvm-passes --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-dead-function-elim \
  --no-fallthrough-jumps

Optimization Flags

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

FlagWhat it controls
--no-llvm-passesLLVM optimization passes (mem2reg, instcombine, etc.)
--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-dead-function-elimRemove unreachable functions from output
--no-fallthrough-jumpsSkip redundant Jump when target is next block

See the Optimizations chapter for details on each.