Skip to content

Design the Wasm exception channel and stack-exhaustion budget (BC-08) - #149

Merged
biuld merged 1 commit into
masterfrom
slice/wasm-exception-channel
Oct 18, 2026
Merged

biuld merged 1 commit into
masterfrom
slice/wasm-exception-channel

Conversation

@biuld

@biuld biuld commented Oct 18, 2026

Copy link
Copy Markdown
Owner

What lands

Design-first slice (docs only): the normative design for adopting the standardized WebAssembly exception-handling proposal (Wasm 3.0, the BC-08 exceptions family) plus a compiler-managed stack-exhaustion budget.

  • docs/design/backend/fp/exception-handling-and-stack-exhaustion.md — the topic document: MIR Tag/TagId/Throw/Try, dominance-carved protected regions, the structured Op::Try + synthesized unwind block + tag section, the budget (weighted W_f prologue/epilogue accounting in a depth global, watermark save/restore at every try_table, budget/limit coordination), the psrs:stack-exhaustion tag, and the checkThrows worked example end to end. Key invariant discovered and solved during design: return_call pops 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.
  • Contract additions (marked Draft design, no implementation claimed) to 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 assertThrows calls observe stack exhaustion, which Wasm EH cannot catch — hence the budget). Out of scope, recorded as future work: 4179.purs's TDZ ReferenceError semantics, Effect.Exception's full surface (BE-21), re-pointing assert' 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.

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.
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