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.
77 lines
2.2 KiB
Plaintext
77 lines
2.2 KiB
Plaintext
$b4f9525c class-literal-fields.js:12:1
|
|
Registers: 15
|
|
Blocks: 1
|
|
Constants:
|
|
[0] = Undefined
|
|
|
|
block0:
|
|
[ 0] GetGlobal dst:reg6, `test`
|
|
[ 18] Call dst:reg5, callee:reg6, this_value:Undefined, test
|
|
[ 38] InitializeLexicalBinding `a`, src:reg5
|
|
[ 50] GetGlobal dst:reg6, `console`
|
|
[ 68] GetById dst:reg7, base:reg6, `log` (console.log)
|
|
[ 88] GetGlobal dst:reg8, `a`
|
|
[ a0] GetById dst:reg9, base:reg8, `x` (a.x)
|
|
[ c0] GetGlobal dst:reg8, `a`
|
|
[ d8] GetById dst:reg10, base:reg8, `y` (a.y)
|
|
[ f8] GetGlobal dst:reg8, `a`
|
|
[ 110] GetById dst:reg11, base:reg8, `z` (a.z)
|
|
[ 130] GetGlobal dst:reg8, `a`
|
|
[ 148] GetById dst:reg12, base:reg8, `w` (a.w)
|
|
[ 168] GetGlobal dst:reg8, `a`
|
|
[ 180] GetById dst:reg13, base:reg8, `s` (a.s)
|
|
[ 1a0] GetGlobal dst:reg8, `a`
|
|
[ 1b8] GetById dst:reg14, base:reg8, `computed` (a.computed)
|
|
[ 1d8] Call dst:reg5, callee:reg7, this_value:reg6, console.log, arguments:[reg9, reg10, reg11, reg12, reg13, reg14]
|
|
[ 210] End value:reg5
|
|
|
|
|
|
test$657cc1d3 class-literal-fields.js:2:5
|
|
Registers: 7
|
|
Blocks: 1
|
|
Locals: A~0
|
|
Constants:
|
|
[0] = String("x")
|
|
[1] = String("y")
|
|
[2] = String("z")
|
|
[3] = String("w")
|
|
[4] = String("s")
|
|
[5] = String("computed")
|
|
[6] = Undefined
|
|
|
|
block0:
|
|
[ 0] GetLexicalEnvironment dst:reg4
|
|
[ 8] CreateLexicalEnvironment dst:reg5, parent:reg4, capacity:0
|
|
[ 18] CreateVariable `A`, is_immutable:true, is_global:false, is_strict:false
|
|
[ 28] SetLexicalEnvironment environment:reg4
|
|
[ 30] NewClass dst:reg6, class_environment:reg5, class_blueprint_index:0, element_keys:[element_keys:String("x"), element_keys:String("y"), element_keys:String("z"), element_keys:String("w"), element_keys:String("s"), element_keys:String("computed")]
|
|
[ 68] Mov dst:A~0, src:reg6
|
|
[ 78] ThrowIfTDZ src:A~0
|
|
[ 80] CallConstruct dst:reg6, callee:A~0, A
|
|
[ 98] Return value:reg6
|
|
|
|
|
|
A$811c9dc5
|
|
Registers: 5
|
|
Blocks: 1
|
|
Constants:
|
|
[0] = Undefined
|
|
|
|
block0:
|
|
[ 0] End value:Undefined
|
|
|
|
|
|
field$4297853c class-literal-fields.js:8:22
|
|
Registers: 5
|
|
Blocks: 1
|
|
Constants:
|
|
[0] = Int32(1)
|
|
[1] = Int32(2)
|
|
[2] = Int32(3)
|
|
|
|
block0:
|
|
[ 0] Return value:Int32(3)
|
|
|
|
|
|
42 -1 true null "hi" 3
|