JIT: Optimize always suspending helpers - #130493
Conversation
Several async helpers are known to always suspend. We can skip the "returned a continuation" check for those.
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
Pull request overview
This PR teaches the CoreCLR JIT’s runtime-async transformation to treat certain async helper calls as always suspending, allowing it to skip generating the “did the call return a continuation?” null check and instead unconditionally branch to the suspension path. To enable this, the relevant helpers are marked [Intrinsic] and recognized by lookupNamedIntrinsic, and a new AsyncCallInfo::AlwaysSuspends bit flows from import to async transformation.
Changes:
- Mark
AsyncHelpers.AwaitAwaiter/UnsafeAwaitAwaiterand CoreCLR’sSuspend*/TransparentSuspend*helpers as[Intrinsic]so the JIT can identify them reliably. - Add new named intrinsics for these helpers and plumb
NamedIntrinsicintoimpSetupAsyncCallto setAsyncCallInfo.AlwaysSuspends. - Update
AsyncTransformation::CreateCheckAndSuspendAfterCallto omit the null-continuation check whenAlwaysSuspendsis set.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.cs | Marks AwaitAwaiter / UnsafeAwaitAwaiter as [Intrinsic] to enable JIT recognition. |
| src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs | Marks Suspend* / TransparentSuspend* helpers as [Intrinsic] for JIT recognition. |
| src/coreclr/jit/namedintrinsiclist.h | Adds new NamedIntrinsic IDs for always-suspending async helpers. |
| src/coreclr/jit/importercalls.cpp | Recognizes new helper intrinsics and plumbs NamedIntrinsic into async-call setup to set AlwaysSuspends. |
| src/coreclr/jit/gentree.h | Extends AsyncCallInfo with AlwaysSuspends. |
| src/coreclr/jit/compiler.h | Updates impSetupAsyncCall signature to accept the callee NamedIntrinsic. |
| src/coreclr/jit/async.cpp | Skips null-continuation check and changes CFG wiring for AlwaysSuspends calls. |
|
Azure Pipelines: Successfully started running 5 pipeline(s). 10 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
cc @dotnet/jit-contrib PTAL @AndyAyersMS Sadly cannot see diffs here because it requires the APIs to be marked |
This comment was marked as spam.
This comment was marked as spam.
|
/ba-g Failure is #128907 |
Several async helpers are known to always suspend. We can skip the "returned a continuation?" check for those.
Several async helpers are known to always suspend. We can skip the "returned a continuation?" check for those.
Fix #128324