Fix wasm R2R JIT validation issues#129555
Conversation
- Use call node type when forming wasm call signatures. - Treat GT_FRAME_SIZE as a wasm leaf during use-edge iteration. - Classify single-register struct call stores by wasm ABI type. - Preserve ABI segment widths for wasm parameter register remaps. - Bail out on wasm method/call signatures over the engine limit. Issue: dotnet#129497 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@adamperlin PTAL |
There was a problem hiding this comment.
Pull request overview
This PR adjusts WebAssembly (Wasm) JIT/R2R codegen plumbing to produce wasm-valid call/method signatures and to avoid validation/assert failures in several JIT phases when compiling for Wasm.
Changes:
- Update Wasm call signature construction and add explicit bailouts when a call/function would exceed the Wasm engine parameter limit (1000).
- Treat
GT_FRAME_SIZEas a leaf for Wasm during use-edge iteration to avoid consumers assuming it has operands. - Refine Wasm ABI typing in lowering for single-register struct call stores and preserve ABI segment widths when inducing parameter-register locals.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/jit/lower.cpp | Adjusts Wasm ABI-based typing for single-reg struct call stores; preserves register-segment type widths for induced parameter locals. |
| src/coreclr/jit/lclvars.cpp | Adds a Wasm-specific compilation bailout when the function argument count exceeds the Wasm engine limit. |
| src/coreclr/jit/gentree.cpp | Treats GT_FRAME_SIZE as a leaf for Wasm in GenTreeUseEdgeIterator. |
| src/coreclr/jit/error.h | Introduces WASM_IMPL_LIMITATION macro (Wasm-only impl-limitation helper). |
| src/coreclr/jit/compiler.h | Defines MaxWasmFunctionParameters constant for Wasm. |
| src/coreclr/jit/codegenwasm.cpp | Adjusts wasm call signature construction and adds a call-argument-count bailout prior to requesting a type symbol. |
For fast tail calls gtType is overwritten to TYP_VOID, so use gtReturnType when forming the wasm call signature. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cross-try-exit Block intervals are backdated to start at the try header, breaking the non-decreasing-start-order invariant assumed by the resolve loop.
|
Not entirely happy with the "backdate" fix for branches out of try interval. Seems like constraint solving ought to be able to handle it, if a block overlaps a try (and since trys are single entry this means the block begins inside the try and ends outside) it should just stretch to encompass the try and (now) the two wrapper intervals. Some of the other fixes are consequences of codegen inserting code (namely the post-try unreached and exception-capturing store) without having IR; this may also be something to revisit. |
Wasm R2R doesn't use personality routines in unwind data, so fall back to the slow EH-clause walk like X86 does.
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
Pri-0 R2R sweep impact
A separate Pri-1 sweep on top of these commits shows 1738 / 1909 tests pass (91.0%). No new R2R-specific failure modes surfaced in the broader Pri-1 set; remaining wrapper failures are tracked separately in #129622 and #129337. |
Wasm uses stack-slot GC info encoding rather than fixed-register tracking, so the emitter concern this assert guards (live updates for LCL_ADDR DEFs of tracked GC vars) does not apply.
davidwrighton
left a comment
There was a problem hiding this comment.
VM changes look good. JIT looks good too, but I'm not a good reviewer of JIT changes. :)
GT_FRAME_SIZEas a wasm leaf during use-edge iteration.findTargetDepthfor plain br targets.IsFilterFuncletpath for wasm R2R (wasm doesn't use personality routines in unwind data). (fixes Wasm / R2R: IsFilterFunclet assertion fires when re-throwing from a finally after a cctor failure (throwinclassconstructor) #129341)Issue: #129497