Repository navigation
JIT: preserve exception order after hoist rejection - #137118
Conversation
Close the exception-ordering barrier for unhoisted throwing operations. Split hoist classification from selection so larger subtrees are considered first. Resolves dotnet#134937 Co-authored-by: Copilot <[email protected]>
|
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. |
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
|
The split classification / selection is to mitigate some of the regressions (and is also better in general). We first try and hoist the largest trees, so that a tree with an invariant, may throw, unprofitable subtree can still be hoisted as a whole, even though we would not just hoist the subtree. These tend to be indirs feeding indirs. Previously we would consider trees only in execution order, so the invariant, may throw, unprofitable subtree would be rejected and block any subsequent hoisting. If hoisting the big tree fails, then we try hosting the subtrees. We can apply this same trick to sibling trees, say a call with two may throw invariant args. If the earlier executing arg is unprofitable and so not hoisted, it will block hoisting of the later arg; to mitigate this we can consider them together as a single hoist candidate. I've left that as a follow-up. ptal @dotnet/jit-contrib |
JulieLeeMSFT
left a comment
There was a problem hiding this comment.
LGTM. It prevents hoisting later throwing exception ahead of earlier unhoisted ones.
Close the exception-ordering barrier for throwing operations that remain in the loop after hoist rejection. Previously, a later throwing candidate could move ahead of an earlier null check rejected for profitability, changing which exception is observed.
Split bottom-up classification from top-down selection so larger subtrees are considered first. Accepted parents skip descendants; rejected parents allow child hoists before applying the parent's exception barrier. Add regression coverage for division-by-zero and overflow, in separate and shared statements, and distinguish both passes in JIT dumps.
Validation
Regression_ro_2: 496 passed before the dump-only edits.Performance
Of the 327 diffs, 298 only prune nested child hoists, 16 also gain cheap invariants, and 13 lose existing hoists. Collection-wide static PerfScore geomeans are effectively neutral: benchmarks -0.000827%, libraries PMI -0.000440%, and PGO/crossgen2 unchanged.
BenchmarkDotNet ShortRun on this shared Windows x64 machine, at 1,000 iterations:
SeparateStatementsQueuedCandidatesThese loops lose the previously hoisted division to preserve exception order; these are not general workload results. JIT compilation throughput and other architectures were not measured.
Resolves #134937
Note
This PR description was generated with GitHub Copilot.