alexcrichton opened PR #13300 from alexcrichton:directly-inline-unsafe-intrinsics to bytecodealliance:main:
This commit is a partway resolution to #13254 borne out of discussion at today's Cranelift meeting. Inlining calls to
context.{get,set}in WASIp3 by default via the standard inlining phase of Wasmtime will require taking a ~15% compile-time performance hit. This is due to the architecture of inlining currently with a "join point" where all functions are translated, then inlining happens, then functions are optimized/codegen'd. This join point results in a large loss in parallelism where otherwise when inlining is disabled functions are all compiled in parallel. The commit here is a solution to this problem for WASIp3 andUnsafeIntrinsics in general without rearchitecting all of inlining.Specifically the translation of
UnsafeIntrinsiccodegen is refactored into a small, standalone, context structure to translate a single intrinsic. This is possible to create during normal intrinsic compilation in addition to during normal module compilation. When settings are appropriate the intrinsic is translated directly without acallinstruction which avoids the need for the general inlining pass to be activated.This scheme is intended to be a temporary stopgap while inlining continues to be disabled by default in Wasmtime. Once inlining is enabled by default in Wasmtime, either because it no longer has a performance hit or the hit is deemed acceptable, then this can all be removed.
<!--
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 uweigand for a review on PR #13300.
alexcrichton requested wasmtime-compiler-reviewers for a review on PR #13300.
alexcrichton requested cfallin for a review on PR #13300.
alexcrichton requested wasmtime-core-reviewers for a review on PR #13300.
alexcrichton updated PR #13300.
alexcrichton unassigned uweigand from PR #13300 Inline UnsafeIntrinsic calls during translation.
:thumbs_up: cfallin submitted PR review:
:+1:
:speech_balloon: cfallin created PR review comment:
This will do a good amount of computation and will alloc a Vec -- perhaps we could test
self.env.tunables.debug_guestinstead?
alexcrichton updated PR #13300.
alexcrichton has enabled auto merge for PR #13300.
alexcrichton added PR #13300 Inline UnsafeIntrinsic calls during translation to the merge queue.
:check: alexcrichton merged PR #13300.
alexcrichton removed PR #13300 Inline UnsafeIntrinsic calls during translation from the merge queue.
Last updated: Jun 01 2026 at 09:49 UTC