ladybird/Tests/LibJS/Bytecode/expected/for-loop-scoping.txt
InvalidUsernameException bb762fb43b LibJS: Do not assume arguments cannot be clobbered
`copy_if_needed_to_preserve_evaluation_order` was introduced in
c372a084a2. At that point function
arguments still needed to be copied into registers with a special
`GetArgument` instructions. Later, in
3f04d18ef7 this was changed and arguments
were made their own operand type that can be accessed directly instead.

Similar to locals, arguments can also be overwritten due to evaluation
order in various scenarios. However, the function was never updated to
account for that. Rectify that here.

With this change, https://volkswagen.de no longer gets blanked shortly
after initial load and the unhandled JS exception spam on that site is
gone too.
2026-03-08 15:01:07 +01:00

54 lines
2.7 KiB
Text

JS bytecode executable ""
[ 0] 0: GetLexicalEnvironment dst:reg4
[ 8] GetGlobal dst:reg6, identifier:console
[ 20] GetById dst:reg7, base:reg6, property:log, base_identifier:console
[ 40] GetGlobal dst:reg9, identifier:forLetClosure
[ 58] Call dst:reg8, callee:reg9, this_value:Undefined, forLetClosure
[ 78] Call dst:reg5, callee:reg7, this_value:reg6, console.log, arguments:[reg8]
[ a0] End value:reg5
JS bytecode executable "forLetClosure"
[ 0] 0: GetLexicalEnvironment dst:reg4
[ 8] NewArray dst:fns~0
[ 18] CreateLexicalEnvironment dst:reg5, parent:reg4, capacity:0
[ 28] CreateVariable identifier:i, is_immutable:false, is_global:false, is_strict:false
[ 38] InitializeLexicalBinding identifier:i, src:Int32(0)
[ 50] GetBinding dst:reg6, identifier:i
[ 68] SetLexicalEnvironment environment:reg4
[ 70] CreateLexicalEnvironment dst:reg5, parent:reg4, capacity:0
[ 80] CreateVariable identifier:i, is_immutable:false, is_global:false, is_strict:false
[ 90] InitializeLexicalBinding identifier:i, src:reg6
[ a8] Jump target:@1b8
[ b0] 1: GetById dst:reg7, base:fns~0, property:push, base_identifier:fns
[ 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, identifier:i
[ 138] SetLexicalEnvironment environment:reg4
[ 140] CreateLexicalEnvironment dst:reg5, parent:reg4, capacity:0
[ 150] CreateVariable identifier:i, is_immutable:false, is_global:false, is_strict:false
[ 160] InitializeLexicalBinding identifier:i, src:reg6
[ 178] 2: GetBinding dst:reg6, identifier:i
[ 190] PostfixIncrement dst:reg7, src:reg6
[ 1a0] SetLexicalBinding identifier:i, src:reg6
[ 1b8] 3: GetBinding dst:reg6, identifier:i
[ 1d0] JumpLessThan lhs:reg6, rhs:Int32(3), true_target:@b0, false_target:@1e8
[ 1e8] 4: SetLexicalEnvironment environment:reg4
[ 1f0] GetById dst:reg6, base:fns~0, property:map, base_identifier:fns
[ 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
JS bytecode executable ""
[ 0] 0: GetLexicalEnvironment dst:reg4
[ 8] Mov dst:reg6, src:arg0
[ 18] Call dst:reg5, callee:reg6, this_value:Undefined, f
[ 38] Return value:reg5
JS bytecode executable ""
[ 0] 0: GetLexicalEnvironment dst:reg4
[ 8] GetBinding dst:reg5, identifier:i
[ 20] Return value:reg5
[ 0, 1, 2 ]