Explorar o código

LibJS: Remove almost all uses of Op::Jump::set_targets()

We should initialize jump targets when constructing the jump instruction
instead of doing it later. This was already the case in all construction
sites but one. This first patch converts all those sites to pass final
targets to the constructor directly.
Andreas Kling hai 1 ano
pai
achega
bdd21cf9db

+ 58 - 89
Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp

@@ -171,17 +171,17 @@ Bytecode::CodeGenerationErrorOr<void> LogicalExpression::generate_bytecode(Bytec
 
 
     switch (m_op) {
     switch (m_op) {
     case LogicalOp::And:
     case LogicalOp::And:
-        generator.emit<Bytecode::Op::JumpConditional>().set_targets(
+        generator.emit<Bytecode::Op::JumpConditional>(
             Bytecode::Label { rhs_block },
             Bytecode::Label { rhs_block },
             Bytecode::Label { end_block });
             Bytecode::Label { end_block });
         break;
         break;
     case LogicalOp::Or:
     case LogicalOp::Or:
-        generator.emit<Bytecode::Op::JumpConditional>().set_targets(
+        generator.emit<Bytecode::Op::JumpConditional>(
             Bytecode::Label { end_block },
             Bytecode::Label { end_block },
             Bytecode::Label { rhs_block });
             Bytecode::Label { rhs_block });
         break;
         break;
     case LogicalOp::NullishCoalescing:
     case LogicalOp::NullishCoalescing:
-        generator.emit<Bytecode::Op::JumpNullish>().set_targets(
+        generator.emit<Bytecode::Op::JumpNullish>(
             Bytecode::Label { rhs_block },
             Bytecode::Label { rhs_block },
             Bytecode::Label { end_block });
             Bytecode::Label { end_block });
         break;
         break;
@@ -192,10 +192,7 @@ Bytecode::CodeGenerationErrorOr<void> LogicalExpression::generate_bytecode(Bytec
     generator.switch_to_basic_block(rhs_block);
     generator.switch_to_basic_block(rhs_block);
     TRY(m_rhs->generate_bytecode(generator));
     TRY(m_rhs->generate_bytecode(generator));
 
 
-    generator.emit<Bytecode::Op::Jump>().set_targets(
-        Bytecode::Label { end_block },
-        {});
-
+    generator.emit<Bytecode::Op::Jump>(Bytecode::Label { end_block });
     generator.switch_to_basic_block(end_block);
     generator.switch_to_basic_block(end_block);
     return {};
     return {};
 }
 }
@@ -538,21 +535,21 @@ Bytecode::CodeGenerationErrorOr<void> AssignmentExpression::generate_bytecode(By
         rhs_block_ptr = &generator.make_block();
         rhs_block_ptr = &generator.make_block();
         end_block_ptr = &generator.make_block();
         end_block_ptr = &generator.make_block();
 
 
-        generator.emit<Bytecode::Op::JumpConditional>().set_targets(
+        generator.emit<Bytecode::Op::JumpConditional>(
             Bytecode::Label { *rhs_block_ptr },
             Bytecode::Label { *rhs_block_ptr },
             Bytecode::Label { *end_block_ptr });
             Bytecode::Label { *end_block_ptr });
     } else if (m_op == AssignmentOp::OrAssignment) { // ||=
     } else if (m_op == AssignmentOp::OrAssignment) { // ||=
         rhs_block_ptr = &generator.make_block();
         rhs_block_ptr = &generator.make_block();
         end_block_ptr = &generator.make_block();
         end_block_ptr = &generator.make_block();
 
 
-        generator.emit<Bytecode::Op::JumpConditional>().set_targets(
+        generator.emit<Bytecode::Op::JumpConditional>(
             Bytecode::Label { *end_block_ptr },
             Bytecode::Label { *end_block_ptr },
             Bytecode::Label { *rhs_block_ptr });
             Bytecode::Label { *rhs_block_ptr });
     } else if (m_op == AssignmentOp::NullishAssignment) { // ??=
     } else if (m_op == AssignmentOp::NullishAssignment) { // ??=
         rhs_block_ptr = &generator.make_block();
         rhs_block_ptr = &generator.make_block();
         end_block_ptr = &generator.make_block();
         end_block_ptr = &generator.make_block();
 
 
-        generator.emit<Bytecode::Op::JumpNullish>().set_targets(
+        generator.emit<Bytecode::Op::JumpNullish>(
             Bytecode::Label { *rhs_block_ptr },
             Bytecode::Label { *rhs_block_ptr },
             Bytecode::Label { *end_block_ptr });
             Bytecode::Label { *end_block_ptr });
     }
     }
@@ -621,10 +618,7 @@ Bytecode::CodeGenerationErrorOr<void> AssignmentExpression::generate_bytecode(By
     TRY(generator.emit_store_to_reference(lhs));
     TRY(generator.emit_store_to_reference(lhs));
 
 
     if (end_block_ptr) {
     if (end_block_ptr) {
-        generator.emit<Bytecode::Op::Jump>().set_targets(
-            Bytecode::Label { *end_block_ptr },
-            {});
-
+        generator.emit<Bytecode::Op::Jump>(Bytecode::Label { *end_block_ptr });
         generator.switch_to_basic_block(*end_block_ptr);
         generator.switch_to_basic_block(*end_block_ptr);
     }
     }
 
 
@@ -676,9 +670,7 @@ Bytecode::CodeGenerationErrorOr<void> LabelledStatement::generate_labelled_evalu
         generator.end_breakable_scope();
         generator.end_breakable_scope();
 
 
         if (!generator.is_current_block_terminated()) {
         if (!generator.is_current_block_terminated()) {
-            generator.emit<Bytecode::Op::Jump>().set_targets(
-                Bytecode::Label { labelled_break_block },
-                {});
+            generator.emit<Bytecode::Op::Jump>(Bytecode::Label { labelled_break_block });
         }
         }
 
 
         generator.switch_to_basic_block(labelled_break_block);
         generator.switch_to_basic_block(labelled_break_block);
@@ -725,14 +717,12 @@ Bytecode::CodeGenerationErrorOr<void> WhileStatement::generate_labelled_evaluati
     auto result_reg = generator.allocate_register();
     auto result_reg = generator.allocate_register();
 
 
     // jump to the test block
     // jump to the test block
-    generator.emit<Bytecode::Op::Jump>().set_targets(
-        Bytecode::Label { test_block },
-        {});
+    generator.emit<Bytecode::Op::Jump>(Bytecode::Label { test_block });
 
 
     generator.switch_to_basic_block(test_block);
     generator.switch_to_basic_block(test_block);
     generator.emit<Bytecode::Op::Store>(result_reg);
     generator.emit<Bytecode::Op::Store>(result_reg);
     TRY(m_test->generate_bytecode(generator));
     TRY(m_test->generate_bytecode(generator));
-    generator.emit<Bytecode::Op::JumpConditional>().set_targets(
+    generator.emit<Bytecode::Op::JumpConditional>(
         Bytecode::Label { body_block },
         Bytecode::Label { body_block },
         Bytecode::Label { load_result_and_jump_to_end_block });
         Bytecode::Label { load_result_and_jump_to_end_block });
 
 
@@ -745,9 +735,7 @@ Bytecode::CodeGenerationErrorOr<void> WhileStatement::generate_labelled_evaluati
     generator.end_continuable_scope();
     generator.end_continuable_scope();
 
 
     if (!generator.is_current_block_terminated()) {
     if (!generator.is_current_block_terminated()) {
-        generator.emit<Bytecode::Op::Jump>().set_targets(
-            Bytecode::Label { test_block },
-            {});
+        generator.emit<Bytecode::Op::Jump>(Bytecode::Label { test_block });
     }
     }
 
 
     generator.switch_to_basic_block(load_result_and_jump_to_end_block);
     generator.switch_to_basic_block(load_result_and_jump_to_end_block);
@@ -784,14 +772,12 @@ Bytecode::CodeGenerationErrorOr<void> DoWhileStatement::generate_labelled_evalua
     generator.emit<Bytecode::Op::Store>(result_reg);
     generator.emit<Bytecode::Op::Store>(result_reg);
 
 
     // jump to the body block
     // jump to the body block
-    generator.emit<Bytecode::Op::Jump>().set_targets(
-        Bytecode::Label { body_block },
-        {});
+    generator.emit<Bytecode::Op::Jump>(Bytecode::Label { body_block });
 
 
     generator.switch_to_basic_block(test_block);
     generator.switch_to_basic_block(test_block);
     generator.emit<Bytecode::Op::Store>(result_reg);
     generator.emit<Bytecode::Op::Store>(result_reg);
     TRY(m_test->generate_bytecode(generator));
     TRY(m_test->generate_bytecode(generator));
-    generator.emit<Bytecode::Op::JumpConditional>().set_targets(
+    generator.emit<Bytecode::Op::JumpConditional>(
         Bytecode::Label { body_block },
         Bytecode::Label { body_block },
         Bytecode::Label { load_result_and_jump_to_end_block });
         Bytecode::Label { load_result_and_jump_to_end_block });
 
 
@@ -803,9 +789,7 @@ Bytecode::CodeGenerationErrorOr<void> DoWhileStatement::generate_labelled_evalua
     generator.end_continuable_scope();
     generator.end_continuable_scope();
 
 
     if (!generator.is_current_block_terminated()) {
     if (!generator.is_current_block_terminated()) {
-        generator.emit<Bytecode::Op::Jump>().set_targets(
-            Bytecode::Label { test_block },
-            {});
+        generator.emit<Bytecode::Op::Jump>(Bytecode::Label { test_block });
     }
     }
 
 
     generator.switch_to_basic_block(load_result_and_jump_to_end_block);
     generator.switch_to_basic_block(load_result_and_jump_to_end_block);
@@ -895,9 +879,7 @@ Bytecode::CodeGenerationErrorOr<void> ForStatement::generate_labelled_evaluation
     if (m_test && m_update)
     if (m_test && m_update)
         generator.emit<Bytecode::Op::Store>(result_reg);
         generator.emit<Bytecode::Op::Store>(result_reg);
 
 
-    generator.emit<Bytecode::Op::Jump>().set_targets(
-        Bytecode::Label { *test_block_ptr },
-        {});
+    generator.emit<Bytecode::Op::Jump>(Bytecode::Label { *test_block_ptr });
 
 
     if (m_test) {
     if (m_test) {
         load_result_and_jump_to_end_block_ptr = &generator.make_block();
         load_result_and_jump_to_end_block_ptr = &generator.make_block();
@@ -907,7 +889,7 @@ Bytecode::CodeGenerationErrorOr<void> ForStatement::generate_labelled_evaluation
             generator.emit<Bytecode::Op::Store>(result_reg);
             generator.emit<Bytecode::Op::Store>(result_reg);
 
 
         TRY(m_test->generate_bytecode(generator));
         TRY(m_test->generate_bytecode(generator));
-        generator.emit<Bytecode::Op::JumpConditional>().set_targets(
+        generator.emit<Bytecode::Op::JumpConditional>(
             Bytecode::Label { *body_block_ptr },
             Bytecode::Label { *body_block_ptr },
             Bytecode::Label { *load_result_and_jump_to_end_block_ptr });
             Bytecode::Label { *load_result_and_jump_to_end_block_ptr });
     }
     }
@@ -919,9 +901,7 @@ Bytecode::CodeGenerationErrorOr<void> ForStatement::generate_labelled_evaluation
             generator.emit<Bytecode::Op::Store>(result_reg);
             generator.emit<Bytecode::Op::Store>(result_reg);
 
 
         TRY(m_update->generate_bytecode(generator));
         TRY(m_update->generate_bytecode(generator));
-        generator.emit<Bytecode::Op::Jump>().set_targets(
-            Bytecode::Label { *test_block_ptr },
-            {});
+        generator.emit<Bytecode::Op::Jump>(Bytecode::Label { *test_block_ptr });
     }
     }
 
 
     generator.switch_to_basic_block(*body_block_ptr);
     generator.switch_to_basic_block(*body_block_ptr);
@@ -934,13 +914,9 @@ Bytecode::CodeGenerationErrorOr<void> ForStatement::generate_labelled_evaluation
 
 
     if (!generator.is_current_block_terminated()) {
     if (!generator.is_current_block_terminated()) {
         if (m_update) {
         if (m_update) {
-            generator.emit<Bytecode::Op::Jump>().set_targets(
-                Bytecode::Label { *update_block_ptr },
-                {});
+            generator.emit<Bytecode::Op::Jump>(Bytecode::Label { *update_block_ptr });
         } else {
         } else {
-            generator.emit<Bytecode::Op::Jump>().set_targets(
-                Bytecode::Label { *test_block_ptr },
-                {});
+            generator.emit<Bytecode::Op::Jump>(Bytecode::Label { *test_block_ptr });
         }
         }
     }
     }
 
 
@@ -1181,7 +1157,7 @@ static Bytecode::CodeGenerationErrorOr<void> generate_object_binding_pattern_byt
             auto& if_undefined_block = generator.make_block();
             auto& if_undefined_block = generator.make_block();
             auto& if_not_undefined_block = generator.make_block();
             auto& if_not_undefined_block = generator.make_block();
 
 
-            generator.emit<Bytecode::Op::JumpUndefined>().set_targets(
+            generator.emit<Bytecode::Op::JumpUndefined>(
                 Bytecode::Label { if_undefined_block },
                 Bytecode::Label { if_undefined_block },
                 Bytecode::Label { if_not_undefined_block });
                 Bytecode::Label { if_not_undefined_block });
 
 
