Stream: git-wasmtime

Topic: wasmtime / PR #14947 cranelift: handle interrupt_poll in ...


view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2026 at 18:09):

Shoryamishra61 opened PR #14947 from Shoryamishra61:fix/interrupt-poll-14926 to bytecodealliance:main:

Fixes #14926

Why this change is needed

When inlining functions that contain interrupt_poll or compiling functions where an interrupt_poll possesses user stack maps, Cranelift encountered several issues:

  1. Inliner Crash / Unknown Call Opcode: interrupt_poll has Opcode::is_call() == true because it transfers control to the runtime interpreter, but it lacks a FuncRef / external callee body. The inliner previously hit the unhandled call assertion.
  2. Calling Convention Invariant: The IR verifier mandates that interrupt_poll only appears in functions with the tail calling convention. Inlining a tail callee containing an interrupt_poll into a caller with a different convention (e.g. system_v) resulted in invalid CLIF.
  3. Exception Table Fixups: When inlining into a try_call site, exception table fixups attempted to inspect interrupt_poll as a callable target.
  4. Backend Safepoints & Stack Map PC: Neither the x64 nor AArch64 backends classified InterruptPoll as a safepoint (is_safepoint()), and stack maps were not attached to the faulting load instruction PC where runtime signal handlers inspect frame state.
  5. Consecutive Stack Map PC Collision: In rare cases where a preserve_all call immediately precedes an interrupt_poll and both have stack maps, the call return PC and the faulting load PC coincide, violating exact-PC stack map uniqueness.

Implementation Highlights

Verification Done

The following test suites were executed locally against current upstream main (257ecb40e665):

AI Tool Usage Disclosure

In compliance with the Bytecode Alliance AI Tool Use Policy: An AI assistant (Antigravity) was used locally to assist with forward-porting the patch to current upstream main, running test harness commands, resolving trailing whitespace on test fixtures, and formatting this submission text. All code logic, test results, and diffs were inspected and reviewed.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2026 at 18:09):

Shoryamishra61 removed the review request for wasmtime-compiler-reviewers from PR #14947.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2026 at 18:09):

Shoryamishra61 requested alexcrichton for a review on PR #14947.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2026 at 18:10):

Shoryamishra61 requested wasmtime-compiler-reviewers for a review on PR #14947.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2026 at 20:47):

github-actions[bot] added the label cranelift on PR #14947.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2026 at 20:47):

github-actions[bot] added the label cranelift:area:machinst on PR #14947.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2026 at 20:47):

github-actions[bot] added the label cranelift:area:x64 on PR #14947.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2026 at 20:47):

github-actions[bot] added the label cranelift:area:aarch64 on PR #14947.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2026 at 20:58):

:memo: alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2026 at 20:58):

:speech_balloon: alexcrichton created PR review comment:

It's ok to trim down verbose LLM comments like this. Basically this just needs to convey "InterruptPoll returns is_call(), but it doesn't participate in inlining"

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2026 at 20:58):

:speech_balloon: alexcrichton created PR review comment:

IIRC we've already got inlining heuristics elsewhere in Wasmtime which would cover things like this. Subjectively I'd say it's ok to drop this and leave this up to callers, and if the heuristics from Wasmtime are ever extracted we could perhaps consolidate with this.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2026 at 20:58):

:speech_balloon: alexcrichton created PR review comment:

IIRC we've already got infrastructure in other places for whether or not metadata applies to after an instruction or that instruction itself (or something like that). For example I think MachDebugTagPos serves that purpose. Personally I think it would be better to improve stack map lookup to handle that as opposed to injecting otherwise-not-useful nops.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2026 at 22:05):

cfallin commented on PR #14947:

interrupt_poll has Opcode::is_call() == true

My intuition here is that this is probably the wrong decision, in hindsight: yes it can "do a call" in a sense, if a signal handler runs, but that's completely transparent. The "can call" opcode characteristic is really more relevant for things like inlining, as we see here, and in most ways the opcode is not a call (with args, with a callee, etc). So we should probably flip the condition here and then work through the implications, IMHO.

(I will take a more detailed look next week when I am fully back at the keyboard; I just wanted to leave this thought now as the discussion is open)

view this post on Zulip Wasmtime GitHub notifications bot (Oct 23 2026 at 15:38):

alexcrichton requested cfallin for a review on PR #14947.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 26 2026 at 20:22):

cfallin commented on PR #14947:

Looking at this a little more, it remains my opinion that interrupt_poll should not be a "call". Some of the other fixes here are good though. @Shoryamishra61 can you address that concern by removing the "callness" of the opcode and then working through the implications?

(Also cc @erikrose)

view this post on Zulip Wasmtime GitHub notifications bot (Oct 28 2026 at 21:28):

erikrose commented on PR #14947:

Yes, we should hold loosely my choice to put .call() on there; it may be less transgressive without. This might also be an opportunity to enrich the documentation of call(), beyond "a call instruction". I struggled with what the right choice was. Thanks for having a second look!

view this post on Zulip Wasmtime GitHub notifications bot (Oct 29 2026 at 20:50):

cfallin commented on PR #14947:

@erikrose would you mind taking on the fix here, since the original creator of this PR hasn't responded for a week?

view this post on Zulip Wasmtime GitHub notifications bot (Oct 29 2026 at 20:55):

Shoryamishra61 commented on PR #14947:

Apologies for the delayed response, @cfallin and @alexcrichton . I've been occupied with other commitments over the past week and wasn't able to follow up on the review discussions.

I'm still interested in seeing this through and addressing the feedback.

I understand the concern about treating interrupt_poll as a call, and I agree that removing its call classification is worth investigating. I'll revisit the affected inliner paths and verifier assumptions, simplify the comments highlighted in review, and look into the existing metadata infrastructure for handling stack map PCs without introducing unnecessary NOPs.

If the work hasn't already been handed over, I'd appreciate the opportunity to make these revisions. If @erikrose has already started, I'm happy to coordinate to avoid duplicating effort.

Thanks for the detailed feedback and your patience.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 29 2026 at 21:44):

cfallin commented on PR #14947:

Ah, no worries @Shoryamishra61, I just wanted to make sure things were moving forward and didn't want to put any pressure on an external contributor (you don't owe us anything!) -- if you want to keep going on this, please do. I guess if you feel like you need to hand it off at any point, it would make sense to pass off to Erik. Either way we (as Cranelift maintainers) do want to see it resolved before declaring the MMU-interruption work done, since this is a bug, but that's not on you to ensure :-)

view this post on Zulip Wasmtime GitHub notifications bot (Nov 01 2026 at 12:22):

Shoryamishra61 updated PR #14947.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 01 2026 at 12:23):

Shoryamishra61 edited PR #14947:

Fixes #14926

Why this change is needed

When inlining functions that contain interrupt_poll or compiling functions where an interrupt_poll possesses user stack maps, Cranelift encountered several issues:

  1. Calling Convention Invariant & Safepoint Mapping: interrupt_poll is a safepoint at which stack maps must be emitted at the faulting load instruction PC for signal handler inspection.
  2. Opcode Classification: Following review feedback from @cfallin, interrupt_poll does not have a callee, arguments, or calling convention (signal handlers are transparent to control flow). It is therefore classified without .call(), but retains safepoint handling (is_safepoint()).
  3. Inlining Logic: Because interrupt_poll is not classified as a call, the inliner copies it directly in the instruction-copying loop, and stack map entries are cleanly copied using opcode.is_safepoint().
  4. Backend Safepoints: Both x64 and AArch64 backends classify InterruptPoll as a safepoint (is_safepoint()), emitting user stack maps at the address of the faulting load without artificial NOP padding.

Implementation Highlights

AI Tool Usage Disclosure

In compliance with the Bytecode Alliance AI Tool Use Policy: An AI assistant was used locally to assist with code inspection, running formatting/syntax checks, and drafting this summary. All code changes were reviewed and verified.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 01 2026 at 12:23):

Shoryamishra61 commented on PR #14947:

Pushed commit \920636a214\ addressing @cfallin's review:

view this post on Zulip Wasmtime GitHub notifications bot (Nov 01 2026 at 14:44):

github-actions[bot] added the label cranelift:meta on PR #14947.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 17:07):

:thumbs_up: cfallin submitted PR review:

Thanks! This is broadly the right shape now; just a few thoughts on comments (cleaning up some LLM-isms) below.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 17:07):

:speech_balloon: cfallin created PR review comment:

To be a little more precise, the reason that we associate with the PC of the load itself is not because of any choice the signal handler makes (indeed, it could skip past the load if it really wanted to); it's because that is the semantics of a SIGSEGV on a load, namely that the signal is delivered with the PC pointing at (not past) the instruction.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 17:07):

:speech_balloon: cfallin created PR review comment:

No need for this narrative comment (which reads as a common pattern I've seen from LLMs, to me at least): it's describing what the thing is not, but the reader is likely not asking "why isn't interrupt_poll a call?". In other words, it's a strange thing to think in the first place so we don't need to say that (more or less) it's not a call because it doesn't do a call.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 17:07):

:speech_balloon: cfallin created PR review comment:

likewise here, update comment as per above

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 17:07):

:speech_balloon: cfallin created PR review comment:

similar to above: no need to say "it is not a call instruction"; no reader is asking that question or assuming that here.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 17:07):

:speech_balloon: cfallin created PR review comment:

LIkewise here, this paragraph reads as "the instruction must not do the thing that an earlier version of this source tree did". The reader will not have this in their mind; it's very confusing to bring it up. (Especially e.g. the bit about exception tables.)

Better to say what we actually are testing here: we want to be sure that the inliner properly inlines interrupt_poll ops and copies over their stackmaps, right?

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 19:28):

Shoryamishra61 updated PR #14947.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 19:30):

Shoryamishra61 commented on PR #14947:

Thanks for the review and the precise corrections. I've cleaned up the five comments, removed the unnecessary historical explanations, and clarified that the stack maps use the faulting load's PC because that is the PC reported on SIGSEGV. The implementation and test expectations are unchanged.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 20:19):

:thumbs_up: cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 20:20):

cfallin added PR #14947 cranelift: handle interrupt_poll in inliner and emit stack map at faulting load PC to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 20:43):

:check: cfallin merged PR #14947.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 20:43):

cfallin removed PR #14947 cranelift: handle interrupt_poll in inliner and emit stack map at faulting load PC from the merge queue.


Last updated: Nov 19 2026 at 20:05 UTC