1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:08:13 +00:00

LibJS: Remove last user of Op::Jump::set_targets() and API itself

This was just a matter of instantiating a BasicBlock earlier so we
can reference it when making the jump.
This commit is contained in:
Andreas Kling 2023-09-28 12:46:17 +02:00
parent bdd21cf9db
commit 887183cad6
2 changed files with 2 additions and 14 deletions

View file

@ -2048,24 +2048,21 @@ Bytecode::CodeGenerationErrorOr<void> IfStatement::generate_bytecode(Bytecode::G
auto& true_block = generator.make_block();
auto& false_block = generator.make_block();
auto& end_block = generator.make_block();
TRY(m_predicate->generate_bytecode(generator));
generator.emit<Bytecode::Op::JumpConditional>(
Bytecode::Label { true_block },
Bytecode::Label { false_block });
Bytecode::Op::Jump* true_block_jump { nullptr };
generator.switch_to_basic_block(true_block);
generator.emit<Bytecode::Op::LoadImmediate>(js_undefined());
TRY(m_consequent->generate_bytecode(generator));
if (!generator.is_current_block_terminated()) {
// FIXME: This should be initialized to the right target right away.
true_block_jump = &generator.emit<Bytecode::Op::Jump>(Bytecode::Label { true_block });
generator.emit<Bytecode::Op::Jump>(Bytecode::Label { end_block });
}
generator.switch_to_basic_block(false_block);
auto& end_block = generator.make_block();
generator.emit<Bytecode::Op::LoadImmediate>(js_undefined());
if (m_alternate)
@ -2073,9 +2070,6 @@ Bytecode::CodeGenerationErrorOr<void> IfStatement::generate_bytecode(Bytecode::G
if (!generator.is_current_block_terminated())
generator.emit<Bytecode::Op::Jump>(Bytecode::Label { end_block });
if (true_block_jump)
true_block_jump->set_targets(Bytecode::Label { end_block }, {});
generator.switch_to_basic_block(end_block);
return {};
}