LibJS/Bytecode: Emit for condition check before update statement

This allows jump elision to eliminate an unnecessary jump since things
now get laid out naturally in memory (normal execution order).
This commit is contained in:
Andreas Kling 2024-05-06 09:34:42 +02:00
parent 24d8b056c7
commit 69cc64e94c
Notes: sideshowbarker 2024-07-17 08:34:29 +09:00

View file

@ -888,16 +888,16 @@ Bytecode::CodeGenerationErrorOr<Optional<Bytecode::Operand>> ForStatement::gener
body_block_ptr = &generator.make_block();
if (m_test)
test_block_ptr = &generator.make_block();
else
test_block_ptr = body_block_ptr;
if (m_update)
update_block_ptr = &generator.make_block();
else
update_block_ptr = body_block_ptr;
if (m_test)
test_block_ptr = &generator.make_block();
else
test_block_ptr = body_block_ptr;
generator.emit<Bytecode::Op::Jump>(Bytecode::Label { *test_block_ptr });
if (m_test) {