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

57 lines
1.4 KiB
Plaintext

$5f9e2ffb class-environment.js:9: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, `classWithName`
[ 50] Call dst:reg8, callee:reg9, this_value:Undefined, classWithName
[ 70] Call dst:reg5, callee:reg7, this_value:reg6, console.log, arguments:[reg8]
[ 98] End value:reg5
classWithName$8829de8e class-environment.js:2:13
Registers: 8
Blocks: 1
Locals: C~0
Constants:
[0] = String("method")
[1] = Undefined
block0:
[ 0] GetLexicalEnvironment dst:reg4
[ 8] CreateLexicalEnvironment dst:reg5, parent:reg4, capacity:0
[ 18] CreateVariable `Foo`, is_immutable:true, is_global:false, is_strict:false
[ 28] SetLexicalEnvironment environment:reg4
[ 30] NewClass dst:C~0, class_environment:reg5, class_blueprint_index:0, element_keys:[element_keys:String("method")]
[ 58] CallConstruct dst:reg6, callee:C~0, C
[ 70] GetById dst:reg7, base:reg6, `method`
[ 90] Call dst:reg5, callee:reg7, this_value:reg6, <object>.method
[ b0] StrictlyEquals dst:reg7, lhs:reg5, rhs:C~0
[ c0] Return value:reg7
Foo$811c9dc5
Registers: 5
Blocks: 1
Constants:
[0] = Undefined
block0:
[ 0] End value:Undefined
method$e3fa2040 class-environment.js:4:13
Registers: 6
Blocks: 1
block0:
[ 0] GetBinding dst:reg5, `Foo`
[ 18] Return value:reg5
true