Repository navigation
JIT: use v128.store for 16-byte wasm zero fills - #137517
Merged
Merged
Conversation
Extend genWasmZeroInit to emit i32.const 0; i8x16.splat; v128.store for constant 16-byte zero fills instead of memory.fill. The splat form is 14 bytes smaller than a zero v128.const and no slower. Co-authored-by: Copilot App <[email protected]>
|
Azure Pipelines: Successfully started running 6 pipeline(s). 9 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: @JulieLeeMSFT, @jakobbotsch |
Member
Author
|
It is a microptimization but considerably faster in the cold case at the cost of a byte |
AndyAyersMS
approved these changes
Nov 13, 2026
Contributor
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
lewing
enabled auto-merge (squash)
November 13, 2026 20:58
Member
Author
|
/ba-g issues created for untracked and unrelated failures |
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.
Follow-up to #137234.
genWasmZeroInitnow emitsi32.const 0; i8x16.splat; v128.storefor constant 16-byte zero fills instead ofmemory.fill. This covers frame zero-init, constant localloc, native initblk and GC-ref zeroing. CoreCLR browser-wasm already requires SIMD.i8x16.splatis used rather than a zerov128.constbecause it is 14 bytes smaller per site (8 vs 22 bytes) and was never slower in the measurements below. It is 1 byte larger than thememory.fillsequence (7 bytes).Size
In a composite R2R browser-wasm publish of a small test app (CoreLib + System.Console + app), 300 of 321 16-byte
memory.fillsites (of 1,539 totalmemory.fills) becamev128.store. The composite image grew from 2,449,568 to 2,449,856 bytes (+288 B).Speed
Pure-wasm microbenchmark, 16-byte zero fill, net ns per fill, Apple M5 Max:
memory.filli8x16.splat+v128.storev128.const 0+v128.storenode --liftoff-only)node --no-liftoff)jsc --useOMGJIT=false)Both baseline tiers compile
memory.fillas an out-of-line call, so code that has not tiered up gains the most. V8's--print-wasm-codeshows both v128 forms as a singlestr q0on arm64.Composite R2R browser-wasm app on node (best of 7 per run, 5 interleaved runs, ns/op). These loops run long enough to tier up:
arr[i] = defaultfor 16-byte structs (twolongs, four refs,Guid,decimal, mixed)List<(string,string,string,string)>Add/RemoveAt,Dictionary<Guid,object>set/remove, decimal mathThe A/B used JITs built from the same commit, swapped into the same crossgen2 and runtime pack. Another build was running on the machine during part of the measurements.
Validation
./build.sh clr.crossarchtools -os browser -arch wasm -c Release /p:RuntimeFlavor=CoreCLRpassed at this commit../build.sh clr.crossarchtools -os browser -arch wasm -c Checked /p:RuntimeFlavor=CoreCLRpassed at this commit.python3 src/coreclr/scripts/jitformat.py -a arm64 -o osx -r <repo>passed with no changes.62278fed5a1, the composite R2R publish (PublishReadyToRun=true,PublishReadyToRunComposite=true) compiled with no asserts under a Checked JIT. The resulting app ran with checksums matching the baseline.Contributes to #135985.
Note
This PR description was generated with GitHub Copilot.