Repository navigation
Conversation
|
Tagging @dotnet/jit-contrib for JIT-EE GUID update |
|
Azure Pipelines: Successfully started running 9 pipeline(s). 6 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: @dotnet/crossgen-contrib |
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
059c229 to
e0b9142
Compare
e0b9142 to
7f8b42a
Compare
ab53abe to
6aa48c5
Compare
6aa48c5 to
7419040
Compare
ab22d22 to
2e8f25d
Compare
f1d6bda to
5def9cd
Compare
Add wasm64 code generation to the Wasm JIT, teach crossgen2 to emit memory64 ReadyToRun Wasm/Webcil images, and wire up the runtime, CoreLib, framework, SDK and runtime-test lane for ReadyToRun on browser-wasm64. This removes the interim interpreter-only guards. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…wrappers Guard ExecutionManager::jumpStub/getNextJumpStub with HOST_64BIT && !TARGET_WASM, matching the other Wasm exclusions in codeman; only native targets call them. Describe the memory64 ReadyToRun wrapper imports and patchWebcilHeader in webcil.md. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
TargetsWasm and CLR_CMAKE_TARGET_ARCH_WASM now cover both widths, so use them instead of comparing arch names, and CLR_CMAKE_TARGET_ARCH_WASM64 for the wasm64-only gcinfo library. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Follow the WASMARCH naming: bare TARGET_WASM, CLR_CMAKE_TARGET_ARCH_WASM and TargetsWasm now mean 32-bit, so the ReadyToRun layer's any-width checks use TARGET_WASMARCH, CLR_CMAKE_TARGET_ARCH_WASMARCH and TargetsWasmArch. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
TARGET_WASM now means 32-bit Wasm, so accept TARGET_WASMARCH in the JIT's target-exclusivity checks, and teach SuperPMI about a wasm64 target. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
ReadyToRun now supports wasm64, so stop marking AlwaysUseCrossGen2 tests unsupported there. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
5def9cd to
5a11463
Compare
davidwrighton
left a comment
There was a problem hiding this comment.
I've looked through this, and fundamentally it looks good. Just a few issues that I found.
| aDstRW[i].Resume = (target_size_t)(uintptr_t)emitAsyncResumeStubEntryPoint; | ||
| aDstRW[i].Resume = (target_size_t)(uintptr_t)emitAsyncResumeStubEntryPoint; | ||
| #ifdef TARGET_WASMARCH | ||
| // The method-relative virtual IP relocation supplies only the low 32 bits, so leave no |
There was a problem hiding this comment.
Either the new comment or the new code is the wrong change here. We've tested the Wasm32 scenario enough, that we should probably fix the original logic to work. That will probably imply adding a new WASM_METHOD_RELATIVE_VIRTUAL_IP_I64 for this scenario and using that in 64bit wasm. If the new code is correct, we should be making this change in a separate PR, since it affects Wasm32 behavior.
There was a problem hiding this comment.
Agreed, I went with the new relocation type in d64ede2. I added WASM_METHOD_RELATIVE_VIRTUAL_IP_I64 (bumping the JIT-EE GUID) and use it for wasm64's 8-byte DiagnosticIP. The wasm32 lines in emit.cpp are restored exactly as they were, with the zeroing gone. The old wasm32 output was already correct: the field is 4 bytes there, so the _I32 relocation overwrote all of it. crossgen2 maps both types through the same virtual-IP fixups. Compiling CoreLib for wasm32 with the old and new JIT gives a byte-identical R2R image.
Note
This reply was generated with GitHub Copilot.
Auto-replied by the GitHub Copilot app
|
|
||
| if (ActualTypeToWasmValueType(genActualType(treeNode->AsOp()->gtOp1->TypeGet())) == WasmValueType::I64) | ||
| { | ||
| // br_table takes an i32 even on wasm64. Saturate rather than wrap so large |
There was a problem hiding this comment.
There is a comment in Compiler::optCreateJumpTableImpliedAssertions that GT_SWITCH is expected to be TYP_INT. Please understand and explain what's happening here.
There was a problem hiding this comment.
This is the native-int switch case. IL can switch on a native int as well as an int32 (the importer asserts genActualTypeIsIntOrI), and on wasm64 a native int is TYP_LONG, so GT_SWITCH can carry a long operand there. On other 64-bit targets that never reaches codegen: LowerSwitch expands to GT_SWITCH_TABLE and widens the index to TYP_I_IMPL. Wasm returns early from LowerSwitch to keep GT_SWITCH for br_table. br_table's index is always i32, even with memory64/table64, because table64 only changes the table instructions (call_indirect, table.get/set, etc.). So codegen narrows the index with saturation, which keeps out-of-range values going to the default.
optCreateJumpTableImpliedAssertions already bails for non-TYP_INT operands, so the only effect there is that this rare shape gets no assertions. Turning that comment into an assert would be wrong, since 64-bit targets can see native-int switches there too. I expanded the codegen comment in 775f975 to explain this.
Note
This reply was generated with GitHub Copilot.
Auto-replied by the GitHub Copilot app
There was a problem hiding this comment.
I do feel like it could be clearer to handle the i64 -> i32 conversion in LowerSwitch somehow. Maybe we could add an extra LIR cast/conversion for the index before the early return? If it's too messy though we could keep the codegen handling.
There was a problem hiding this comment.
Moved it into LowerSwitch in 0077ba9. It worked out cleanly with existing nodes. For a TYP_LONG index, wasm64 lowering inserts CAST(double <- ulong) and then CAST(uint <- double) before GT_SWITCH. Wasm float-to-int casts already use trunc_sat, so this is the same saturating sequence as before (f64.convert_i64_u + i32.trunc_sat_f64_u). genTableBasedSwitch now just asserts an i32 index. I tested a native-int switch on wasm64: in-range, -1, 2^32+1 and INT64_MAX all reach the right target. The wasm32 CoreLib R2R image is byte-identical.
Note
This reply was generated with GitHub Copilot.
Auto-replied by the GitHub Copilot app
…tive-int switches Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
5a11463 to
4f967ce
Compare
…ative virtual IP Add WASM_METHOD_RELATIVE_VIRTUAL_IP_I64 for wasm64's pointer-sized DiagnosticIP field, and restore the original wasm32 emit logic, whose 4-byte relocation already covers the whole field. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
| // treeNode - the compare tree | ||
| // | ||
| // Notes: | ||
| // On 64-bit targets lowering can turn a TYP_LONG GT_UDIV into a GT_GE that keeps its type. |
There was a problem hiding this comment.
Is this kind of handling done in codegen on other targets? Would it be appropriate to change the lowering for wasm?
There was a problem hiding this comment.
Other 64-bit targets do this too, just implicitly in codegen. xarch produces compare results with setcc plus a 32-bit movzx, and arm64 with cset. Both leave a zero-extended 0/1 in a full register that's already valid as TYP_LONG. Wasm's value stack is typed, so a TYP_LONG compare node needs an explicit i64.extend_i32_u after the i32 result. Doing it in lowering would mean retyping each TYP_LONG relop to TYP_INT and inserting a widening cast wherever one can appear; the UDIV→GE transform in LowerUnsignedDivOrMod is one source. That spreads Wasm-specific handling into shared lowering for a single instruction, so I'd prefer to keep it in codegen. Happy to change it if you feel strongly.
Note
This reply was generated with GitHub Copilot.
Auto-replied by the GitHub Copilot app
4f967ce to
769f7d7
Compare
Insert saturating casts in lowering so GT_SWITCH always reaches codegen with an i32 index for br_table, instead of narrowing in genTableBasedSwitch. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…rapped IL's module AsyncMethodIL.Module returned the variant's owning module even when the wrapped IL is a ManifestModuleWrappedMethodIL whose tokens live in the MutableModule, so cross-module-inlined async variants of CoreLib methods resolved tokens against the wrong metadata. Carried here until the main PR merges. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
769f7d7 to
350b4d6
Compare
Adds browser-wasm64 CoreCLR ReadyToRun. This is layer 2 of the stack, on top of #138166 (interpreter). Library outerloop CI follows in layer 3.
wasm64cross-JIT.WasmTargetPtr, plus the JIT interface, corinfo and helper updates.corelib.h/jitinterface.cppchanges and the R2R async resume-info (DiagnosticIP) fixup inreadytoruninfo.cpp.webcil.mddescribes the memory64 R2R wrapper (i64bases, table64,patchWebcilHeader(i64, i32)).Validated locally (macOS arm64, node 26):
./build.sh -s provision.emsdk+clr+libs -os browser -arch wasm64 -c Release -rc checkedpassed, producing the cross-JIT and an R2RSystem.Private.CoreLib.wasm.RunCrossGen2=1) on wasm64:readytorun/wasm/WasmInterpreterTransitionspassed.asyncmerged runner passed: 142 passed, 0 failed, 16 skipped. That includesasync/regression/125805../build.sh -s clr+libs -os browser -arch wasm -c Release -rc checkedpassed (wasm32 regression check). WasmInterpreterTransitions also passed under R2R on wasm32.Note
This PR description was generated with GitHub Copilot.