Skip to content

Preserve collection initializer operands across exception regions - #628

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

jogibear9988 wants to merge 1 commit into
dadhi:masterfrom
jogibear9988:fix/collection-initializer-exceptions-independent

Conversation

@jogibear9988

Copy link
Copy Markdown
Contributor

Collection Add arguments containing exception regions can clear the collection receiver and earlier argument values from the stack. Save the collection and Add arguments before reloading them in call order, reusing the existing constructor emitter. Record actual exception-region arguments during collection and spill only the affected collection expression and Add calls.

Class and struct collections, multiple Add arguments, cleanup, throwing arguments, nonvoid Add results, ignored results and constructor arguments. 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 495 passed 1,756 passed
.NET 8 495 passed 1,755 passed
.NET Framework 4.7.2 474 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 1084.2 → 1152.6 2.0 → 2.0 872.0 → 872.0 0.0 → 0.0
Standard / list_initializer 1383.7 → 1355.5 11.1 → 12.5 1008.0 → 1008.0 72.0 → 72.0
Standard / list_initializer_unrelated_try 1933.9 → 1793.2 11.7 → 10.5 1608.0 → 1608.0 72.0 → 72.0
Light / add_control 1151.1 → 1137.2 2.0 → 2.0 872.0 → 872.0 0.0 → 0.0
Light / list_initializer 1219.9 → 1334.8 10.8 → 10.3 1040.0 → 1008.0 72.0 → 72.0
Light / list_initializer_unrelated_try 1623.5 → 1793.9 13.1 → 13.9 1640.0 → 1608.0 72.0 → 72.0
net10.0 results (master → change)
API / workload Compile ns Invoke ns Compile B/op Invoke B/op
Standard / add_control 4184.8 → 4213.3 2.0 → 1.9 872.1 → 872.1 0.0 → 0.0
Standard / list_initializer 3377.3 → 3665.1 38.8 → 43.9 1008.0 → 1008.0 72.0 → 72.0
Standard / list_initializer_unrelated_try 4144.3 → 4006.0 44.1 → 41.3 1608.0 → 1608.0 72.0 → 72.0
Light / add_control 4543.6 → 4109.4 2.0 → 2.0 872.0 → 872.0 0.0 → 0.0
Light / list_initializer 2959.2 → 3235.3 44.6 → 45.4 1040.0 → 1008.0 72.0 → 72.0
Light / list_initializer_unrelated_try 3282.6 → 3382.2 42.3 → 41.0 1640.0 → 1608.0 72.0 → 72.0

Emitted IL differs in these measured workloads: none.
No measured allocation increase above 0.1 B/op in these controls.
Light / list_initializer compile allocation: 32 B/op less than master.
Light / list_initializer_unrelated_try compile allocation: 32 B/op less than master.

Collection Add arguments containing exception regions can clear the collection receiver and earlier argument values from the stack. Save the collection and Add arguments before reloading them in call order, reusing the existing constructor emitter. Record actual exception-region arguments during collection and spill only the affected collection expression and Add calls.

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