@@ -1193,9 +1169,7 @@ static Bytecode::CodeGenerationErrorOr<void> generate_object_binding_pattern_byt
             } else {
             } else {
                 TRY(initializer->generate_bytecode(generator));
                 TRY(initializer->generate_bytecode(generator));
             }
             }
-            generator.emit<Bytecode::Op::Jump>().set_targets(
-                Bytecode::Label { if_not_undefined_block },
-                {});
+            generator.emit<Bytecode::Op::Jump>(Bytecode::Label { if_not_undefined_block });
 
 
             generator.switch_to_basic_block(if_not_undefined_block);
             generator.switch_to_basic_block(if_not_undefined_block);
         }
         }
@@ -1307,22 +1281,18 @@ static Bytecode::CodeGenerationErrorOr<void> generate_array_binding_pattern_byte
                 auto& continuation_block = generator.make_block();
                 auto& continuation_block = generator.make_block();
 
 
                 generator.emit<Bytecode::Op::Load>(is_iterator_exhausted_register);
                 generator.emit<Bytecode::Op::Load>(is_iterator_exhausted_register);
-                generator.emit<Bytecode::Op::JumpConditional>().set_targets(
+                generator.emit<Bytecode::Op::JumpConditional>(
                     Bytecode::Label { if_exhausted_block },
                     Bytecode::Label { if_exhausted_block },
                     Bytecode::Label { if_not_exhausted_block });
                     Bytecode::Label { if_not_exhausted_block });
 
 
                 generator.switch_to_basic_block(if_exhausted_block);
                 generator.switch_to_basic_block(if_exhausted_block);
                 generator.emit<Bytecode::Op::NewArray>();
                 generator.emit<Bytecode::Op::NewArray>();
