Skip to content

JIT/wasm: bail R2R for calls passing 16-byte SIMD by value#129816

Merged
AndyAyersMS merged 1 commit into
dotnet:mainfrom
AndyAyersMS:fix-wasm-simd-call-arg-bail
Jun 25, 2026
Merged

JIT/wasm: bail R2R for calls passing 16-byte SIMD by value#129816
AndyAyersMS merged 1 commit into
dotnet:mainfrom
AndyAyersMS:fix-wasm-simd-call-arg-bail

Conversation

@AndyAyersMS

Copy link
Copy Markdown
Member

On wasm, building a call_indirect signature emits v128 for a 16-byte SIMD
(Vector128/Vector<T>) argument passed by value, but codegen materializes that
argument as an i32 (a by-ref pointer) — so the pushed value (local.get of an
i32) doesn't match the v128 the signature requires, and the whole module fails
WebAssembly.Module() validation (call_indirect[N] expected type v128, found local.get of type i32).

This blocks R2R compilation of System.Private.CoreLib (59 SIMD methods —
Vector128.Shuffle/Round, Vector<T>.Equals, the ISimdVector WhereAllBitsSet
helpers, etc. — all fail identically).

Until the SIMD-by-value call ABI is implemented, mark such methods
R2R-unsupported via NYI_WASM_SIMD (consistent with the existing
SIMD16 local load bail), so they fall back to the interpreter and the module
validates. With this change System.Private.CoreLib.wasm validates cleanly
(0 invalid functions, was 59).

Passing a Vector128 (v128) argument by value through a call is not yet
correctly implemented on wasm: the argument is materialized as an i32
(by-ref) while the call signature requires v128, producing an invalid
module. Mark such methods R2R-unsupported via NYI_WASM_SIMD until the
SIMD call ABI is implemented. Lets System.Private.CoreLib.wasm validate.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 24, 2026 18:43
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 24, 2026
@AndyAyersMS AndyAyersMS requested a review from adamperlin June 24, 2026 18:44
@AndyAyersMS

Copy link
Copy Markdown
Member Author

@adamperlin PTAL

Hopefully this is surgical enough and won't mess with your work.

fyi @dotnet/wasm-contrib

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.

Pull request overview

This PR updates the WASM JIT code generator to proactively bail out of ReadyToRun (R2R) compilation when generating a call signature that includes a v128 (SIMD16) argument passed by value, using NYI_WASM_SIMD to mark the method as R2R-unsupported instead of emitting an invalid WebAssembly module.

Changes:

  • Detect WasmValueType::V128 call arguments when building the wasm-level call signature in CodeGen::genCallInstruction.
  • Invoke NYI_WASM_SIMD("SIMD16 call argument") to fail R2R compilation for these cases, avoiding invalid wasm validation scenarios.

@pavelsavara pavelsavara added the arch-wasm WebAssembly architecture label Jun 24, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

@adamperlin adamperlin 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.

This looks good to me, I don't think this will affect my work for the time being. Thanks for putting this fix in place!

@AndyAyersMS AndyAyersMS merged commit cd27dce into dotnet:main Jun 25, 2026
148 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants