Files
ladybird/Tests/LibJS/Bytecode/expected/switch-completion-value.txt
Andreas Kling 51758f3022 LibJS: Make bytecode register allocator O(1)
Generator::allocate_register used to scan the free pool to find the
lowest-numbered register and then Vec::remove it, making every
allocation O(n) in the size of the pool. When loading https://x.com/
on my Linux machine, we spent ~800ms in this function alone!

This logic only existed to match the C++ register allocation ordering
while transitioning from C++ to Rust in the LibJS compiler, so now
we can simply get rid of it and make it instant. :^)

So drop the "always hand out the lowest-numbered free register" policy
and use the pool as a plain LIFO stack. Pushing and popping the back
of the Vec are both O(1), and peak register usage is unchanged since
the policy only affects which specific register gets reused, not how
aggressively.
2026-04-21 13:59:55 +02:00

111 lines
2.8 KiB
Plaintext

$bb1bc930 switch-completion-value.js:1:1
Registers: 11
Blocks: 1
Constants:
[0] = Undefined
[1] = String("switch(1) { case 1: 'hello'; let x = 1; }")
[2] = String("switch(1) { case 1: 'first'; 'second'; }")
[3] = String("switch(1) { case 1: 'matched'; break; default: 'default'; }")
block0:
[ 0] GetGlobal dst:reg6, `console`
[ 18] GetById dst:reg7, base:reg6, `log` (console.log)
[ 38] GetGlobal dst:reg9, `eval`
[ 50] CallDirectEval dst:reg8, callee:reg9, this_value:Undefined, eval, arguments:[String("switch(1) { case 1: 'hello'; let x = 1; }")]
[ 78] Call dst:reg5, callee:reg7, this_value:reg6, console.log, arguments:[reg8]
[ a0] GetGlobal dst:reg6, `console`
[ b8] GetById dst:reg8, base:reg6, `log` (console.log)
[ d8] GetGlobal dst:reg10, `eval`
[ f0] CallDirectEval dst:reg9, callee:reg10, this_value:Undefined, eval, arguments:[String("switch(1) { case 1: 'first'; 'second'; }")]
[ 118] Call dst:reg7, callee:reg8, this_value:reg6, console.log, arguments:[reg9]
[ 140] GetGlobal dst:reg8, `console`
[ 158] GetById dst:reg6, base:reg8, `log` (console.log)
[ 178] GetGlobal dst:reg10, `eval`
[ 190] CallDirectEval dst:reg9, callee:reg10, this_value:Undefined, eval, arguments:[String("switch(1) { case 1: 'matched'; break; default: 'default'; }")]
[ 1b8] Call dst:reg5, callee:reg6, this_value:reg8, console.log, arguments:[reg9]
[ 1e0] End value:reg5
eval$802caa65 line 1, column 1
Registers: 7
Blocks: 5
Locals: x~0
Constants:
[0] = Undefined
[1] = Int32(1)
[2] = String("hello")
block0:
[ 0] Mov dst:reg5, src:Undefined
block1:
[ 10] JumpStrictlyEquals lhs:Int32(1), rhs:Int32(1), true_target:block3, false_target:block2
block2:
[ 28] End value:reg5
block3:
[ 30] Mov2 dst1:reg5, src1:String("hello"), dst2:x~0, src2:Int32(1)
block4:
[ 48] End value:reg5
eval$e4733afc line 1, column 1
Registers: 7
Blocks: 5
Constants:
[0] = Undefined
[1] = Int32(1)
[2] = String("first")
[3] = String("second")
block0:
[ 0] Mov dst:reg5, src:Undefined
block1:
[ 10] JumpStrictlyEquals lhs:Int32(1), rhs:Int32(1), true_target:block3, false_target:block2
block2:
[ 28] End value:reg5
block3:
[ 30] Mov2 dst1:reg5, src1:String("first"), dst2:reg5, src2:String("second")
block4:
[ 48] End value:reg5
eval$94daef6a line 1, column 1
Registers: 7
Blocks: 6
Constants:
[0] = Undefined
[1] = Int32(1)
[2] = String("matched")
[3] = String("default")
block0:
[ 0] Mov dst:reg5, src:Undefined
block1:
[ 10] JumpStrictlyEquals lhs:Int32(1), rhs:Int32(1), true_target:block3, false_target:block2
block2:
[ 28] Jump target:block4
block3:
[ 30] Mov dst:reg5, src:String("matched")
[ 40] End value:reg5
block4:
[ 48] Mov dst:reg5, src:String("default")
block5:
[ 58] End value:reg5
"hello"
"second"
"matched"