JIT: Add an AsyncHelpers.TailAwait intrinsic#124175
Closed
jakobbotsch wants to merge 4 commits intodotnet:mainfrom
Closed
JIT: Add an AsyncHelpers.TailAwait intrinsic#124175jakobbotsch wants to merge 4 commits intodotnet:mainfrom
jakobbotsch wants to merge 4 commits intodotnet:mainfrom
Conversation
Can be used to instruct the JIT that an upcoming await should not create an explicit suspension point. This can be used to optimize instantiating/unboxing stubs and will simplify the NAOT side of the implementation of those.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new AsyncHelpers.TailAwait intrinsic to let the runtime/JIT treat certain awaits as “tail awaits”, avoiding creation of an additional suspension point/continuation in forwarding stubs (notably instantiating/unboxing stubs), and updates the runtime async codegen documentation accordingly.
Changes:
- Emit
AsyncHelpers.TailAwait()from instantiating/unboxing IL stubs when the target method is async. - Add JIT recognition of
AsyncHelpers.TailAwait(named intrinsic + importer handling) and plumb a “tail await” flag into async call metadata. - Extend async transformation to rewrite tail awaits to directly return the callee’s continuation (no new continuation allocation), plus small comment/doc updates.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/vm/prestub.cpp | Emits TailAwait before async calli in generated instantiating/unboxing IL stubs. |
| src/coreclr/vm/corelib.h | Adds CoreLib binder entry for AsyncHelpers.TailAwait. |
| src/coreclr/vm/asyncthunks.cpp | Updates comment to refer to AsyncHelpers.AsyncCallContinuation. |
| src/coreclr/jit/namedintrinsiclist.h | Adds named intrinsic enum value for AsyncHelpers.TailAwait. |
| src/coreclr/jit/importercalls.cpp | Maps and imports TailAwait, setting a “next await is tail” flag that’s consumed by async-call setup. |
| src/coreclr/jit/gentree.h | Adds IsTailAwait to AsyncCallInfo. |
| src/coreclr/jit/compiler.h | Adds m_nextAwaitIsTail importer state. |
| src/coreclr/jit/async.h | Adds tail-await transformation helpers and adjusts liveness plumbing signatures. |
| src/coreclr/jit/async.cpp | Implements tail-await transformation and refactors continuation temp allocation to be lazy. |
| src/coreclr/System.Private.CoreLib/.../AsyncHelpers.CoreCLR.cs | Adds intrinsic stub for TailAwait. |
| docs/design/coreclr/botr/runtime-async-codegen.md | Updates documentation to reference AsyncHelpers.AsyncCallContinuation. |
6f12379 to
5e8f24f
Compare
Member
Author
|
Folded into #122126 |
MichalStrehovsky
added a commit
that referenced
this pull request
Feb 12, 2026
We need to: * Compile the unboxing/instantiating thunk as `CORJIT_FLAG_ASYNC` when the target is AsyncCall * Use the TailAwait intrinsic to just return the suspended state from the called method instead of trying to suspend the instantiating thunk too. Also includes a JIT change from #124175. Fixes #121781.
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.
Can be used to instruct the JIT that an upcoming await should not create an explicit suspension point. This can be used to optimize instantiating/unboxing stubs and will simplify the NAOT side of the implementation of those (#122126).