Closed Bug 1929878 Opened 10 months ago Closed 10 months ago

Optimize array.copy for the different kinds of value types

Categories

(Core :: JavaScript: WebAssembly, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
134 Branch
Tracking Status
firefox134 --- fixed

People

(Reporter: yury, Assigned: yury)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

The array.copy instruction is very hot in GC applications and shows up in profiles. We currently do it with an instance builtin call [1] that is very generic and could be optimized quite a bit.

I think first generating a different Instance::arrayCopyX for {i8, i16, i32, i64, f32, f64, ref} and call the right one depending on the type of array.copy instruction would go a long way.

After that we could consider emitting some inline code if we think that would help.

[1] https://searchfox.org/mozilla-central/rev/1235dca15fb62be4357e9e6d78a0d8751ea173b6/js/src/wasm/WasmInstance.cpp#1792-1897

For barista3 test I profiled it for count of instructions. The existing code spends 32,623,195 ins in the function that is doing array.copy, after the change the number drops to 6,918,427 ins (4 times less). The latest code relies on numElements != 0 check, and if we remove it, the function executes 11,761,813 ins -- it's recommended to keep the check.

The patch changes how barriers are invoked.

Expose native array memory and refs copy operations.

Pushed by ydelendik@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d6cf2adcc82d [wasm-gc] Speed up arrayCopy operation. r=rhunt
Status: NEW → RESOLVED
Closed: 10 months ago
Resolution: --- → FIXED
Target Milestone: --- → 134 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: