JIT: Fully share helper-based suspension tails#126360
Open
jakobbotsch wants to merge 1 commit intodotnet:mainfrom
Open
JIT: Fully share helper-based suspension tails#126360jakobbotsch wants to merge 1 commit intodotnet:mainfrom
jakobbotsch wants to merge 1 commit intodotnet:mainfrom
Conversation
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the CoreCLR async-await JIT transformation to further reduce generated code size by fully sharing the “finish suspension” tail logic (context capture/restore + return-suspend) across multiple awaits via shared blocks, leveraging the helper-based suspension helpers added previously.
Changes:
- Adds two new AsyncHelpers “finish suspension” helpers to the JIT/EE async interface (CORINFO_ASYNC_INFO) and wires them through VM, SuperPMI, and JIT interface tooling.
- Updates the JIT async transformation to optionally route multiple suspension epilogs through shared “finish context handling” blocks (separately for with/without continuation-context capture).
- Exposes
ExecutionContext.InstanceIsFlowSuppressedto support the new helpers’ flow-suppressed handling logic.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Private.CoreLib/src/System/Threading/ExecutionContext.cs | Adds internal instance accessor for flow-suppressed state used by new suspension helpers. |
| src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs | Adds FinishSuspension* helper implementations used by JIT-generated suspension tails. |
| src/coreclr/inc/corinfo.h | Extends CORINFO_ASYNC_INFO with method handles for the new finish-suspension helpers. |
| src/coreclr/vm/corelib.h | Adds CoreLib binder entries for the new AsyncHelpers methods. |
| src/coreclr/vm/jitinterface.cpp | Populates the new helper method handles in CEEInfo::getAsyncInfo. |
| src/coreclr/jit/async.h | Adds helper selection and accounting types + fields for shared finish-context-handling blocks. |
| src/coreclr/jit/async.cpp | Implements shared finish-suspension block creation and reroutes suspension epilogs to shared blocks when beneficial. |
| src/coreclr/jit/gentree.h | Adds a hook for “needs execution context save/restore” used by the async transformation logic. |
| src/coreclr/inc/jiteeversionguid.h | Bumps JIT/EE version GUID to reflect the interface change. |
| src/coreclr/tools/superpmi/superpmi-shared/agnostic.h | Updates SuperPMI agnostic async info struct to include the new method handles. |
| src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp | Records/replays the new async helper handles for SuperPMI. |
| src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs | Updates managed projection of CORINFO_ASYNC_INFO. |
| src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs | Provides the new helper method handles to the managed JIT interface implementation. |
| src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs | Ensures R2R compilation includes references to the new AsyncHelpers methods. |
| src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs | Adds dependency scanning for the new AsyncHelpers methods. |
This was referenced Apr 1, 2026
Open
79d9b7e to
96b408c
Compare
96b408c to
b8e698f
Compare
b8e698f to
8cba3d6
Compare
8cba3d6 to
6415139
Compare
When multiple awaits have common context handling logic during suspension we can share that logic completely by jumping to a common block. This PR implements that size optimization.
6415139 to
dba203d
Compare
This was referenced Apr 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When multiple awaits have common context handling logic during suspension we can share that logic completely by jumping to a common block. This PR implements that size optimization.
Codegen diff
NativeAOT Test size diffs