Effect Handlers for WebAssembly

The WasmFX project extends WebAssembly (abbreviated Wasm) with effect handlers as a unifying mechanism to enable efficient compilation of control idioms, such as async/await, generators/iterators, first-class continuations, etc.

WasmFX is currently being considered as the basis for stack switching in WebAssembly. The concrete proposal is known as typed continuations. Join the conversation over at the official WebAssembly stack switching repository.

Efficient and fast

WasmFX provides a general and flexible instruction set for fast stack switching, paving the way for efficient implementations of various non-local control flow abstractions, which would otherwise have to be implemented using whole-program transformations such as continuation passing style. WasmFX is carefully designed to enable Wasm to maintain backwards-compatible performance for legacy programs.

Modular and composable

WasmFX provides a modular and composable basis for implementing non-local control flow abstractions via delimited control, as the design draws heavily on Plotkin and Pretnar's handlers for algebraic effects. As such the design is based on strong and well-understood theoretical foundations; at the same time it also incorporates the practical lessons learnt during the previous 30 years of research on delimited control.

Debuggable and profilable

WasmFX is designed to preserve the debugging and profiling experience of WebAssembly. The structure of WasmFX stacks offers excellent compatibility with popular formats such as DWARF stack unwind tables, enabling WebAssembly implementations to maintain compatibility with standard debugging and profiling tools.

Minimal and compatible

WasmFX is designed as a minimal and compatible extension to WebAssembly for structured non-local control flow. The extension is minimal in the sense that it leverages WebAssembly's existing instruction set and type system. It extends the instruction set with six new instructions and the type system with a new reference type.