Skip to content

Conversation

@alexcrichton
Copy link
Member

This is a follow-up to #11932 where the TrampolineCompiler type is further specialized to just working with the wasm ABI instead of trying to multiplex two ABIs now that the array ABI is handled by calling the wasm ABI. This involved purging the self.abi field and updating all callers as appropriate.

This then performed some small refactoring to use TrampolineCompiler for compiler intrinsics. Unsafe intrinsics also now have the same strategy of calling the wasm ABI trampoline when compiling for the array ABI. This should ensure that all entry trampolines are going through the same function.

This is a follow-up to bytecodealliance#11932 where the `TrampolineCompiler` type is
further specialized to just working with the wasm ABI instead of trying
to multiplex two ABIs now that the array ABI is handled by calling the
wasm ABI. This involved purging the `self.abi` field and updating all
callers as appropriate.

This then performed some small refactoring to use `TrampolineCompiler`
for compiler intrinsics. Unsafe intrinsics also now have the same
strategy of calling the wasm ABI trampoline when compiling for the array
ABI. This should ensure that all entry trampolines are going through the
same function.
@alexcrichton alexcrichton requested review from a team as code owners October 24, 2025 22:36
@alexcrichton alexcrichton requested review from cfallin and dicej and removed request for a team October 24, 2025 22:36
Comment on lines 885 to 898
// Skip inlining into array-abi functions which are entry
// trampolines into wasm. ABI-wise it's required that these have a
// single `try_call` into the module and it doesn't work if multiple
// get inlined or if the `try_call` goes away. Pevent all inlining
// to guarantee the structure of entry trampolines.
(
FuncKey::ArrayToWasmTrampoline(..)
| FuncKey::ComponentTrampoline(Abi::Array, _)
| FuncKey::UnsafeIntrinsic(Abi::Array, _),
_,
) => {
log::trace!(" --> not inlining: not inlining into array-abi caller");
return false;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @fitzgen on this. One reason is that cranelift inlining doesn't support get_exception_handler_address but even if it did we couldn't properly inline in entry trampolines because we wouldn't have the right handler recorded at all call points. To handle that I disabled inlining into these callers no matter what.

My thinking is that these aren't perf-sensitive and if they are we need to figure something else out other than inlining.

@github-actions github-actions bot added wasmtime:api Related to the API of the `wasmtime` crate itself winch Winch issues or pull requests labels Oct 25, 2025
@github-actions
Copy link

Subscribe to Label Action

cc @saulecabrera

This issue or pull request has been labeled: "wasmtime:api", "winch"

Thus the following users have been cc'd because of the following labels:

  • saulecabrera: winch

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

Copy link
Contributor

@dicej dicej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, and should make adding new trampolines easier to do correctly. Thanks for doing this!

Co-authored-by: Joel Dice <joel.dice@fermyon.com>
@alexcrichton alexcrichton added this pull request to the merge queue Oct 30, 2025
Merged via the queue into bytecodealliance:main with commit 093b520 Oct 30, 2025
45 checks passed
@alexcrichton alexcrichton deleted the more-trampoline-compiler-refactors branch October 30, 2025 23:19
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 winch Winch issues or pull requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants