Repository navigation
Preserve binary array receivers across exception regions - #616
Merged
dadhi merged 2 commits intoNov 10, 2026
Merged
Conversation
dadhi
requested changes
Nov 10, 2026
Binary ArrayIndex emission leaves the array reference on the stack while evaluating its index. Save and reload the receiver when an exception region can occur during emission, so a try/finally index retains the array and evaluation order.
Restore a saved left operand below either a stack-held or cached right operand through one aggressively inlined helper. Preserve existing local types, local order and emitted instruction order. Check noncommutative arithmetic and evaluation/finally effects for integer, long, decimal and nullable operands against System compilation.
jogibear9988
force-pushed
the
fix/binary-index-exceptions-standalone
branch
from
November 10, 2026 14:11
343180b to
d1bb492
Compare
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.
Binary ArrayIndex emission leaves the array reference on the stack while evaluating its index. Save and reload the receiver when an exception region can occur during emission, so a try/finally index retains the array and evaluation order. Share the aggressively inlined EmitLoadLeftAndRight helper with arithmetic emission: restore a saved left operand beneath a right operand, saving the right first only when it is still on the stack. Existing local types, allocation order and operand order are preserved.
Vector and non-vector arrays with lower bounds -2, 0 and 1; receiver/index/finally side effects. Arithmetic regressions also check subtraction results and left/right/finally effects for int, long, decimal and their nullable forms, including null left operands, against System compilation. Regressions use strict FEC compilation for both Standard and LightExpression.
Validation
Release solution build: zero warnings/errors.
Measurements
Current master
ce28e2b0→ this change, Release, Windows ARM64, .NET 8.0.28 / 10.0.9. Compilation uses prebuilt trees; runtime measures invocation through the same wrapper. Two fresh process rounds with reversed load order, seven samples per round, about 30 ms calibration, one logical CPU and tiered compilation disabled. Tables use the median of the two per-round medians.The controls below produce correct results on master for their measured inputs. Newly supported trees have no valid before/after execution comparison because master rejects them, produces incorrect results or emits invalid IL. Timings include machine and JIT/code-placement variation; the unchanged add control helps show that variation. These observations do not prove universal performance neutrality.
net8.0 results (master → change)
net10.0 results (master → change)
Array-index spilling remains conservative: a try elsewhere in the lambda can also activate the save/reload path. This accounts for the IL difference in
binary_index_unrelated_try.Emitted IL differs in these measured workloads:
binary_index_unrelated_try.No measured allocation increase above 0.1 B/op in these controls.