Skip to content

Commit

Permalink
Remove GeneratorResumeReturn opcode
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Jul 20, 2023
1 parent 55ee085 commit 01947e0
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 31 deletions.
1 change: 0 additions & 1 deletion boa_engine/src/bytecompiler/expression/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ impl ByteCompiler<'_, '_> {
self.close_active_iterators();

self.emit_opcode(Opcode::SetReturnValue);
self.emit_opcode(Opcode::GeneratorResumeReturn);
self.r#return();

self.patch_jump(throw_method_undefined);
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 @@ -550,7 +550,6 @@ impl CodeBlock {
| Opcode::CreateForInIterator
| Opcode::GetIterator
| Opcode::GetAsyncIterator
| Opcode::GeneratorResumeReturn
| Opcode::IteratorNext
| Opcode::IteratorNextWithoutPop
| Opcode::IteratorFinishAsyncNext
Expand Down Expand Up @@ -654,7 +653,8 @@ impl CodeBlock {
| Opcode::Reserved59
| Opcode::Reserved60
| Opcode::Reserved61
| Opcode::Reserved62 => unreachable!("Reserved opcodes are unrechable"),
| Opcode::Reserved62
| Opcode::Reserved63 => unreachable!("Reserved opcodes are unrechable"),
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions boa_engine/src/vm/flowgraph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ impl CodeBlock {
graph.add_node(previous_pc, NodeShape::None, label.into(), Color::None);
graph.add_edge(previous_pc, pc, None, Color::None, EdgeStyle::Line);
}
Opcode::Return | Opcode::GeneratorResumeReturn => {
Opcode::Return => {
// FIXME:
//
// graph.add_node(previous_pc, NodeShape::None, label.into(), Color::None);
Expand Down Expand Up @@ -673,7 +673,8 @@ impl CodeBlock {
| Opcode::Reserved59
| Opcode::Reserved60
| Opcode::Reserved61
| Opcode::Reserved62 => unreachable!("Reserved opcodes are unrechable"),
| Opcode::Reserved62
| Opcode::Reserved63 => unreachable!("Reserved opcodes are unrechable"),
}
}

Expand Down
19 changes: 0 additions & 19 deletions boa_engine/src/vm/opcode/generator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,6 @@ impl Operation for GeneratorSetReturn {
}
}

/// `GeneratorResumeReturn` implements the Opcode Operation for `Opcode::GeneratorResumeReturn`
///
/// Operation:
/// - Resumes a generator with a return completion.
#[derive(Debug, Clone, Copy)]
pub(crate) struct GeneratorResumeReturn;

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

fn execute(context: &mut Context<'_>) -> JsResult<CompletionType> {
if context.vm.frame().generator_resume_kind == GeneratorResumeKind::Throw {
return Err(JsError::from_opaque(context.vm.pop()));
}
Ok(CompletionType::Normal)
}
}

/// `GeneratorDelegateNext` implements the Opcode Operation for `Opcode::GeneratorDelegateNext`
///
/// Operation:
Expand Down
9 changes: 2 additions & 7 deletions boa_engine/src/vm/opcode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1530,13 +1530,6 @@ generate_impl! {
/// Stack: received **=>**
GeneratorNext,

/// Resumes a generator with a return completion.
///
/// Operands:
///
/// Stack: **=>**
GeneratorResumeReturn,

/// Yields from the current async generator execution.
///
/// Operands:
Expand Down Expand Up @@ -1762,6 +1755,8 @@ generate_impl! {
Reserved61 => Reserved,
/// Reserved [`Opcode`].
Reserved62 => Reserved,
/// Reserved [`Opcode`].
Reserved63 => Reserved,
}
}

Expand Down

0 comments on commit 01947e0

Please sign in to comment.