alexcrichton opened PR #11454 from alexcrichton:remove-send-bound-from-async-stuff to bytecodealliance:main:
This commit removes the need for
Sendfor all usages of fiber-related
bits. The goal is that the future returned fromasyncfunctions is
Sendif all the inputs areSend, but there's no actual need to
require that in the function signatures themselves. This property was
identified in upcoming work to make more internals of Wasmtimeasync
whereasyncfunctions are going to be used to implement the
synchronous path through Wasmtime whereSendisn't a bound today, nor
ideally do we want to have it there.The way this commit works is:
First
make_fibernow has aSendbound which makes it sound. Before
https://github.com/bytecodealliance/wasmtime/pull/11444 it took&mut dyn VMStorewhich is neverSendand the
refactoring there missed adding this bound. This change required a few
Sendbounds inconcurrent.rswhere it's expected to have no
impact as everything there is basically alreadySend.Next
make_fiber_uncheckedis added which is the same asmake_fiber
except without aSendbound. Theon_fiberfunction is then updated
to use this*_uncheckedvariant. This means that fibers can now be
used with non-Sendstores. Crucially though the structure of
internals in play means that future produced is still onlySendif
T: Sendmeaning that there is no loss in safety.Next some
Sendbounds were dropped throughout async functions in
Wasmtime as a proof-of-concept to require these changes toon_fiber.
This means that these entrypoints into Wasmtime no longer require
Send, but still naturally requireSendif the result future is
sent to various threads.Finally a new doctest is added to
Instance::new_asyncwith a
compile_failexample to ensure that this fails. This is
unfortunately a very brittle test because all we can assert is that
compilation failed, not why compilation failed. That means that this
is likely to regress over time, but it's the best we can do at this
time.Note that the goal here is NOT to remove
Sendbounds throughout
Wasmtime. Many of them are still required, for example all the ones
related toLinker. The realization is that we can remove some of the
"edge" bounds on entrypoints where the resulting future can be
conditionallySenddepending onTmeaning we don't actually have to
write down any bounds ourselves.This refactoring will enable future refactorings to have sync-and-async
functions use the same internals and neither entrypoint needs to have a
Sendbound.
alexcrichton requested pchickey for a review on PR #11454.
alexcrichton requested wasmtime-core-reviewers for a review on PR #11454.
alexcrichton commented on PR #11454:
Procedurally this is built on https://github.com/bytecodealliance/wasmtime/pull/11444 and https://github.com/bytecodealliance/wasmtime/pull/11453. The goal is to work towards https://github.com/bytecodealliance/wasmtime/pull/11430
alexcrichton updated PR #11454.
fitzgen requested fitzgen for a review on PR #11454.
fitzgen commented on PR #11454:
I can review this once it is rebased, now that the things it was based on top of are approved (and presumably will land shortly)
alexcrichton updated PR #11454.
alexcrichton commented on PR #11454:
I've rebased on the merge commit of https://github.com/bytecodealliance/wasmtime/pull/11444 since I need to head out soon, but if/when that PR merges github won't actually remove the commit from this PR, I think I'll have to open/close it or something like that (it's weird)
fitzgen submitted PR review.
fitzgen created PR review comment:
Maybe add a comment here that
Rcis notSend, just to make it a little easier to follow the example. Alternatively, below say "Store<Rc<()>> is not Send because Rc<()> is not Send" or something.
fitzgen created PR review comment:
?
alexcrichton submitted PR review.
alexcrichton created PR review comment:
what
(Forgot to delete after testing)
github-actions[bot] commented on PR #11454:
Subscribe to Label Action
cc @fitzgen
<details>
This issue or pull request has been labeled: "wasmtime:api", "wasmtime:ref-types"Thus the following users have been cc'd because of the following labels:
- fitzgen: wasmtime:ref-types
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
alexcrichton updated PR #11454.
alexcrichton updated PR #11454.
alexcrichton has enabled auto merge for PR #11454.
alexcrichton merged PR #11454.
Last updated: Dec 06 2025 at 06:05 UTC