Files
ladybird/Tests/LibJS/Bytecode/expected/sequential-try-blocks.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

72 lines
1.7 KiB
Plaintext

$d96d9efb sequential-try-blocks.js:17:1
Registers: 10
Blocks: 1
Constants:
[0] = Undefined
block0:
[ 0] GetGlobal dst:reg6, `console`
[ 18] GetById dst:reg7, base:reg6, `log` (console.log)
[ 38] GetGlobal dst:reg9, `sequentialTryCatch`
[ 50] Call dst:reg8, callee:reg9, this_value:Undefined, sequentialTryCatch
[ 70] Call dst:reg5, callee:reg7, this_value:reg6, console.log, arguments:[reg8]
[ 98] End value:reg5
sequentialTryCatch$4bff3490 sequential-try-blocks.js:2:5
Registers: 8
Blocks: 7
Locals: e~0, e~1, result~2
Constants:
[0] = String("")
[1] = String("b")
[2] = String("a")
[3] = Int32(1)
[4] = String("d")
[5] = String("c")
[6] = Int32(2)
block0:
[ 0] GetLexicalEnvironment dst:reg4
[ 8] Mov dst:result~2, src:String("")
[ 18] Jump target:block3
block1:
[ 20] Catch dst:reg5
[ 28] SetLexicalEnvironment environment:reg4
[ 30] Mov2 dst1:e~0, src1:reg5, dst2:reg6, src2:result~2
[ 48] Add dst:reg7, lhs:reg6, rhs:String("b")
[ 58] Mov dst:result~2, src:reg7
block2:
[ 68] Jump target:block6
block3:
[ 70] Mov dst:reg5, src:result~2
[ 80] Add dst:reg7, lhs:reg5, rhs:String("a")
[ 90] Mov dst:result~2, src:reg7
[ a0] Throw src:Int32(1)
block4:
[ a8] Catch dst:reg7
[ b0] SetLexicalEnvironment environment:reg4
[ b8] Mov2 dst1:e~1, src1:reg7, dst2:reg5, src2:result~2
[ d0] Add dst:reg6, lhs:reg5, rhs:String("d")
[ e0] Mov dst:result~2, src:reg6
block5:
[ f0] Return value:result~2
block6:
[ f8] Mov dst:reg7, src:result~2
[ 108] Add dst:reg6, lhs:reg7, rhs:String("c")
[ 118] Mov dst:result~2, src:reg6
[ 128] Throw src:Int32(2)
Exception handlers:
[ 70 .. a8] => handler block1
[ f8 .. 130] => handler block4
"abcd"