From 089d10695a74619e66f8b1f866412dcae6cdbc1d Mon Sep 17 00:00:00 2001 From: Haled Odat <8566042+HalidOdat@users.noreply.github.com> Date: Wed, 12 Jul 2023 15:16:43 +0200 Subject: [PATCH] Remove LoopStart opcode --- boa_engine/src/bytecompiler/statement/loop.rs | 3 --- boa_engine/src/bytecompiler/statement/switch.rs | 2 -- boa_engine/src/vm/code_block.rs | 4 ++-- boa_engine/src/vm/flowgraph/mod.rs | 4 ++-- boa_engine/src/vm/opcode/iteration/loop_ops.rs | 17 ----------------- boa_engine/src/vm/opcode/mod.rs | 7 ++----- 6 files changed, 6 insertions(+), 31 deletions(-) diff --git a/boa_engine/src/bytecompiler/statement/loop.rs b/boa_engine/src/bytecompiler/statement/loop.rs index 381cb023906..7438db829ec 100644 --- a/boa_engine/src/bytecompiler/statement/loop.rs +++ b/boa_engine/src/bytecompiler/statement/loop.rs @@ -57,7 +57,6 @@ impl ByteCompiler<'_, '_> { } self.push_empty_loop_jump_control(use_expr); - self.emit_opcode(Opcode::LoopStart); let initial_jump = self.jump(); let start_address = self.next_opcode_location(); @@ -415,7 +414,6 @@ impl ByteCompiler<'_, '_> { label: Option, use_expr: bool, ) { - self.emit_opcode(Opcode::LoopStart); let start_address = self.next_opcode_location(); self.emit_opcode(Opcode::LoopContinue); self.push_loop_control_info(label, start_address, use_expr); @@ -437,7 +435,6 @@ impl ByteCompiler<'_, '_> { label: Option, use_expr: bool, ) { - self.emit_opcode(Opcode::LoopStart); let initial_label = self.jump(); let start_address = self.next_opcode_location(); diff --git a/boa_engine/src/bytecompiler/statement/switch.rs b/boa_engine/src/bytecompiler/statement/switch.rs index 6fd0ccaf3cd..46df6c692f9 100644 --- a/boa_engine/src/bytecompiler/statement/switch.rs +++ b/boa_engine/src/bytecompiler/statement/switch.rs @@ -11,8 +11,6 @@ impl ByteCompiler<'_, '_> { self.block_declaration_instantiation(switch); - self.emit_opcode(Opcode::LoopStart); - let start_address = self.next_opcode_location(); self.push_switch_control_info(None, start_address, use_expr); diff --git a/boa_engine/src/vm/code_block.rs b/boa_engine/src/vm/code_block.rs index 34f177a1651..ddce1edcb4a 100644 --- a/boa_engine/src/vm/code_block.rs +++ b/boa_engine/src/vm/code_block.rs @@ -544,7 +544,6 @@ impl CodeBlock { | Opcode::Return | Opcode::PopEnvironment | Opcode::LoopContinue - | Opcode::LoopStart | Opcode::CreateForInIterator | Opcode::GetIterator | Opcode::GetAsyncIterator @@ -651,7 +650,8 @@ impl CodeBlock { | Opcode::Reserved58 | Opcode::Reserved59 | Opcode::Reserved60 - | Opcode::Reserved61 => unreachable!("Reserved opcodes are unrechable"), + | Opcode::Reserved61 + | Opcode::Reserved62 => unreachable!("Reserved opcodes are unrechable"), } } } diff --git a/boa_engine/src/vm/flowgraph/mod.rs b/boa_engine/src/vm/flowgraph/mod.rs index 4913ca2a931..bbbb3c7c2b2 100644 --- a/boa_engine/src/vm/flowgraph/mod.rs +++ b/boa_engine/src/vm/flowgraph/mod.rs @@ -546,7 +546,6 @@ impl CodeBlock { | Opcode::This | Opcode::Super | Opcode::LoopContinue - | Opcode::LoopStart | Opcode::CreateForInIterator | Opcode::GetIterator | Opcode::GetAsyncIterator @@ -672,7 +671,8 @@ impl CodeBlock { | Opcode::Reserved58 | Opcode::Reserved59 | Opcode::Reserved60 - | Opcode::Reserved61 => unreachable!("Reserved opcodes are unrechable"), + | Opcode::Reserved61 + | Opcode::Reserved62 => unreachable!("Reserved opcodes are unrechable"), } } diff --git a/boa_engine/src/vm/opcode/iteration/loop_ops.rs b/boa_engine/src/vm/opcode/iteration/loop_ops.rs index bf210637ff4..d2b248268cf 100644 --- a/boa_engine/src/vm/opcode/iteration/loop_ops.rs +++ b/boa_engine/src/vm/opcode/iteration/loop_ops.rs @@ -4,22 +4,6 @@ use crate::{ Context, JsResult, }; -/// `LoopStart` implements the Opcode Operation for `Opcode::LoopStart` -/// -/// Operation: -/// - Push loop start marker. -#[derive(Debug, Clone, Copy)] -pub(crate) struct LoopStart; - -impl Operation for LoopStart { - const NAME: &'static str = "LoopStart"; - const INSTRUCTION: &'static str = "INST - LoopStart"; - - fn execute(_context: &mut Context<'_>) -> JsResult { - Ok(CompletionType::Normal) - } -} - /// `LoopContinue` implements the Opcode Operation for `Opcode::LoopContinue`. /// /// Operation: @@ -42,7 +26,6 @@ impl Operation for LoopContinue { } context.vm.frame_mut().loop_iteration_count = previous_iteration_count.wrapping_add(1); - Ok(CompletionType::Normal) } } diff --git a/boa_engine/src/vm/opcode/mod.rs b/boa_engine/src/vm/opcode/mod.rs index 717e4239e14..6adb27b0615 100644 --- a/boa_engine/src/vm/opcode/mod.rs +++ b/boa_engine/src/vm/opcode/mod.rs @@ -1356,11 +1356,6 @@ generate_impl! { /// Stack: **=>** PopEnvironment, - /// Loop start marker. - /// - /// Stack: **=>** - LoopStart, - /// Clean up environments when a loop continues. /// /// Operands: @@ -1765,6 +1760,8 @@ generate_impl! { Reserved60 => Reserved, /// Reserved [`Opcode`]. Reserved61 => Reserved, + /// Reserved [`Opcode`]. + Reserved62 => Reserved, } }