mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-11 09:27:00 +02:00
The scope collector stored identifier_groups and variables in HashMaps and then sorted them alphabetically before assigning local register indices. The sorts existed only because HashMap iteration order is non-deterministic; alphabetical was a stable choice for comparing bytecode against the now-removed C++ port. Switch both maps to indexmap::IndexMap so iteration follows the order of first reference (= source order), and drop the alphabetical sorts. Local indices now reflect declaration order, which matches what shows up in bytecode dumps and is easier to read alongside the source. Add a focused bytecode test using zebra/yak/aardvark to pin the new allocation order; existing tests using let/var declarations have their local indices renumbered to match.
27 lines
691 B
Plaintext
27 lines
691 B
Plaintext
$da832d31 local-source-order.js:12:1
|
|
Registers: 7
|
|
Blocks: 1
|
|
Constants:
|
|
[0] = Undefined
|
|
|
|
block0:
|
|
[ 0] GetGlobal dst:reg6, `source_order_locals`
|
|
[ 18] Call dst:reg5, callee:reg6, this_value:Undefined, source_order_locals
|
|
[ 38] End value:reg5
|
|
|
|
|
|
source_order_locals$7988cb5f local-source-order.js:6:5
|
|
Registers: 7
|
|
Blocks: 1
|
|
Locals: zebra~0, yak~1, aardvark~2
|
|
Constants:
|
|
[0] = Int32(1)
|
|
[1] = Int32(2)
|
|
[2] = Int32(3)
|
|
|
|
block0:
|
|
[ 0] Mov3 dst1:zebra~0, src1:Int32(1), dst2:yak~1, src2:Int32(2), dst3:aardvark~2, src3:Int32(3)
|
|
[ 20] Add dst:reg5, lhs:zebra~0, rhs:yak~1
|
|
[ 30] Add dst:reg6, lhs:reg5, rhs:aardvark~2
|
|
[ 40] Return value:reg6
|