Skip to content

Correct instance receiver dispatch and discarded getter results - #619

Merged
dadhi merged 2 commits into
dadhi:masterfrom
jogibear9988:fix/property-getter-receivers-standalone
Nov 10, 2026
Merged

dadhi merged 2 commits into
dadhi:masterfrom
jogibear9988:fix/property-getter-receivers-standalone

Conversation

@jogibear9988

@jogibear9988 jogibear9988 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Interface property and indexer getters on struct receivers can produce invalid IL. Reference getters and collection Add methods also require callvirt to check null receivers even when the target method is nonvirtual. Use one receiver-aware dispatch helper for ordinary method calls, property reads, indexer reads and collection initialization. It emits direct calls for methods declared on the struct, constrained virtual calls for interface/base methods on structs, and virtual calls for reference receivers. Pop discarded property/indexer getter results while preserving their side effects.

Tests compare results and exceptions with System compilation: interface getters, ordinary interface/base calls, struct mutation, indexer reads, discarded results, null reference receivers, interface Add calls on structs and collection initialization through a null member. LightExpression collection trees are constructed directly because conversion from System ListInit is unsupported. Getter opcode expectations in three legacy issue fixtures are updated for the required callvirt instruction; their behavior assertions remain. Regressions use strict FEC compilation for both Standard and LightExpression.

Validation

Release solution build: zero warnings/errors.

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

Measurements

Current master ce28e2b0 → 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.

The reference getter control uses a non-null receiver. Its new callvirt also supplies the previously missing null check, so any runtime cost of that correctness change is included.

net8.0 results (master → change)
API / workload Compile ns Invoke ns Compile B/op Invoke B/op
Standard / add_control 1649.8 → 1755.3 2.6 → 2.7 872.0 → 872.0 0.0 → 0.0
Standard / struct_read 1604.6 → 1562.8 2.9 → 2.6 904.1 → 904.1 0.0 → 0.0
Standard / struct_interface_call 2279.1 → 1432.0 3.6 → 3.3 936.1 → 936.1 0.0 → 0.0
Standard / nonvirtual_list_initializer 1412.0 → 1771.0 4.8 → 4.2 960.1 → 960.1 24.0 → 24.0
Standard / list_initializer 3854.1 → 2882.3 16.3 → 21.7 1008.0 → 1008.0 72.0 → 72.0
Standard / list_read 2884.6 → 3242.8 3.7 → 3.3 952.0 → 952.0 0.0 → 0.0
Standard / property_read 2189.9 → 2230.6 3.4 → 3.4 904.1 → 904.1 0.0 → 0.0
Standard / nullable_hasvalue 2294.1 → 2532.7 3.4 → 3.4 952.0 → 952.0 0.0 → 0.0
Light / add_control 1911.2 → 1712.2 2.6 → 2.6 872.0 → 872.0 0.0 → 0.0
Light / struct_read 1377.0 → 1446.2 2.5 → 2.6 904.0 → 904.0 0.0 → 0.0
Light / struct_interface_call 1960.4 → 1600.6 3.7 → 4.3 936.0 → 936.0 0.0 → 0.0
Light / nonvirtual_list_initializer 1371.3 → 1709.6 5.4 → 9.3 992.0 → 992.0 24.0 → 24.0
Light / list_initializer 4149.8 → 1779.1 91.8 → 45.6 1040.0 → 1040.0 72.0 → 72.0
Light / list_read 8908.4 → 4283.1 4.3 → 4.0 952.1 → 952.1 0.0 → 0.0
Light / property_read 15768.0 → 9652.4 14.8 → 19.2 904.0 → 904.0 0.0 → 0.0
Light / nullable_hasvalue 3209.7 → 4328.2 6.2 → 5.9 952.0 → 952.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 5923.9 → 5652.0 7.3 → 12.8 872.1 → 872.1 0.0 → 0.0
Standard / struct_read 5313.3 → 10639.2 2.9 → 3.6 904.2 → 904.2 0.0 → 0.0
Standard / struct_interface_call 5653.4 → 5858.0 8.3 → 3.7 936.8 → 936.8 0.0 → 0.0
Standard / nonvirtual_list_initializer 5999.4 → 5691.1 7.7 → 6.9 960.3 → 960.3 24.0 → 24.0
Standard / list_initializer 5360.9 → 5028.9 76.6 → 66.5 1008.1 → 1008.1 72.0 → 72.0
Standard / list_read 5861.9 → 5856.4 2.6 → 2.8 952.1 → 952.1 0.0 → 0.0
Standard / property_read 5239.6 → 4768.8 2.7 → 2.7 904.2 → 904.2 0.0 → 0.0
Standard / nullable_hasvalue 5194.4 → 5126.3 2.7 → 2.8 952.0 → 952.0 0.0 → 0.0
Light / add_control 3998.7 → 3769.7 3.1 → 2.9 872.1 → 872.1 0.0 → 0.0
Light / struct_read 4647.2 → 4145.4 2.5 → 2.6 904.0 → 904.0 0.0 → 0.0
Light / struct_interface_call 3908.0 → 3832.1 2.4 → 2.6 936.0 → 936.0 0.0 → 0.0
Light / nonvirtual_list_initializer 3619.7 → 3436.2 5.0 → 4.7 992.0 → 992.0 24.0 → 24.0
Light / list_initializer 3361.6 → 3532.8 61.7 → 64.7 1040.0 → 1040.0 72.0 → 72.0
Light / list_read 3346.9 → 5806.3 3.5 → 3.4 952.0 → 952.0 0.0 → 0.0
Light / property_read 5553.0 → 5567.6 3.9 → 4.1 904.0 → 904.0 0.0 → 0.0
Light / nullable_hasvalue 4140.1 → 4360.7 3.6 → 4.0 952.0 → 952.0 0.0 → 0.0

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

Interface property getters on struct receivers can produce invalid IL or crash. Dispatch value-type getters with the required constrained call, use callvirt for reference receiver null checks, and pop discarded getter values.
Reuse receiver-aware call emission for ordinary methods, indexer reads and collection initializers. Preserve struct addresses for interface calls, reference receiver null checks and discarded getter side effects.

Cover Standard and LightExpression using System compilation as the result and exception oracle. Construct LightExpression collection initializers directly.
@jogibear9988
jogibear9988 force-pushed the fix/property-getter-receivers-standalone branch from 934d634 to df6d0aa Compare November 10, 2026 13:58
@jogibear9988 jogibear9988 changed the title Correct property getter receiver dispatch and discarded results Correct instance receiver dispatch and discarded getter results Nov 10, 2026
@dadhi
dadhi merged commit 094d067 into dadhi:master Nov 10, 2026
4 checks passed
@jogibear9988
jogibear9988 deleted the fix/property-getter-receivers-standalone branch November 10, 2026 22:01
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