Repository navigation
Design the Wasm exception channel and stack-exhaustion budget (BC-08) - #149
Merged
Merged
Conversation
Author the normative design for adopting the WebAssembly 3.0 exception-handling proposal minimally behind the existing `exceptions` capability flag, paired with a compiler-managed stack-exhaustion budget, and the DEC-23 decision record amending DEC-05's disabled list. This is a design-first slice: no code changes and no acceptance claims. - docs/design/backend/fp/exception-handling-and-stack-exhaustion.md: the topic design. MIR gains tags and Try/Throw terminators with dominance-checked protected regions; the structuring machinery gains a composite try unit, a synthesized unwind block, and anonymous label entries; the thin encoding gains Op::Try, catch clauses, TagDef/TagIndex, and the tag section. The budget installs a per-function frame-weight prologue/epilogue on a mutable i32 depth global, throwing a payload-less compiler tag before the engine's pinned stack limit, and every try region carries a stack-watermark save/restore because EH unwinding skips epilogues. The worked example traces Test.Assert.checkThrows end to end for TCOMutRec's deep non-tail recursion; boundaries record the 4179 TDZ group, assert' storage trap, pattern-match traps, and the control machine's orthogonality as out of scope or future work. - docs/decision/DEC-23-wasm-exception-channel.md: adopts the channel and the budget behind one flag with no fallback ABI, amends DEC-05 (exceptions move from permanently disabled to adopted-minimally with full evidence obligations), and updates the stale premise of DEC-19's stack-switching rejection while leaving that decision unchanged. - docs/implementation/backend/exception-handling.md: the follow-up checklist with EH-01..EH-17, six vertical slices (gate+encoding, MIR, structuring, budget, library surface, profile flip), all Unverified. - Contract additions without implementation claims: capability-profile.md's exceptions gate row and disabled-until-evidence default; the encoding document's Op::Try, tag section, and TagIndex contract; a pointer in mir.md's terminator section; the backend design index row.
This was referenced Oct 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What lands
Design-first slice (docs only): the normative design for adopting the standardized WebAssembly exception-handling proposal (Wasm 3.0, the BC-08
exceptionsfamily) plus a compiler-managed stack-exhaustion budget.docs/design/backend/fp/exception-handling-and-stack-exhaustion.md— the topic document: MIRTag/TagId/Throw/Try, dominance-carved protected regions, the structuredOp::Try+ synthesized unwind block + tag section, the budget (weightedW_fprologue/epilogue accounting in a depth global, watermark save/restore at everytry_table, budget/limit coordination), thepsrs:stack-exhaustiontag, and thecheckThrowsworked example end to end. Key invariant discovered and solved during design:return_callpops the caller's frame and silently discards armed handlers, so no protected block may end in a forced tail call (verifier-checked).docs/decision/DEC-23-wasm-exception-channel.md— amends DEC-05's disabled list (DEC-22 is taken).docs/implementation/backend/exception-handling.md— execution checklist EH-01…EH-17 across six vertical slices, all Unverified.capability-profile.md,encoding-and-structuring.md,fp/mir.md, and the backend design index. D-04 untouched — status claims land with implementation evidence.Scope boundary (recorded, not designed half-way)
TCOMutRec is the channel's only current corpus consumer (its four
assertThrowscalls observe stack exhaustion, which Wasm EH cannot catch — hence the budget). Out of scope, recorded as future work:4179.purs's TDZReferenceErrorsemantics,Effect.Exception's full surface (BE-21), re-pointingassert'failures, pattern-match-failure observability,exnref/catch_ref/throw_ref, irreducible CFGs with try regions.Validation
Docs-only commit; relative links checked to resolve; every Code map anchor verified against the tree. No code changed, so fmt/clippy/tests are unaffected.