-
Notifications
You must be signed in to change notification settings - Fork 0
Emit async methods #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: EmitTaskReturningThunks
Are you sure you want to change the base?
Conversation
…necessary methods
…c thunks to be inlined.
…er/runtime into EmitAsyncMethods
There was a problem hiding this 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 |
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/JitHelper.cs
Outdated
Show resolved
Hide resolved
src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs
Outdated
Show resolved
Hide resolved
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/CompilerTypeSystemContext.ReadyToRun.cs
Outdated
Show resolved
Hide resolved
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/CompilerTypeSystemContext.ReadyToRun.cs
Outdated
Show resolved
Hide resolved
| 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); | ||
|
|
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
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.
| // 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. |
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs
Outdated
Show resolved
Hide resolved
…nCodegenCompilation.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.