GC and Exceptions in Wasmtime
Wasmtime 47 enables the WebAssembly GC and exceptions proposals by default, letting objects-and-references languages use the runtime's collector instead of shipping their own, and letting exception-using languages use zero-overhead unwinding instead of custom return-flag calling conventions. Wasmtime's collector is a Cheney-style semi-space copying GC with bump allocation and no read/write barriers, built on top of a Wasm linear memory with 32-bit indices as references. That choice gives sandbox defense-in-depth against collector bugs, guard-page bounds-check elision, compact references, preserved 5µs pooled instantiation and portability. Correctness was hardened with GC support in wasm-smith plus two targeted fuzzers, but throughput and latency are not yet competitive with V8 or SpiderMonkey because the design targets many short-lived instances. Upcoming work covers GC-type-aware alias analysis and component model integration via lazy value lowering.
Related posts
- A new way to bring garbage collected programming languages efficiently to WebAssembly · V8
V8 hardMasterGarbage-collected languages like Java, Kotlin, Dart, Python and C# can reach WebAssembly in two ways: compile an existing language VM to linear-memory WasmMVP, or lower the language's objects onto WasmGC structs and arrays managed by the host VM's garbage collector. WasmGC produces smaller binaries because no GC or malloc is shipped, collects cycles between JS and Wasm at fine granularity, sees stack references without shadow stacks, and avoids linear-memory fragmentation. It also reuses the browser's generational and incremental GC and integrates with DevTools heap profiling. The costs are substantial new toolchain work and possible compromises in language semantics, since struct fields have fixed indexes and types and there are no interior pointers, whereas a traditional port preserves exact semantics with little effort. Later sections cover V8 and toolchain optimizations for WasmGC, with benchmark numbers.
- Extensible Language Support in Zed - Part 1
Zed mediumAdeptZed loads third-party Tree-sitter grammars as WebAssembly modules using a hybrid design. Native code consumes the parser's static parse tables after they are copied out of wasm linear memory, while only the lexing functions, including hand-written external scanners, run inside Wasmtime. This avoids depending on the user's C compiler and keeps buggy scanners from crashing the editor. It also avoids copying large syntax trees out of wasm memory on every keystroke. A new `WasmStore` API lets wasm-loaded languages behave identically to native ones, and a bundled mini-libc with a bump allocator that is reset each parse makes scanner memory leaks impossible.
- Introducing the JetStream 3 Benchmark Suite
WebKit hardMasterJetStream 3 replaces JetStream 2's separate Wasm Startup/Runtime scores with the JavaScript-style first-iteration, worst-case and average-case scoring. The old scheme broke once engines hit sub-millisecond startup that Date.now() rounded to zero, giving infinite scores. The suite also favors larger workloads over microbenchmarks. WebKit details the JavaScriptCore work behind its results. Inlining WasmGC object fields into one allocation gave about 40% on the WasmGC subtests, and removing per-object destructors gave about 40% on Dart-flute-wasm. Other work inlines bump-pointer allocation into the BBQ and OMG tiers, uses Cohen's display for constant-time subtype checks, makes priority-based non-local inlining decisions, and profiles indirect calls for guarded inlining.
- Contributing support for a Wasm instruction to Winch
Shopify Engineering hardMasterAdding a WebAssembly instruction to Winch, Wasmtime's baseline non-optimizing compiler, touches several layers: the wasmparser VisitOperator visitor, the CodeGenContext that manages the value stack, register allocation and spilling, an ISA-independent MacroAssembler, and an x86_64 assembler built on Cranelift's ISLE-generated instruction definitions. The i32.clz example shows how the MacroAssembler emits lzcnt when the CPU supports it and otherwise falls back to a bsr/setne sequence. Changes are tested in two ways: filetests check the emitted machine code without running it, so they work on AArch64 Macs, and differential fuzzing on x86_64 hardware compares Winch's results against another Wasm engine.
- WebAssembly and Back Again: Fine-Grained Sandboxing in Firefox 95
Mozilla Hacks mediumAdeptFirefox 95 ships RLBox, a fine-grained sandboxing technique that compiles third-party C/C++ libraries (Graphite, Hunspell, Ogg, with Expat and Woff2 following in 96) to WebAssembly and then back to native code, so untrusted code runs in-process but cannot jump to unexpected code or touch memory outside its region. This avoids the asynchrony refactoring and memory overhead of process-based isolation, needing only sanitization of values crossing the boundary via RLBox's tainting layer. The production pipeline replaced the Cranelift prototype with wasm2c, translating wasm to C and feeding it back into Clang, which preserves PGO, cross-boundary inlining, crash reporting and debugger support. Mozilla now pays bug bounties for sandbox escapes even without a library vulnerability.