Uh oh!
There was an error while loading. Please reload this page.
Add WASM_MEMORY_ADDR_REL_LEB Relocation Type - #126676
Conversation
- This is used to make loads/stores more efficient. loads/stores have an offset baked into them, so instead of global.get 1 i32.const <reloc> add i32.load We can do global.get 1 i32.load offset=<reloc> Overall this saves 3 bytes of space per load from an RVA relative address
There was a problem hiding this comment.
Pull request overview
Adds a new WebAssembly relocation kind to represent an image-base-relative memory offset encoded as ULEB128, enabling R2R scenarios where the relocation can be used directly as the offset immediate of a load/store (paired with global.get $__image_base).
Changes:
- Introduces
WASM_MEMORY_ADDR_REL_LEBinCorInfoRelocandRelocType, plus the managed JIT-interface mapping. - Extends the Wasm object writer relocation resolver to apply
WASM_MEMORY_ADDR_REL_LEB. - Refactors Wasm instruction encoding to allow memory-arg offsets to be either constants or relocatable symbols; adds
I32.LoadWithRVAOffset(...). - Bumps the JIT/EE versioning GUID for the interface change.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs | Adds new CorInfoReloc enum member for wasm relative memory offset (ULEB). |
| src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs | Maps new CorInfoReloc to RelocType. |
| src/coreclr/tools/Common/Compiler/ObjectWriter/WasmObjectWriter.cs | Adds relocation resolution logic for WASM_MEMORY_ADDR_REL_LEB. |
| src/coreclr/tools/Common/Compiler/ObjectWriter/WasmInstructions.cs | Generalizes memory-arg encoding to support relocatable offsets; adds helper API. |
| src/coreclr/tools/Common/Compiler/DependencyAnalysis/Relocation.cs | Adds RelocType value and read/write/size support for the new relocation. |
| src/coreclr/inc/jiteeversionguid.h | Updates JIT/EE version GUID due to interface change. |
| src/coreclr/inc/corinfo.h | Adds the native CorInfoReloc enum member. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…n.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…erlin/runtime into adamperlin/wasm-addr-rel-leb-reloc
3197172 to
bddab45CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This PR contains one of @davidwrighton's commits extracted from #126662 to reduce the PR size and complexity. It adds a relocation type that is essentially
R_WASM_MEMORY_ADDR_REL_LEB, so that a relocation corresponding to a relative offset from r2rimageBasecan be used directly as theoffsetin a load, like:The functionality isn't used yet, but will be in #126662.