Skip to content

Preserve reference operands across exception regions - #622

Open
jogibear9988 wants to merge 1 commit into
dadhi:masterfrom
jogibear9988:fix/reference-comparison-exceptions-independent
Open

jogibear9988 wants to merge 1 commit into
dadhi:masterfrom
jogibear9988:fix/reference-comparison-exceptions-independent

Conversation

@jogibear9988

Copy link
Copy Markdown
Contributor

LightExpression reference comparisons can emit invalid IL when the right operand contains try/finally. Route complex right operands through the existing comparison emitter while retaining the ordinary reference-comparison fast path.

Equal and unequal objects, ReferenceEqual and ReferenceNotEqual, exactly-once left/right/finally ordering and compiler flags. Regressions require strict FEC compilation. Native suites cover Standard and LightExpression.

Validation

Local validation uses master baseline 094d067 plus this change. Release solution build: zero warnings/errors.

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

Measurements

Master baseline 094d0678 → 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 2182.7 → 2217.6 3.2 → 3.2 872.0 → 872.0 0.0 → 0.0
Standard / try_reference 2469.0 → 2301.7 2.8 → 3.0 1584.0 → 1584.0 0.0 → 0.0
Standard / reference_equal 2379.6 → 3080.8 3.1 → 3.0 880.0 → 880.0 0.0 → 0.0
Standard / reference_equal_try 4800.5 → 4260.9 7.8 → 7.6 1872.2 → 1864.2 0.0 → 0.0
Light / add_control 1804.9 → 1935.1 2.8 → 2.7 872.0 → 872.0 0.0 → 0.0
Light / try_reference 1931.3 → 1940.3 3.1 → 7.8 1584.0 → 1584.0 0.0 → 0.0
Light / reference_equal 4130.2 → 5498.5 4.1 → 5.2 880.0 → 880.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 5224.5 → 6479.3 3.3 → 3.0 872.1 → 872.1 0.0 → 0.0
Standard / try_reference 6081.8 → 5919.6 3.3 → 3.0 1584.0 → 1584.0 0.0 → 0.0
Standard / reference_equal 6612.9 → 6532.9 2.8 → 2.8 880.1 → 880.1 0.0 → 0.0
Standard / reference_equal_try 14328.7 → 13182.5 5.7 → 5.7 1872.1 → 1864.1 0.0 → 0.0
Light / add_control 3730.4 → 3882.2 2.8 → 3.4 872.0 → 872.0 0.0 → 0.0
Light / try_reference 4738.7 → 5649.9 3.1 → 3.4 1584.0 → 1584.0 0.0 → 0.0
Light / reference_equal 3961.6 → 3686.5 2.3 → 2.6 880.0 → 880.0 0.0 → 0.0

Emitted IL differs in these measured workloads: reference_equal_try.
No measured allocation increase above 0.1 B/op in these controls.
Standard / reference_equal_try compile allocation: 8 B/op less than master.

LightExpression reference comparisons can emit invalid IL when the right operand contains try/finally. Route complex right operands through the existing comparison emitter while retaining the ordinary reference-comparison fast path.

Validation: Release solution build; full Standard and LightExpression .NET 8, .NET 10 and Framework runners pass.

Measurements: master 094d067 versus this change, compilation and invocation, both APIs, .NET 8/10, two opposite-order process rounds with seven samples each. No measured allocation increase above 0.1 B/op in the selected working controls. Timings and emitted IL are recorded in the PR description; these controls do not establish universal performance neutrality.
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.

1 participant