-                generator.emit<Bytecode::Op::Jump>().set_targets(
-                    Bytecode::Label { continuation_block },
-                    {});
+                generator.emit<Bytecode::Op::Jump>(Bytecode::Label { continuation_block });
 
 
                 generator.switch_to_basic_block(if_not_exhausted_block);
                 generator.switch_to_basic_block(if_not_exhausted_block);
                 generator.emit<Bytecode::Op::Load>(iterator_reg);
                 generator.emit<Bytecode::Op::Load>(iterator_reg);
                 generator.emit<Bytecode::Op::IteratorToArray>();
                 generator.emit<Bytecode::Op::IteratorToArray>();
-                generator.emit<Bytecode::Op::Jump>().set_targets(
-                    Bytecode::Label { continuation_block },
-                    {});
+                generator.emit<Bytecode::Op::Jump>(Bytecode::Label { continuation_block });
 
 
                 generator.switch_to_basic_block(continuation_block);
                 generator.switch_to_basic_block(continuation_block);
             }
             }
@@ -1342,7 +1312,7 @@ static Bytecode::CodeGenerationErrorOr<void> generate_array_binding_pattern_byte
             auto& iterator_is_not_exhausted_block = generator.make_block();
             auto& iterator_is_not_exhausted_block = generator.make_block();
 
 
             generator.emit<Bytecode::Op::Load>(is_iterator_exhausted_register);
             generator.emit<Bytecode::Op::Load>(is_iterator_exhausted_register);
-            generator.emit<Bytecode::Op::JumpConditional>().set_targets(
+            generator.emit<Bytecode::Op::JumpConditional>(
                 Bytecode::Label { iterator_is_exhausted_block },
                 Bytecode::Label { iterator_is_exhausted_block },
                 Bytecode::Label { iterator_is_not_exhausted_block });
                 Bytecode::Label { iterator_is_not_exhausted_block });
 
 
@@ -1358,7 +1328,7 @@ static Bytecode::CodeGenerationErrorOr<void> generate_array_binding_pattern_byte
         // We still have to check for exhaustion here. If the iterator is exhausted,
         // We still have to check for exhaustion here. If the iterator is exhausted,
         // we need to bail before trying to get the value
         // we need to bail before trying to get the value
         auto& no_bail_block = generator.make_block();
         auto& no_bail_block = generator.make_block();
-        generator.emit<Bytecode::Op::JumpConditional>().set_targets(
+        generator.emit<Bytecode::Op::JumpConditional>(
             Bytecode::Label { iterator_is_exhausted_block },
             Bytecode::Label { iterator_is_exhausted_block },
             Bytecode::Label { no_bail_block });
             Bytecode::Label { no_bail_block });
 
 
@@ -1369,16 +1339,12 @@ static Bytecode::CodeGenerationErrorOr<void> generate_array_binding_pattern_byte
         generator.emit<Bytecode::Op::IteratorResultValue>();
         generator.emit<Bytecode::Op::IteratorResultValue>();
 
 
         auto& create_binding_block = generator.make_block();
         auto& create_binding_block = generator.make_block();
-        generator.emit<Bytecode::Op::Jump>().set_targets(
-            Bytecode::Label { create_binding_block },
-            {});
+        generator.emit<Bytecode::Op::Jump>(Bytecode::Label { create_binding_block });
 
 
         // The iterator is exhausted, so we just load undefined and continue binding
         // The iterator is exhausted, so we just load undefined and continue binding
         generator.switch_to_basic_block(iterator_is_exhausted_block);
         generator.switch_to_basic_block(iterator_is_exhausted_block);
         generator.emit<Bytecode::Op::LoadImmediate>(js_undefined());
         generator.emit<Bytecode::Op::LoadImmediate>(js_undefined());
-        generator.emit<Bytecode::Op::Jump>().set_targets(
-            Bytecode::Label { create_binding_block },
-            {});
+        generator.emit<Bytecode::Op::Jump>(Bytecode::Label { create_binding_block });
 
 
         // Create the actual binding. The value which this entry must bind is now in the
         // Create the actual binding. The value which this entry must bind is now in the
         // accumulator. We can proceed, processing the alias as a nested  destructuring
         // accumulator. We can proceed, processing the alias as a nested  destructuring
@@ -1389,7 +1355,7 @@ static Bytecode::CodeGenerationErrorOr<void> generate_array_binding_pattern_byte
             auto& value_is_undefined_block = generator.make_block();
             auto& value_is_undefined_block = generator.make_block();
             auto& value_is_not_undefined_block = generator.make_block();
             auto& value_is_not_undefined_block = generator.make_block();
 
 
-            generator.emit<Bytecode::Op::JumpUndefined>().set_targets(
+            generator.emit<Bytecode::Op::JumpUndefined>(
                 Bytecode::Label { value_is_undefined_block },
                 Bytecode::Label { value_is_undefined_block },
                 Bytecode::Label { value_is_not_undefined_block });
                 Bytecode::Label { value_is_not_undefined_block });
 
 
@@ -1416,7 +1382,7 @@ static Bytecode::CodeGenerationErrorOr<void> generate_array_binding_pattern_byte
     auto& not_done_block = generator.make_block();
     auto& not_done_block = generator.make_block();
 
 
     generator.emit<Bytecode::Op::Load>(is_iterator_exhausted_register);
     generator.emit<Bytecode::Op::Load>(is_iterator_exhausted_register);
-    generator.emit<Bytecode::Op::JumpConditional>().set_targets(
+    generator.emit<Bytecode::Op::JumpConditional>(
         Bytecode::Label { done_block },
         Bytecode::Label { done_block },
         Bytecode::Label { not_done_block });
         Bytecode::Label { not_done_block });
 
 
