mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-03 21:12:08 +02:00
The scope collector uses HashMaps for identifier groups and variables, which means their iteration order is non-deterministic. This causes local variable indices and function declaration instantiation (FDI) bytecode to vary between runs. Fix this by sorting identifier group keys alphabetically before assigning local variable indices, and sorting vars_to_initialize by name before emitting FDI bytecode. Also make register allocation deterministic by always picking the lowest-numbered free register instead of whichever one happens to be at the end of the free list. This is preparation for bringing in a new source->bytecode pipeline written in Rust. Checking for regressions is significantly easier if we can expect identical output from both pipelines.
54 lines
2.6 KiB
Plaintext
54 lines
2.6 KiB
Plaintext
JS bytecode executable ""
|
|
[ 0] 0: GetLexicalEnvironment dst:reg4
|
|
[ 8] CreateLexicalEnvironment dst:reg5, parent:reg4, capacity:0
|
|
[ 18] CreateVariable identifier:A, is_immutable:true, is_global:false, is_strict:false
|
|
[ 28] GetGlobal dst:reg6, identifier:Object
|
|
[ 38] SetLexicalEnvironment environment:reg4
|
|
[ 40] NewClass dst:reg7, super_class:reg6, class_environment:reg5, class_blueprint_index:0, element_keys:[element_keys:String("read"), element_keys:String("write"), element_keys:String("update")]
|
|
[ 70] InitializeLexicalBinding identifier:A, src:reg7
|
|
[ 88] GetGlobal dst:reg7, identifier:A
|
|
[ 98] CallConstruct dst:reg6, callee:reg7, A
|
|
[ b0] GetById dst:reg7, base:reg6, property:read
|
|
[ c8] Call dst:reg5, callee:reg7, this_value:reg6, <object>.read
|
|
[ e8] GetGlobal dst:reg8, identifier:A
|
|
[ f8] CallConstruct dst:reg7, callee:reg8, A
|
|
[ 110] GetById dst:reg8, base:reg7, property:write
|
|
[ 128] Call dst:reg6, callee:reg8, this_value:reg7, <object>.write
|
|
[ 148] GetGlobal dst:reg8, identifier:A
|
|
[ 158] CallConstruct dst:reg7, callee:reg8, A
|
|
[ 170] GetById dst:reg8, base:reg7, property:update
|
|
[ 188] Call dst:reg5, callee:reg8, this_value:reg7, <object>.update
|
|
[ 1a8] End value:reg5
|
|
|
|
JS bytecode executable "A"
|
|
[ 0] 0: GetLexicalEnvironment dst:reg4
|
|
[ 8] CreateVariable identifier:args, is_immutable:false, is_global:false, is_strict:false
|
|
[ 18] CreateRestParams dst:arg0, rest_index:0
|
|
[ 28] InitializeLexicalBinding identifier:args, src:arg0
|
|
[ 40] GetBinding dst:reg5, identifier:args
|
|
[ 58] SuperCallWithArgumentArray dst:reg6, arguments:reg5, is_synthetic:true
|
|
[ 68] Return value:reg6
|
|
|
|
JS bytecode executable "read"
|
|
[ 0] 0: GetLexicalEnvironment dst:reg4
|
|
[ 8] ResolveThisBinding
|
|
[ 10] ResolveSuperBase dst:reg5
|
|
[ 18] GetByIdWithThis dst:reg6, base:reg5, property:x, this_value:this
|
|
[ 30] Return value:reg6
|
|
|
|
JS bytecode executable "write"
|
|
[ 0] 0: GetLexicalEnvironment dst:reg4
|
|
[ 8] ResolveThisBinding
|
|
[ 10] ResolveSuperBase dst:reg5
|
|
[ 18] PutNormalByIdWithThis base:reg5, this_value:this, property:x, src:Int32(42)
|
|
[ 30] End value:Undefined
|
|
|
|
JS bytecode executable "update"
|
|
[ 0] 0: GetLexicalEnvironment dst:reg4
|
|
[ 8] ResolveThisBinding
|
|
[ 10] ResolveSuperBase dst:reg5
|
|
[ 18] GetByIdWithThis dst:reg6, base:reg5, property:x, this_value:this
|
|
[ 30] PostfixIncrement dst:reg7, src:reg6
|
|
[ 40] PutNormalByIdWithThis base:reg5, this_value:this, property:x, src:reg6
|
|
[ 58] End value:Undefined
|