Files
ladybird/Tests/LibJS/Bytecode/expected/super-constructor-call.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

47 lines
1.4 KiB
Plaintext

$e065c380 super-constructor-call.js:1:1
Registers: 8
Blocks: 1
Constants:
[0] = Undefined
[1] = Int32(1)
block0:
[ 0] GetLexicalEnvironment dst:reg4
[ 8] CreateLexicalEnvironment dst:reg5, parent:reg4, capacity:0
[ 18] CreateVariable `Base`, is_immutable:true, is_global:false, is_strict:false
[ 28] SetLexicalEnvironment environment:reg4
[ 30] NewClass dst:reg6, class_environment:reg5, class_blueprint_index:0
[ 50] InitializeLexicalBinding `Base`, src:reg6
[ 68] CreateLexicalEnvironment dst:reg6, parent:reg4, capacity:0
[ 78] CreateVariable `Derived`, is_immutable:true, is_global:false, is_strict:false
[ 88] GetGlobal dst:reg5, `Base`
[ a0] SetLexicalEnvironment environment:reg4
[ a8] NewClass dst:reg7, super_class:reg5, class_environment:reg6, class_blueprint_index:1
[ c8] InitializeLexicalBinding `Derived`, src:reg7
[ e0] GetGlobal dst:reg6, `Derived`
[ f8] CallConstruct dst:reg7, callee:reg6, Derived, arguments:[Int32(1)]
[ 118] End value:reg7
Derived$3808ea25 super-constructor-call.js:4:14
Registers: 7
Blocks: 1
Constants:
[0] = Undefined
block0:
[ 0] Mov dst:reg6, src:arg0
[ 10] NewArray dst:reg5, elements:[reg6]
[ 28] SuperCallWithArgumentArray dst:reg6, arguments:reg5, is_synthetic:false
[ 38] End value:Undefined
Base$811c9dc5
Registers: 5
Blocks: 1
Constants:
[0] = Undefined
block0:
[ 0] End value:Undefined