mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
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.
16 lines
223 B
JavaScript
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());
|