Skip to content

Conversation

@alexcrichton
Copy link
Member

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 and Func::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 *_async constructors 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 pushed async further 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:

  • *_unchecked constructors now work with MaybeUninit<ValRaw> to correctly model how some values may not be initialized.
  • Some *_async functions picked up T: Send which 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.

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 and `Func::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 `*_async` constructors 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 pushed
`async` further 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:

* `*_unchecked` constructors now work with `MaybeUninit<ValRaw>` to
  correctly model how some values may not be initialized.
* Some `*_async` functions picked up `T: Send` which 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.
@alexcrichton alexcrichton requested a review from a team as a code owner January 16, 2026 23:07
@alexcrichton alexcrichton requested review from fitzgen and removed request for a team January 16, 2026 23:07
@alexcrichton alexcrichton requested a review from a team as a code owner January 17, 2026 01:00
@github-actions github-actions bot added wasmtime:api Related to the API of the `wasmtime` crate itself wasmtime:c-api Issues pertaining to the C API. labels Jan 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wasmtime:api Related to the API of the `wasmtime` crate itself wasmtime:c-api Issues pertaining to the C API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant