Files
ladybird/Tests/LibJS/Bytecode/input/mov-merging.js
Andreas Kling 31606fddd3 LibJS: Add Mov2/Mov3 instructions to reduce dispatch overhead
Add Mov2 and Mov3 bytecode instructions that perform 2 or 3 register
moves in a single dispatch. A peephole optimization pass during
bytecode assembly merges consecutive Mov instructions within each
basic block into these combined instructions.

When merging, identical Movs are deduplicated (e.g. two identical Movs
become a single Mov, not a Mov2). This optimization is implemented in
both the C++ and Rust codegen pipelines.

The goal is to reduce the per-instruction dispatch overhead, which is
significant compared to the actual cost of moving a value.

This isn't fancy or elegant, but provides a real speed-up on many
workloads. As an example, Kraken/imaging-desaturate.js improves by
~1.07x on my laptop.
2026-03-11 17:04:32 +01:00

16 lines
223 B
JavaScript

function twoLocals() {
let a = 1;
let b = 2;
return a + b;
}
function threeLocals() {
let a = 1;
let b = 2;
let c = 3;
return a + b + c;
}
console.log(twoLocals());
console.log(threeLocals());