Repository navigation
[wasm] Fix v128.load / v128.store opcodes in the R2R ObjectWriter - #130941
Merged
Merged
Conversation
The WasmExprKind opcode constants for the two 128-bit memory instructions
were wrong:
V128Load = 0xFD00000A // sub-opcode 0x0A is v128.load64_splat
V128Store = 0xFD000000 // sub-opcode 0x00 is v128.load
The SIMD sub-opcodes are v128.load = 0x00 and v128.store = 0x0B, so
V128.Store() emitted a v128.load and V128.Load() emitted a v128.load64_splat.
Any thunk that spills/reloads a v128 argument (e.g. the delay-load helper for
a method call with Vector128<T> parameters) therefore produced an invalid
module ("v128.load[0] expected type i32, found ... v128") or a corrupted
vector (load64_splat reads 8 bytes and splats instead of loading the full 16).
Correct both to v128.load = 0xFD 0x00 and v128.store = 0xFD 0x0B. Audited the
rest of the WasmExprKind opcodes (base, 0xFC bulk-memory/table, SIMD) against
the spec; these two were the only incorrect entries.
This was latent until Vector128<T> began flowing through these thunks by value.
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @agocke |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR corrects the WebAssembly SIMD opcode constants used by the R2R wasm ObjectWriter so that v128.load / v128.store are encoded with the proper 0xFD-prefixed sub-opcodes.
Changes:
- Fix
WasmExprKind.V128Loadto use sub-opcode0x00(v128.load). - Fix
WasmExprKind.V128Storeto use sub-opcode0x0B(v128.store).
tannergooding
approved these changes
Jul 17, 2026
lewing
enabled auto-merge (squash)
July 17, 2026 01:46
Member
|
/ba-g unrelated windows x86 COMInterface/LibraryImport test, also failing on other PRs |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
The
WasmExprKindopcode constants for the two 128-bit memory instructions in the R2R wasm ObjectWriter were wrong:The SIMD sub-opcodes are
v128.load=0x00andv128.store=0x0B(the encoder writes byte 0 =kind >> 24=0xFDprefix, then the low 24 bits as the ULEB sub-opcode). SoV128.Store()emitted av128.loadandV128.Load()emitted av128.load64_splat.Any thunk that spills/reloads a
v128argument — e.g. the delay-load helper for a method call withVector128<T>parameters — therefore produced an invalid module:(the "store" was actually a load, consuming the v128 value as the address), or, on the reload side, a corrupted vector (
load64_splatreads 8 bytes and splats them instead of loading the full 16).Fix
I audited the rest of the
WasmExprKindopcodes (base,0xFCbulk-memory/table, SIMD) against the spec — these two were the only incorrect entries.Why it was latent
Nothing emitted
V128.Store/V128.LoaduntilVector128<T>began flowing through these thunks by value (the wasm v128 ABI work in #130866). Verified end-to-end on the R2R-on-wasm prototype: with this fix, aVector128method call whose delay-load thunk spills/reloads the vector produces a valid module that executes correctly as R2R (the emitted thunk now showsv128.storeon spill andv128.loadon reload). Helps unblock #130866.Note
This pull request was authored with the assistance of GitHub Copilot.