mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-04 10:18:51 +00:00
LibJS/Bytecode: Fix multiple wrong jumps in ForStatement codegen
This commit is contained in:
parent
0772a23c65
commit
6f39882f11
Notes:
sideshowbarker
2024-07-17 03:10:07 +09:00
Author: https://github.com/awesomekling
Commit: 6f39882f11
Pull-request: https://github.com/SerenityOS/serenity/pull/19408
Issue: https://github.com/SerenityOS/serenity/issues/15210
1 changed files with 13 additions and 8 deletions
|
@ -831,8 +831,16 @@ Bytecode::CodeGenerationErrorOr<void> ForStatement::generate_labelled_evaluation
|
|||
Bytecode::Label { end_block });
|
||||
}
|
||||
|
||||
if (m_update) {
|
||||
generator.switch_to_basic_block(*update_block_ptr);
|
||||
TRY(m_update->generate_bytecode(generator));
|
||||
generator.emit<Bytecode::Op::Jump>().set_targets(
|
||||
Bytecode::Label { *test_block_ptr },
|
||||
{});
|
||||
}
|
||||
|
||||
generator.switch_to_basic_block(*body_block_ptr);
|
||||
generator.begin_continuable_scope(Bytecode::Label { *update_block_ptr }, label_set);
|
||||
generator.begin_continuable_scope(Bytecode::Label { m_update ? *update_block_ptr : *test_block_ptr }, label_set);
|
||||
generator.begin_breakable_scope(Bytecode::Label { end_block }, label_set);
|
||||
TRY(m_body->generate_bytecode(generator));
|
||||
generator.end_breakable_scope();
|
||||
|
@ -843,14 +851,11 @@ Bytecode::CodeGenerationErrorOr<void> ForStatement::generate_labelled_evaluation
|
|||
generator.emit<Bytecode::Op::Jump>().set_targets(
|
||||
Bytecode::Label { *update_block_ptr },
|
||||
{});
|
||||
|
||||
generator.switch_to_basic_block(*update_block_ptr);
|
||||
TRY(m_update->generate_bytecode(generator));
|
||||
} else {
|
||||
generator.emit<Bytecode::Op::Jump>().set_targets(
|
||||
Bytecode::Label { *test_block_ptr },
|
||||
{});
|
||||
}
|
||||
|
||||
generator.emit<Bytecode::Op::Jump>().set_targets(
|
||||
Bytecode::Label { *test_block_ptr },
|
||||
{});
|
||||
}
|
||||
|
||||
generator.switch_to_basic_block(end_block);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue