Skip to content

Conversation

@jtschuster
Copy link
Member

Add R2R helpers for AllocContinuation, AllocContinuationMethod, and AllocContinuationClass.

Implements change #3 from async methods R2R breakdown.

Adds helpers 0x113-0x115 for allocating continuation objects.
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 adds Ready-to-Run (R2R) helpers for three new continuation allocation helpers: AllocContinuation, AllocContinuationMethod, and AllocContinuationClass. These helpers are part of the infrastructure for async method support in R2R compiled code.

Changes:

  • Added three new R2R helper enum values (0x113-0x115) across C++ and C# codebases
  • Added JIT helper mappings to mark these as allocators and heap mutators
  • Added entry point resolution to System.Runtime.CompilerServices.AsyncHelpers class
  • Minor trailing whitespace cleanup in CorInfoImpl.ReadyToRun.cs

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/inc/readytorun.h Added C++ enum values for the three new R2R helpers
src/coreclr/inc/readytorunhelpers.h Added helper macro mappings from R2R helpers to CORINFO helpers
src/coreclr/jit/utils.cpp Configured new helpers as allocators that mutate heap
src/coreclr/tools/Common/Internal/Runtime/ReadyToRunConstants.cs Added C# enum values for the three new R2R helpers
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/JitHelper.cs Added entry point resolution to AsyncHelpers methods
src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs Added JIT interface mappings and whitespace cleanup
src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ReadyToRunSignature.cs Added signature parsing for the new helpers

Comment on lines +356 to +357
AllocContinuationMethod = 0x114,
AllocContinuationClass = 0x115,
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The ordering of AllocContinuationMethod and AllocContinuationClass is inconsistent between ReadyToRunConstants.cs and readytorun.h. In ReadyToRunConstants.cs, AllocContinuationMethod has value 0x114 and AllocContinuationClass has value 0x115, but in readytorun.h (lines 470-471), these values are swapped. The enum values must match exactly across both files to ensure correct helper resolution.

Suggested change
AllocContinuationMethod = 0x114,
AllocContinuationClass = 0x115,
AllocContinuationMethod = 0x115,
AllocContinuationClass = 0x114,

Copilot uses AI. Check for mistakes.
Comment on lines 341 to 346
case ReadyToRunHelper.AllocContinuationMethod:
methodDesc = context.GetCoreLibEntryPoint("System.Runtime.CompilerServices"u8, "AsyncHelpers"u8, "AllocContinuationMethod"u8, null);
break;
case ReadyToRunHelper.AllocContinuationClass:
methodDesc = context.GetCoreLibEntryPoint("System.Runtime.CompilerServices"u8, "AsyncHelpers"u8, "AllocContinuationClass"u8, null);
break;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
case ReadyToRunHelper.AllocContinuationMethod:
methodDesc = context.GetCoreLibEntryPoint("System.Runtime.CompilerServices"u8, "AsyncHelpers"u8, "AllocContinuationMethod"u8, null);
break;
case ReadyToRunHelper.AllocContinuationClass:
methodDesc = context.GetCoreLibEntryPoint("System.Runtime.CompilerServices"u8, "AsyncHelpers"u8, "AllocContinuationClass"u8, null);
break;

This file is for NativeAOT. These variants do not exist for NativeAOT so no need to list them here.

break;

case ReadyToRunHelper.AllocContinuation:
methodDesc = context.GetCoreLibEntryPoint("System.Runtime.CompilerServices"u8, "AsyncHelpers"u8, "AllocContinuation"u8, null);
Copy link
Member

Choose a reason for hiding this comment

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

The existing places should be updated to reference ReadyToRunHelper.AllocContinuation instead of the method now that we have ReadyToRunHelper id for it.

src\coreclr\tools\aot\ILCompiler.Compiler\IL\ILImporter.Scanner.cs(470):_dependencies.Add(_factory.MethodEntrypoint(asyncHelpers.GetKnownMethod("AllocContinuation"u8, null)), asyncReason);
src\coreclr\tools\aot\ILCompiler.RyuJit\JitInterface\CorInfoImpl.RyuJit.cs(765):"AsyncHelpers"u8, "AllocContinuation"u8, null));

ilc doesn't need AllocContinuationMethod/Class
Update places that reference the method to use the R2RHelper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants