Skip to content

Lower fused adapter trap intrinsics to CLIF trap instructions - #14113

Merged
fitzgen merged 2 commits into
bytecodealliance:mainfrom
fitzgen:use-clif-trap-inst-in-fused-adapters
Aug 13, 2026
Merged

Lower fused adapter trap intrinsics to CLIF trap instructions#14113
fitzgen merged 2 commits into
bytecodealliance:mainfrom
fitzgen:use-clif-trap-inst-in-fused-adapters

Conversation

@fitzgen

@fitzgen fitzgen commented Aug 10, 2026

Copy link
Copy Markdown
Member

Before, we would emit a call to a host function, passing the trap code as a
constant argument. Now we emit a trap <code> instruction directly.

This is a large improvement for our sync adapter disas tests.

Depends on #14111

@fitzgen
fitzgen requested review from a team as code owners August 10, 2026 20:32
@fitzgen
fitzgen requested review from alexcrichton and removed request for a team August 10, 2026 20:32
Comment thread crates/cranelift/src/func_environ.rs Outdated
.value_def(trap_code)
.inst()
.expect("FACT emits an instruction for this argument");
let ir::InstructionData::UnaryImm {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm a bit wary of doing this even though it probably works out generally fine, but for example with guest-debug enabled I'd be worried that we'd spill/reload something or something like that. Could the payload here be directly on FactInlineIntrinsic::Trap? That'd require adding it to Trampoline::Trap too which I suspect wouldn't have much impact.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Just pushed a commit implementing this. A bit of shepherding and such, but ultimately nicer yeah.

@github-actions github-actions Bot added the cranelift Issues related to the Cranelift code generator label Aug 10, 2026
Before, we would emit a call to a host function, passing the trap code as a
constant argument. Now we emit a `trap <code>` instruction directly.

This is a large improvement for our sync adapter disas tests.
@fitzgen
fitzgen force-pushed the use-clif-trap-inst-in-fused-adapters branch from 2eb1c97 to 366139f Compare August 12, 2026 21:47
@github-actions github-actions Bot added the wasmtime:api Related to the API of the `wasmtime` crate itself label Aug 12, 2026
@fitzgen
fitzgen enabled auto-merge August 13, 2026 13:44
@fitzgen
fitzgen added this pull request to the merge queue Aug 13, 2026
Merged via the queue into bytecodealliance:main with commit cb7f6c4 Aug 13, 2026
104 of 106 checks passed
@fitzgen
fitzgen deleted the use-clif-trap-inst-in-fused-adapters branch August 13, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift Issues related to the Cranelift code generator wasmtime:api Related to the API of the `wasmtime` crate itself

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants