Hasty Briefsbeta

Bilingual

Wastrel, a Profligate Implementation of WebAssembly

6 months ago
  • #Compiler
  • #WASI
  • #WebAssembly
  • Wastrel is a new WebAssembly (Wasm) implementation that compiles Wasm modules to standalone binaries by emitting C and then compiling that C.
  • Key differences from similar projects (wasm2c, w2c2) include aiming to support automatic memory management via WasmGC using the Whippet garbage collection library.
  • Wastrel's CLI resembles wasmtime, compiling and running the C output by default, unlike wasm2c which focuses on C production.
  • Implements WASI 0.1 (WASI preview 1), allowing direct execution of binaries using WASI imports.
  • Emits optimized C code with a lightweight effects analysis to minimize useless temporaries.
  • Performance benchmarks show Wastrel is 2-5% slower than native, comparable to w2c2, and significantly faster than Wasmtime.
  • Implementing WASI was challenging due to the need to handle ABIs with limited types, the complexity of WASI functions like poll_oneoff, and underspecification issues.
  • Uses Linux's filesystem namespaces for secure sandboxing, making it Linux-only and emphasizing a capabilities-based approach.
  • Motivations include advocating for garbage collection in WASI, supporting WasmGC languages outside browsers, and promoting the Whippet GC library.
  • Future goals include exploring performance against ocamlopt and enabling native compilation of Guile programs via Hoot, Whippet, and Wastrel.