Parcourir la source

LibJS/Bytecode: Stop emitting unnecessary jump at end of `for` statement

Andreas Kling il y a 1 an
Parent
commit
f3d57db774
1 fichiers modifiés avec 1 ajouts et 8 suppressions
  1. 1 8
      Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp

+ 1 - 8
Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp

@@ -850,7 +850,6 @@ Bytecode::CodeGenerationErrorOr<Optional<Bytecode::Operand>> ForStatement::gener
     Bytecode::BasicBlock* test_block_ptr { nullptr };
     Bytecode::BasicBlock* body_block_ptr { nullptr };
     Bytecode::BasicBlock* update_block_ptr { nullptr };
-    Bytecode::BasicBlock* load_result_and_jump_to_end_block_ptr { nullptr };
 
     auto& end_block = generator.make_block();
 
@@ -901,14 +900,13 @@ Bytecode::CodeGenerationErrorOr<Optional<Bytecode::Operand>> ForStatement::gener
     generator.emit<Bytecode::Op::Jump>(Bytecode::Label { *test_block_ptr });
 
     if (m_test) {
-        load_result_and_jump_to_end_block_ptr = &generator.make_block();
         generator.switch_to_basic_block(*test_block_ptr);
 
         auto test = TRY(m_test->generate_bytecode(generator)).value();
         generator.emit<Bytecode::Op::JumpIf>(
             test,
             Bytecode::Label { *body_block_ptr },
-            Bytecode::Label { *load_result_and_jump_to_end_block_ptr });
+            Bytecode::Label { end_block });
     }
 
     if (m_update) {
@@ -933,11 +931,6 @@ Bytecode::CodeGenerationErrorOr<Optional<Bytecode::Operand>> ForStatement::gener
         }
     }
 
-    if (load_result_and_jump_to_end_block_ptr) {
-        generator.switch_to_basic_block(*load_result_and_jump_to_end_block_ptr);
-        generator.emit<Bytecode::Op::Jump>(Bytecode::Label { end_block });
-    }
-
     generator.switch_to_basic_block(end_block);
 
     if (has_lexical_environment)