mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibJS/Bytecode: Remove pointless basic block in SwitchStatement codegen
This commit is contained in:
parent
6873628317
commit
18b8fae85c
Notes:
sideshowbarker
2024-07-17 05:09:48 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/18b8fae85c Pull-request: https://github.com/SerenityOS/serenity/pull/24260 Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/mattco98
1 changed files with 2 additions and 8 deletions
|
@ -2588,7 +2588,6 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> SwitchStatement::genera
|
|||
|
||||
for (auto& switch_case : m_cases) {
|
||||
auto& case_block = generator.make_block();
|
||||
auto& case_entry_block = generator.make_block();
|
||||
if (switch_case->test()) {
|
||||
generator.switch_to_basic_block(*next_test_block);
|
||||
auto test_value = TRY(switch_case->test()->generate_bytecode(generator)).value();
|
||||
|
@ -2597,17 +2596,12 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> SwitchStatement::genera
|
|||
next_test_block = &generator.make_block();
|
||||
generator.emit<Bytecode::Op::JumpIf>(
|
||||
result,
|
||||
Bytecode::Label { case_entry_block },
|
||||
Bytecode::Label { case_block },
|
||||
Bytecode::Label { *next_test_block });
|
||||
} else {
|
||||
entry_block_for_default = &case_entry_block;
|
||||
entry_block_for_default = &case_block;
|
||||
}
|
||||
|
||||
// Initialize the completion value of the switch statement to empty. We can't do this in the case's basic block directly,
|
||||
// as we must not clobber the possible non-empty completion value of the previous case when falling through.
|
||||
generator.switch_to_basic_block(case_entry_block);
|
||||
generator.emit<Bytecode::Op::Jump>(Bytecode::Label { case_block });
|
||||
|
||||
case_blocks.append(case_block);
|
||||
}
|
||||
generator.switch_to_basic_block(*next_test_block);
|
||||
|
|
Loading…
Reference in a new issue