diff --git a/boa_engine/src/bytecompiler/statement/loop.rs b/boa_engine/src/bytecompiler/statement/loop.rs index fa8b68eaee5..38c2f18ecba 100644 --- a/boa_engine/src/bytecompiler/statement/loop.rs +++ b/boa_engine/src/bytecompiler/statement/loop.rs @@ -79,7 +79,7 @@ impl ByteCompiler<'_, '_> { } } - self.emit_opcode(Opcode::LoopContinue); + self.emit_opcode(Opcode::IncrementLoopIteration); if let Some(final_expr) = for_loop.final_expr() { self.compile_expr(final_expr, false); @@ -154,7 +154,7 @@ impl ByteCompiler<'_, '_> { let start_address = self.next_opcode_location(); self.push_loop_control_info_for_of_in_loop(label, start_address, use_expr); - self.emit_opcode(Opcode::LoopContinue); + self.emit_opcode(Opcode::IncrementLoopIteration); self.emit_opcode(Opcode::IteratorNext); self.emit_opcode(Opcode::IteratorDone); @@ -277,7 +277,7 @@ impl ByteCompiler<'_, '_> { } else { self.push_loop_control_info_for_of_in_loop(label, start_address, use_expr); } - self.emit_opcode(Opcode::LoopContinue); + self.emit_opcode(Opcode::IncrementLoopIteration); self.emit_opcode(Opcode::IteratorNext); if for_of_loop.r#await() { @@ -409,7 +409,7 @@ impl ByteCompiler<'_, '_> { use_expr: bool, ) { let start_address = self.next_opcode_location(); - self.emit_opcode(Opcode::LoopContinue); + self.emit_opcode(Opcode::IncrementLoopIteration); self.push_loop_control_info(label, start_address, use_expr); self.compile_expr(while_loop.condition(), true); @@ -436,7 +436,7 @@ impl ByteCompiler<'_, '_> { self.push_loop_control_info(label, start_address, use_expr); let condition_label_address = self.next_opcode_location(); - self.emit_opcode(Opcode::LoopContinue); + self.emit_opcode(Opcode::IncrementLoopIteration); self.compile_expr(do_while_loop.cond(), true); let exit = self.jump_if_false(); diff --git a/boa_engine/src/vm/code_block.rs b/boa_engine/src/vm/code_block.rs index e62698188fa..7d8f3fe9880 100644 --- a/boa_engine/src/vm/code_block.rs +++ b/boa_engine/src/vm/code_block.rs @@ -571,7 +571,7 @@ impl CodeBlock { | Opcode::Super | Opcode::Return | Opcode::PopEnvironment - | Opcode::LoopContinue + | Opcode::IncrementLoopIteration | Opcode::CreateForInIterator | Opcode::GetIterator | Opcode::GetAsyncIterator diff --git a/boa_engine/src/vm/flowgraph/mod.rs b/boa_engine/src/vm/flowgraph/mod.rs index f76d4f4e262..4499331ba27 100644 --- a/boa_engine/src/vm/flowgraph/mod.rs +++ b/boa_engine/src/vm/flowgraph/mod.rs @@ -492,7 +492,7 @@ impl CodeBlock { | Opcode::ToBoolean | Opcode::This | Opcode::Super - | Opcode::LoopContinue + | Opcode::IncrementLoopIteration | Opcode::CreateForInIterator | Opcode::GetIterator | Opcode::GetAsyncIterator diff --git a/boa_engine/src/vm/opcode/iteration/loop_ops.rs b/boa_engine/src/vm/opcode/iteration/loop_ops.rs index d2b248268cf..94fd85b0da2 100644 --- a/boa_engine/src/vm/opcode/iteration/loop_ops.rs +++ b/boa_engine/src/vm/opcode/iteration/loop_ops.rs @@ -4,16 +4,16 @@ use crate::{ Context, JsResult, }; -/// `LoopContinue` implements the Opcode Operation for `Opcode::LoopContinue`. +/// `IncrementLoopIteration` implements the Opcode Operation for `Opcode::IncrementLoopIteration`. /// /// Operation: -/// - Pushes a clean environment onto the frame's `EnvEntryStack`. +/// - Increment loop itearation count. #[derive(Debug, Clone, Copy)] -pub(crate) struct LoopContinue; +pub(crate) struct IncrementLoopIteration; -impl Operation for LoopContinue { - const NAME: &'static str = "LoopContinue"; - const INSTRUCTION: &'static str = "INST - LoopContinue"; +impl Operation for IncrementLoopIteration { + const NAME: &'static str = "IncrementLoopIteration"; + const INSTRUCTION: &'static str = "INST - IncrementLoopIteration"; fn execute(context: &mut Context<'_>) -> JsResult { let previous_iteration_count = context.vm.frame_mut().loop_iteration_count; diff --git a/boa_engine/src/vm/opcode/mod.rs b/boa_engine/src/vm/opcode/mod.rs index b91fe1373a9..d43841c7328 100644 --- a/boa_engine/src/vm/opcode/mod.rs +++ b/boa_engine/src/vm/opcode/mod.rs @@ -1368,12 +1368,14 @@ generate_impl! { /// Stack: **=>** PopEnvironment, - /// Clean up environments when a loop continues. + /// Increment loop itearation count. + /// + /// Used for limiting the loop iteration. /// /// Operands: /// /// Stack: **=>** - LoopContinue, + IncrementLoopIteration, /// Creates the ForInIterator of an object. ///