Skip to content

Comments

Cranelift: move exception-handler metadata into callsites.#10609

Merged
fitzgen merged 2 commits intobytecodealliance:mainfrom
cfallin:exceptions-at-call-sites
Apr 18, 2025
Merged

Cranelift: move exception-handler metadata into callsites.#10609
fitzgen merged 2 commits intobytecodealliance:mainfrom
cfallin:exceptions-at-call-sites

Conversation

@cfallin
Copy link
Member

@cfallin cfallin commented Apr 17, 2025

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_clif to use our exception support for native unwind.

Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>

@cfallin cfallin requested a review from a team as a code owner April 17, 2025 17:39
@cfallin cfallin requested review from fitzgen and removed request for a team April 17, 2025 17:39
@cfallin cfallin force-pushed the exceptions-at-call-sites branch 2 times, most recently from b1f77d7 to b41af09 Compare April 17, 2025 18:39
Copy link
Contributor

@bjorn3 bjorn3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with cg_clif.

…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.
@cfallin cfallin force-pushed the exceptions-at-call-sites branch from b41af09 to bba8196 Compare April 17, 2025 18:54
@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. cranelift:area:aarch64 Issues related to AArch64 backend. cranelift:area:x64 Issues related to x64 codegen labels Apr 17, 2025
Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@fitzgen fitzgen added this pull request to the merge queue Apr 18, 2025
Merged via the queue into bytecodealliance:main with commit c9db233 Apr 18, 2025
71 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift:area:aarch64 Issues related to AArch64 backend. cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. cranelift:area:x64 Issues related to x64 codegen cranelift Issues related to the Cranelift code generator

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants