Skip to content

Make invocation values addressable for ref arguments - #607

Merged
dadhi merged 2 commits into
dadhi:masterfrom
jogibear9988:fix/invoke-ref-arguments-standalone
Nov 9, 2026
Merged

dadhi merged 2 commits into
dadhi:masterfrom
jogibear9988:fix/invoke-ref-arguments-standalone

Conversation

@jogibear9988

Copy link
Copy Markdown
Contributor

A value returned by delegate invocation cannot currently be used reliably as a ref argument. Materialize the value once in a typed temporary. Preserve genuine byref-return aliases, inlined invocation results and discarded-result effects.

Validation

The focused regression reproduces a failure or crash on master a0950432 and passes with this change. Release solution build passes with zero warnings/errors. Both Standard and LightExpression native suites run.

Runtime TestX passed Legacy passed
.NET 10 363 1,756
.NET 8 363 1,755
.NET Framework 4.7.2 342 1,639

Measurements

Compare master a0950432 with this commit de1f8aab. Windows ARM64, Release; .NET 8.0.28 and 10.0.9. Compilation uses prebuilt trees; invocation uses precompiled delegates and excludes expression construction/compilation. Standard and LightExpression are measured separately.

Two fresh process rounds reverse version-loading order, pin execution to one logical CPU, disable tiered compilation, warm both versions, and alternate measurement order. Values below are medians across 14 samples per side (seven per round; 30 ms calibration target).

Measured compilation and invocation allocations match master on every control. Control delegate IL matches master.

Identical-master control runs also varied: compilation -15.2% to +23.4%, invocation -21.5% to +8.9%. Timings below are observations, not a speedup or universal performance-neutrality claim. Cases that fail or produce invalid IL on master have no meaningful before/after invocation ratio; the table uses executable controls that return the expected result in both versions. Framework correctness is tested above; its performance is not measured here.

All table pairs are master → this change. B/op is allocated bytes per operation.

.NET / API Control Compile ns/op Compile B/op Invoke ns/op Invoke B/op
10 / Light add_control 4,055 → 4,758 872 → 872 2.54 → 2.64 0 → 0
10 / Light delegate_invoke 3,832 → 3,782 952 → 952 3.47 → 3.02 0 → 0
10 / Light inlined_invoke 4,061 → 3,765 872 → 872 2.51 → 2.49 0 → 0
10 / Standard add_control 3,810 → 4,159 872 → 872 2.36 → 2.31 0 → 0
10 / Standard delegate_invoke 5,398 → 4,878 952 → 952 3.21 → 3.07 0 → 0
10 / Standard inlined_invoke 4,816 → 4,623 872 → 872 2.47 → 2.43 0 → 0
8 / Light add_control 1,212 → 1,284 872 → 872 2.47 → 2.33 0 → 0
8 / Light delegate_invoke 1,514 → 1,688 952 → 952 2.95 → 2.97 0 → 0
8 / Light inlined_invoke 1,223 → 1,470 872 → 872 2.49 → 2.41 0 → 0
8 / Standard add_control 1,758 → 1,947 872 → 872 3.44 → 2.91 0 → 0
8 / Standard delegate_invoke 2,219 → 1,975 952 → 952 3.13 → 3.14 0 → 0
8 / Standard inlined_invoke 1,709 → 1,543 872 → 872 2.49 → 2.37 0 → 0

jogibear9988 and others added 2 commits November 9, 2026 09:31
Forward ref-argument context into invocation emission and materialize value-returning delegate or inlined invocation results in typed temporaries. Preserve genuine byref-return aliases and ignored-result side effects.
@dadhi
dadhi merged commit 423ebea into dadhi:master Nov 9, 2026
4 checks passed
@jogibear9988
jogibear9988 deleted the fix/invoke-ref-arguments-standalone branch November 9, 2026 23:18
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