You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Relax the `Send` bound on fiber creation
This commit removes the need for `Send` for all usages of fiber-related
bits. The goal is that the future returned from `async` functions is
`Send` if all the inputs are `Send`, 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 Wasmtime `async`
where `async` functions are going to be used to implement the
synchronous path through Wasmtime where `Send` isn't a bound today, nor
ideally do we want to have it there.
The way this commit works is:
* First `make_fiber` now has a `Send` bound which makes it sound. Before
bytecodealliance#11444 it took `&mut dyn VMStore` which is never `Send` and the
refactoring there missed adding this bound. This change required a few
`Send` bounds in `concurrent.rs` where it's expected to have no
impact as everything there is basically already `Send`.
* Next `make_fiber_unchecked` is added which is the same as `make_fiber`
except without a `Send` bound. The `on_fiber` function is then updated
to use this `*_unchecked` variant. This means that fibers can now be
used with non-`Send` stores. Crucially though the structure of
internals in play means that future produced is still only `Send` if
`T: Send` meaning that there is no loss in safety.
* Next some `Send` bounds were dropped throughout async functions in
Wasmtime as a proof-of-concept to require these changes to `on_fiber`.
This means that these entrypoints into Wasmtime no longer require
`Send`, but still naturally require `Send` if the result future is
sent to various threads.
* Finally a new doctest is added to `Instance::new_async` with a
`compile_fail` example 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 `Send` bounds throughout
Wasmtime. Many of them are still required, for example all the ones
related to `Linker`. The realization is that we can remove some of the
"edge" bounds on entrypoints where the resulting future can be
conditionally `Send` depending on `T` meaning 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
`Send` bound.
* Review comments
0 commit comments