Repository navigation
Absolute/global addressing changes for native AOT/WASM - #135768
MichalStrehovsky merged 2 commits into
Conversation
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
|
Azure Pipelines: Successfully started running 6 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.
🔵 Needs a closer look
Cross-layer codegen and relocation changes need maintainer review and reproducible validation beyond the reported combined-tree probes; no builds or tests were run here.
1 open finding
What changed in this PR
Advances NativeAOT/WASI support by using linker-relocated absolute addresses while preserving CoreCLR’s image-relative addressing.
Changes:
- Selects absolute relocations for NativeAOT addresses and JIT data.
- Folds global memory accesses into relocated offsets.
- Maps function-address relocations to table indices.
| File | Description |
|---|---|
| src/coreclr/tools/Common/Compiler/ObjectWriter/WasmRelocatableObjectWriter.cs | Maps absolute function relocations to table indices. |
| src/coreclr/jit/lowerwasm.cpp | Enables NativeAOT global-address folding. |
| src/coreclr/jit/lir.h | Documents expanded FoldedAddr semantics. |
| src/coreclr/jit/emitwasm.cpp | Selects absolute or image-relative address emission. |
| src/coreclr/jit/codegenwasm.cpp | Emits zero-base folded global accesses. |
🧠 Review effort: Balanced
This is so we can emit proper relocs, not offsets from__image_base. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: c78266f3-08e3-4918-b2e5-9fe0ddf2ca17
6d201e7 to
cdf64b2
Compare
|
@dotnet/jit-contrib could someone have a look? this is blocking progress for native AOT WASM. We cannot start testing anything in the CI if memory access doesn't work and native AOT WASM already got broken twice since I started working on it. |
adamperlin
left a comment
There was a problem hiding this comment.
Looking now! This one was on my list.
|
@MichalStrehovsky I'm not sure we need to use LIR::Flags::FoldedAddr here. I think for NativeAOT address codegen can just be a relocated constant for the absolute address like: If there's no base/offset split in the addr then I don't think we save any instructions by using the FoldedAddr flag. |
Materialize relocated absolute addresses directly and use the ordinary zero-offset store path. Keep FoldedAddr limited to local frame addresses. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: c78266f3-08e3-4918-b2e5-9fe0ddf2ca17
Yeah, the form in the PR matches clang codegen but there doesn't seem to be an advantage in that. |
|
/ba-g lots of mutex failures that are known |

Part of a series of pull requests that enable compiling, linking, and running a
Console.WriteLinehello world on WASI/native AOT.Summary
Use linker-relocated absolute addresses for NativeAOT Wasm instead of CoreCLR's image-base-relative model:
WASM_MEMORY_ADDR_SLEBrelocations to table-index relocations.emitImageBase()remains R2R-only, and CoreCLR's image-relative paths are unchanged. This matches the WASI SDK clang non-PIC global-access model.Validation
.\src\coreclr\build-runtime.cmd -checked -x64 -component wasmjit- passed.verify-global-codegen.ps1- 10/10 methods passed compilation, object/executable validation, and Wasmtime execution; 30 value comparisons passed across integer, long, double, address-taking, and nonzero field-offset cases.These results are from the combined local bringup tree, including prerequisite NativeAOT/Wasm enablement, not a fresh build of this isolated main-based branch. The probe scripts are local fixtures, not tests added by this PR.
Note
This PR description was generated by GitHub Copilot.