Avoid resolving direct awaits to thunks#124283
Merged
jakobbotsch merged 6 commits intodotnet:mainfrom Feb 13, 2026
Merged
Conversation
This just results in extra jitting and the thunks are harder for the JIT to see through and optimize.
Member
Author
|
FYI @VSadov |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refines the runtime-async “await pattern” token resolution so direct awaits don’t get rewritten to async-variant thunks, reducing unnecessary JITting and improving optimizer visibility (contributing to #115771).
Changes:
- Introduces a new token kind (
CORINFO_TOKENKIND_AwaitVirtual) to distinguishcallvirtawaits from direct-call awaits. - Updates CoreCLR token resolution to avoid resolving effectively-direct awaits to async-variant thunks.
- Updates NativeAOT JitInterface logic to account for the new token kind and devirtualization heuristics.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/vm/jitinterface.cpp | Extends await token resolution to handle virtual awaits and avoid resolving direct awaits to thunk async variants. |
| src/coreclr/jit/importer.cpp | Passes AwaitVirtual for callvirt await patterns instead of always using Await. |
| src/coreclr/inc/corinfo.h | Adds the CORINFO_TOKENKIND_AwaitVirtual enum value. |
| src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs | Mirrors the new token kind in the managed CorInfo enum. |
| src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs | Adds managed-side “effectively direct” logic for await token handling in NativeAOT tooling. |
| src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs | Refactors devirtualization checks to use a shared “effectively direct” helper (but currently has a correctness issue). |
src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs
Show resolved
Hide resolved
VSadov
reviewed
Feb 11, 2026
This was referenced Feb 12, 2026
janvorli
approved these changes
Feb 13, 2026
richlander
pushed a commit
to richlander/runtime
that referenced
this pull request
Feb 14, 2026
This just results in extra jitting and the thunks are harder for the JIT to see through and optimize. Contributes to dotnet#115771
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This just results in extra jitting and the thunks are harder for the JIT to see through and optimize.
Contributes to #115771