Files
ladybird/Tests/LibJS/Bytecode/expected/parameter-createvariable-order.txt
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

29 lines
1.4 KiB
Plaintext

JS bytecode executable ""
[ 0] 0: GetLexicalEnvironment dst:reg4
[ 8] GetGlobal dst:reg6, identifier:f
[ 20] Call dst:reg5, callee:reg6, this_value:Undefined, f, arguments:[Int32(1), Int32(2), Int32(3)]
[ 50] End value:reg5
JS bytecode executable "f"
[ 0] 0: GetLexicalEnvironment dst:reg4
[ 8] CreateVariable identifier:a, is_immutable:false, is_global:false, is_strict:false
[ 18] CreateVariable identifier:b, is_immutable:false, is_global:false, is_strict:false
[ 28] CreateVariable identifier:c, is_immutable:false, is_global:false, is_strict:false
[ 38] InitializeLexicalBinding identifier:a, src:arg0
[ 50] InitializeLexicalBinding identifier:b, src:arg1
[ 68] InitializeLexicalBinding identifier:c, src:arg2
[ 80] Mov dst:inner~0, src:Undefined
[ 90] NewFunction dst:reg5, shared_function_data_index:0, lhs_name:inner
[ a8] Mov2 dst1:inner~0, src1:reg5, dst2:reg6, src2:inner~0
[ c0] Call dst:reg5, callee:reg6, this_value:Undefined, inner
[ e0] Return value:reg5
JS bytecode executable "inner"
[ 0] 0: GetLexicalEnvironment dst:reg4
[ 8] GetBinding dst:reg5, identifier:a
[ 20] GetBinding dst:reg6, identifier:b
[ 38] Add dst:reg7, lhs:reg5, rhs:reg6
[ 48] GetBinding dst:reg5, identifier:c
[ 60] Add dst:reg6, lhs:reg7, rhs:reg5
[ 70] Return value:reg6