mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-11 09:27:00 +02:00
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.
87 lines
2.5 KiB
Plaintext
87 lines
2.5 KiB
Plaintext
$5198286f for-loop-scoping.js:8: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, `forLetClosure`
|
|
[ 50] Call dst:reg8, callee:reg9, this_value:Undefined, forLetClosure
|
|
[ 70] Call dst:reg5, callee:reg7, this_value:reg6, console.log, arguments:[reg8]
|
|
[ 98] End value:reg5
|
|
|
|
|
|
forLetClosure$ab480781 for-loop-scoping.js:2:15
|
|
Registers: 10
|
|
Blocks: 5
|
|
Locals: fns~0
|
|
Constants:
|
|
[0] = Int32(0)
|
|
[1] = Int32(3)
|
|
|
|
block0:
|
|
[ 0] GetLexicalEnvironment dst:reg4
|
|
[ 8] NewArray dst:fns~0
|
|
[ 18] CreateLexicalEnvironment dst:reg5, parent:reg4, capacity:0
|
|
[ 28] CreateVariable `i`, is_immutable:false, is_global:false, is_strict:false
|
|
[ 38] InitializeLexicalBinding `i`, src:Int32(0)
|
|
[ 50] GetBinding dst:reg6, `i`
|
|
[ 68] SetLexicalEnvironment environment:reg4
|
|
[ 70] CreateLexicalEnvironment dst:reg5, parent:reg4, capacity:0
|
|
[ 80] CreateVariable `i`, is_immutable:false, is_global:false, is_strict:false
|
|
[ 90] InitializeLexicalBinding `i`, src:reg6
|
|
[ a8] Jump target:block3
|
|
|
|
block1:
|
|
[ b0] GetById dst:reg7, base:fns~0, `push` (fns.push)
|
|
[ d0] Mov dst:reg8, src:fns~0
|
|
[ e0] NewFunction dst:reg9, shared_function_data_index:0
|
|
[ f8] Call dst:reg6, callee:reg7, this_value:reg8, fns.push, arguments:[reg9]
|
|
[ 120] GetBinding dst:reg6, `i`
|
|
[ 138] SetLexicalEnvironment environment:reg4
|
|
[ 140] CreateLexicalEnvironment dst:reg5, parent:reg4, capacity:0
|
|
[ 150] CreateVariable `i`, is_immutable:false, is_global:false, is_strict:false
|
|
[ 160] InitializeLexicalBinding `i`, src:reg6
|
|
|
|
block2:
|
|
[ 178] GetBinding dst:reg7, `i`
|
|
[ 190] PostfixIncrement dst:reg6, src:reg7
|
|
[ 1a0] SetLexicalBinding `i`, src:reg7
|
|
|
|
block3:
|
|
[ 1b8] GetBinding dst:reg6, `i`
|
|
[ 1d0] JumpLessThan lhs:reg6, rhs:Int32(3), true_target:block1, false_target:block4
|
|
|
|
block4:
|
|
[ 1e8] SetLexicalEnvironment environment:reg4
|
|
[ 1f0] GetById dst:reg6, base:fns~0, `map` (fns.map)
|
|
[ 210] Mov dst:reg7, src:fns~0
|
|
[ 220] NewFunction dst:reg8, shared_function_data_index:1
|
|
[ 238] Call dst:reg5, callee:reg6, this_value:reg7, fns.map, arguments:[reg8]
|
|
[ 260] Return value:reg5
|
|
|
|
|
|
$a78bf47f for-loop-scoping.js:6:20
|
|
Registers: 6
|
|
Blocks: 1
|
|
Constants:
|
|
[0] = Undefined
|
|
|
|
block0:
|
|
[ 0] Call dst:reg5, callee:arg0, this_value:Undefined, f
|
|
[ 20] Return value:reg5
|
|
|
|
|
|
$ceed13fe for-loop-scoping.js:4:18
|
|
Registers: 6
|
|
Blocks: 1
|
|
|
|
block0:
|
|
[ 0] GetBinding dst:reg5, `i`
|
|
[ 18] Return value:reg5
|
|
|
|
|
|
[ 0, 1, 2 ]
|