Files
ladybird/Tests/LibJS/Bytecode/expected/block-scoped-function-no-tdz.txt
Andreas Kling cd2576c031 LibJS: Mark block-scoped function declaration locals as initialized
When emitting block declaration instantiation, we were not calling
set_local_initialized() after writing block-scoped function
declarations to local variables via Mov. This caused unnecessary
ThrowIfTDZ checks to be emitted when those locals were later read.

Block-scoped function declarations are always initialized at block
entry (via NewFunction + Mov), so TDZ checks for them are redundant.
2026-02-19 02:45:37 +01:00

22 lines
849 B
Plaintext

JS bytecode executable ""
[ 0] 0: GetLexicalEnvironment dst:reg4
[ 8] GetGlobal dst:reg6, identifier:test
[ 18] Call dst:reg5, callee:reg6, this_value:Undefined, test
[ 38] End value:reg5
JS bytecode executable "test"
[ 0] 0: GetLexicalEnvironment dst:reg4
[ 8] Mov dst:result~1, src:Undefined
[ 18] CreateLexicalEnvironment dst:reg5, parent:reg4, capacity:0
[ 28] NewFunction dst:reg6, shared_function_data_index:0
[ 40] Mov dst:foo~0, src:reg6
[ 50] Mov dst:reg7, src:foo~0
[ 60] Call dst:reg6, callee:reg7, this_value:Undefined, foo
[ 80] Mov dst:result~1, src:reg6
[ 90] SetLexicalEnvironment environment:reg4
[ 98] Return value:result~1
JS bytecode executable "foo"
[ 0] 0: GetLexicalEnvironment dst:reg4
[ 8] Return value:Int32(42)