Skip to content
friendlymatthewPublic

About

Snapshotable WebAssembly interpreter from scratch

Topics

Resources

Stars

245 stars

Watchers

1 watching

Forks

Repository files navigation

gabagool logo

gabagool

A WebAssembly interpreter written from scratch.

This project aims to build a serious, fully spec-compliant, performant WASM interpreter whose entire execution state can be serialized, suspended, and restored. gabagool is no_std, so it never touches the host OS.


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

As a pure interpreter, it is safe to assume gabagool is spec compliant. 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.

gabagool is not focused on performance optimization. No serious profiling/benchmarking has been done (yet!). That said, the goal is to make gabagool performant while preserving its snapshot friendly execution model. gabagool already lowers WASM instructions into a compact, serializable intermediate representation. A future direction is a JIT compiler based on copy and patch compilation.

Current work focuses on how gabagool interacts with its host environment. This includes a robust, virtualized WASI Preview 1 implementation whose state can be snapshotted and restored alongside the interpreter.

Usage

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

# compare against the committed CI baseline
python3 check-core-tests.py

# lock newly passing assertions and cases into the baseline
python3 check-core-tests.py --update

# 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 -- ./test-programs/stair_climb.wasm stair_climb 20

Reading

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

Wasm Component Model

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

Copy and patch compilation

https://fredrikbk.com/publications/copy-and-patch.pdf
https://www.youtube.com/watch?v=HxSHIpEQRjs

About

Snapshotable WebAssembly interpreter from scratch

Topics

Resources

Stars

245 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages