Cranelift: move exception-handler metadata into callsites.#10609
Merged
fitzgen merged 2 commits intobytecodealliance:mainfrom Apr 18, 2025
Merged
Cranelift: move exception-handler metadata into callsites.#10609fitzgen merged 2 commits intobytecodealliance:mainfrom
fitzgen merged 2 commits intobytecodealliance:mainfrom
Conversation
bjorn3
reviewed
Apr 17, 2025
bjorn3
reviewed
Apr 17, 2025
b1f77d7 to
b41af09
Compare
bjorn3
reviewed
Apr 17, 2025
…tor. This commit updates the call-site metadata to refer to a range in a flattened vector containing tuples of handler tags and labels (before finalization) or code offsets (after finalization). It also provides an iterator accessor `.call_sites()` on the finalized buffer that yields this information in a safe way.
b41af09 to
bba8196
Compare
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.
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>