[Wasm RyuJit] Debug SPC Wasm Validation Fixes#125852
[Wasm RyuJit] Debug SPC Wasm Validation Fixes#125852AndyAyersMS wants to merge 9 commits intodotnet:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR targets WebAssembly RyuJit “Debug SPC” validation failures by adjusting Wasm calling signatures and fixing/guarding several codegen and lowering cases that produce invalid Wasm.
Changes:
- Update Wasm method signature lowering to include generic-context and async-continuation hidden arguments.
- Fix/adjust Wasm codegen for relop result typing, shift amount typing, and selected intrinsics with mixed operand/result widths.
- Add a Wasm-only JIT config (
JitR2RUnsupportedRange) to force R2R-unsupported bailouts for selected method hashes.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/tools/Common/JitInterface/WasmLowering.cs | Extends Wasm signature construction to include async continuation + generic context hidden args. |
| src/coreclr/jit/morph.cpp | Tweaks struct arg field list creation for Wasm to use the segment register type. |
| src/coreclr/jit/jitconfigvalues.h | Adds JitR2RUnsupportedRange config string under TARGET_WASM. |
| src/coreclr/jit/codegenwasm.cpp | Fixes several Wasm instruction typing issues; adds CopyBlk NYI guard; updates intrinsic handling for mixed types. |
| src/coreclr/jit/codegencommon.cpp | Adds debug-only Wasm hook to fail R2R codegen for method-hash ranges. |
src/coreclr/jit/morph.cpp
Outdated
| // Note this will cause DNER if the arg was an unpromoted local. | ||
| // | ||
| #if defined(TARGET_WASM) | ||
| var_types slotType = regType; |
There was a problem hiding this comment.
This looks like something that needs to be handled in createSlotAccess, as another instance of LOWER_DECOMPOSE_LONGS == 0 problem. As-is we'll lose the GC types here (I don't have a clean change in mind though, it looks tricky for the general multi-reg case, and like we should really be passing regType down and making decisions based on that).
There was a problem hiding this comment.
I meant to bypass this for GC structs; I think the createSlotAccess logic works there, at least for now.
There was a problem hiding this comment.
I would suggest adding an overload of ABIRegisterSegment::GetRegisterType that takes ClassLayout and teaching it to return GC types appropriately, then switch the code here to always use the regType returned by that. I think multiple places can benefit from that.
There was a problem hiding this comment.
GetRegisterType(ClassLayout*, unsigned offset)?
There was a problem hiding this comment.
Ah I guess we can assume offset is part of the seg. Seems like we already have that overload.
There was a problem hiding this comment.
I don't think you need an offset version here, you can use the layout from the signature. Looks like the overload actually already exists. So probably
var_types regType = arg->GetSignatureLayout() != null ? seg.GetRegisterType(arg->GetSignatureLayout()) : seg.GetRegisterType()
would work.
There was a problem hiding this comment.
(actually layout can be used in place of arg->GetSignatureLayout())
There was a problem hiding this comment.
Yes. How do you feel about allowing GetRegisterType(nullptr)?
There was a problem hiding this comment.
Just changed this one spot. Verified no x64 diffs locally.
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
jakobbotsch
left a comment
There was a problem hiding this comment.
Morph changes look good to me. I think the arm64 diffs are fine (we stop doing some "out-of-bounds" loads resulting in fewer ldp's, I assume).
Fixes for validation issues 2, 3, 4, 5, and 7 for Debug SPC.
See #125756 (comment)
Also add another bail-out option
JitR2RUnsupportedRangethat causes the JIT to fail R2R compilations for methods with the indicated JIT hashes. This is useful for selectively suppressing JIT codegen that has validation failures so we can find the full set without having fixes (since the validator will stop at the first error).