@@ -2084,7 +2050,7 @@ Bytecode::CodeGenerationErrorOr<void> IfStatement::generate_bytecode(Bytecode::G
     auto& false_block = generator.make_block();
     auto& false_block = generator.make_block();
 
 
     TRY(m_predicate->generate_bytecode(generator));
     TRY(m_predicate->generate_bytecode(generator));
-    generator.emit<Bytecode::Op::JumpConditional>().set_targets(
+    generator.emit<Bytecode::Op::JumpConditional>(
         Bytecode::Label { true_block },
         Bytecode::Label { true_block },
         Bytecode::Label { false_block });
         Bytecode::Label { false_block });
 
 
@@ -2093,8 +2059,10 @@ Bytecode::CodeGenerationErrorOr<void> IfStatement::generate_bytecode(Bytecode::G
     generator.switch_to_basic_block(true_block);
     generator.switch_to_basic_block(true_block);
     generator.emit<Bytecode::Op::LoadImmediate>(js_undefined());
     generator.emit<Bytecode::Op::LoadImmediate>(js_undefined());
     TRY(m_consequent->generate_bytecode(generator));
     TRY(m_consequent->generate_bytecode(generator));
-    if (!generator.is_current_block_terminated())
-        true_block_jump = &generator.emit<Bytecode::Op::Jump>();
+    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.switch_to_basic_block(false_block);
     generator.switch_to_basic_block(false_block);
     auto& end_block = generator.make_block();
     auto& end_block = generator.make_block();
@@ -2103,7 +2071,7 @@ Bytecode::CodeGenerationErrorOr<void> IfStatement::generate_bytecode(Bytecode::G
     if (m_alternate)
     if (m_alternate)
         TRY(m_alternate->generate_bytecode(generator));
         TRY(m_alternate->generate_bytecode(generator));
     if (!generator.is_current_block_terminated())
     if (!generator.is_current_block_terminated())
-        generator.emit<Bytecode::Op::Jump>().set_targets(Bytecode::Label { end_block }, {});
+        generator.emit<Bytecode::Op::Jump>(Bytecode::Label { end_block });
 
 
     if (true_block_jump)
     if (true_block_jump)
         true_block_jump->set_targets(Bytecode::Label { end_block }, {});
         true_block_jump->set_targets(Bytecode::Label { end_block }, {});
@@ -2148,21 +2116,17 @@ Bytecode::CodeGenerationErrorOr<void> ConditionalExpression::generate_bytecode(B
     auto& end_block = generator.make_block();
     auto& end_block = generator.make_block();
 
 
     TRY(m_test->generate_bytecode(generator));
     TRY(m_test->generate_bytecode(generator));
-    generator.emit<Bytecode::Op::JumpConditional>().set_targets(
+    generator.emit<Bytecode::Op::JumpConditional>(
         Bytecode::Label { true_block },
         Bytecode::Label { true_block },
         Bytecode::Label { false_block });
         Bytecode::Label { false_block });
 
 
     generator.switch_to_basic_block(true_block);
     generator.switch_to_basic_block(true_block);
     TRY(m_consequent->generate_bytecode(generator));
     TRY(m_consequent->generate_bytecode(generator));
-    generator.emit<Bytecode::Op::Jump>().set_targets(
-        Bytecode::Label { end_block },
-        {});
+    generator.emit<Bytecode::Op::Jump>(Bytecode::Label { end_block });
 
 
     generator.switch_to_basic_block(false_block);
     generator.switch_to_basic_block(false_block);
     TRY(m_alternate->generate_bytecode(generator));
     TRY(m_alternate->generate_bytecode(generator));
-    generator.emit<Bytecode::Op::Jump>().set_targets(
-        Bytecode::Label { end_block },
-        {});
+    generator.emit<Bytecode::Op::Jump>(Bytecode::Label { end_block });
 
 
     generator.switch_to_basic_block(end_block);
     generator.switch_to_basic_block(end_block);
     return {};
     return {};
@@ -2406,7 +2370,7 @@ Bytecode::CodeGenerationErrorOr<void> TryStatement::generate_bytecode(Bytecode::
 
 
         if (!generator.is_current_block_terminated()) {
         if (!generator.is_current_block_terminated()) {
             if (m_finalizer) {
             if (m_finalizer) {
-                generator.emit<Bytecode::Op::Jump>(finalizer_target);
+                generator.emit<Bytecode::Op::Jump>(*finalizer_target);
             } else {
             } else {
                 VERIFY(!next_block);
                 VERIFY(!next_block);
                 next_block = &generator.make_block();
                 next_block = &generator.make_block();
@@ -2429,7 +2393,7 @@ Bytecode::CodeGenerationErrorOr<void> TryStatement::generate_bytecode(Bytecode::
     TRY(m_block->generate_bytecode(generator));
     TRY(m_block->generate_bytecode(generator));
     if (!generator.is_current_block_terminated()) {
     if (!generator.is_current_block_terminated()) {
         if (m_finalizer) {
         if (m_finalizer) {
-            generator.emit<Bytecode::Op::Jump>(finalizer_target);
+            generator.emit<Bytecode::Op::Jump>(*finalizer_target);
         } else {
         } else {
             if (!next_block)
             if (!next_block)
                 next_block = &generator.make_block();
                 next_block = &generator.make_block();
@@ -2466,7 +2430,7 @@ Bytecode::CodeGenerationErrorOr<void> SwitchStatement::generate_labelled_evaluat
     if (has_lexical_declarations)
     if (has_lexical_declarations)
         generator.block_declaration_instantiation(*this);
         generator.block_declaration_instantiation(*this);
 
 
-    generator.emit<Bytecode::Op::Jump>().set_targets(Bytecode::Label { *next_test_block }, {});
+    generator.emit<Bytecode::Op::Jump>(Bytecode::Label { *next_test_block });
 
 
     for (auto& switch_case : m_cases) {
     for (auto& switch_case : m_cases) {
         auto& case_block = generator.make_block();
         auto& case_block = generator.make_block();
@@ -2476,7 +2440,9 @@ Bytecode::CodeGenerationErrorOr<void> SwitchStatement::generate_labelled_evaluat
             TRY(switch_case->test()->generate_bytecode(generator));
             TRY(switch_case->test()->generate_bytecode(generator));
             generator.emit<Bytecode::Op::StrictlyEquals>(discriminant_reg);
             generator.emit<Bytecode::Op::StrictlyEquals>(discriminant_reg);
             next_test_block = &generator.make_block();
             next_test_block = &generator.make_block();
-            generator.emit<Bytecode::Op::JumpConditional>().set_targets(Bytecode::Label { case_entry_block }, Bytecode::Label { *next_test_block });
+            generator.emit<Bytecode::Op::JumpConditional>(
+                Bytecode::Label { case_entry_block },
+                Bytecode::Label { *next_test_block });
         } else {
         } else {
             entry_block_for_default = &case_entry_block;
             entry_block_for_default = &case_entry_block;
         }
         }
@@ -2485,7 +2451,7 @@ Bytecode::CodeGenerationErrorOr<void> SwitchStatement::generate_labelled_evaluat
         // as we must not clobber the possible non-empty completion value of the previous case when falling through.
         // 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.switch_to_basic_block(case_entry_block);
         generator.emit<Bytecode::Op::LoadImmediate>(js_undefined());
         generator.emit<Bytecode::Op::LoadImmediate>(js_undefined());
-        generator.emit<Bytecode::Op::Jump>().set_targets(Bytecode::Label { case_block }, {});
+        generator.emit<Bytecode::Op::Jump>(Bytecode::Label { case_block });
 
 
         case_blocks.append(case_block);
         case_blocks.append(case_block);
     }
     }
@@ -2493,10 +2459,10 @@ Bytecode::CodeGenerationErrorOr<void> SwitchStatement::generate_labelled_evaluat
     auto& end_block = generator.make_block();
     auto& end_block = generator.make_block();
 
 
     if (entry_block_for_default != nullptr) {
     if (entry_block_for_default != nullptr) {
-        generator.emit<Bytecode::Op::Jump>().set_targets(Bytecode::Label { *entry_block_for_default }, {});
+        generator.emit<Bytecode::Op::Jump>(Bytecode::Label { *entry_block_for_default });
     } else {
     } else {
         generator.emit<Bytecode::Op::LoadImmediate>(js_undefined());
         generator.emit<Bytecode::Op::LoadImmediate>(js_undefined());
-        generator.emit<Bytecode::Op::Jump>().set_targets(Bytecode::Label { end_block }, {});
+        generator.emit<Bytecode::Op::Jump>(Bytecode::Label { end_block });
     }
     }
     auto current_block = case_blocks.begin();
     auto current_block = case_blocks.begin();
     generator.begin_breakable_scope(Bytecode::Label { end_block }, label_set);
     generator.begin_breakable_scope(Bytecode::Label { end_block }, label_set);
@@ -2512,9 +2478,9 @@ Bytecode::CodeGenerationErrorOr<void> SwitchStatement::generate_labelled_evaluat
             auto next_block = current_block;
             auto next_block = current_block;
             next_block++;
             next_block++;
             if (next_block.is_end()) {
             if (next_block.is_end()) {
-                generator.emit<Bytecode::Op::Jump>().set_targets(Bytecode::Label { end_block }, {});
+                generator.emit<Bytecode::Op::Jump>(Bytecode::Label { end_block });
             } else {
             } else {
-                generator.emit<Bytecode::Op::Jump>().set_targets(Bytecode::Label { *next_block }, {});
+                generator.emit<Bytecode::Op::Jump>(Bytecode::Label { *next_block });
             }
             }
         }
         }
         current_block++;
         current_block++;
@@ -2747,8 +2713,9 @@ static Bytecode::CodeGenerationErrorOr<ForInOfHeadEvaluationResult> for_in_of_he
         // a. If exprValue is undefined or null, then
         // a. If exprValue is undefined or null, then
         auto& nullish_block = generator.make_block();
         auto& nullish_block = generator.make_block();
         auto& continuation_block = generator.make_block();
         auto& continuation_block = generator.make_block();
-        auto& jump = generator.emit<Bytecode::Op::JumpNullish>();
-        jump.set_targets(Bytecode::Label { nullish_block }, Bytecode::Label { continuation_block });
+        generator.emit<Bytecode::Op::JumpNullish>(
+            Bytecode::Label { nullish_block },
+            Bytecode::Label { continuation_block });
 
 
         // i. Return Completion Record { [[Type]]: break, [[Value]]: empty, [[Target]]: empty }.
         // i. Return Completion Record { [[Type]]: break, [[Value]]: empty, [[Target]]: empty }.
         generator.switch_to_basic_block(nullish_block);
         generator.switch_to_basic_block(nullish_block);
@@ -2834,7 +2801,9 @@ static Bytecode::CodeGenerationErrorOr<void> for_in_of_body_evaluation(Bytecode:
     generator.emit<Bytecode::Op::IteratorResultDone>();
     generator.emit<Bytecode::Op::IteratorResultDone>();
     // e. If done is true, return V.
     // e. If done is true, return V.
     auto& loop_continue = generator.make_block();
     auto& loop_continue = generator.make_block();
-    generator.emit<Bytecode::Op::JumpConditional>().set_targets(Bytecode::Label { loop_end }, Bytecode::Label { loop_continue });
+    generator.emit<Bytecode::Op::JumpConditional>(
+        Bytecode::Label { loop_end },
+        Bytecode::Label { loop_continue });
     generator.switch_to_basic_block(loop_continue);
     generator.switch_to_basic_block(loop_continue);
 
 
     // f. Let nextValue be ? IteratorValue(nextResult).
     // f. Let nextValue be ? IteratorValue(nextResult).
@@ -2983,7 +2952,7 @@ static Bytecode::CodeGenerationErrorOr<void> for_in_of_body_evaluation(Bytecode:
 
 
     // The body can contain an unconditional block terminator (e.g. return, throw), so we have to check for that before generating the Jump.
     // The body can contain an unconditional block terminator (e.g. return, throw), so we have to check for that before generating the Jump.
     if (!generator.is_current_block_terminated())
     if (!generator.is_current_block_terminated())
-        generator.emit<Bytecode::Op::Jump>().set_targets(Bytecode::Label { loop_update }, {});
+        generator.emit<Bytecode::Op::Jump>(Bytecode::Label { loop_update });
 
 
     generator.switch_to_basic_block(loop_end);
     generator.switch_to_basic_block(loop_end);
     generator.emit<Bytecode::Op::Load>(result_register);
     generator.emit<Bytecode::Op::Load>(result_register);

+ 3 - 3
Userland/Libraries/LibJS/Bytecode/Generator.cpp

@@ -394,13 +394,13 @@ void Generator::generate_scoped_jump(JumpType type)
         switch (boundary) {
         switch (boundary) {
         case Break:
         case Break:
             if (type == JumpType::Break) {
             if (type == JumpType::Break) {
-                emit<Op::Jump>().set_targets(nearest_breakable_scope(), {});
+                emit<Op::Jump>(nearest_breakable_scope());
                 return;
                 return;
             }
             }
             break;
             break;
         case Continue:
         case Continue:
             if (type == JumpType::Continue) {
             if (type == JumpType::Continue) {
-                emit<Op::Jump>().set_targets(nearest_continuable_scope(), {});
+                emit<Op::Jump>(nearest_continuable_scope());
                 return;
                 return;
             }
             }
             break;
             break;
@@ -455,7 +455,7 @@ void Generator::generate_labelled_jump(JumpType type, DeprecatedFlyString const&
         }
         }
 
 
         if (jumpable_scope.language_label_set.contains_slow(label)) {
         if (jumpable_scope.language_label_set.contains_slow(label)) {
-            emit<Op::Jump>().set_targets(jumpable_scope.bytecode_target, {});
+            emit<Op::Jump>(jumpable_scope.bytecode_target);
             return;
             return;
         }
         }
     }
     }

+ 6 - 6
Userland/Libraries/LibJS/Bytecode/Op.h

@@ -816,21 +816,21 @@ class Jump : public Instruction {
 public:
 public:
     constexpr static bool IsTerminator = true;
     constexpr static bool IsTerminator = true;
 
 
-    explicit Jump(Type type, Optional<Label> taken_target = {}, Optional<Label> nontaken_target = {})
+    explicit Jump(Type type, Label taken_target, Optional<Label> nontaken_target = {})
         : Instruction(type, sizeof(*this))
         : Instruction(type, sizeof(*this))
         , m_true_target(move(taken_target))
         , m_true_target(move(taken_target))
         , m_false_target(move(nontaken_target))
         , m_false_target(move(nontaken_target))
     {
     {
     }
     }
 
 
-    explicit Jump(Optional<Label> taken_target = {}, Optional<Label> nontaken_target = {})
+    explicit Jump(Label taken_target, Optional<Label> nontaken_target = {})
         : Instruction(Type::Jump, sizeof(*this))
         : Instruction(Type::Jump, sizeof(*this))
         , m_true_target(move(taken_target))
         , m_true_target(move(taken_target))
         , m_false_target(move(nontaken_target))
         , m_false_target(move(nontaken_target))
     {
     {
     }
     }
 
 
-    void set_targets(Optional<Label> true_target, Optional<Label> false_target)
+    void set_targets(Label true_target, Optional<Label> false_target)
     {
     {
         m_true_target = move(true_target);
         m_true_target = move(true_target);
         m_false_target = move(false_target);
         m_false_target = move(false_target);
@@ -849,7 +849,7 @@ protected:
 
 
 class JumpConditional final : public Jump {
 class JumpConditional final : public Jump {
 public:
 public:
-    explicit JumpConditional(Optional<Label> true_target = {}, Optional<Label> false_target = {})
+    explicit JumpConditional(Label true_target, Label false_target)
         : Jump(Type::JumpConditional, move(true_target), move(false_target))
         : Jump(Type::JumpConditional, move(true_target), move(false_target))
     {
     {
     }
     }
@@ -860,7 +860,7 @@ public:
 
 
 class JumpNullish final : public Jump {
 class JumpNullish final : public Jump {
 public:
 public:
-    explicit JumpNullish(Optional<Label> true_target = {}, Optional<Label> false_target = {})
+    explicit JumpNullish(Label true_target, Label false_target)
         : Jump(Type::JumpNullish, move(true_target), move(false_target))
         : Jump(Type::JumpNullish, move(true_target), move(false_target))
     {
     {
     }
     }
@@ -871,7 +871,7 @@ public:
 
 
 class JumpUndefined final : public Jump {
 class JumpUndefined final : public Jump {
 public:
 public:
-    explicit JumpUndefined(Optional<Label> true_target = {}, Optional<Label> false_target = {})
+    explicit JumpUndefined(Label true_target, Label false_target)
         : Jump(Type::JumpUndefined, move(true_target), move(false_target))
         : Jump(Type::JumpUndefined, move(true_target), move(false_target))
     {
     {
     }
     }