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

52 lines
1.3 KiB
Plaintext

$69cce752 async-await.js:9:1
Registers: 7
Blocks: 1
Constants:
[0] = Undefined
block0:
[ 0] GetGlobal dst:reg6, `f`
[ 18] Call dst:reg5, callee:reg6, this_value:Undefined, f
[ 38] End value:reg5
f$c9505126 async-await.js:7:5
Registers: 10
Blocks: 8
Constants:
[0] = Undefined
[1] = Int32(42)
[2] = Int32(1)
block0:
[ 0] Yield continuation_label:block1, value:Undefined
block1:
[ 10] GetGlobal dst:reg6, `Promise`
[ 28] GetById dst:reg7, base:reg6, `resolve` (Promise.resolve)
[ 48] Call dst:reg5, callee:reg7, this_value:reg6, Promise.resolve, arguments:[Int32(42)]
[ 70] Mov dst:reg7, src:reg0
[ 80] Await continuation_label:block2, argument:reg5
block2:
[ 90] Mov dst:reg7, src:reg0
[ a0] GetCompletionFields type_dst:reg6, value_dst:reg8, completion:reg7
[ b0] JumpStrictlyEquals lhs:reg6, rhs:Int32(1), true_target:block3, false_target:block4
block3:
[ c8] Await continuation_label:block5, argument:reg8
block4:
[ d8] Throw src:reg8
block5:
[ e0] Mov dst:reg5, src:reg0
[ f0] GetCompletionFields type_dst:reg7, value_dst:reg6, completion:reg5
[ 100] JumpStrictlyEquals lhs:reg7, rhs:Int32(1), true_target:block6, false_target:block7
block6:
[ 118] Yield value:reg6
block7:
[ 128] Throw src:reg6