Skip to content

Treat Wasm Vector<T> layout as fixed - #135804

Merged
davidwrighton merged 2 commits into
dotnet:mainfrom
davidwrighton:split/wasm-vector-layout
Oct 19, 2026
Merged

davidwrighton merged 2 commits into
dotnet:mainfrom
davidwrighton:split/wasm-vector-layout

Conversation

@davidwrighton

Copy link
Copy Markdown
Member

Description

Extract the independent Wasm vector-layout change from #135553 onto main.

Treat System.Numerics.Vector<T> as having fixed layout on Wasm32, where its width is fixed at 128 bits. Avoid redundant runtime-dependent vector layout checks on that target. Containing types can also have fixed layout when their remaining layout is fixed within the version bubble.

Other targets retain runtime-dependent vector layout checks, and ordinary version-bubble restrictions remain in place for containing types. Add regular/composite regression cases covering vectors, wrappers, and vector-containing tuples, and document the Wasm layout rule.

Source commit: 6a269adea70a2ea611bc2a3da78c43cdc08545c7. This PR does not include the separate canonical SIMD-root exclusion, two-phase compilation, direct calls, or the prolog/frame-identity changes.

Historical size measurements

These matched before/after Wasm measurements were collected on the original development branch, not on this newly extracted/rebased PR. The recorded JIT hashes match between baseline and updated builds. Brotli used quality 11 and window 22.

Wasm image Raw before Raw after Raw savings Brotli before Brotli after Brotli savings
Retail CoreLib 19,395,699 19,140,186 255,513 3,632,758 3,586,455 46,303
CoreLib + CallPerformance composite 13,123,330 12,834,328 289,002 2,875,741 2,844,264 31,477

These are historical size measurements, not throughput benchmarks or a guarantee of equivalent savings on current main.

Validation

  • git diff --check upstream/main...split/wasm-vector-layout — passed.
  • Inspected the extracted four-file diff; it includes only the Wasm layout decision, related regression cases, and documentation.
  • Builds, runtime tests, and new benchmarks for this extracted branch — not run, at the user's explicit request.

This remains a draft; build and runtime validation on the independent branch are outstanding.

Note

This PR was prepared with GitHub Copilot.

Skip runtime-dependent vector layout checks on Wasm while retaining checks on native targets and for types outside the version bubble. Add cross-target compiler regressions for vectors, wrappers, and tuples.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/crossgen-contrib
See info in area-owners.md if you want to be subscribed.

@davidwrighton
davidwrighton marked this pull request as ready for review October 14, 2026 21:53
@davidwrighton
davidwrighton requested review from jtschuster and tannergooding and a balanced review from Copilot October 14, 2026 21:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The unconditional regression theory expects compiled vector methods on targets where their layout is indeterminate.

1 open finding
What changed in this PR

Treats Wasm32 Vector<T> layout as fixed in ReadyToRun compilation, avoiding redundant checks while preserving other targets’ behavior and version-bubble restrictions.

Changes:

  • Recognizes Wasm32 vectors as fixed-layout types.
  • Adds regular/composite regression cases for vectors, wrappers, and tuples.
  • Documents the Wasm layout rule.

Builds and tests were not run during this review.

File Description
src/​coreclr/​tools/​aot/​ILCompiler.ReadyToRun/​Compiler/​ReadyToRunCodegenCompilation.cs Adds the Wasm32 fixed-layout decision.
src/​coreclr/​tools/​aot/​ILCompiler.ReadyToRun.Tests/​TestCases/​Webcil/​WasmSimdModule.cs Adds vector tuple fixtures.
src/​coreclr/​tools/​aot/​ILCompiler.ReadyToRun.Tests/​TestCases/​R2RTestSuites.cs Checks layout fixups across compilation modes.
docs/​design/​coreclr/​botr/​readytorun-format.md Documents fixed Wasm vector layout.

🧠 Review effort: Balanced

Preserve the Vector<T> optimism policy in InstructionSetSupport and use it for fixed-layout decisions instead of special-casing Wasm. Cover fixed and optimistic configurations in regular and composite tests, and gate the tests on target vector support.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8f7879c0-2733-4f0e-a679-07cc5a1b6ad2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants