[Wasm RyuJIT] Use offset reloc for call indirection-cell loads#127654
Draft
[Wasm RyuJIT] Use offset reloc for call indirection-cell loads#127654
Conversation
…s in Wasm RyuJIT calls Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/b83ac7fa-44cd-4275-b00e-efcd272eb66d Co-authored-by: adamperlin <10533886+adamperlin@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Optimize call codegen by switching to offset reloc
[Wasm RyuJIT] Use offset reloc for call indirection-cell loads
May 1, 2026
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wasm RyuJIT call codegen dereferences the indirection cell with
i32.const <reloc> ; i32.add ; i32.load 0, using aWASM_MEMORY_ADDR_REL_SLEBconst reloc. The two scaffolding instructions (i32.const_address,i32.add) can be folded into the load itself by emitting the relocation as the load'soffsetimmediate (WASM_MEMORY_ADDR_REL_LEB), shrinking every helper/indirect call site.Before:
After:
Changes
emitwasm.cpp—IF_MEMARGencoding: route the offset immediate throughemitOutputConstant(..., UNSIGNED, WASM_MEMORY_ADDR_REL_LEB)so aidIsCnsReloc()instruction emits a padded-ULEB128 reloc in the offset slot; non-reloc cases keep the plain ULEB128 path. Size calculation already accounted for this.emitwasm.{h,cpp}— new helperemitter::emitLoadAtAddressConstant(instruction ins, void* address): emitsglobal.get $__r2r_start+<ins> offset=<reloc>for anyIF_MEMARGload/store, asserting the format.codegenwasm.cpp—genEmitHelperCall: replace bothemitAddressConstant(addr) + emitIns_I(INS_I_load, EA_PTRSIZE, 0)pairs (managed-helper PEP push andEC_INDIR_Rindirection-cell deref) withemitLoadAtAddressConstant(INS_I_load, addr). The trailing PEP-deref load onEC_INDIR_Ris unchanged.emitAddressConstantis retained forgenCodeForConstant, which takes an address rather than dereferencing it.