alexcrichton opened PR #11468 from alexcrichton:more-gc-async to bytecodealliance:main:
This commit is extracted from #11430 to accurately reflect how const-expr evaluation is an async operation due to GC pauses that may happen. The changes in this commit are:
- Const-expr evaluation is, at its core, now an
asyncfunction.- To leverage this new
async-ness all internal operations are switched from*_maybe_asyncto*_asyncmeaning all the*_maybe_asyncmethods can be removed.- Some libcalls using
*_maybe_asyncare switch to using*_asyncplus theblock_on!utility to help jettison more*_maybe_asyncmethods.- Instance initialization is now an
asyncfunction. This is temporarily handled withblock_onduring instance initialization to avoid propagating theasync-ness further upwards. Thisblock_onwill get deleted in future refactorings.- Const-expr evaluation has been refactored slightly to enable having a fast path in global initialization which skips an
awaitpoint entirely, achieving performance-parity in benchmarks prior to this commit.This ended up fixing a niche issue with GC where if a wasm execution was suspended during
table.init, for example, during a const-expr evaluation triggering a GC then if the wasm execution was cancelled it would panic the host. This panic was because the GC operation returnedResultbut it wasunwrap'd as part of the const-expr evaluation which can fail not only to invalid-ness but also due to "computation is cancelled" traps.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
alexcrichton requested pchickey for a review on PR #11468.
alexcrichton requested wasmtime-core-reviewers for a review on PR #11468.
alexcrichton commented on PR #11468:
Actually, thinking more, the issue about panicking on const expr evaluation failure means allocation failure in GC is a host panic which isn't great. Deferring that to a separate issue.
alexcrichton updated PR #11468.
github-actions[bot] commented on PR #11468:
Subscribe to Label Action
cc @fitzgen
<details>
This issue or pull request has been labeled: "wasmtime:api", "wasmtime:ref-types"Thus the following users have been cc'd because of the following labels:
- fitzgen: wasmtime:ref-types
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
alexcrichton updated PR #11468.
pchickey requested fitzgen for a review on PR #11468.
fitzgen submitted PR review:
:+1:
fitzgen created PR review comment:
Are there any non-async
retry_after_gccalls at this point? I think all of them should be async by the time we finish the asyncification of the internals, but I'm not sure if we are there yet or not. But when we are, we should delete the non-async version and then just rename the async variation to plainretry_after_gc.
fitzgen created PR review comment:
And then
Instance::new_rawwill become anasyncfunction in another follow up PR?
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Soon! (got a PR queued up after #11470 to delete the sync version
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Indeed! That'll be #11470
alexcrichton merged PR #11468.
Last updated: Dec 06 2025 at 07:03 UTC