Skip to content

Avoid resolving direct awaits to thunks#124283

Merged
jakobbotsch merged 6 commits intodotnet:mainfrom
jakobbotsch:skip-thunks
Feb 13, 2026
Merged

Avoid resolving direct awaits to thunks#124283
jakobbotsch merged 6 commits intodotnet:mainfrom
jakobbotsch:skip-thunks

Conversation

@jakobbotsch
Copy link
Member

This just results in extra jitting and the thunks are harder for the JIT to see through and optimize.

Contributes to #115771

This just results in extra jitting and the thunks are harder for the JIT
to see through and optimize.
Copilot AI review requested due to automatic review settings February 11, 2026 16:30
@github-actions github-actions bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Feb 11, 2026
@jakobbotsch
Copy link
Member Author

FYI @VSadov

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 distinguish callvirt awaits 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).

Copilot AI review requested due to automatic review settings February 11, 2026 17:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Copilot AI review requested due to automatic review settings February 12, 2026 14:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

@jakobbotsch jakobbotsch marked this pull request as ready for review February 12, 2026 18:20
@jakobbotsch jakobbotsch requested a review from VSadov February 12, 2026 18:20
Copy link
Member

@VSadov VSadov left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

Copy link
Member

@janvorli janvorli left a comment

Choose a reason for hiding this comment

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

LGTM with a minor nit.

@jakobbotsch jakobbotsch merged commit ab6bfad into dotnet:main Feb 13, 2026
124 of 126 checks passed
@jakobbotsch jakobbotsch deleted the skip-thunks branch February 13, 2026 16:57
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants