Skip to content

Reuse constructor emission inside member initializers - #629

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

jogibear9988 wants to merge 1 commit into
dadhi:masterfrom
jogibear9988:fix/member-constructor-exceptions-independent

Conversation

@jogibear9988

Copy link
Copy Markdown
Contributor

Member initializers emit constructor arguments inline, leaving earlier arguments on the stack across a later try/finally. Delegate constructor emission to the existing TryEmitNew path, then apply the member bindings.

Class and struct constructors, argument/finally/constructor/binding order and initialized values, compared with System compilation. On .NET Framework the struct EH initializer uses equivalent direct C# as its oracle because the Framework System compiler rejects that shape; class cases use System compilation. 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 1148.7 → 1190.3 2.0 → 2.0 872.0 → 872.0 0.0 → 0.0
Standard / member_init 1451.1 → 1544.4 3.8 → 3.7 1064.1 → 1064.1 24.0 → 24.0
Standard / member_init_constructor 1535.0 → 1464.7 3.9 → 4.1 976.1 → 976.1 24.0 → 24.0
Light / add_control 1074.7 → 1061.6 2.1 → 2.0 872.0 → 872.0 0.0 → 0.0
Light / member_init 1457.0 → 1220.9 3.7 → 3.8 1064.0 → 1064.0 24.0 → 24.0
Light / member_init_constructor 1452.7 → 1264.0 3.7 → 3.5 976.0 → 976.0 24.0 → 24.0
net10.0 results (master → change)
API / workload Compile ns Invoke ns Compile B/op Invoke B/op
Standard / add_control 3289.8 → 3295.8 2.0 → 1.9 872.0 → 872.0 0.0 → 0.0
Standard / member_init 3907.4 → 3918.2 3.9 → 3.9 1064.2 → 1064.2 24.0 → 24.0
Standard / member_init_constructor 4100.7 → 4138.2 4.1 → 4.1 976.2 → 976.2 24.0 → 24.0
Light / add_control 2562.6 → 2517.8 2.0 → 2.0 872.0 → 872.0 0.0 → 0.0
Light / member_init 3249.7 → 3277.8 4.8 → 3.9 1064.0 → 1064.0 24.0 → 24.0
Light / member_init_constructor 2954.2 → 2985.4 3.9 → 3.8 976.0 → 976.0 24.0 → 24.0

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

Member initializers emit constructor arguments inline, leaving earlier arguments on the stack across a later try/finally. Delegate constructor emission to the existing TryEmitNew path, then apply the member bindings.

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