alexcrichton opened PR #12366 from alexcrichton:more-func-refactor to bytecodealliance:main:
This commit refactors the internals of how guest functions call out to the host. Previously Wasmtime had a split where
Func::new-style constructors used one entrypoint andFunc::wrap-style entrypoints used a different entrypoint. This was required long ago when we had an array and native ABI calling convention, but nowadays this is no longer required. This refactors things to have a single base-level signature which is the narrow waist through which all other function entrypoints go through. This enables having a single function handle all the things like panicking, call hooks, etc, and everything further builds on top of it.This commit additionally pushes the async-ness of a function down even further. Previously many
*_asyncconstructors would quickly delegate to their non-async counterpart, but this is expected to more-or-less become not the right way to do things as wasmtime moves into the future. Historical refactorings related to GC, for example, have pushedasyncfurther down within Wasmtime and this continues that trend. There's no immediate benefit just yet, but this is hoped to make future refactorings easier.Along the way some minor API changes happened too:
*_uncheckedconstructors now work withMaybeUninit<ValRaw>to correctly model how some values may not be initialized.- Some
*_asyncfunctions picked upT: Sendwhich should have in theory been required before and are now compiler-required.- Longstanding/old internal functions have been shuffled around/refactored.
Finally, another eventual goal of this work is to share more between core wasm and components in terms of implementation. Right now the component host function entrypoints are quite different than the core wasm ones and that ideally wouldn't endure forever.
<!--
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 fitzgen for a review on PR #12366.
alexcrichton requested wasmtime-core-reviewers for a review on PR #12366.
alexcrichton updated PR #12366.
alexcrichton updated PR #12366.
alexcrichton requested wasmtime-default-reviewers for a review on PR #12366.
github-actions[bot] added the label wasmtime:api on PR #12366.
github-actions[bot] added the label wasmtime:c-api on PR #12366.
fitzgen created PR review comment:
A while back we found that our
pub fn new(impl AsContextMut)/pub(crate) fn _new(&mut StoreOpaque)pair conventions were hiding when the latter constructor was dead code due to its underscore prefix.Do we want to avoid the underscore prefix here as well?
fitzgen submitted PR review:
Looks great, thanks for this clean up!
fitzgen created PR review comment:
ensure!?
fitzgen created PR review comment:
Nitpick: newlines between methods in the impl block.
alexcrichton updated PR #12366.
alexcrichton has enabled auto merge for PR #12366.
alexcrichton added PR #12366 Refactor core wasm host entrypoints to the merge queue.
alexcrichton merged PR #12366.
alexcrichton removed PR #12366 Refactor core wasm host entrypoints from the merge queue.
Last updated: Jan 29 2026 at 13:25 UTC