Skip to content

Evaluate switch tests on an empty stack across exception regions - #615

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

dadhi merged 1 commit into
dadhi:masterfrom
jogibear9988:fix/ordered-switch-exceptions-standalone

Conversation

@jogibear9988

Copy link
Copy Markdown
Contributor

An ordered switch test containing try/finally can invalidate the switch comparison stack. Evaluate and store the test value before loading the saved switch operand, preserving test order and cleanup behavior.

Nullable and non-nullable switch values, matching and missing cases, throwing tests and cleanup order. Regressions use strict FEC compilation for both Standard and LightExpression.

Validation

Release solution build: zero warnings/errors.

Runtime TestX groups Legacy tests
.NET 10 443 passed 1,756 passed
.NET 8 443 passed 1,755 passed
.NET Framework 4.7.2 422 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 1191.2 → 1192.6 2.2 → 2.2 872.0 → 872.0 0.0 → 0.0
Standard / switch_runtime_int 1928.9 → 1802.1 2.2 → 2.3 1112.1 → 1112.1 0.0 → 0.0
Standard / switch_runtime_unrelated_try 2183.5 → 2435.1 2.1 → 2.2 1528.1 → 1528.1 0.0 → 0.0
Light / add_control 1345.7 → 1383.5 2.0 → 2.0 872.0 → 872.0 0.0 → 0.0
Light / switch_runtime_int 1573.4 → 1536.0 2.0 → 2.1 1112.0 → 1112.0 0.0 → 0.0
Light / switch_runtime_unrelated_try 2302.6 → 2631.2 2.5 → 2.5 1528.0 → 1528.0 0.0 → 0.0
net10.0 results (master → change)
API / workload Compile ns Invoke ns Compile B/op Invoke B/op
Standard / add_control 4120.7 → 4137.5 2.6 → 2.5 872.1 → 872.1 0.0 → 0.0
Standard / switch_runtime_int 6843.9 → 6672.4 2.4 → 2.4 1112.1 → 1112.1 0.0 → 0.0
Standard / switch_runtime_unrelated_try 5918.3 → 7581.3 2.1 → 2.1 1528.1 → 1528.1 0.0 → 0.0
Light / add_control 2629.6 → 3120.9 2.5 → 2.4 872.0 → 872.0 0.0 → 0.0
Light / switch_runtime_int 4156.4 → 4437.5 2.5 → 2.5 1112.0 → 1112.0 0.0 → 0.0
Light / switch_runtime_unrelated_try 4802.8 → 5268.4 2.1 → 2.0 1528.0 → 1528.0 0.0 → 0.0

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

An ordered switch test containing try/finally can invalidate the switch comparison stack. Evaluate and store the test value before loading the saved switch operand, preserving test order and cleanup behavior.
@dadhi
dadhi merged commit be5101c into dadhi:master Nov 10, 2026
4 checks passed
@jogibear9988
jogibear9988 deleted the fix/ordered-switch-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