Repository navigation
Correct instance receiver dispatch and discarded getter results - #619
Merged
dadhi merged 2 commits intoNov 10, 2026
Merged
Conversation
dadhi
requested changes
Nov 10, 2026
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
force-pushed
the
fix/property-getter-receivers-standalone
branch
from
November 10, 2026 13:58
934d634 to
df6d0aa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
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)
net10.0 results (master → change)
Emitted IL differs in these measured workloads:
nonvirtual_list_initializer,property_read.No measured allocation increase above 0.1 B/op in these controls.