Skip to content

Emit exact array accessors for nonvector element storage - #609

Merged
dadhi merged 3 commits into
dadhi:masterfrom
jogibear9988:fix/nonvector-arrays-standalone
Nov 9, 2026
Merged

dadhi merged 3 commits into
dadhi:masterfrom
jogibear9988:fix/nonvector-arrays-standalone

Conversation

@jogibear9988

Copy link
Copy Markdown
Contributor

Passing some nonvector array elements by reference emits invalid IL. Use the actual vector/nonvector type to choose element opcodes versus runtime Get/Address/Set accessors. Preserve lower bounds, writable struct storage, covariance checks and ignored-read validation.

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 367 1,756
.NET 8 367 1,755
.NET Framework 4.7.2 348 1,639

Measurements

Compare master a0950432 with this commit 3a8eb6a0. 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 2,488 → 2,314 872 → 872 1.89 → 1.91 0 → 0
10 / Light multirank_read 6,642 → 6,345 2416 → 2416 2.22 → 2.23 0 → 0
10 / Light vector_array_read 2,727 → 2,620 872 → 872 1.79 → 1.80 0 → 0
10 / Standard add_control 2,938 → 2,960 872 → 872 1.92 → 1.94 0 → 0
10 / Standard multirank_read 6,919 → 7,098 2416 → 2416 2.24 → 2.17 0 → 0
10 / Standard vector_array_read 3,082 → 3,196 872 → 872 1.79 → 1.78 0 → 0
8 / Light add_control 928 → 946 872 → 872 1.92 → 1.94 0 → 0
8 / Light multirank_read 2,272 → 2,328 2368 → 2368 2.19 → 2.19 0 → 0
8 / Light vector_array_read 1,010 → 994 872 → 872 1.78 → 1.85 0 → 0
8 / Standard add_control 1,025 → 979 872 → 872 1.90 → 1.92 0 → 0
8 / Standard multirank_read 2,360 → 2,558 2368 → 2368 2.17 → 2.20 0 → 0
8 / Standard vector_array_read 1,199 → 1,035 872 → 872 1.84 → 1.77 0 → 0

Classify vector types by their actual runtime type and share typed array Get/Address emission. Preserve lower bounds, writable struct element storage, reference covariance checks and ignored-read bounds/null checks. Keep ordinary vector access on its existing path.
@jogibear9988
jogibear9988 force-pushed the fix/nonvector-arrays-standalone branch from 3a8eb6a to b6c4d1e Compare November 9, 2026 22:25
@dadhi
dadhi merged commit d9cf35c into dadhi:master Nov 9, 2026
4 checks passed
@jogibear9988
jogibear9988 deleted the fix/nonvector-arrays-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