Skip to content

Conversation

@badeend
Copy link

@badeend badeend commented Oct 8, 2023

@rvolosatovs
Copy link
Owner

Thank you, looks good to me!

@rvolosatovs rvolosatovs merged commit 412347e into rvolosatovs:feat/preview2_udp Oct 8, 2023
rvolosatovs pushed a commit that referenced this pull request Oct 11, 2023
…dealliance#7029)

* Rename `Host*` things to avoid name conflicts with bindings.

* Update to the latest resource-enabled wit files.

* Adapting the code to the new bindings.

* Update wasi-http to the resource-enabled wit deps.

* Start adapting the wasi-http code to the new bindings.

* Make `get_directories` always return new owned handles.

* Simplify the `poll_one` implementation.

* Update the wasi-preview1-component-adapter.

FIXME: temporarily disable wasi-http tests.

Add logging to the cli world, since stderr is now a reseource that
can only be claimed once.

* Work around a bug hit by poll-list, fix a bug in poll-one.

* Comment out `test_fd_readwrite_invalid_fd`, which panics now.

* Fix a few FIXMEs.

* Use `.as_ref().trapping_unwrap()` instead of `TrappingUnwrapRef`.

* Use `drop_in_place`.

* Remove `State::with_mut`.

* Remove the `RefCell` around the `State`.

* Update to wit-bindgen 0.12.

* Update wasi-http to use resources for poll and I/O.

This required making incoming-body and outgoing-body resourrces too, to
work with `push_input_stream_child` and `push_output_stream_child`.

* Re-enable disabled tests, remove logging from the worlds.

* Remove the `poll_list` workarounds that are no longer needed.

* Remove logging from the adapter.

That said, there is no replacement yet, so add a FIXME comment.

* Reenable a test that now passes.

* Remove `.descriptors_mut` and use `with_descriptors_mut` instead.

Replace `.descriptors()` and `.descriptors_mut()` with functions
that take closures, which limits their scope, to prevent them from
invalid aliasing.

* Implement dynamic borrow checking for descriptors.

* Add a cargo-vet audit for wasmtime-wmemcheck.

* Update cargo vet for wit-bindgen 0.12.

* Cut down on duplicate sync/async resource types (#1)

* Allow calling `get-directories` more than once (#2)

For now `Clone` the directories into new descriptor slots as needed.

* Start to lift restriction of stdio only once  (bytecodealliance#3)

* Start to lift restriction of stdio only once

This commit adds new `{Stdin,Stdout}Stream` traits which take over the
job of the stdio streams in `WasiCtxBuilder` and `WasiCtx`. These traits
bake in the ability to create a stream at any time to satisfy the API
of `wasi:cli`. The TTY functionality is folded into them as while I was
at it.

The implementation for stdin is relatively trivial since the stdin
implementation already handles multiple streams reading it. Built-in
impls of the `StdinStream` trait are also provided for helper types in
`preview2::pipe` which resulted in the implementation of
`MemoryInputPipe` being updated to support `Clone` where all clones read
the same original data.

* Get tests building

* Un-ignore now-passing test

* Remove unneeded argument from `WasiCtxBuilder::build`

* Fix tests

* Remove some workarounds

Stdio functions can now be called multiple times.

* If `poll_oneoff` fails part-way through, clean up properly.

Fix the `Drop` implementation for pollables to only drop the pollables
that have been successfully added to the list.

This fixes the poll_oneoff_files failure and removes a FIXME.

---------

Co-authored-by: Alex Crichton <[email protected]>
rvolosatovs pushed a commit that referenced this pull request Jan 22, 2025
This adds support for loading, compiling, linking, and running components which
use the [Async
ABI](https://github.com/WebAssembly/component-model/blob/main/design/mvp/Async.md)
along with the [`stream`, `future`, and
`error-context`](WebAssembly/component-model#405) types.
It also adds support for generating host bindings such that multiple host
functions can be run concurrently with guest tasks -- without monopolizing the
`Store`.

See the [implementation RFC](bytecodealliance/rfcs#38)
for details, as well as [this
repo](https://github.com/dicej/component-async-demo) containing end-to-end smoke
tests.

Signed-off-by: Joel Dice <[email protected]>

fix clippy warnings and bench/fuzzing errors

Signed-off-by: Joel Dice <[email protected]>

revert atomic.wit whitespace change

Signed-off-by: Joel Dice <[email protected]>

fix build when component-model disabled

Signed-off-by: Joel Dice <[email protected]>

bless component-macro expected output

Signed-off-by: Joel Dice <[email protected]>

fix no-std build error

Signed-off-by: Joel Dice <[email protected]>

fix build with --no-default-features --features runtime,component-model

Signed-off-by: Joel Dice <[email protected]>

partly fix no-std build

It's still broken due to the use of `std::collections::HashMap` in
crates/wasmtime/src/runtime/vm/component.rs.  I'll address that as part of the
work to avoid exposing global task/future/stream/error-context handles to
guests.

Signed-off-by: Joel Dice <[email protected]>

maintain per-instance tables for futures, streams, and error-contexts

Signed-off-by: Joel Dice <[email protected]>

refactor task/stream/future handle lifting/lowering

This addresses a couple of issues:

- Previously, we were passing task/stream/future/error-context reps directly to
  instances while keeping track of which instance had access to which rep.  That
  worked fine in that there was no way to forge access to inaccessible reps, but
  it leaked information about what other instances were doing.  Now we maintain
  per-instance waitable and error-context tables which map the reps to and from
  the handles which the instance sees.

- The `no_std` build was broken due to use of `HashMap` in
  `runtime::vm::component`, which is now fixed.

Note that we use one single table per instance for all tasks, streams, and
futures.  This is partly necessary because, when async events are delivered to
the guest, it wouldn't have enough context to know which stream or future we're
talking about if each unique stream and future type had its own table.  So at
minimum, we need to use the same table for all streams (regardless of payload
type), and likewise for futures.  Also, per
WebAssembly/component-model#395 (comment),
the plan is to move towards a shared table for all resource types as well, so
this moves us in that direction.

Signed-off-by: Joel Dice <[email protected]>

fix wave breakage due to new stream/future/error-context types

Signed-off-by: Joel Dice <[email protected]>

switch wasm-tools to v1.220.0-based branch

Signed-off-by: Joel Dice <[email protected]>

check `task.return` type at runtime

We can't statically verify a given call to `task.return` corresponds to the
expected core signature appropriate for the currently running task, so we must
do so at runtime.  In order to make that check efficient, we intern the types.

My initial plan was to use `ModuleInternedTypeIndex` and/or `VMSharedTypeIndex`
for interning, but that got hairy with WasmGC considerations, so instead I added
new fields to `ComponentTypes` and `ComponentTypesBuilder`.

Signed-off-by: Joel Dice <[email protected]>

add `TypedFunc::call_concurrent` and refine stream/future APIs

This implements what I proposed in https://github.com/dicej/rfcs/blob/component-async/accepted/component-model-async.md#wasmtime.  Specifically, it adds:

- A new `Promise` type, useful for working with concurrent operations that require access to a `Store` to make progress.
- A new `PromisesUnordered` type for `await`ing multiple promises concurrently
-`TypedFunc::call_concurrent` (which returns a `Promise`), allowing multiple host->guest calls to run concurrently on the same instance.
- Updated `{Stream|Future}{Writer|Reader}` APIs which use `Promise`

The upshot is that the embedder can now ergonomically manage arbitrary numbers
of concurrent operations.  Previously, this was a lot more difficult to do
without accidentally starving some of the operations due to another one
monopolizing the `Store`.

Finally, this includes various refactorings and fixes for bugs exposed by the
newer, more versatile APIs.

Signed-off-by: Joel Dice <[email protected]>

clean up verbosity in component/func.rs

Signed-off-by: Joel Dice <[email protected]>

snapshot

Signed-off-by: Joel Dice <[email protected]>

implement stream/future read/write cancellation

This required a somewhat viral addition of `Send` and `Sync` bounds for async
host function closure types, unfortunately.

Signed-off-by: Joel Dice <[email protected]>

add `Func::call_concurrent` and `LinkerInstance::func_new_concurrent`

Signed-off-by: Joel Dice <[email protected]>

dynamic API support for streams/futures/error-contexts

Signed-off-by: Joel Dice <[email protected]>

support callback-less (AKA stackful) async lifts

Signed-off-by: Joel Dice <[email protected]>

fix `call_host` regression

Signed-off-by: Joel Dice <[email protected]>

add component model async end-to-end tests

I've ported these over from https://github.com/dicej/component-async-demo

Signed-off-by: Joel Dice <[email protected]>

fix test regressions and clippy warnings

Signed-off-by: Joel Dice <[email protected]>

satisfy clippy

Signed-off-by: Joel Dice <[email protected]>

fix async tests when `component-model-async` enabled

Enabling this feature for all tests revealed various missing pieces in the new
`concurrent.rs` fiber mechanism, which I've addressed.

This adds a bunch of ugly `#[cfg(feature = "component-model-async")]` guards,
but those will all go away once I unify the two async fiber implementations.

Signed-off-by: Joel Dice <[email protected]>

add and modify tests to cover concurrent APIs

Primarily, this tests and implements cases where parameters and/or results must
be passed via linear memory instead of the stack.

Signed-off-by: Joel Dice <[email protected]>

`concurrent_{imports|exports}` component macro codegen tests

This enables codegen testing of the `concurrent_imports` and
`concurrent_exports` options to `wasmtime::component::bindgen` and also fixes
code generation for world-level function and resource exports that use the
concurrent call style.

Signed-off-by: Joel Dice <[email protected]>

`concurrent_{imports|exports}` component macro expanded tests

This enables testing of the `concurrent_imports` and `concurrent_exports`
options in `crates/component-macro/tests/expanded.rs`.

Signed-off-by: Joel Dice <[email protected]>

add tests/misc_testsuite/component-model-async/*.wast

These only test instantiation of components which use various async options and
built-ins so far.  Next, I'll happy and sad path tests which actually execute
code.

Signed-off-by: Joel Dice <[email protected]>

appease clippy

Signed-off-by: Joel Dice <[email protected]>

add tests/misc_testsuite/component-model-async/fused.wast

Signed-off-by: Joel Dice <[email protected]>

add non-panicking bounds checks where appropriate

Signed-off-by: Joel Dice <[email protected]>

remove post-return bits from async result lift code

...at least until we've determined whether post-return options even make sense
for async-lifted exports.

Signed-off-by: Joel Dice <[email protected]>

fix component-model-async/fused.wast test failure

Signed-off-by: Joel Dice <[email protected]>

use `enum` types to represent status and event codes

Signed-off-by: Joel Dice <[email protected]>

fix component-model-async/fused.wast test failure (2nd try)

Signed-off-by: Joel Dice <[email protected]>

use `gc_types = true` in component-model-async/fused.wast

We use `Instruction::RefFunc` when generating adapters for async lifts and/or
lowers, which Winch doesn't understand, and apparently `gc_types = true` is what
tells the test infra not to use Winch.

Signed-off-by: Joel Dice <[email protected]>

trap if async function finishes without calling `task.return`

Signed-off-by: Joel Dice <[email protected]>

update wit-bindgen and fix rebase damage

Signed-off-by: Joel Dice <[email protected]>

call post-return function if any for async->sync fused calls

Signed-off-by: Joel Dice <[email protected]>

fix non-component-model-async build; appease clippy

Signed-off-by: Joel Dice <[email protected]>

bless bindgen output whitespace changes

Signed-off-by: Joel Dice <[email protected]>

enforce resource borrow requirements for async calls

Signed-off-by: Joel Dice <[email protected]>

update `wit-bindgen` and simplify `async_borrowing_callee` test

Signed-off-by: Joel Dice <[email protected]>

call `InstanceFlags::set_may_enter` where appropriate

There's still more work to do to fully implement (and test) the reentrance rules
for concurrent tasks, but this is a start.

Signed-off-by: Joel Dice <[email protected]>

finish implementing reentrance checks

Signed-off-by: Joel Dice <[email protected]>

feat: implement error-context (#1)

* feat: initial error-context implementation

This commit implements error-context related functions inside the VM,
along with tests to ensure that basic error-context.new and
error-context.debug-message functionality works.

Signed-off-by: Victor Adossi <[email protected]>

* wip: add test for error context callee/caller transfer

Signed-off-by: Victor Adossi <[email protected]>

* wip: test for async context transfer

Signed-off-by: Victor Adossi <[email protected]>

---------

Signed-off-by: Victor Adossi <[email protected]>

run cargo fmt

Signed-off-by: Joel Dice <[email protected]>

appease clippy

Signed-off-by: Joel Dice <[email protected]>

pull in Roman's unit stream work; add world-level export test

Signed-off-by: Joel Dice <[email protected]>

add unit stream tests

Signed-off-by: Joel Dice <[email protected]>
rvolosatovs pushed a commit that referenced this pull request Jan 23, 2025
This adds support for loading, compiling, linking, and running components which
use the [Async
ABI](https://github.com/WebAssembly/component-model/blob/main/design/mvp/Async.md)
along with the [`stream`, `future`, and
`error-context`](WebAssembly/component-model#405) types.
It also adds support for generating host bindings such that multiple host
functions can be run concurrently with guest tasks -- without monopolizing the
`Store`.

See the [implementation RFC](bytecodealliance/rfcs#38)
for details, as well as [this
repo](https://github.com/dicej/component-async-demo) containing end-to-end smoke
tests.

Signed-off-by: Joel Dice <[email protected]>

fix clippy warnings and bench/fuzzing errors

Signed-off-by: Joel Dice <[email protected]>

revert atomic.wit whitespace change

Signed-off-by: Joel Dice <[email protected]>

fix build when component-model disabled

Signed-off-by: Joel Dice <[email protected]>

bless component-macro expected output

Signed-off-by: Joel Dice <[email protected]>

fix no-std build error

Signed-off-by: Joel Dice <[email protected]>

fix build with --no-default-features --features runtime,component-model

Signed-off-by: Joel Dice <[email protected]>

partly fix no-std build

It's still broken due to the use of `std::collections::HashMap` in
crates/wasmtime/src/runtime/vm/component.rs.  I'll address that as part of the
work to avoid exposing global task/future/stream/error-context handles to
guests.

Signed-off-by: Joel Dice <[email protected]>

maintain per-instance tables for futures, streams, and error-contexts

Signed-off-by: Joel Dice <[email protected]>

refactor task/stream/future handle lifting/lowering

This addresses a couple of issues:

- Previously, we were passing task/stream/future/error-context reps directly to
  instances while keeping track of which instance had access to which rep.  That
  worked fine in that there was no way to forge access to inaccessible reps, but
  it leaked information about what other instances were doing.  Now we maintain
  per-instance waitable and error-context tables which map the reps to and from
  the handles which the instance sees.

- The `no_std` build was broken due to use of `HashMap` in
  `runtime::vm::component`, which is now fixed.

Note that we use one single table per instance for all tasks, streams, and
futures.  This is partly necessary because, when async events are delivered to
the guest, it wouldn't have enough context to know which stream or future we're
talking about if each unique stream and future type had its own table.  So at
minimum, we need to use the same table for all streams (regardless of payload
type), and likewise for futures.  Also, per
WebAssembly/component-model#395 (comment),
the plan is to move towards a shared table for all resource types as well, so
this moves us in that direction.

Signed-off-by: Joel Dice <[email protected]>

fix wave breakage due to new stream/future/error-context types

Signed-off-by: Joel Dice <[email protected]>

switch wasm-tools to v1.220.0-based branch

Signed-off-by: Joel Dice <[email protected]>

check `task.return` type at runtime

We can't statically verify a given call to `task.return` corresponds to the
expected core signature appropriate for the currently running task, so we must
do so at runtime.  In order to make that check efficient, we intern the types.

My initial plan was to use `ModuleInternedTypeIndex` and/or `VMSharedTypeIndex`
for interning, but that got hairy with WasmGC considerations, so instead I added
new fields to `ComponentTypes` and `ComponentTypesBuilder`.

Signed-off-by: Joel Dice <[email protected]>

add `TypedFunc::call_concurrent` and refine stream/future APIs

This implements what I proposed in https://github.com/dicej/rfcs/blob/component-async/accepted/component-model-async.md#wasmtime.  Specifically, it adds:

- A new `Promise` type, useful for working with concurrent operations that require access to a `Store` to make progress.
- A new `PromisesUnordered` type for `await`ing multiple promises concurrently
-`TypedFunc::call_concurrent` (which returns a `Promise`), allowing multiple host->guest calls to run concurrently on the same instance.
- Updated `{Stream|Future}{Writer|Reader}` APIs which use `Promise`

The upshot is that the embedder can now ergonomically manage arbitrary numbers
of concurrent operations.  Previously, this was a lot more difficult to do
without accidentally starving some of the operations due to another one
monopolizing the `Store`.

Finally, this includes various refactorings and fixes for bugs exposed by the
newer, more versatile APIs.

Signed-off-by: Joel Dice <[email protected]>

clean up verbosity in component/func.rs

Signed-off-by: Joel Dice <[email protected]>

snapshot

Signed-off-by: Joel Dice <[email protected]>

implement stream/future read/write cancellation

This required a somewhat viral addition of `Send` and `Sync` bounds for async
host function closure types, unfortunately.

Signed-off-by: Joel Dice <[email protected]>

add `Func::call_concurrent` and `LinkerInstance::func_new_concurrent`

Signed-off-by: Joel Dice <[email protected]>

dynamic API support for streams/futures/error-contexts

Signed-off-by: Joel Dice <[email protected]>

support callback-less (AKA stackful) async lifts

Signed-off-by: Joel Dice <[email protected]>

fix `call_host` regression

Signed-off-by: Joel Dice <[email protected]>

add component model async end-to-end tests

I've ported these over from https://github.com/dicej/component-async-demo

Signed-off-by: Joel Dice <[email protected]>

fix test regressions and clippy warnings

Signed-off-by: Joel Dice <[email protected]>

satisfy clippy

Signed-off-by: Joel Dice <[email protected]>

fix async tests when `component-model-async` enabled

Enabling this feature for all tests revealed various missing pieces in the new
`concurrent.rs` fiber mechanism, which I've addressed.

This adds a bunch of ugly `#[cfg(feature = "component-model-async")]` guards,
but those will all go away once I unify the two async fiber implementations.

Signed-off-by: Joel Dice <[email protected]>

add and modify tests to cover concurrent APIs

Primarily, this tests and implements cases where parameters and/or results must
be passed via linear memory instead of the stack.

Signed-off-by: Joel Dice <[email protected]>

`concurrent_{imports|exports}` component macro codegen tests

This enables codegen testing of the `concurrent_imports` and
`concurrent_exports` options to `wasmtime::component::bindgen` and also fixes
code generation for world-level function and resource exports that use the
concurrent call style.

Signed-off-by: Joel Dice <[email protected]>

`concurrent_{imports|exports}` component macro expanded tests

This enables testing of the `concurrent_imports` and `concurrent_exports`
options in `crates/component-macro/tests/expanded.rs`.

Signed-off-by: Joel Dice <[email protected]>

add tests/misc_testsuite/component-model-async/*.wast

These only test instantiation of components which use various async options and
built-ins so far.  Next, I'll happy and sad path tests which actually execute
code.

Signed-off-by: Joel Dice <[email protected]>

appease clippy

Signed-off-by: Joel Dice <[email protected]>

add tests/misc_testsuite/component-model-async/fused.wast

Signed-off-by: Joel Dice <[email protected]>

add non-panicking bounds checks where appropriate

Signed-off-by: Joel Dice <[email protected]>

remove post-return bits from async result lift code

...at least until we've determined whether post-return options even make sense
for async-lifted exports.

Signed-off-by: Joel Dice <[email protected]>

fix component-model-async/fused.wast test failure

Signed-off-by: Joel Dice <[email protected]>

use `enum` types to represent status and event codes

Signed-off-by: Joel Dice <[email protected]>

fix component-model-async/fused.wast test failure (2nd try)

Signed-off-by: Joel Dice <[email protected]>

use `gc_types = true` in component-model-async/fused.wast

We use `Instruction::RefFunc` when generating adapters for async lifts and/or
lowers, which Winch doesn't understand, and apparently `gc_types = true` is what
tells the test infra not to use Winch.

Signed-off-by: Joel Dice <[email protected]>

trap if async function finishes without calling `task.return`

Signed-off-by: Joel Dice <[email protected]>

update wit-bindgen and fix rebase damage

Signed-off-by: Joel Dice <[email protected]>

call post-return function if any for async->sync fused calls

Signed-off-by: Joel Dice <[email protected]>

fix non-component-model-async build; appease clippy

Signed-off-by: Joel Dice <[email protected]>

bless bindgen output whitespace changes

Signed-off-by: Joel Dice <[email protected]>

enforce resource borrow requirements for async calls

Signed-off-by: Joel Dice <[email protected]>

update `wit-bindgen` and simplify `async_borrowing_callee` test

Signed-off-by: Joel Dice <[email protected]>

call `InstanceFlags::set_may_enter` where appropriate

There's still more work to do to fully implement (and test) the reentrance rules
for concurrent tasks, but this is a start.

Signed-off-by: Joel Dice <[email protected]>

finish implementing reentrance checks

Signed-off-by: Joel Dice <[email protected]>

feat: implement error-context (#1)

* feat: initial error-context implementation

This commit implements error-context related functions inside the VM,
along with tests to ensure that basic error-context.new and
error-context.debug-message functionality works.

Signed-off-by: Victor Adossi <[email protected]>

* wip: add test for error context callee/caller transfer

Signed-off-by: Victor Adossi <[email protected]>

* wip: test for async context transfer

Signed-off-by: Victor Adossi <[email protected]>

---------

Signed-off-by: Victor Adossi <[email protected]>

run cargo fmt

Signed-off-by: Joel Dice <[email protected]>

appease clippy

Signed-off-by: Joel Dice <[email protected]>

pull in Roman's unit stream work; add world-level export test

Signed-off-by: Joel Dice <[email protected]>

add unit stream tests

Signed-off-by: Joel Dice <[email protected]>
rvolosatovs pushed a commit that referenced this pull request Jan 24, 2025
This adds support for loading, compiling, linking, and running components which
use the [Async
ABI](https://github.com/WebAssembly/component-model/blob/main/design/mvp/Async.md)
along with the [`stream`, `future`, and
`error-context`](WebAssembly/component-model#405) types.
It also adds support for generating host bindings such that multiple host
functions can be run concurrently with guest tasks -- without monopolizing the
`Store`.

See the [implementation RFC](bytecodealliance/rfcs#38)
for details, as well as [this
repo](https://github.com/dicej/component-async-demo) containing end-to-end smoke
tests.

Signed-off-by: Joel Dice <[email protected]>

fix clippy warnings and bench/fuzzing errors

Signed-off-by: Joel Dice <[email protected]>

revert atomic.wit whitespace change

Signed-off-by: Joel Dice <[email protected]>

fix build when component-model disabled

Signed-off-by: Joel Dice <[email protected]>

bless component-macro expected output

Signed-off-by: Joel Dice <[email protected]>

fix no-std build error

Signed-off-by: Joel Dice <[email protected]>

fix build with --no-default-features --features runtime,component-model

Signed-off-by: Joel Dice <[email protected]>

partly fix no-std build

It's still broken due to the use of `std::collections::HashMap` in
crates/wasmtime/src/runtime/vm/component.rs.  I'll address that as part of the
work to avoid exposing global task/future/stream/error-context handles to
guests.

Signed-off-by: Joel Dice <[email protected]>

maintain per-instance tables for futures, streams, and error-contexts

Signed-off-by: Joel Dice <[email protected]>

refactor task/stream/future handle lifting/lowering

This addresses a couple of issues:

- Previously, we were passing task/stream/future/error-context reps directly to
  instances while keeping track of which instance had access to which rep.  That
  worked fine in that there was no way to forge access to inaccessible reps, but
  it leaked information about what other instances were doing.  Now we maintain
  per-instance waitable and error-context tables which map the reps to and from
  the handles which the instance sees.

- The `no_std` build was broken due to use of `HashMap` in
  `runtime::vm::component`, which is now fixed.

Note that we use one single table per instance for all tasks, streams, and
futures.  This is partly necessary because, when async events are delivered to
the guest, it wouldn't have enough context to know which stream or future we're
talking about if each unique stream and future type had its own table.  So at
minimum, we need to use the same table for all streams (regardless of payload
type), and likewise for futures.  Also, per
WebAssembly/component-model#395 (comment),
the plan is to move towards a shared table for all resource types as well, so
this moves us in that direction.

Signed-off-by: Joel Dice <[email protected]>

fix wave breakage due to new stream/future/error-context types

Signed-off-by: Joel Dice <[email protected]>

switch wasm-tools to v1.220.0-based branch

Signed-off-by: Joel Dice <[email protected]>

check `task.return` type at runtime

We can't statically verify a given call to `task.return` corresponds to the
expected core signature appropriate for the currently running task, so we must
do so at runtime.  In order to make that check efficient, we intern the types.

My initial plan was to use `ModuleInternedTypeIndex` and/or `VMSharedTypeIndex`
for interning, but that got hairy with WasmGC considerations, so instead I added
new fields to `ComponentTypes` and `ComponentTypesBuilder`.

Signed-off-by: Joel Dice <[email protected]>

add `TypedFunc::call_concurrent` and refine stream/future APIs

This implements what I proposed in https://github.com/dicej/rfcs/blob/component-async/accepted/component-model-async.md#wasmtime.  Specifically, it adds:

- A new `Promise` type, useful for working with concurrent operations that require access to a `Store` to make progress.
- A new `PromisesUnordered` type for `await`ing multiple promises concurrently
-`TypedFunc::call_concurrent` (which returns a `Promise`), allowing multiple host->guest calls to run concurrently on the same instance.
- Updated `{Stream|Future}{Writer|Reader}` APIs which use `Promise`

The upshot is that the embedder can now ergonomically manage arbitrary numbers
of concurrent operations.  Previously, this was a lot more difficult to do
without accidentally starving some of the operations due to another one
monopolizing the `Store`.

Finally, this includes various refactorings and fixes for bugs exposed by the
newer, more versatile APIs.

Signed-off-by: Joel Dice <[email protected]>

clean up verbosity in component/func.rs

Signed-off-by: Joel Dice <[email protected]>

snapshot

Signed-off-by: Joel Dice <[email protected]>

implement stream/future read/write cancellation

This required a somewhat viral addition of `Send` and `Sync` bounds for async
host function closure types, unfortunately.

Signed-off-by: Joel Dice <[email protected]>

add `Func::call_concurrent` and `LinkerInstance::func_new_concurrent`

Signed-off-by: Joel Dice <[email protected]>

dynamic API support for streams/futures/error-contexts

Signed-off-by: Joel Dice <[email protected]>

support callback-less (AKA stackful) async lifts

Signed-off-by: Joel Dice <[email protected]>

fix `call_host` regression

Signed-off-by: Joel Dice <[email protected]>

add component model async end-to-end tests

I've ported these over from https://github.com/dicej/component-async-demo

Signed-off-by: Joel Dice <[email protected]>

fix test regressions and clippy warnings

Signed-off-by: Joel Dice <[email protected]>

satisfy clippy

Signed-off-by: Joel Dice <[email protected]>

fix async tests when `component-model-async` enabled

Enabling this feature for all tests revealed various missing pieces in the new
`concurrent.rs` fiber mechanism, which I've addressed.

This adds a bunch of ugly `#[cfg(feature = "component-model-async")]` guards,
but those will all go away once I unify the two async fiber implementations.

Signed-off-by: Joel Dice <[email protected]>

add and modify tests to cover concurrent APIs

Primarily, this tests and implements cases where parameters and/or results must
be passed via linear memory instead of the stack.

Signed-off-by: Joel Dice <[email protected]>

`concurrent_{imports|exports}` component macro codegen tests

This enables codegen testing of the `concurrent_imports` and
`concurrent_exports` options to `wasmtime::component::bindgen` and also fixes
code generation for world-level function and resource exports that use the
concurrent call style.

Signed-off-by: Joel Dice <[email protected]>

`concurrent_{imports|exports}` component macro expanded tests

This enables testing of the `concurrent_imports` and `concurrent_exports`
options in `crates/component-macro/tests/expanded.rs`.

Signed-off-by: Joel Dice <[email protected]>

add tests/misc_testsuite/component-model-async/*.wast

These only test instantiation of components which use various async options and
built-ins so far.  Next, I'll happy and sad path tests which actually execute
code.

Signed-off-by: Joel Dice <[email protected]>

appease clippy

Signed-off-by: Joel Dice <[email protected]>

add tests/misc_testsuite/component-model-async/fused.wast

Signed-off-by: Joel Dice <[email protected]>

add non-panicking bounds checks where appropriate

Signed-off-by: Joel Dice <[email protected]>

remove post-return bits from async result lift code

...at least until we've determined whether post-return options even make sense
for async-lifted exports.

Signed-off-by: Joel Dice <[email protected]>

fix component-model-async/fused.wast test failure

Signed-off-by: Joel Dice <[email protected]>

use `enum` types to represent status and event codes

Signed-off-by: Joel Dice <[email protected]>

fix component-model-async/fused.wast test failure (2nd try)

Signed-off-by: Joel Dice <[email protected]>

use `gc_types = true` in component-model-async/fused.wast

We use `Instruction::RefFunc` when generating adapters for async lifts and/or
lowers, which Winch doesn't understand, and apparently `gc_types = true` is what
tells the test infra not to use Winch.

Signed-off-by: Joel Dice <[email protected]>

trap if async function finishes without calling `task.return`

Signed-off-by: Joel Dice <[email protected]>

update wit-bindgen and fix rebase damage

Signed-off-by: Joel Dice <[email protected]>

call post-return function if any for async->sync fused calls

Signed-off-by: Joel Dice <[email protected]>

fix non-component-model-async build; appease clippy

Signed-off-by: Joel Dice <[email protected]>

bless bindgen output whitespace changes

Signed-off-by: Joel Dice <[email protected]>

enforce resource borrow requirements for async calls

Signed-off-by: Joel Dice <[email protected]>

update `wit-bindgen` and simplify `async_borrowing_callee` test

Signed-off-by: Joel Dice <[email protected]>

call `InstanceFlags::set_may_enter` where appropriate

There's still more work to do to fully implement (and test) the reentrance rules
for concurrent tasks, but this is a start.

Signed-off-by: Joel Dice <[email protected]>

finish implementing reentrance checks

Signed-off-by: Joel Dice <[email protected]>

feat: implement error-context (#1)

* feat: initial error-context implementation

This commit implements error-context related functions inside the VM,
along with tests to ensure that basic error-context.new and
error-context.debug-message functionality works.

Signed-off-by: Victor Adossi <[email protected]>

* wip: add test for error context callee/caller transfer

Signed-off-by: Victor Adossi <[email protected]>

* wip: test for async context transfer

Signed-off-by: Victor Adossi <[email protected]>

---------

Signed-off-by: Victor Adossi <[email protected]>

run cargo fmt

Signed-off-by: Joel Dice <[email protected]>

appease clippy

Signed-off-by: Joel Dice <[email protected]>

pull in Roman's unit stream work; add world-level export test

Signed-off-by: Joel Dice <[email protected]>

add unit stream tests

Signed-off-by: Joel Dice <[email protected]>
rvolosatovs pushed a commit that referenced this pull request Jan 28, 2025
This adds support for loading, compiling, linking, and running components which
use the [Async
ABI](https://github.com/WebAssembly/component-model/blob/main/design/mvp/Async.md)
along with the [`stream`, `future`, and
`error-context`](WebAssembly/component-model#405) types.
It also adds support for generating host bindings such that multiple host
functions can be run concurrently with guest tasks -- without monopolizing the
`Store`.

See the [implementation RFC](bytecodealliance/rfcs#38)
for details, as well as [this
repo](https://github.com/dicej/component-async-demo) containing end-to-end smoke
tests.

Signed-off-by: Joel Dice <[email protected]>

fix clippy warnings and bench/fuzzing errors

Signed-off-by: Joel Dice <[email protected]>

revert atomic.wit whitespace change

Signed-off-by: Joel Dice <[email protected]>

fix build when component-model disabled

Signed-off-by: Joel Dice <[email protected]>

bless component-macro expected output

Signed-off-by: Joel Dice <[email protected]>

fix no-std build error

Signed-off-by: Joel Dice <[email protected]>

fix build with --no-default-features --features runtime,component-model

Signed-off-by: Joel Dice <[email protected]>

partly fix no-std build

It's still broken due to the use of `std::collections::HashMap` in
crates/wasmtime/src/runtime/vm/component.rs.  I'll address that as part of the
work to avoid exposing global task/future/stream/error-context handles to
guests.

Signed-off-by: Joel Dice <[email protected]>

maintain per-instance tables for futures, streams, and error-contexts

Signed-off-by: Joel Dice <[email protected]>

refactor task/stream/future handle lifting/lowering

This addresses a couple of issues:

- Previously, we were passing task/stream/future/error-context reps directly to
  instances while keeping track of which instance had access to which rep.  That
  worked fine in that there was no way to forge access to inaccessible reps, but
  it leaked information about what other instances were doing.  Now we maintain
  per-instance waitable and error-context tables which map the reps to and from
  the handles which the instance sees.

- The `no_std` build was broken due to use of `HashMap` in
  `runtime::vm::component`, which is now fixed.

Note that we use one single table per instance for all tasks, streams, and
futures.  This is partly necessary because, when async events are delivered to
the guest, it wouldn't have enough context to know which stream or future we're
talking about if each unique stream and future type had its own table.  So at
minimum, we need to use the same table for all streams (regardless of payload
type), and likewise for futures.  Also, per
WebAssembly/component-model#395 (comment),
the plan is to move towards a shared table for all resource types as well, so
this moves us in that direction.

Signed-off-by: Joel Dice <[email protected]>

fix wave breakage due to new stream/future/error-context types

Signed-off-by: Joel Dice <[email protected]>

switch wasm-tools to v1.220.0-based branch

Signed-off-by: Joel Dice <[email protected]>

check `task.return` type at runtime

We can't statically verify a given call to `task.return` corresponds to the
expected core signature appropriate for the currently running task, so we must
do so at runtime.  In order to make that check efficient, we intern the types.

My initial plan was to use `ModuleInternedTypeIndex` and/or `VMSharedTypeIndex`
for interning, but that got hairy with WasmGC considerations, so instead I added
new fields to `ComponentTypes` and `ComponentTypesBuilder`.

Signed-off-by: Joel Dice <[email protected]>

add `TypedFunc::call_concurrent` and refine stream/future APIs

This implements what I proposed in https://github.com/dicej/rfcs/blob/component-async/accepted/component-model-async.md#wasmtime.  Specifically, it adds:

- A new `Promise` type, useful for working with concurrent operations that require access to a `Store` to make progress.
- A new `PromisesUnordered` type for `await`ing multiple promises concurrently
-`TypedFunc::call_concurrent` (which returns a `Promise`), allowing multiple host->guest calls to run concurrently on the same instance.
- Updated `{Stream|Future}{Writer|Reader}` APIs which use `Promise`

The upshot is that the embedder can now ergonomically manage arbitrary numbers
of concurrent operations.  Previously, this was a lot more difficult to do
without accidentally starving some of the operations due to another one
monopolizing the `Store`.

Finally, this includes various refactorings and fixes for bugs exposed by the
newer, more versatile APIs.

Signed-off-by: Joel Dice <[email protected]>

clean up verbosity in component/func.rs

Signed-off-by: Joel Dice <[email protected]>

snapshot

Signed-off-by: Joel Dice <[email protected]>

implement stream/future read/write cancellation

This required a somewhat viral addition of `Send` and `Sync` bounds for async
host function closure types, unfortunately.

Signed-off-by: Joel Dice <[email protected]>

add `Func::call_concurrent` and `LinkerInstance::func_new_concurrent`

Signed-off-by: Joel Dice <[email protected]>

dynamic API support for streams/futures/error-contexts

Signed-off-by: Joel Dice <[email protected]>

support callback-less (AKA stackful) async lifts

Signed-off-by: Joel Dice <[email protected]>

fix `call_host` regression

Signed-off-by: Joel Dice <[email protected]>

add component model async end-to-end tests

I've ported these over from https://github.com/dicej/component-async-demo

Signed-off-by: Joel Dice <[email protected]>

fix test regressions and clippy warnings

Signed-off-by: Joel Dice <[email protected]>

satisfy clippy

Signed-off-by: Joel Dice <[email protected]>

fix async tests when `component-model-async` enabled

Enabling this feature for all tests revealed various missing pieces in the new
`concurrent.rs` fiber mechanism, which I've addressed.

This adds a bunch of ugly `#[cfg(feature = "component-model-async")]` guards,
but those will all go away once I unify the two async fiber implementations.

Signed-off-by: Joel Dice <[email protected]>

add and modify tests to cover concurrent APIs

Primarily, this tests and implements cases where parameters and/or results must
be passed via linear memory instead of the stack.

Signed-off-by: Joel Dice <[email protected]>

`concurrent_{imports|exports}` component macro codegen tests

This enables codegen testing of the `concurrent_imports` and
`concurrent_exports` options to `wasmtime::component::bindgen` and also fixes
code generation for world-level function and resource exports that use the
concurrent call style.

Signed-off-by: Joel Dice <[email protected]>

`concurrent_{imports|exports}` component macro expanded tests

This enables testing of the `concurrent_imports` and `concurrent_exports`
options in `crates/component-macro/tests/expanded.rs`.

Signed-off-by: Joel Dice <[email protected]>

add tests/misc_testsuite/component-model-async/*.wast

These only test instantiation of components which use various async options and
built-ins so far.  Next, I'll happy and sad path tests which actually execute
code.

Signed-off-by: Joel Dice <[email protected]>

appease clippy

Signed-off-by: Joel Dice <[email protected]>

add tests/misc_testsuite/component-model-async/fused.wast

Signed-off-by: Joel Dice <[email protected]>

add non-panicking bounds checks where appropriate

Signed-off-by: Joel Dice <[email protected]>

remove post-return bits from async result lift code

...at least until we've determined whether post-return options even make sense
for async-lifted exports.

Signed-off-by: Joel Dice <[email protected]>

fix component-model-async/fused.wast test failure

Signed-off-by: Joel Dice <[email protected]>

use `enum` types to represent status and event codes

Signed-off-by: Joel Dice <[email protected]>

fix component-model-async/fused.wast test failure (2nd try)

Signed-off-by: Joel Dice <[email protected]>

use `gc_types = true` in component-model-async/fused.wast

We use `Instruction::RefFunc` when generating adapters for async lifts and/or
lowers, which Winch doesn't understand, and apparently `gc_types = true` is what
tells the test infra not to use Winch.

Signed-off-by: Joel Dice <[email protected]>

trap if async function finishes without calling `task.return`

Signed-off-by: Joel Dice <[email protected]>

update wit-bindgen and fix rebase damage

Signed-off-by: Joel Dice <[email protected]>

call post-return function if any for async->sync fused calls

Signed-off-by: Joel Dice <[email protected]>

fix non-component-model-async build; appease clippy

Signed-off-by: Joel Dice <[email protected]>

bless bindgen output whitespace changes

Signed-off-by: Joel Dice <[email protected]>

enforce resource borrow requirements for async calls

Signed-off-by: Joel Dice <[email protected]>

update `wit-bindgen` and simplify `async_borrowing_callee` test

Signed-off-by: Joel Dice <[email protected]>

call `InstanceFlags::set_may_enter` where appropriate

There's still more work to do to fully implement (and test) the reentrance rules
for concurrent tasks, but this is a start.

Signed-off-by: Joel Dice <[email protected]>

finish implementing reentrance checks

Signed-off-by: Joel Dice <[email protected]>

feat: implement error-context (#1)

* feat: initial error-context implementation

This commit implements error-context related functions inside the VM,
along with tests to ensure that basic error-context.new and
error-context.debug-message functionality works.

Signed-off-by: Victor Adossi <[email protected]>

* wip: add test for error context callee/caller transfer

Signed-off-by: Victor Adossi <[email protected]>

* wip: test for async context transfer

Signed-off-by: Victor Adossi <[email protected]>

---------

Signed-off-by: Victor Adossi <[email protected]>

run cargo fmt

Signed-off-by: Joel Dice <[email protected]>

appease clippy

Signed-off-by: Joel Dice <[email protected]>

pull in Roman's unit stream work; add world-level export test

Signed-off-by: Joel Dice <[email protected]>

add unit stream tests

Signed-off-by: Joel Dice <[email protected]>
rvolosatovs pushed a commit that referenced this pull request Feb 11, 2025
This adds support for loading, compiling, linking, and running components which
use the [Async
ABI](https://github.com/WebAssembly/component-model/blob/main/design/mvp/Async.md)
along with the [`stream`, `future`, and
`error-context`](WebAssembly/component-model#405) types.
It also adds support for generating host bindings such that multiple host
functions can be run concurrently with guest tasks -- without monopolizing the
`Store`.

See the [implementation RFC](bytecodealliance/rfcs#38)
for details, as well as [this
repo](https://github.com/dicej/component-async-demo) containing end-to-end smoke
tests.

Signed-off-by: Joel Dice <[email protected]>

fix clippy warnings and bench/fuzzing errors

Signed-off-by: Joel Dice <[email protected]>

revert atomic.wit whitespace change

Signed-off-by: Joel Dice <[email protected]>

fix build when component-model disabled

Signed-off-by: Joel Dice <[email protected]>

bless component-macro expected output

Signed-off-by: Joel Dice <[email protected]>

fix no-std build error

Signed-off-by: Joel Dice <[email protected]>

fix build with --no-default-features --features runtime,component-model

Signed-off-by: Joel Dice <[email protected]>

partly fix no-std build

It's still broken due to the use of `std::collections::HashMap` in
crates/wasmtime/src/runtime/vm/component.rs.  I'll address that as part of the
work to avoid exposing global task/future/stream/error-context handles to
guests.

Signed-off-by: Joel Dice <[email protected]>

maintain per-instance tables for futures, streams, and error-contexts

Signed-off-by: Joel Dice <[email protected]>

refactor task/stream/future handle lifting/lowering

This addresses a couple of issues:

- Previously, we were passing task/stream/future/error-context reps directly to
  instances while keeping track of which instance had access to which rep.  That
  worked fine in that there was no way to forge access to inaccessible reps, but
  it leaked information about what other instances were doing.  Now we maintain
  per-instance waitable and error-context tables which map the reps to and from
  the handles which the instance sees.

- The `no_std` build was broken due to use of `HashMap` in
  `runtime::vm::component`, which is now fixed.

Note that we use one single table per instance for all tasks, streams, and
futures.  This is partly necessary because, when async events are delivered to
the guest, it wouldn't have enough context to know which stream or future we're
talking about if each unique stream and future type had its own table.  So at
minimum, we need to use the same table for all streams (regardless of payload
type), and likewise for futures.  Also, per
WebAssembly/component-model#395 (comment),
the plan is to move towards a shared table for all resource types as well, so
this moves us in that direction.

Signed-off-by: Joel Dice <[email protected]>

fix wave breakage due to new stream/future/error-context types

Signed-off-by: Joel Dice <[email protected]>

switch wasm-tools to v1.220.0-based branch

Signed-off-by: Joel Dice <[email protected]>

check `task.return` type at runtime

We can't statically verify a given call to `task.return` corresponds to the
expected core signature appropriate for the currently running task, so we must
do so at runtime.  In order to make that check efficient, we intern the types.

My initial plan was to use `ModuleInternedTypeIndex` and/or `VMSharedTypeIndex`
for interning, but that got hairy with WasmGC considerations, so instead I added
new fields to `ComponentTypes` and `ComponentTypesBuilder`.

Signed-off-by: Joel Dice <[email protected]>

add `TypedFunc::call_concurrent` and refine stream/future APIs

This implements what I proposed in https://github.com/dicej/rfcs/blob/component-async/accepted/component-model-async.md#wasmtime.  Specifically, it adds:

- A new `Promise` type, useful for working with concurrent operations that require access to a `Store` to make progress.
- A new `PromisesUnordered` type for `await`ing multiple promises concurrently
-`TypedFunc::call_concurrent` (which returns a `Promise`), allowing multiple host->guest calls to run concurrently on the same instance.
- Updated `{Stream|Future}{Writer|Reader}` APIs which use `Promise`

The upshot is that the embedder can now ergonomically manage arbitrary numbers
of concurrent operations.  Previously, this was a lot more difficult to do
without accidentally starving some of the operations due to another one
monopolizing the `Store`.

Finally, this includes various refactorings and fixes for bugs exposed by the
newer, more versatile APIs.

Signed-off-by: Joel Dice <[email protected]>

clean up verbosity in component/func.rs

Signed-off-by: Joel Dice <[email protected]>

snapshot

Signed-off-by: Joel Dice <[email protected]>

implement stream/future read/write cancellation

This required a somewhat viral addition of `Send` and `Sync` bounds for async
host function closure types, unfortunately.

Signed-off-by: Joel Dice <[email protected]>

add `Func::call_concurrent` and `LinkerInstance::func_new_concurrent`

Signed-off-by: Joel Dice <[email protected]>

dynamic API support for streams/futures/error-contexts

Signed-off-by: Joel Dice <[email protected]>

support callback-less (AKA stackful) async lifts

Signed-off-by: Joel Dice <[email protected]>

fix `call_host` regression

Signed-off-by: Joel Dice <[email protected]>

add component model async end-to-end tests

I've ported these over from https://github.com/dicej/component-async-demo

Signed-off-by: Joel Dice <[email protected]>

fix test regressions and clippy warnings

Signed-off-by: Joel Dice <[email protected]>

satisfy clippy

Signed-off-by: Joel Dice <[email protected]>

fix async tests when `component-model-async` enabled

Enabling this feature for all tests revealed various missing pieces in the new
`concurrent.rs` fiber mechanism, which I've addressed.

This adds a bunch of ugly `#[cfg(feature = "component-model-async")]` guards,
but those will all go away once I unify the two async fiber implementations.

Signed-off-by: Joel Dice <[email protected]>

add and modify tests to cover concurrent APIs

Primarily, this tests and implements cases where parameters and/or results must
be passed via linear memory instead of the stack.

Signed-off-by: Joel Dice <[email protected]>

`concurrent_{imports|exports}` component macro codegen tests

This enables codegen testing of the `concurrent_imports` and
`concurrent_exports` options to `wasmtime::component::bindgen` and also fixes
code generation for world-level function and resource exports that use the
concurrent call style.

Signed-off-by: Joel Dice <[email protected]>

`concurrent_{imports|exports}` component macro expanded tests

This enables testing of the `concurrent_imports` and `concurrent_exports`
options in `crates/component-macro/tests/expanded.rs`.

Signed-off-by: Joel Dice <[email protected]>

add tests/misc_testsuite/component-model-async/*.wast

These only test instantiation of components which use various async options and
built-ins so far.  Next, I'll happy and sad path tests which actually execute
code.

Signed-off-by: Joel Dice <[email protected]>

appease clippy

Signed-off-by: Joel Dice <[email protected]>

add tests/misc_testsuite/component-model-async/fused.wast

Signed-off-by: Joel Dice <[email protected]>

add non-panicking bounds checks where appropriate

Signed-off-by: Joel Dice <[email protected]>

remove post-return bits from async result lift code

...at least until we've determined whether post-return options even make sense
for async-lifted exports.

Signed-off-by: Joel Dice <[email protected]>

fix component-model-async/fused.wast test failure

Signed-off-by: Joel Dice <[email protected]>

use `enum` types to represent status and event codes

Signed-off-by: Joel Dice <[email protected]>

fix component-model-async/fused.wast test failure (2nd try)

Signed-off-by: Joel Dice <[email protected]>

use `gc_types = true` in component-model-async/fused.wast

We use `Instruction::RefFunc` when generating adapters for async lifts and/or
lowers, which Winch doesn't understand, and apparently `gc_types = true` is what
tells the test infra not to use Winch.

Signed-off-by: Joel Dice <[email protected]>

trap if async function finishes without calling `task.return`

Signed-off-by: Joel Dice <[email protected]>

update wit-bindgen and fix rebase damage

Signed-off-by: Joel Dice <[email protected]>

call post-return function if any for async->sync fused calls

Signed-off-by: Joel Dice <[email protected]>

fix non-component-model-async build; appease clippy

Signed-off-by: Joel Dice <[email protected]>

bless bindgen output whitespace changes

Signed-off-by: Joel Dice <[email protected]>

enforce resource borrow requirements for async calls

Signed-off-by: Joel Dice <[email protected]>

update `wit-bindgen` and simplify `async_borrowing_callee` test

Signed-off-by: Joel Dice <[email protected]>

call `InstanceFlags::set_may_enter` where appropriate

There's still more work to do to fully implement (and test) the reentrance rules
for concurrent tasks, but this is a start.

Signed-off-by: Joel Dice <[email protected]>

finish implementing reentrance checks

Signed-off-by: Joel Dice <[email protected]>

feat: implement error-context (#1)

* feat: initial error-context implementation

This commit implements error-context related functions inside the VM,
along with tests to ensure that basic error-context.new and
error-context.debug-message functionality works.

Signed-off-by: Victor Adossi <[email protected]>

* wip: add test for error context callee/caller transfer

Signed-off-by: Victor Adossi <[email protected]>

* wip: test for async context transfer

Signed-off-by: Victor Adossi <[email protected]>

---------

Signed-off-by: Victor Adossi <[email protected]>

run cargo fmt

Signed-off-by: Joel Dice <[email protected]>

appease clippy

Signed-off-by: Joel Dice <[email protected]>

pull in Roman's unit stream work; add world-level export test

Signed-off-by: Joel Dice <[email protected]>

add unit stream tests

Signed-off-by: Joel Dice <[email protected]>

CI fixes

Signed-off-by: Joel Dice <[email protected]>

fix non-component-model-async build

Signed-off-by: Joel Dice <[email protected]>

add round-trip tests with many parameters and results

This adds tests to cover round-tripping values whose flattened form exceed
`MAX_FLAT_PARAMS`.  Although we already had tests to cover this in
tests/all/component_model/func.rs, those tests did not involve any flavor of
composition; these do.

Signed-off-by: Joel Dice <[email protected]>

test: add multiple send as initial context stream test

Signed-off-by: Victor Adossi <[email protected]>

fix Victor's test case

Turns out this was the first test case where the host calls a component via an
async-lifted export, which in turn calls another component's async-lifted export
via a sync-lowered import, which didn't work.  Now it does!

Signed-off-by: Joel Dice <[email protected]>

refactor sync->async component call adapters

We no longer use global variables to stash parameters and results due to the
hazard of concurrent calls clobbering them.  Instead, we now stash them in the
`GuestTask` object for the task.

Signed-off-by: Joel Dice <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants