-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Emit async method thunks in Native AOT #121565
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
Conversation
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 PR implements async method thunks in Native AOT by replacing a ThrowNotSupportedException placeholder with actual IL generation code in the EmitAsyncMethodThunk method. The implementation mirrors the existing CoreCLR VM C++ implementation to ensure consistency across runtimes.
Key Changes
- Removed the NotSupportedException throw and implemented full IL generation for async method thunks
- Added logic to handle both ValueTask and Task return types (generic and non-generic variants)
- Implemented instantiation handling for generic types and methods
- Added cross-reference comments between C++ and C# implementations
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/coreclr/vm/asyncthunks.cpp | Updated comment capitalization and added cross-reference comment to C# implementation |
| src/coreclr/tools/Common/TypeSystem/IL/Stubs/AsyncThunks.cs | Implemented full async method thunk IL generation matching CoreCLR VM behavior, handling ValueTask/Task paths with completion checking and awaiting logic |
|
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas |
MichalStrehovsky
left a comment
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.
This looks good to me, however the failure in the Checked leg is real. You'll need to wait for #121573 to clear it.
The method matches EmitAsyncMethodThunk in CoreCLR.