Skip to content

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
jakobbotsch:tail-await-interpreter
Draft

Implement AsyncHelpers.TailAwait in the interpreter and use it for instantiating and unboxing stubs on CoreCLR#124861
jakobbotsch wants to merge 4 commits intodotnet:mainfrom
jakobbotsch:tail-await-interpreter

Conversation

@jakobbotsch
Copy link
Member

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.

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @BrzVlad, @janvorli, @kg
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 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_CONTINUATION opcode
  • 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>
Copilot AI review requested due to automatic review settings February 25, 2026 16:19
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 1 comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants