Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: dev, v36.0.9, v44.0.1, v43.0.2, v36.0.8, v24.0.8, v44.0.0, v43.0.1, v42.0.2, v36.0.7, v24.0.7, v43.0.0, v42.0.1, v41.0.4, v42.0.0, v40.0.4, v36.0.6, v24.0.6, v41.0.3, v41.0.2, v41.0.1, v36.0.5, v40.0.3, v41.0.0, v36.0.4, v39.0.2, v40.0.2, v40.0.1, v40.0.0, v39.0.1, v39.0.0, v38.0.4, v37.0.3, v36.0.3, v24.0.5, v38.0.3, v38.0.2, v38.0.1, v37.0.2, v37.0.1, v37.0.0, v36.0.2, v36.0.1, v36.0.0
# e8189549 12-Aug-2025 Joel Dice <[email protected]>

use a single table per instance for resources, waitables, etc. (#11374)

* use a single table per instance for resources, waitables, etc.

Per https://github.com/WebAssembly/component-model/pull/513,

use a single table per instance for resources, waitables, etc. (#11374)

* use a single table per instance for resources, waitables, etc.

Per https://github.com/WebAssembly/component-model/pull/513, the spec now puts
resources, waitables, waitable sets, subtasks, and error contexts in the same
table per instance. This updates the implementation to match.

- Combine the `ResourceTable` and `StateTable` data structures into a single `HandleTable` structure

- Rename `ComponentInstance::instance_resource_tables` to `instance_handle_tables`

- Remove `ConcurrentState::waitable_tables` and `error_context_tables` in favor of the above

- Move various associated functions from `ConcurrentState` to `ComponentInstance` so they can access `instance_resource_tables`

While I was doing table-related things, I also updated `concurrent::Table::new`
to reserve the zero handle to mean "invalid". This won't affect what the guest
sees in any way, but it allows us to use `TableId::new(0)` to invalidate
host-owned handles in e.g. `{Stream,Future}{Reader,Writer}::close`.

Fixes #11189

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

Re-internalize `ResourceKind` to `mod handle_table`

Remove `ResourceKind`

Start flattening the representation of `Slot`

Internalize `get_mut_handle_by_index`

Internalize implementation details such as the representation of slots
to and make methods a bit more targeted in their functionality.

Internalize more details of `HandleTable`

Don't expose `HandleKind` and of per-function methods for operating on
the various kinds of handles that reside in the table.

Flatten the representation of `Slot`

There's still some more work to do for host/guest resource handles, but
this helps realize the goal of the previous refactorings in the
meantime.

* stop using `HandleTable::reps_to_indexes` when delivering events

Per review feedback, we'd like to get rid of `HandleTable::reps_to_indexes`
entirely. This commit doesn't go quite that far, but now we only use it for
`error-context` handles. For waitables, which can only be referenced by at most
one guest at a time, we now store the guest handle in `WaitableCommon::handle`
and retrieve it from there when delivering an event for that waitable.

For `error-context` handles, the spec requirement that we always lower the same
handle for the same `error-context`, combined with the fact that an
`error-context` may be referenced by more than one component instance at a time,
means we still need some general way to convert a host rep plus component index
into a handle. Going forward, we could consider either removing that "same
handle" requirement from the spec or consider an alternative implementation
(e.g. storing a `HashMap<RuntimeComponentIndex, usize>` in the `ErrorContext`
host state for keeping track of the handles for each referencing instance.

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

* remove `HandleTable::reps_to_indexes`

Turns out the spec no longer requires that guests receive the same handle for a
given `error-context` as the one they already have, so we no longer need this
field -- nor do we need to maintain a per-component-instance reference count.

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

---------

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

show more ...


Revision tags: v35.0.0, v24.0.4, v33.0.2, v34.0.2
# fa70f025 11-Jul-2025 Joel Dice <[email protected]>

implement Component Model async ABI (#11127)

* implement Component Model async ABI

This commit replaces the stub functions and types in
`wasmtime::runtime::component::concurrent` and its submodules

implement Component Model async ABI (#11127)

* implement Component Model async ABI

This commit replaces the stub functions and types in
`wasmtime::runtime::component::concurrent` and its submodules with the working
implementation developed in the `wasip3-prototyping` repo. For ease of review,
it does not include any new tests; I'll add those in a follow-up commit.

Note that this builds on #11123; only the most recent commit is new.

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

* clear params pointer in `call_async` when future is dropped

This ensures that the closure we pass to `prepare_call` will never see a stale
pointer.

Note that this could potentially be made more efficient; I'm starting with a
simple solution, and we can refine from there.

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

* Remove unsafety from accessing concurrent async state

* Remove a dead variant when async is disabled

* Add tests for `tls.rs` unsafe code

* Refactor `AbortHandle`

* Don't close over the entire future in the `AbortHandle`, instead
change it to just the bare minimum state to manage aborts.
* Move aborting logic into a helper `AbortHandle::run` function which
handles the is-this-aborted-check internally.
* Refactor some logic around spawns how `AbortHandle` is
managed/created.

* Internalize some functions/types

* add FIXME comment to `states.rs`

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

* reference issue 11190 in `table.rs` TODO

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

* switch `use` directives to conventional syntax

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

* remove redundant accessor methods

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

* reference issue 11191 in `yield` TODO comments

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

* replace `dummy_waker` with `Waker::noop`

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

* remove obsolete `AsyncState::spawned_tasks` field

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

* only call post-return automatically for `call_concurrent`

This restores the original behavior of requiring explicit post-return calls for
`call[_async]` invocations.

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

* Favor function arguments before closures

* Simplify `watch` a bit

Mostly move unnecessary state out of the `Arc`.

* fix task handle leaks and add test coverage

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]>

* Encapsulate type erasure in stream buffers

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.

* Remove some methods ending in underscores

* Refactor unsafety in `buffers.rs`

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.

* remove task on drop in `TypedFunc::call_async`

This avoids the need for an `Arc`.

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

* remove obsolete clause from `FutureReader::read` docs

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

* unhide and expand docs for `WriteBuffer` and `ReadBuffer`

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

* add optional `component-model-async-bytes` feature

This gates interop with the `bytes` crate, making it optional and non-default.

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

---------

Signed-off-by: Joel Dice <[email protected]>
Co-authored-by: Alex Crichton <[email protected]>

show more ...