Skip to content

Preserve array bounds across exception regions - #613

Merged
dadhi merged 1 commit into
dadhi:masterfrom
jogibear9988:fix/array-bound-exceptions-standalone
Nov 10, 2026
Merged

dadhi merged 1 commit into
dadhi:masterfrom
jogibear9988:fix/array-bound-exceptions-standalone

Conversation

@jogibear9988

Copy link
Copy Markdown
Contributor

A try/finally in a later multidimensional array bound can clear earlier bounds from the evaluation stack and produce invalid IL. Record those bounds during collection and spill their evaluated values before constructing the array. The first bound alone does not require this spill.

Multidimensional bounds, ordered side effects, cleanup and failing bounds. Regressions use strict FEC compilation for both Standard and LightExpression.

Validation

Release solution build: zero warnings/errors.

Runtime TestX groups Legacy tests
.NET 10 445 passed 1,756 passed
.NET 8 445 passed 1,755 passed
.NET Framework 4.7.2 424 passed 1,639 passed

Measurements

Current master f1d2fb33 → 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)
API / workload Compile ns Invoke ns Compile B/op Invoke B/op
Standard / add_control 1709.2 → 1724.9 3.1 → 3.2 872.0 → 872.0 0.0 → 0.0
Standard / array_bounds 2527.0 → 2461.4 43.3 → 42.9 960.0 → 960.0 64.0 → 64.0
Standard / array_bounds_first_try 1921.4 → 2102.0 37.5 → 35.9 1560.0 → 1560.0 64.0 → 64.0
Standard / array_bounds_unrelated_try 2539.7 → 2647.7 53.9 → 60.8 1560.0 → 1560.0 64.0 → 64.0
Light / add_control 1773.7 → 1683.4 3.1 → 3.0 872.0 → 872.0 0.0 → 0.0
Light / array_bounds 2114.6 → 2284.6 48.5 → 49.7 960.0 → 960.0 64.0 → 64.0
Light / array_bounds_first_try 2597.4 → 2724.1 54.2 → 48.6 1560.0 → 1560.0 64.0 → 64.0
Light / array_bounds_unrelated_try 2759.2 → 2723.0 49.3 → 57.5 1560.0 → 1560.0 64.0 → 64.0
net10.0 results (master → change)
API / workload Compile ns Invoke ns Compile B/op Invoke B/op
Standard / add_control 4404.4 → 4269.8 2.5 → 2.6 872.0 → 872.0 0.0 → 0.0
Standard / array_bounds 7004.7 → 6592.7 45.1 → 35.0 960.0 → 960.0 64.0 → 64.0
Standard / array_bounds_first_try 7359.7 → 7866.3 43.0 → 46.7 1560.0 → 1560.0 64.0 → 64.0
Standard / array_bounds_unrelated_try 7199.1 → 7128.9 44.9 → 50.6 1560.0 → 1560.0 64.0 → 64.0
Light / add_control 3735.7 → 4010.5 3.0 → 3.1 872.0 → 872.0 0.0 → 0.0
Light / array_bounds 5162.7 → 5163.2 44.5 → 50.1 960.0 → 960.0 64.0 → 64.0
Light / array_bounds_first_try 6764.0 → 6238.3 43.1 → 47.0 1560.0 → 1560.0 64.0 → 64.0
Light / array_bounds_unrelated_try 5842.7 → 5904.5 42.1 → 41.3 1560.0 → 1560.0 64.0 → 64.0

Emitted IL differs in these measured workloads: none.
No measured allocation increase above 0.1 B/op in these controls.

A try/finally in a later multidimensional array bound can clear earlier bounds from the evaluation stack and produce invalid IL. Record those bounds during collection and spill their evaluated values before constructing the array. The first bound alone does not require this spill.
@dadhi
dadhi merged commit ffcaa52 into dadhi:master Nov 10, 2026
4 checks passed
@jogibear9988
jogibear9988 deleted the fix/array-bound-exceptions-standalone branch November 10, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants