Skip to content

feat: support Wasm plugins that use exception handling - #1371

Merged
dsherret merged 1 commit into
mainfrom
wasm-exceptions
Oct 18, 2026
Merged

dsherret merged 1 commit into
mainfrom
wasm-exceptions

Conversation

@dsherret

@dsherret dsherret commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Enables wasmtime's gc and gc-drc features so plugins can use the exception-handling proposal. Wasmtime requires gc for it because an exception is an exnref on its GC heap. Without this, such a plugin fails to load:

failed to parse WebAssembly module: exception refs not supported without the exception handling feature

This is for plugins compiled from .NET with NativeAOT-LLVM's WasmEnableExceptionHandling, which throws and catches .NET exceptions with Wasm's own instructions instead of the emulation it uses otherwise. For dprint-plugin-prettier (compiled from TypeScript to C# by nts) the module gets 17% smaller (29.9 MB against 35.9 MB) and formatting 5–7% faster. One thread, ms, three alternating rounds:

CSS (813 files) JSON (1,284 files)
this branch, plugin without Wasm exceptions 5,117–5,198 4,551–4,628
this branch, plugin with Wasm exceptions 4,749–4,802 4,322–4,353

Other plugins are not slower (one thread, ms, five alternating rounds of dprint-plugin-typescript and dprint-plugin-json):

TypeScript (1,000 files) JSON (1,284 files)
without gc 2,585–2,645 436–457
with gc 2,529–2,559 436–441

The binary is 119 KB larger (30.64 to 30.76 MB on Windows).

No plugin cache change is needed: the cache key includes wasmtime's precompile_compatibility_hash, which covers the enabled Wasm features, so modules compiled before this get new entries.

gc-drc is the collector because exceptions hold no cycles. The new test fails without the features with the error above.

@dsherret
dsherret merged commit 7c64f55 into main Oct 18, 2026
22 checks passed
@dsherret
dsherret deleted the wasm-exceptions branch October 18, 2026 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant