cfallin requested fitzgen for a review on PR #10609.
cfallin opened PR #10609 from cfallin:exceptions-at-call-sites to bytecodealliance:main:
This PR starts with a cherry-pick of @bjorn3's work at [1], which switches exception-handler metadata from a separate list of records (of callsite offset, tag, handler offset tuples) to per-callsite (tag, handler) tuples. This is cleaner for both the native-code use-case and for our planned Wasmtime use-case: in both cases one knows the specific callsite in each frame and wants to look at handlers only for that callsite. The old representation was designed for fast emission and flat storage, but we can get flat storage with this semantic structure as well...
... with the second commit, in which I've updated @bjorn3's implementation to keep a separate vector of handler tuples in the
MachBuffer, and refer to ranges in this vector in the callsite metadata. It also provides an iterator that yields per-callsite information in a safe way.No functional change in-tree (because Cranelift and Wasmtime both do not use this metadata yet) but should enable
cg_clifto use our exception support for native unwind.Co-authored-by:
bjorn3 <17426603+bjorn3@users.noreply.github.com>
cfallin requested wasmtime-compiler-reviewers for a review on PR #10609.
bjorn3 submitted PR review.
bjorn3 created PR review comment:
This doesn't need to be a separate type anymore as
MachCallSiteno longer containsMachLabels.
bjorn3 submitted PR review.
bjorn3 created PR review comment:
Or actually, maybe we should store
MachCallSiteand havebuffer.call_sites()return ownedFInalizedMachCallSite<'a>values with theexception_handler_rangefield replaced byexception_handler: &'a [(PackedOption<ir::ExceptionTag>, CodeOffset)]?
bjorn3 edited PR review comment.
bjorn3 submitted PR review.
bjorn3 created PR review comment:
Looks like line 2525 needs to be changed to
buf.reserve_labels_for_blocks(3);.
cfallin updated PR #10609.
cfallin submitted PR review.
cfallin created PR review comment:
Yep, that explains the failures in CI, thanks!
cfallin submitted PR review.
cfallin created PR review comment:
Ah, yes, I like the latter option a lot -- updated, thanks!
cfallin updated PR #10609.
bjorn3 submitted PR review.
bjorn3 created PR review comment:
Shouldn't these all say "relative to the containing function"? There can be multiple functions in a single section.
bjorn3 submitted PR review:
Tested with cg_clif.
cfallin updated PR #10609.
cfallin submitted PR review.
cfallin created PR review comment:
I think the existing wording with "section" was added when we began using the MachBuffer to fix up calls between functions in a module as well. I suspect "buffer" is probably the neutral word here -- they are offsets into whatever the MachBuffer is representing. Updated!
fitzgen submitted PR review:
Nice!
fitzgen merged PR #10609.
Last updated: Dec 06 2025 at 07:03 UTC