-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Add support for runtime async in the scanner #121622
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
Add support for runtime async in the scanner #121622
Conversation
Before we start generating native code using RyuJIT, we do an IL scanning pass where we build the whole program view. The whole program view builds a dependency graph that is similar to the one we create during code generation. Instead of generating code, we look at method IL and generate whatever dependency nodes are going to be needed for real codegen (ConstructedEETypeNode for newobj, more scanned method nodes for calls, etc.). This PR adds support for scanning methods that compile into state machine. It also suppresses some of the whole program optimizations around the special `Continuation` type.
|
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas |
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 adds support for runtime async in the IL scanner phase of Native AOT compilation. The scanner builds a whole program view by analyzing method IL and generating dependency nodes before actual code generation begins.
Key Changes:
- Added pattern matching to detect task await patterns in async methods during IL scanning
- Introduced infrastructure to track and add async-related dependencies (continuation types, async helpers, resumption stubs)
- Refactored continuation type access to use a centralized property to improve code maintainability
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| ILImporter.Scanner.cs | Implements async pattern detection (MatchTaskAwaitPattern) and adds dependencies for async infrastructure when scanning calls to async methods from async state machines |
| ILScanner.cs | Prevents devirtualization optimizations on continuation types since they're dynamically generated and not well tracked |
| CorInfoImpl.cs | Refactors to use the new centralized ContinuationType property instead of directly calling GetKnownType |
| CompilerTypeSystemContext.Async.cs | Introduces public ContinuationType property for centralized access to the base continuation type and refactors internal hashtable to use it |
src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs
Outdated
Show resolved
Hide resolved
src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs
Outdated
Show resolved
Hide resolved
|
@dotnet/ilc-contrib this is ready for another round of reviews. This might be the last thing we need to start running src/tests/async (I do have the async tree passing locally already). |
|
@jakobbotsch Could you please review that this matches the JIT importer behavior? (Also, any changes in that behavior will need to be reflected here going forward.) |
Before we start generating native code using RyuJIT, we do an IL scanning pass where we build the whole program view. The whole program view builds a dependency graph that is similar to the one we create during code generation.
Instead of generating code, we look at method IL and generate whatever dependency nodes are going to be needed for real codegen (ConstructedEETypeNode for newobj, more scanned method nodes for calls, etc.).
This PR adds support for scanning methods that compile into state machine. It also suppresses some of the whole program optimizations around the special
Continuationtype.Cc @dotnet/ilc-contrib (@jakobbotsch for the
impMatchTaskAwaitPatterncopy)