Uh oh!
There was an error while loading. Please reload this page.
JIT: Fully share helper-based suspension tails - #126360
Conversation
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
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. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
79d9b7e to
96b408cCompare96b408c to
b8e698fCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
b8e698f to
8cba3d6Compare8cba3d6 to
6415139CompareWhen 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
dba203dCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
jakobbotsch
commented
Apr 29, 2026
Uh oh!
There was an error while loading. Please reload this page.
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