Skip to content

Commit

Permalink
Remove LoopStart opcode
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Jul 12, 2023
1 parent 8ab2742 commit 089d106
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 31 deletions.
3 changes: 0 additions & 3 deletions boa_engine/src/bytecompiler/statement/loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -415,7 +414,6 @@ impl ByteCompiler<'_, '_> {
label: Option<Sym>,
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);
Expand All @@ -437,7 +435,6 @@ impl ByteCompiler<'_, '_> {
label: Option<Sym>,
use_expr: bool,
) {
self.emit_opcode(Opcode::LoopStart);
let initial_label = self.jump();

let start_address = self.next_opcode_location();
Expand Down
2 changes: 0 additions & 2 deletions boa_engine/src/bytecompiler/statement/switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions boa_engine/src/vm/code_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,6 @@ impl CodeBlock {
| Opcode::Return
| Opcode::PopEnvironment
| Opcode::LoopContinue
| Opcode::LoopStart
| Opcode::CreateForInIterator
| Opcode::GetIterator
| Opcode::GetAsyncIterator
Expand Down Expand Up @@ -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"),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions boa_engine/src/vm/flowgraph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,6 @@ impl CodeBlock {
| Opcode::This
| Opcode::Super
| Opcode::LoopContinue
| Opcode::LoopStart
| Opcode::CreateForInIterator
| Opcode::GetIterator
| Opcode::GetAsyncIterator
Expand Down Expand Up @@ -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"),
}
}

Expand Down
17 changes: 0 additions & 17 deletions boa_engine/src/vm/opcode/iteration/loop_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CompletionType> {
Ok(CompletionType::Normal)
}
}

/// `LoopContinue` implements the Opcode Operation for `Opcode::LoopContinue`.
///
/// Operation:
Expand All @@ -42,7 +26,6 @@ impl Operation for LoopContinue {
}

context.vm.frame_mut().loop_iteration_count = previous_iteration_count.wrapping_add(1);

Ok(CompletionType::Normal)
}
}
7 changes: 2 additions & 5 deletions boa_engine/src/vm/opcode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1356,11 +1356,6 @@ generate_impl! {
/// Stack: **=>**
PopEnvironment,

/// Loop start marker.
///
/// Stack: **=>**
LoopStart,

/// Clean up environments when a loop continues.
///
/// Operands:
Expand Down Expand Up @@ -1765,6 +1760,8 @@ generate_impl! {
Reserved60 => Reserved,
/// Reserved [`Opcode`].
Reserved61 => Reserved,
/// Reserved [`Opcode`].
Reserved62 => Reserved,
}
}

Expand Down

0 comments on commit 089d106

Please sign in to comment.