Skip to content

Conversation

@jtschuster
Copy link
Owner

No description provided.

Copy link

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 pull request adds support for emitting async methods in the ReadyToRun (R2R) compiler infrastructure. The changes enable async method compilation for ahead-of-time (AOT) scenarios by introducing a new continuation type layout system, async method variant handling, and related JIT interface support.

Changes:

  • Introduces ELEMENT_TYPE_CONTINUATION (0x46) for representing async continuation types in metadata
  • Adds R2R fixup kind for continuation layout encoding
  • Implements AsyncContinuationType with GCPointerMap-based identification
  • Removes restrictions on compiling async methods in ReadyToRun
  • Adds cross-module inlining support for async thunks and variants

Reviewed changes

Copilot reviewed 36 out of 37 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/tests/profiler/native/rejitprofiler/sigparse.h Adds ELEMENT_TYPE_CONTINUATION constant definition with alignment fixes
src/tests/async/awaitingnotasync/awaitingnotasync.cs Comments out all test assertions (work in progress)
src/libraries/System.Private.CoreLib/src/System/Reflection/CorElementType.cs Adds ELEMENT_TYPE_CONTINUATION enum value
src/coreclr/vm/readytoruninfo.cpp Removes async variant restrictions from R2R entry point lookup
src/coreclr/vm/jitinterface.cpp Adds GetContinuationTypeFromLayout for parsing continuation type signatures
src/coreclr/tools/aot/aot.slnx Adds new solution file for AOT tooling
src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ReadyToRunSignature.cs Adds ContinuationLayout fixup parsing and display
src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs Implements continuation type handling, fixes context type parameters
src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj Removes ILStubReferences.cs, adds AsyncMethodVariant.Mangling.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/Stubs/ILStubReferences.cs Deleted file (no longer needed)
src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/ReadyToRunILProvider.cs Adds async thunk IL generation and wrapping
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunTableManager.cs Updates method categorization for async variants
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilerContext.cs Initializes continuation type hashtable, adds layout algorithm
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilationModuleGroupBase.cs Code formatting/whitespace fixes
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs Adds async reference handling and mutable IL body support
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunSymbolNodeFactory.cs Adds continuation type fixup symbol creation
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunCodegenNodeFactory.cs Filters AsyncResumptionStub from enumeration
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeFixupSignature.cs Implements ContinuationLayout encoding
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/SignatureBuilder.cs Adds AsyncContinuationType check in type signature emission
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/ModuleTokenResolver.cs Adds GetModuleTokenForField method
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/MethodFixupSignature.cs Adds comment about async variant handling
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/InstanceEntryPointTableNode.cs Updates method signature building for async variants
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/InliningInfoNode.cs Filters async thunks from inlining info
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/ExceptionInfoLookupTableNode.cs Excludes AsyncResumptionStub from EH layout
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/CompilerTypeSystemContext.ReadyToRun.cs New file: implements R2R-specific continuation type hashtable
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/JitHelper.cs Adds helper entry points for continuation allocation
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.Aot.cs Adds AOT continuation type hashtable
src/coreclr/tools/Common/TypeSystem/IL/Stubs/AsyncThunks.cs Adds ILCompiler namespace import
src/coreclr/tools/Common/TypeSystem/IL/Stubs/AsyncResumptionStub.cs Moves TargetMethod property declaration
src/coreclr/tools/Common/TypeSystem/IL/InstantiatedMethodIL.cs Removes assertion that breaks with async variants
src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs Implements getContinuationType and getAsyncResumptionStub for R2R
src/coreclr/tools/Common/Internal/Runtime/ReadyToRunConstants.cs Adds ContinuationLayout fixup kind and helper constants
src/coreclr/tools/Common/Compiler/CompilerTypeSystemContext.Async.cs Moves continuation type hashtable to platform-specific files
src/coreclr/tools/Common/Compiler/AsyncMethodVariant.cs Updates IsAsyncThunk to include AsyncResumptionStub
src/coreclr/tools/Common/Compiler/AsyncContinuationType.cs Adds OwningMethod for R2R, implements layout algorithm
src/coreclr/tools/.editorconfig Minor whitespace fix
src/coreclr/inc/readytorun.h Adds READYTORUN_FIXUP_Continuation_Layout constant

var method = _compilation.NodeFactory.TypeSystemContext.GetCoreLibEntryPoint("System.Runtime.CompilerServices"u8, "AsyncHelpers"u8, "AllocContinuation"u8, null);
var methodWithToken = new MethodWithToken(method, _compilation.CompilationModuleGroup.Resolver.GetModuleTokenForMethod(method, true, true), null, false, null);
return _compilation.NodeFactory.MethodEntrypoint(methodWithToken, false, false, false);

Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

Inconsistent handling for CORINFO_HELP_ALLOC_CONTINUATION_METHOD and CORINFO_HELP_ALLOC_CONTINUATION_CLASS. The CORINFO_HELP_ALLOC_CONTINUATION case returns early with a method entrypoint, but the _METHOD and _CLASS variants fall through to throw RequiresRuntimeJitException. This appears to be incomplete implementation - either these cases should have their own implementation or they should be explicitly documented as unimplemented.

Suggested change
// The *_METHOD and *_CLASS variants of continuation allocation are not implemented
// for ReadyToRun. They are expected to fall through to the RequiresRuntimeJitException
// thrown at the end of this switch.

Copilot uses AI. Check for mistakes.
jtschuster and others added 4 commits January 16, 2026 12:10
…nCodegenCompilation.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants