-
Notifications
You must be signed in to change notification settings - Fork 1.5k
implement Component Model async ABI #11127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement Component Model async ABI #11127
Conversation
4fd3b8e
to
c4020df
Compare
This pulls in the tests from the `wasip3-prototyping` repo, minus the ones requiring WASIp3 support in `wasmtime-wasi[-http]`, which will be PR'd separately. Note that this builds on bytecodealliance#11114, bytecodealliance#11123, and bytecodealliance#11127; only the fourth commit is new. Signed-off-by: Joel Dice <[email protected]>
This pulls in the tests from the `wasip3-prototyping` repo, minus the ones requiring WASIp3 support in `wasmtime-wasi[-http]`, which will be PR'd separately. Note that this builds on bytecodealliance#11114, bytecodealliance#11123, and bytecodealliance#11127; only the fourth commit is new. Signed-off-by: Joel Dice <[email protected]>
c4020df
to
8d7e0af
Compare
This pulls in the tests from the `wasip3-prototyping` repo, minus the ones requiring WASIp3 support in `wasmtime-wasi[-http]`, which will be PR'd separately. Note that this builds on bytecodealliance#11123 and bytecodealliance#11127; only the most recent commit is new. Signed-off-by: Joel Dice <[email protected]>
8d7e0af
to
bee8ccf
Compare
Subscribe to Label Actioncc @fitzgen
This issue or pull request has been labeled: "fuzzing", "wasmtime:api", "wasmtime:c-api"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
bee8ccf
to
26c0fbf
Compare
This commit is extracted from from review of bytecodealliance#11123 and bytecodealliance#11127. While not literally present in those PRs it's my own personal conclusion that it's best to just go ahead and add these bounds at the "base" of the component trait hierarchy. The current implementation in bytecodealliance#11123 adds bounds in many locations and this would remove the need to add bounds everywhere and instead have everything inherited through the `Lift` and `Lower` traits. This raises the question of: why? The main conclusion that I've reached leading to this change is that Wasmtime currently will store `R`, a return value, on the stack during the lowering process back into linear memory. This might involve allocation, however, meaning that wasm can be invoked and a context switch could happen. For Wasmtime's `unsafe impl` of `Send` and `Sync` on fibers to be sound it requires that this stack-local variable is also `Send` and `Sync` as it's an entirely user-provided type. Thus I've concluded that for results it's always required for these to be both `Send` and `Sync` (or at the very least, `Send`). Given that I've gone ahead and updated to require both `Send` and `Sync` for both params and results. This is not expected to actually have any impact in practice since all primitives are already `Send`/`Sync` (minus `Rc` impls all removed here) and all `bindgen!`-generated types are compositions of `Send`/`Sync` primitives meaning that they're also `Send` and `Sync`.
This commit is extracted from from review of bytecodealliance#11123 and bytecodealliance#11127. While not literally present in those PRs it's my own personal conclusion that it's best to just go ahead and add these bounds at the "base" of the component trait hierarchy. The current implementation in bytecodealliance#11123 adds bounds in many locations and this would remove the need to add bounds everywhere and instead have everything inherited through the `Lift` and `Lower` traits. This raises the question of: why? The main conclusion that I've reached leading to this change is that Wasmtime currently will store `R`, a return value, on the stack during the lowering process back into linear memory. This might involve allocation, however, meaning that wasm can be invoked and a context switch could happen. For Wasmtime's `unsafe impl` of `Send` and `Sync` on fibers to be sound it requires that this stack-local variable is also `Send` and `Sync` as it's an entirely user-provided type. Thus I've concluded that for results it's always required for these to be both `Send` and `Sync` (or at the very least, `Send`). Given that I've gone ahead and updated to require both `Send` and `Sync` for both params and results. This is not expected to actually have any impact in practice since all primitives are already `Send`/`Sync` (minus `Rc` impls all removed here) and all `bindgen!`-generated types are compositions of `Send`/`Sync` primitives meaning that they're also `Send` and `Sync`.
@dicej on this one thing I want to write down before I forget (I've forgotten this many times so far...) Index allocation for futures/streams/error-context I believe are going to need to be updated here. I believe the current state of this PR is such that there's one indexing namespace for all resources within a component, and then there's another index namespace for futures/streams/error-context. Spec-wise I believe it's required we unify these index namespaces. I realize that this is an artifact of the history of the implementation here, but it's something that I want to be sure to write down and not forget. Effectively my naive expectation would be that this type grows to include |
* Add `Send`/`Sync` bounds to `ComponentType` This commit is extracted from from review of #11123 and #11127. While not literally present in those PRs it's my own personal conclusion that it's best to just go ahead and add these bounds at the "base" of the component trait hierarchy. The current implementation in #11123 adds bounds in many locations and this would remove the need to add bounds everywhere and instead have everything inherited through the `Lift` and `Lower` traits. This raises the question of: why? The main conclusion that I've reached leading to this change is that Wasmtime currently will store `R`, a return value, on the stack during the lowering process back into linear memory. This might involve allocation, however, meaning that wasm can be invoked and a context switch could happen. For Wasmtime's `unsafe impl` of `Send` and `Sync` on fibers to be sound it requires that this stack-local variable is also `Send` and `Sync` as it's an entirely user-provided type. Thus I've concluded that for results it's always required for these to be both `Send` and `Sync` (or at the very least, `Send`). Given that I've gone ahead and updated to require both `Send` and `Sync` for both params and results. This is not expected to actually have any impact in practice since all primitives are already `Send`/`Sync` (minus `Rc` impls all removed here) and all `bindgen!`-generated types are compositions of `Send`/`Sync` primitives meaning that they're also `Send` and `Sync`. * Remove some now-unnecessary bounds * Promote to doc comments
db7f20a
to
a4e9243
Compare
This pulls in the tests from the `wasip3-prototyping` repo, minus the ones requiring WASIp3 support in `wasmtime-wasi[-http]`, which will be PR'd separately. Note that this builds on bytecodealliance#11123 and bytecodealliance#11127; only the most recent commit is new. Signed-off-by: Joel Dice <[email protected]>
Signed-off-by: Joel Dice <[email protected]>
Signed-off-by: Joel Dice <[email protected]>
Signed-off-by: Joel Dice <[email protected]>
This restores the original behavior of requiring explicit post-return calls for `call[_async]` invocations. Signed-off-by: Joel Dice <[email protected]>
This pulls in the tests from the `wasip3-prototyping` repo, minus the ones requiring WASIp3 support in `wasmtime-wasi[-http]`, which will be PR'd separately. Note that this builds on bytecodealliance#11123 and bytecodealliance#11127; only the most recent commit is new. Signed-off-by: Joel Dice <[email protected]>
Mostly move unnecessary state out of the `Arc`.
We weren't always disposing of guest or host task handles once they became unreachable. This adds a couple of hidden methods which integration tests may use to guard against use-after-delete, double-delete, and leak bugs regarding waitable handles. It also tightens up handle management in `concurrent.rs` to ensure those tests pass. Signed-off-by: Joel Dice <[email protected]>
Don't rely on all buffers to handle `TypeId` and assertions and such, instead have a helper type which is the one location of the assertions and everything else can stay typed.
Mostly move away from raw pointers and instead use utilities like `&[MaybeUninit<T>]`. Also make `WriteBuffer` an `unsafe` trait after absorbing the `TakeBuffer` trait. Update all safety-related comments here and there too.
crates/wasmtime/src/runtime/component/concurrent/futures_and_streams.rs
Outdated
Show resolved
Hide resolved
crates/wasmtime/src/runtime/component/concurrent/futures_and_streams/buffers.rs
Outdated
Show resolved
Hide resolved
crates/wasmtime/src/runtime/component/concurrent/futures_and_streams/buffers.rs
Show resolved
Hide resolved
This pulls in the tests from the `wasip3-prototyping` repo, minus the ones requiring WASIp3 support in `wasmtime-wasi[-http]`, which will be PR'd separately. Note that this builds on bytecodealliance#11123 and bytecodealliance#11127; only the most recent commit is new. Signed-off-by: Joel Dice <[email protected]>
This avoids the need for an `Arc`. Signed-off-by: Joel Dice <[email protected]>
Signed-off-by: Joel Dice <[email protected]>
Signed-off-by: Joel Dice <[email protected]>
This gates interop with the `bytes` crate, making it optional and non-default. Signed-off-by: Joel Dice <[email protected]>
This pulls in the tests from the `wasip3-prototyping` repo, minus the ones requiring WASIp3 support in `wasmtime-wasi[-http]`, which will be PR'd separately. Note that this builds on bytecodealliance#11123 and bytecodealliance#11127; only the most recent commit is new. Signed-off-by: Joel Dice <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I believe we've filed issues for follow-up tasks but otherwise this is an off-by-default feature and in a pretty good spot otherwise, so I'm going to flag for merge. Thanks again @dicej!
This commit replaces the stub functions and types in
wasmtime::runtime::component::concurrent
and its submodules with the working implementation developed in thewasip3-prototyping
repo. For ease of review, it does not include any new tests; I'll add those in a follow-up commit.