Skip to content

Commit

Permalink
Remove IteratorLoopStart opcode
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Jul 5, 2023
1 parent 175630a commit 445f63d
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 49 deletions.
2 changes: 1 addition & 1 deletion boa_engine/src/bytecompiler/jump_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl JumpRecord {
JumpRecordKind::Return if start_address != ByteCompiler::DUMMY_ADDRESS => {
compiler.returns_to_patch.push(Label {
index: start_address,
})
});
}
JumpRecordKind::Return => {
compiler.emit_opcode(Opcode::Return);
Expand Down
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 @@ -153,8 +153,6 @@ impl ByteCompiler<'_, '_> {
let early_exit = self.jump_if_null_or_undefined();
self.emit_opcode(Opcode::CreateForInIterator);

self.emit_opcode(Opcode::IteratorLoopStart);

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);
Expand Down Expand Up @@ -274,7 +272,6 @@ impl ByteCompiler<'_, '_> {
self.emit_opcode(Opcode::GetIterator);
}

self.emit_opcode(Opcode::IteratorLoopStart);
let start_address = self.next_opcode_location();
if for_of_loop.r#await() {
self.push_loop_control_info_for_await_of_loop(label, 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 @@ -551,7 +551,6 @@ impl CodeBlock {
| Opcode::PopEnvironment
| Opcode::LoopContinue
| Opcode::LoopStart
| Opcode::IteratorLoopStart
| Opcode::CreateForInIterator
| Opcode::GetIterator
| Opcode::GetAsyncIterator
Expand Down Expand Up @@ -656,7 +655,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 @@ -548,7 +548,6 @@ impl CodeBlock {
| Opcode::Super
| Opcode::LoopContinue
| Opcode::LoopStart
| Opcode::IteratorLoopStart
| 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
32 changes: 0 additions & 32 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,
};

/// `IteratorLoopStart` implements the Opcode Operation for `Opcode::IteratorLoopStart`
///
/// Operation:
/// - Push iterator loop start marker.
#[derive(Debug, Clone, Copy)]
pub(crate) struct IteratorLoopStart;

impl Operation for IteratorLoopStart {
const NAME: &'static str = "IteratorLoopStart";
const INSTRUCTION: &'static str = "INST - IteratorLoopStart";

fn execute(_context: &mut Context<'_>) -> JsResult<CompletionType> {
Ok(CompletionType::Normal)
}
}

/// `LoopStart` implements the Opcode Operation for `Opcode::LoopStart`
///
/// Operation:
Expand Down Expand Up @@ -62,19 +46,3 @@ impl Operation for LoopContinue {
Ok(CompletionType::Normal)
}
}

/// `LoopEnd` implements the Opcode Operation for `Opcode::LoopEnd`
///
/// Operation:
/// - Clean up environments at the end of a loop.
#[derive(Debug, Clone, Copy)]
pub(crate) struct LoopEnd;

impl Operation for LoopEnd {
const NAME: &'static str = "LoopEnd";
const INSTRUCTION: &'static str = "INST - LoopEnd";

fn execute(_context: &mut Context<'_>) -> JsResult<CompletionType> {
Ok(CompletionType::Normal)
}
}
11 changes: 2 additions & 9 deletions boa_engine/src/vm/opcode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1382,15 +1382,6 @@ generate_impl! {
/// Iterator Stack: `iterator`
CreateForInIterator,

/// Push iterator loop start marker.
///
/// Operands:
/// - start: `u32`
/// - exit: `u32`
///
/// Stack: **=>**
IteratorLoopStart,

/// Gets the iterator of an object.
///
/// Operands:
Expand Down Expand Up @@ -1767,6 +1758,8 @@ generate_impl! {
Reserved60 => Reserved,
/// Reserved [`Opcode`].
Reserved61 => Reserved,
/// Reserved [`Opcode`].
Reserved62 => Reserved,
}
}

Expand Down

0 comments on commit 445f63d

Please sign in to comment.