A fully snapshotable Wasm interpreter

Source: github.com
34 points by matthewkim 5 hours ago on lobsters | 4 comments

A WebAssembly interpreter written from scratch.

This project aims to build a fully spec-compliant, performant interpreter whose entire execution state can be serialized, suspended, and restored.

See demo
Game of Life demo
Each fork snapshots the entire WebAssembly execution state, spawns a brand new process, and resumes exactly where it left off.

Status

gabagool is tested against the WebAssembly spec test suite. 1,960 tests pass out of 2,049 (96%). gabagool passes on arithmetic, control flow, memory, tables, globals, function references, imports/exports, and exceptions. Remaining tests involve supporting SIMD and garbage collection.

# run the core test suite
uv run download-spec-tests.py
cargo t --features core-tests

# run the component test suite
# you need wasm-tools installed!
cd tests/components && bash fetch_components.sh
cargo t --features component-tests

# run an example wasm program
cargo r -- ./programs/stair_climb.wasm stair_climb 20

gabagool is not optimized and no serious profiling/benchmarking has been done. That said, the goal is to make it as performant as a pure interpreter can be. The most interesting direction is a translation phase that lowers WASM instructions into a compact intermediate representation, designed for efficient dispatch and serialization.

Reading

https://webassembly.github.io/spec/core/
bytecodealliance/wasmtime#3017
bytecodealliance/wasmtime#4002

https://www.infoq.com/podcasts/web-assembly-component-model/
https://blog.sunfishcode.online/what-is-a-wasm-component/
https://www.fermyon.com/blog/webassembly-component-model
https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md
https://github.com/WebAssembly/component-model/blob/main/design/mvp/Binary.md
https://github.com/WebAssembly/component-model/blob/main/design/mvp/CanonicalABI.md