Files
ladybird/Tests/LibJS/Bytecode/expected/nested-try-finally-continue.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

129 lines
3.0 KiB
Plaintext

$058cd786 nested-try-finally-continue.js:14:1
Registers: 7
Blocks: 1
Constants:
[0] = Undefined
block0:
[ 0] GetGlobal dst:reg6, `nestedTryFinallyContinue`
[ 18] Call dst:reg5, callee:reg6, this_value:Undefined, nestedTryFinallyContinue
[ 38] End value:reg5
nestedTryFinallyContinue$f4bfe0d3 nested-try-finally-continue.js:2:5
Registers: 13
Blocks: 24
Locals: i~0
Constants:
[0] = Int32(0)
[1] = Int32(3)
[2] = Int32(1)
[3] = String("inner")
[4] = Int32(2)
[5] = Undefined
[6] = String("outer")
block0:
[ 0] GetLexicalEnvironment dst:reg4
[ 8] Mov dst:i~0, src:Int32(0)
[ 18] Jump target:block3
block1:
[ 20] Jump target:block7
block2:
[ 28] PostfixIncrement dst:reg5, src:i~0
block3:
[ 38] JumpLessThan lhs:i~0, rhs:Int32(3), true_target:block1, false_target:block4
block4:
[ 50] End value:Undefined
block5:
[ 58] Catch dst:reg6
[ 60] SetLexicalEnvironment environment:reg4
[ 68] Mov dst:reg5, src:Int32(1)
block6:
[ 78] GetGlobal dst:reg8, `console`
[ 90] GetById dst:reg9, base:reg8, `log` (console.log)
[ b0] Mov dst:reg11, src:i~0
[ c0] Call dst:reg7, callee:reg9, this_value:reg8, console.log, arguments:[String("outer"), reg11]
[ e8] JumpStrictlyEquals lhs:reg5, rhs:Int32(0), true_target:block19, false_target:block20
block7:
[ 100] Jump target:block10
block8:
[ 108] Catch dst:reg8
[ 110] SetLexicalEnvironment environment:reg4
[ 118] Mov dst:reg7, src:Int32(1)
block9:
[ 128] GetGlobal dst:reg10, `console`
[ 140] GetById dst:reg11, base:reg10, `log` (console.log)
[ 160] Mov dst:reg12, src:i~0
[ 170] Call dst:reg9, callee:reg11, this_value:reg10, console.log, arguments:[String("inner"), reg12]
[ 198] JumpStrictlyEquals lhs:reg7, rhs:Int32(0), true_target:block14, false_target:block15
block10:
[ 1b0] JumpStrictlyEquals lhs:i~0, rhs:Int32(1), true_target:block11, false_target:block12
block11:
[ 1c8] Mov dst:reg7, src:Int32(3)
[ 1d8] Jump target:block9
block12:
[ 1e0] Mov dst:reg7, src:Int32(0)
[ 1f0] Jump target:block9
block13:
[ 1f8] Mov dst:reg5, src:Int32(3)
[ 208] Jump target:block6
block14:
[ 210] Mov dst:reg5, src:Int32(0)
[ 220] Jump target:block6
block15:
[ 228] JumpStrictlyEquals lhs:reg7, rhs:Int32(3), true_target:block13, false_target:block16
block16:
[ 240] JumpStrictlyEquals lhs:reg7, rhs:Int32(2), true_target:block17, false_target:block18
block17:
[ 258] Mov2 dst1:reg5, src1:reg7, dst2:reg6, src2:reg8
[ 270] Jump target:block6
block18:
[ 278] Throw src:reg8
block19:
[ 280] Jump target:block2
block20:
[ 288] JumpStrictlyEquals lhs:reg5, rhs:Int32(3), true_target:block2, false_target:block21
block21:
[ 2a0] JumpStrictlyEquals lhs:reg5, rhs:Int32(2), true_target:block22, false_target:block23
block22:
[ 2b8] Return value:reg6
block23:
[ 2c0] Throw src:reg6
Exception handlers:
[ 100 .. 1b0] => handler block5
[ 1b0 .. 210] => handler block8
[ 210 .. 280] => handler block5
"inner" 0
"outer" 0
"inner" 1
"outer" 1
"inner" 2
"outer" 2