Files
ladybird/Tests/LibJS/Bytecode/expected/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

168 lines
4.1 KiB
Plaintext

$e54891d8 try-finally-continue.js:13:1
Registers: 11
Blocks: 1
Constants:
[0] = Undefined
block0:
[ 0] GetGlobal dst:reg6, `console`
[ 18] GetById dst:reg7, base:reg6, `log` (console.log)
[ 38] GetGlobal dst:reg9, `continueThroughFinally`
[ 50] Call dst:reg8, callee:reg9, this_value:Undefined, continueThroughFinally
[ 70] Call dst:reg5, callee:reg7, this_value:reg6, console.log, arguments:[reg8]
[ 98] GetGlobal dst:reg6, `console`
[ b0] GetById dst:reg8, base:reg6, `log` (console.log)
[ d0] GetGlobal dst:reg10, `breakThroughFinally`
[ e8] Call dst:reg9, callee:reg10, this_value:Undefined, breakThroughFinally
[ 108] Call dst:reg7, callee:reg8, this_value:reg6, console.log, arguments:[reg9]
[ 130] End value:reg7
continueThroughFinally$8372c35a try-finally-continue.js:2:5
Registers: 9
Blocks: 15
Locals: i~0, result~1
Constants:
[0] = Int32(0)
[1] = Int32(3)
[2] = Int32(1)
[3] = Int32(10)
[4] = Int32(2)
[5] = Undefined
block0:
[ 0] GetLexicalEnvironment dst:reg4
[ 8] Mov2 dst1:result~1, src1:Int32(0), dst2:i~0, src2:Int32(0)
[ 20] Jump target:block3
block1:
[ 28] Jump target:block7
block2:
[ 30] PostfixIncrement dst:reg5, src:i~0
block3:
[ 40] JumpLessThan lhs:i~0, rhs:Int32(3), true_target:block1, false_target:block4
block4:
[ 58] Return value:result~1
block5:
[ 60] Catch dst:reg6
[ 68] SetLexicalEnvironment environment:reg4
[ 70] Mov dst:reg5, src:Int32(1)
block6:
[ 80] Mov dst:reg8, src:result~1
[ 90] Add dst:reg7, lhs:reg8, rhs:Int32(10)
[ a0] Mov dst:result~1, src:reg7
[ b0] JumpStrictlyEquals lhs:reg5, rhs:Int32(0), true_target:block10, false_target:block11
block7:
[ c8] JumpStrictlyEquals lhs:i~0, rhs:Int32(1), true_target:block8, false_target:block9
block8:
[ e0] Mov dst:reg5, src:Int32(3)
[ f0] Jump target:block6
block9:
[ f8] Mov dst:reg7, src:result~1
[ 108] Add dst:reg8, lhs:reg7, rhs:i~0
[ 118] Mov2 dst1:result~1, src1:reg8, dst2:reg5, src2:Int32(0)
[ 130] Jump target:block6
block10:
[ 138] Jump target:block2
block11:
[ 140] JumpStrictlyEquals lhs:reg5, rhs:Int32(3), true_target:block2, false_target:block12
block12:
[ 158] JumpStrictlyEquals lhs:reg5, rhs:Int32(2), true_target:block13, false_target:block14
block13:
[ 170] Return value:reg6
block14:
[ 178] Throw src:reg6
Exception handlers:
[ c8 .. 138] => handler block5
breakThroughFinally$9e814d0d try-finally-continue.js:16:5
Registers: 9
Blocks: 15
Locals: i~0, result~1
Constants:
[0] = Int32(0)
[1] = Int32(10)
[2] = Int32(1)
[3] = Int32(2)
[4] = Int32(3)
[5] = Int32(100)
[6] = Undefined
block0:
[ 0] GetLexicalEnvironment dst:reg4
[ 8] Mov2 dst1:result~1, src1:Int32(0), dst2:i~0, src2:Int32(0)
[ 20] Jump target:block3
block1:
[ 28] Jump target:block7
block2:
[ 30] PostfixIncrement dst:reg5, src:i~0
block3:
[ 40] JumpLessThan lhs:i~0, rhs:Int32(10), true_target:block1, false_target:block4
block4:
[ 58] Return value:result~1
block5:
[ 60] Catch dst:reg6
[ 68] SetLexicalEnvironment environment:reg4
[ 70] Mov dst:reg5, src:Int32(1)
block6:
[ 80] Mov dst:reg8, src:result~1
[ 90] Add dst:reg7, lhs:reg8, rhs:Int32(100)
[ a0] Mov dst:result~1, src:reg7
[ b0] JumpStrictlyEquals lhs:reg5, rhs:Int32(0), true_target:block10, false_target:block11
block7:
[ c8] JumpStrictlyEquals lhs:i~0, rhs:Int32(2), true_target:block8, false_target:block9
block8:
[ e0] Mov dst:reg5, src:Int32(3)
[ f0] Jump target:block6
block9:
[ f8] Mov dst:reg7, src:result~1
[ 108] Add dst:reg8, lhs:reg7, rhs:i~0
[ 118] Mov2 dst1:result~1, src1:reg8, dst2:reg5, src2:Int32(0)
[ 130] Jump target:block6
block10:
[ 138] Jump target:block2
block11:
[ 140] JumpStrictlyEquals lhs:reg5, rhs:Int32(3), true_target:block4, false_target:block12
block12:
[ 158] JumpStrictlyEquals lhs:reg5, rhs:Int32(2), true_target:block13, false_target:block14
block13:
[ 170] Return value:reg6
block14:
[ 178] Throw src:reg6
Exception handlers:
[ c8 .. 138] => handler block5
32
301