Implement AsyncHelpers.TailAwait in the interpreter and use it for instantiating and unboxing stubs on CoreCLR#124861
Draft
jakobbotsch wants to merge 4 commits intodotnet:mainfrom
Draft
Implement AsyncHelpers.TailAwait in the interpreter and use it for instantiating and unboxing stubs on CoreCLR#124861jakobbotsch wants to merge 4 commits intodotnet:mainfrom
AsyncHelpers.TailAwait in the interpreter and use it for instantiating and unboxing stubs on CoreCLR#124861jakobbotsch wants to merge 4 commits intodotnet:mainfrom
Conversation
…stantiating and unboxing stubs on CoreCLR
Contributor
|
Tagging subscribers to this area: @BrzVlad, @janvorli, @kg |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements the AsyncHelpers.TailAwait intrinsic in the CoreCLR interpreter and uses it in instantiating and unboxing IL stubs for async methods, bringing CoreCLR to parity with NativeAOT's existing implementation. The TailAwait optimization eliminates the need to construct additional continuations in these stubs by directly returning the continuation from the called async method.
Changes:
- Adds interpreter support for the TailAwait intrinsic via a new
INTOP_RET_EXISTING_CONTINUATIONopcode - Updates IL stub generation (unboxing and instantiating stubs) to emit TailAwait calls before async method invocations
- Includes minor code quality improvements (parameter naming, whitespace)
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/vm/prestub.cpp | Adds TailAwait calls in unboxing and instantiating IL stub generation for async methods |
| src/coreclr/vm/interpexec.cpp | Implements the INTOP_RET_EXISTING_CONTINUATION opcode that handles tail await semantics |
| src/coreclr/vm/corelib.h | Defines the TAIL_AWAIT method reference for use in IL stub generation |
| src/coreclr/interpreter/intrinsics.cpp | Recognizes TailAwait as a named intrinsic in the interpreter |
| src/coreclr/interpreter/inc/intops.def | Defines the new INTOP_RET_EXISTING_CONTINUATION opcode |
| src/coreclr/interpreter/compiler.h | Adds m_nextAwaitIsTail flag to track when the next await should be a tail await |
| src/coreclr/interpreter/compiler.cpp | Implements TailAwait intrinsic handling and integrates it into the suspend logic; includes parameter naming fix |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
There is no need to construct additional continuations in these stubs. NativeAOT is already using this intrinsic, so implement it in the interpreter and start using it for CoreCLR too.