Stream: git-wasmtime

Topic: wasmtime / PR #11238 Start to use `&Accessor<T, D>` more ...


view this post on Zulip Wasmtime GitHub notifications bot (Jul 14 2025 at 20:10):

alexcrichton opened PR #11238 from alexcrichton:accessor-apis to bytecodealliance:main:

After discussion with Joel we've concluded that while &mut Accessor<T, D> was originally added to model host functions it is also appropriate to use it to model embedder-rooted invocations of items such as wasm as well. Effectively the conclusion we reached was that *::call_concurrent should be taking &Accessor, not StoreContextMut. This has a number of benefits to it over the previous iteration:

In doing this one of the main questions we were faced with was what to do about &mut Accessor<T, D>, namely the mut part. With a mutable accessor it would be only possible to call one function concurrently. One option considered was to add combinators like Accessor::join and Accessor::race but in the end we decided to avoid going that direction and instead switch to &Accessor<T, D> everywhere, freely enabling aliasing of the accessor. This has the downside that Accessor::with is now a relatively dangerous function in that it can panic, but idiomatic usage of it is not expected to panic as the distinction between the async and sync boundary of Accessor vs StoreContextMut is expected to naturally make the recursive panic condition of with rare to come up in practice.

Concrete changes in this commit are:

Note that this commit does not yet update the internal implementations of these functions to benefit from the new abilities that taking &Accessor implies. Instead that's deferred to a future update as necessary. Instead this is only updating the public API of the wasmtime crate to enable these refactorings in the future.

Also note that this does not yet update all functions to take &Accessor. Notably futures and streams still need to be updated.

cc #11224

<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Jul 14 2025 at 20:10):

alexcrichton requested dicej for a review on PR #11238.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 14 2025 at 20:10):

alexcrichton requested wasmtime-core-reviewers for a review on PR #11238.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 14 2025 at 20:11):

alexcrichton commented on PR #11238:

One other update: Instance::run_with is updated to now take AyncFnOnce instead of FnOnce() -> Box<...>

view this post on Zulip Wasmtime GitHub notifications bot (Jul 15 2025 at 14:51):

dicej created PR review comment:

Could collapse the if expression here into ("async", "_async", ".await", self.generator.opts.concurrent_exports)

view this post on Zulip Wasmtime GitHub notifications bot (Jul 15 2025 at 14:51):

dicej submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 15 2025 at 15:00):

alexcrichton updated PR #11238.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 15 2025 at 15:00):

alexcrichton has enabled auto merge for PR #11238.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 15 2025 at 15:38):

alexcrichton merged PR #11238.


Last updated: Dec 06 2025 at 06:05 UTC