Skip to content

Long-lived AsyncMethodVariant in MethodWithGCInfo/MethodWithToken - #121357

Merged
MichalStrehovsky merged 18 commits into
dotnet:mainfrom
jtschuster:LongAsyncMethodVariant
Nov 5, 2025
Merged

Long-lived AsyncMethodVariant in MethodWithGCInfo/MethodWithToken#121357
MichalStrehovsky merged 18 commits into
dotnet:mainfrom
jtschuster:LongAsyncMethodVariant

Conversation

@jtschuster

Copy link
Copy Markdown
Member

Incorporates feedback from #121218, creating a long-lived async MethodDesc. There will be more warts that need to be worked out once we actually compile these, in particular lots of (EcmaMethod)methodDesc.GetMethodDefinition(), which doesn't work with AsyncMethodVariant.

CopilotAI review requested due to automatic review settings November 4, 2025 22:45

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request adds support for async method variants in the ReadyToRun compiler. The changes introduce a new AsyncMethodVariant type system abstraction that represents special calling convention variants for async methods.

Key Changes:

  • Added new AsyncMethodVariant infrastructure to represent async method implementations and thunks with special calling conventions
  • Extended the type system with async-related properties (IsAsync, AsyncMethodKind) across multiple method descriptor types
  • Updated ReadyToRun signatures and metadata to track async variant methods
  • Modified code generation to create async variants for Task-returning methods

Reviewed Changes

Copilot reviewed 27 out of 28 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
ILCompiler.TypeSystem.csprojAdded new async-related partial class files to the build
ILCompiler.ReadyToRun.csprojRemoved obsolete async method descriptor files
CorInfoImpl.ReadyToRun.csAdded asyncVariant parameter handling and async method factory
ReadyToRunILProvider.csAdded early return for async methods that aren't yet implemented
ReadyToRunTableManager.csAdded IsAsyncThunk condition for generic methods tracking
ReadyToRunCodegenNodeFactory.csFixed whitespace formatting
SignatureBuilder.csAdded async thunk variant flag to method signatures
MethodWithGCInfo.csAdded debug assertion and AsyncVariant property
MethodFixupSignature.csAdded task-returning check to optimization condition
InstanceEntryPointTableNode.csAdded asyncVariant parameter to signature building
AllMethodsOnTypeNode.csAdded automatic async variant dependencies for Task-returning methods
ReadyToRunObjectWriter.csRemoved unused using statement
MethodForRuntimeDeterminedType.csAdded IsAsync and AsyncMethodKind property forwarding
EcmaMethod.csReorganized flags and added formatting pragma
EcmaMethod.Async.csNew file implementing async method kind logic
TypeSystemContext.csChanged return type to be more specific
TypeSystemContext.Async.csNew file adding GetAsyncVariant factory method
MethodForInstantiatedType.csRefactored signature initialization
MethodForInstantiatedType.Async.csNew file forwarding AsyncMethodKind from typical method
MethodDesc.csRenamed AsyncCallConv flag for consistency
MethodDesc.Async.csNew file with core async method infrastructure
MethodDelegator.Async.csNew file making AsyncMethodKind abstract
InstantiatedMethod.Async.csNew file forwarding AsyncMethodKind from method definition
AsyncMethodVariant.csNew file implementing the async variant wrapper type
UnboxingMethodDesc.csAdded AsyncMethodKind property forwarding
CorInfoTypes.csAdded CORINFO_CALLCONV_ASYNCCALL constant
CorInfoImpl.csAdded async calling convention handling
ReadyToRunConstants.csChanged flags enum to ushort and added async thunk flag

Comment threadsrc/coreclr/tools/aot/ILCompiler.TypeSystem/ILCompiler.TypeSystem.csproj Outdated

@MichalStrehovskyMichalStrehovsky left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks good to me otherwise. We could merge with this feedback addressed.

Comment threadsrc/coreclr/tools/Common/Compiler/AsyncMethodVariant.cs
Comment threadsrc/coreclr/tools/Common/TypeSystem/Common/AsyncMethodVariant.cs Outdated
Comment threadsrc/coreclr/tools/Common/Compiler/AsyncMethodVariant.cs
Comment threadsrc/coreclr/tools/Common/TypeSystem/Common/MethodDesc.Async.cs Outdated
Comment threadsrc/coreclr/tools/aot/ILCompiler.TypeSystem/ILCompiler.TypeSystem.csproj Outdated
Comment threadsrc/coreclr/tools/Common/Internal/Runtime/ReadyToRunConstants.cs Outdated
Comment threadsrc/coreclr/tools/Common/TypeSystem/Common/AsyncMethodVariant.cs Outdated
Comment threadsrc/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs Outdated
Comment threadsrc/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs
Comment threadsrc/coreclr/tools/Common/Compiler/AsyncMethodVariant.cs Outdated
Comment threadsrc/coreclr/tools/Common/JitInterface/CorInfoTypes.cs Outdated
Comment threadsrc/coreclr/tools/Common/JitInterface/CorInfoTypes.cs Outdated
@MichalStrehovsky

Copy link
Copy Markdown
Member

/ba-g android timeouts

@MichalStrehovsky
MichalStrehovsky merged commit 0769ce2 into dotnet:mainNov 5, 2025
96 of 98 checks passed
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Dec 5, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@jtschuster@MichalStrehovsky@jkotas