Skip to content

Add interrupt_poll Cranelift instruction. - #14579

Open
erikrose wants to merge 3 commits into
bytecodealliance:mainfrom
erikrose:interrupt-poll-instruction
Open

erikrose wants to merge 3 commits into
bytecodealliance:mainfrom
erikrose:interrupt-poll-instruction

Conversation

@erikrose

@erikrose erikrose commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

This is the first step toward implementing MMU-triggered interruption of Wasm (originally suggested in #1749). It's the first little PR broken off the large #12990 for ease of review.


This PR introduces a Cranelift instruction that facilitates resumeable preemptions: in this case, with MMU-based Wasm interruption in mind. However, the same technique is used by HotSpot for stop-the-world GC, so there is potential for other applications.

The original name for this instruction was dead_load_with_context. At the time, that was sufficiently descriptive. However, since then, we've added…

  • Reserving a second register as scratch space for trampolining
  • Returning a new ptr to load from next time

Thus, it's become specialized enough to the task of implementing virtual-memory-triggered interruption mechanisms that it makes sense to rename it with that in mind. Other names I considered include "preempt_poll" (but it ultimately functions cooperatively, so nah), "yield_poll" (too tightly coupled to the one use case I'm chasing right now), and "probe" instead of "poll". HotSpot uses "poll" for their mechanism, so that'll be familiar to some, and it usefully suggests that it will have to be done repeatedly in the usual case.

I recommend reviewing this commit-by-commit.

@erikrose
erikrose force-pushed the interrupt-poll-instruction branch from c9c67c6 to 0b0e8f5 Compare October 6, 2026 20:15
@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 cranelift:docs cranelift:meta Everything related to the meta-language. wasmtime:api Related to the API of the `wasmtime` crate itself labels Oct 6, 2026
erikrose and others added 3 commits October 6, 2026 19:47
It facilitates the cooperative interruption of Cranelift-compiled code, triggered by a background thread's twiddling of MMU protection bits on a polled page of memory.

This is the first step toward implementing MMU-triggered interruption of Wasm (bytecodealliance#1749).

Saúl did the aarch64 implementation.

Co-authored-by: Saúl Cabrera <saulecabrera@gmail.com>
@erikrose
erikrose force-pushed the interrupt-poll-instruction branch from 6d6549c to 877e60a Compare October 6, 2026 23:47
@erikrose
erikrose marked this pull request as ready for review October 7, 2026 00:00
@erikrose
erikrose requested review from a team as code owners October 7, 2026 00:00
@erikrose
erikrose requested review from alexcrichton and removed request for a team October 7, 2026 00:00

This branch has not been deployed

No deployments
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:docs cranelift:meta Everything related to the meta-language. 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.

1 participant