Skip to content

Use new JIT helpers for instantiating and continuation thunks#121952

Merged
MichalStrehovsky merged 3 commits intodotnet:mainfrom
MichalStrehovsky:newhelper
Nov 26, 2025
Merged

Use new JIT helpers for instantiating and continuation thunks#121952
MichalStrehovsky merged 3 commits intodotnet:mainfrom
MichalStrehovsky:newhelper

Conversation

@MichalStrehovsky
Copy link
Member

Takes advantage of the new functionality added in #121799.

Cc @dotnet/ilc-contrib @jakobbotsch

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

@MichalStrehovsky
Copy link
Member Author

/azp run runtime-nativeaot-outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jakobbotsch
Copy link
Member

Can you change this code to assert(node->AsCall()->IsAsync());:

if (!node->AsCall()->IsAsync())
{
JITDUMP("Marking the call [%06u] before async continuation [%06u] as an async call\n",
Compiler::dspTreeID(node), Compiler::dspTreeID(asyncCont));
node->AsCall()->SetIsAsync(new (comp, CMK_Async) AsyncCallInfo);
}

Also the part in the comment above about NAOT can be removed.

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 modernizes the AOT compiler's approach to handling instantiation and continuation thunks by leveraging new JIT helper intrinsics introduced in #121799. Instead of using custom fake method signatures to explicitly pass hidden parameters (generic context and continuation), the code now uses JIT intrinsics (SetNextCallGenericContext and SetNextCallAsyncContinuation) to communicate this information.

Key changes:

  • Removed architecture-specific (x86 vs non-x86) parameter ordering logic that is no longer needed with the new intrinsics
  • Deleted three custom MethodDesc wrapper classes: ValueTypeInstanceMethodWithHiddenParameter, DefaultInterfaceMethodImplementationWithHiddenParameter, and ExplicitContinuationAsyncMethod
  • Simplified IL emission in thunks by removing fake method references and using direct calls with intrinsics

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
RyuJitNodeFactory.cs Removed method entrypoint mapping logic for special thunks since they no longer use fake methods
ILScanNodeFactory.cs Same removal as RyuJitNodeFactory.cs for the scanner path
ILImporter.Scanner.cs Simplified instantiation parameter dependency tracking by removing special case for unboxing thunks
CompilerTypeSystemContext.Sorting.cs Removed sorting implementations for deleted wrapper method types
CompilerTypeSystemContext.InterfaceThunks.cs Replaced fake method calls with SetNextCallGenericContext intrinsic; deleted DefaultInterfaceMethodImplementationWithHiddenParameter class and removed x86-specific parameter ordering
CompilerTypeSystemContext.BoxedTypes.cs Replaced fake method calls with SetNextCallGenericContext intrinsic; deleted ValueTypeInstanceMethodWithHiddenParameter class and updated documentation; removed x86-specific parameter ordering
AsyncResumptionStub.cs Replaced ExplicitContinuationAsyncMethod with direct calls using SetNextCallGenericContext and SetNextCallAsyncContinuation intrinsics; deleted ExplicitContinuationAsyncMethod class and removed x86-specific parameter ordering
AsyncResumptionStub.Sorting.cs Removed sorting implementation for deleted ExplicitContinuationAsyncMethod
CorInfoImpl.cs Removed special handling for unboxing thunk hidden parameters since they're now managed by the JIT

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Removed comments about marking calls as async for NativeAOT and added an assertion to ensure the call is async.
@MichalStrehovsky
Copy link
Member Author

/ba-g osx brownout

@MichalStrehovsky MichalStrehovsky merged commit cd847a6 into dotnet:main Nov 26, 2025
91 of 106 checks passed
@MichalStrehovsky MichalStrehovsky deleted the newhelper branch November 26, 2025 07:27
@github-actions github-actions bot locked and limited conversation to collaborators Dec 26, 2025
Sign up for free to 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.

3 participants