Repository navigation
Handle cross-targeting Vector<T> size mismatch in the JIT - #130873
tannergooding merged 2 commits into
Conversation
getBaseTypeAndSizeOfSIMDType asserts that the JIT-computed SIMD size equals the VM's class size. Vector<T> is the only case whose size is target-dependent (getVectorTByteLength), so under a cross-targeting altjit -- e.g. SuperPMI replaying an x64-captured context with the wasm altjit, where the recorded class size reflects the host's Vector<T> length -- the two legitimately differ. Rather than relax the assert and carry a size the VM disagrees with (which would leave later size queries inconsistent and emit misleading SIMD codegen), treat Vector<T> as a regular struct when the sizes disagree, the same way the FEATURE_HW_INTRINSICS path already degrades on an unrecognized size. This keeps every size query consistent with the VM and only affects mismatched-VM altjit scenarios; matched VMs are unchanged. Co-authored-by: Copilot App <[email protected]>
|
Azure Pipelines: Successfully started running 5 pipeline(s). 10 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
Pull request overview
This PR updates the JIT’s SIMD type classification for System.Numerics.Vector<T> to avoid failing internal invariants when the JIT target and the VM’s recorded type layout don’t match (e.g., cross-targeting altjit/SuperPMI replay scenarios). The change makes the JIT treat Vector<T> as a regular struct (non-SIMD) when the JIT-computed Vector<T> size disagrees with the VM’s getClassSize, preventing downstream SIMD codegen from operating on an inconsistent size.
Changes:
- Add a
Vector<T>-specific size-consistency check ingetBaseTypeAndSizeOfSIMDType. - Degrade
Vector<T>to non-SIMD (TYP_UNDEF) when the JIT’sgetVectorTByteLength()disagrees with the VM’s recorded class size.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/jit/simd.cpp | Adds a Vector<T> size mismatch guard to avoid asserting/using inconsistent SIMD sizes under cross-targeting scenarios. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 1
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
|
CC. @dotnet/jit-contrib, @adamperlin, removes one of the WASM SPMI asserts and generally improves the mismatched VM (altjit) scenario for cases where the collection hasn't forced the Vector size using the JIT config knob. |
adamperlin
left a comment
There was a problem hiding this comment.
This looks good to me.
getBaseTypeAndSizeOfSIMDTypeasserts that the JIT-computed SIMD size equals the VM's class size.Vector<T>is the only case whose size is target-dependent (getVectorTByteLength), so under a cross-targeting altjit -- e.g. SuperPMI replaying an x64-captured context with the wasm altjit, where the recorded class size reflects the host'sVector<T>length -- the two legitimately differ and the assert fires (simd.cpp (448), duringMorph - Inlining, overSystem.Numerics.Vector<T>methods).Rather than relax the assert and carry a size the VM disagrees with (which would leave later size queries inconsistent and emit misleading SIMD codegen), treat
Vector<T>as a regular struct when the sizes disagree -- the same way theFEATURE_HW_INTRINSICSpath already degrades on an unrecognized size. This keeps every size query consistent with the VM and only affects mismatched-VM altjit scenarios; matched VMs are unchanged (theresize == getClassSizealways holds, exactly what the existing assert guarantees).Validated via SuperPMI base-vs-diff over the libraries MCH (
libraries_tests_no_tiered_compilation.run, 397,158 contexts) with the wasm altjit andJitWasmSimdNyiToR2RUnsupported=1:simd.cpp (448)Total assert occurrences drop by exactly 137 with no new signatures introduced; the formerly-asserting
Vector<T>methods now replay as SuperPMI misses (a collection gap already tolerated for the wasm SIMD-NYI path).Note
This PR description was drafted by Copilot.