mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-30 11:37:16 +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.
32 lines
1.6 KiB
Plaintext
32 lines
1.6 KiB
Plaintext
JS bytecode executable ""
|
|
[ 0] 0: GetLexicalEnvironment dst:reg4
|
|
[ 8] GetGlobal dst:reg6, identifier:multi_yield
|
|
[ 18] Call dst:reg5, callee:reg6, this_value:Undefined, multi_yield
|
|
[ 38] SetGlobal identifier:g, src:reg5
|
|
[ 48] GetGlobal dst:reg6, identifier:g
|
|
[ 58] GetById dst:reg7, base:reg6, property:next, base_identifier:g
|
|
[ 70] Call dst:reg5, callee:reg7, this_value:reg6, g.next
|
|
[ 90] GetGlobal dst:reg7, identifier:g
|
|
[ a0] GetById dst:reg8, base:reg7, property:next, base_identifier:g
|
|
[ b8] Call dst:reg6, callee:reg8, this_value:reg7, g.next
|
|
[ d8] End value:reg6
|
|
|
|
JS bytecode executable "multi_yield"
|
|
[ 0] 0: GetLexicalEnvironment dst:reg4
|
|
[ 8] Yield continuation_label:@18, value:Undefined
|
|
[ 18] 1: Yield continuation_label:@28, value:Int32(1)
|
|
[ 28] 2: Mov dst:reg5, src:reg0
|
|
[ 38] GetCompletionFields type_dst:reg6, value_dst:reg7, completion:reg5
|
|
[ 48] JumpStrictlyEquals lhs:reg6, rhs:Int32(1), true_target:@60, false_target:@70
|
|
[ 60] 3: Yield continuation_label:@a0, value:Int32(2)
|
|
[ 70] 4: JumpStrictlyEquals lhs:reg6, rhs:Int32(5), true_target:@88, false_target:@90
|
|
[ 88] 5: Throw src:reg7
|
|
[ 90] 6: Yield value:reg7
|
|
[ a0] 7: Mov dst:reg5, src:reg0
|
|
[ b0] GetCompletionFields type_dst:reg6, value_dst:reg7, completion:reg5
|
|
[ c0] JumpStrictlyEquals lhs:reg6, rhs:Int32(1), true_target:@d8, false_target:@e8
|
|
[ d8] 8: Yield value:Undefined
|
|
[ e8] 9: JumpStrictlyEquals lhs:reg6, rhs:Int32(5), true_target:@100, false_target:@108
|
|
[ 100] 10: Throw src:reg7
|
|
[ 108] 11: Yield value:reg7
|