Skip to content

Commit

Permalink
Remove TryStart opcode
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Jul 9, 2023
1 parent 08e42bf commit 8ab2742
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 66 deletions.
2 changes: 1 addition & 1 deletion boa_engine/src/bytecompiler/statement/try.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl ByteCompiler<'_, '_> {
let has_finally = t.finally().is_some();
self.push_try_control_info(has_finally, try_start, use_expr);

self.emit_opcode(Opcode::TryStart);
// Compile try block
self.compile_block(t.block(), use_expr);

let end_address = self.next_opcode_location();
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 @@ -472,7 +472,6 @@ impl CodeBlock {
format!("done: {done}")
}
Opcode::Pop
| Opcode::TryStart
| Opcode::Dup
| Opcode::Swap
| Opcode::PushZero
Expand Down Expand Up @@ -651,7 +650,8 @@ impl CodeBlock {
| Opcode::Reserved57
| Opcode::Reserved58
| Opcode::Reserved59
| Opcode::Reserved60 => unreachable!("Reserved opcodes are unrechable"),
| Opcode::Reserved60
| Opcode::Reserved61 => 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 @@ -479,7 +479,6 @@ impl CodeBlock {
graph.add_edge(previous_pc, pc, None, Color::None, EdgeStyle::Line);
}
Opcode::Pop
| Opcode::TryStart
| Opcode::Dup
| Opcode::Swap
| Opcode::PushZero
Expand Down Expand Up @@ -672,7 +671,8 @@ impl CodeBlock {
| Opcode::Reserved57
| Opcode::Reserved58
| Opcode::Reserved59
| Opcode::Reserved60 => unreachable!("Reserved opcodes are unrechable"),
| Opcode::Reserved60
| Opcode::Reserved61 => unreachable!("Reserved opcodes are unrechable"),
}
}

Expand Down
2 changes: 0 additions & 2 deletions boa_engine/src/vm/opcode/control_flow/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
pub(crate) mod r#return;
pub(crate) mod throw;
pub(crate) mod r#try;

pub(crate) use r#return::*;
pub(crate) use r#try::*;
pub(crate) use throw::*;
32 changes: 0 additions & 32 deletions boa_engine/src/vm/opcode/control_flow/return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,6 @@ impl Operation for Return {
const INSTRUCTION: &'static str = "INST - Return";

fn execute(_context: &mut Context<'_>) -> JsResult<CompletionType> {
// let current_address = context.vm.frame().pc;
// let mut env_to_pop = 0;
// let mut finally_address = None;
// while let Some(env_entry) = context.vm.frame().env_stack.last() {
// if env_entry.is_finally_env() {
// if env_entry.start_address() < current_address {
// finally_address = Some(env_entry.exit_address());
// } else {
// finally_address = Some(env_entry.start_address());
// }
// break;
// }

// env_to_pop += env_entry.env_num();
// if env_entry.is_global_env() {
// break;
// }

// context.vm.frame_mut().env_stack.pop();
// }

// let env_truncation_len = context.vm.environments.len().saturating_sub(env_to_pop);
// context.vm.environments.truncate(env_truncation_len);

// let record = AbruptCompletionRecord::new_return();
// context.vm.frame_mut().abrupt_completion = Some(record);

// if let Some(finally) = finally_address {
// context.vm.frame_mut().pc = finally;
// return Ok(CompletionType::Normal);
// }

Ok(CompletionType::Return)
}
}
Expand Down
20 changes: 0 additions & 20 deletions boa_engine/src/vm/opcode/control_flow/try.rs

This file was deleted.

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 @@ -1152,13 +1152,6 @@ generate_impl! {
/// Stack: **=>**
ThrowNewTypeError,

/// TODO: doc
///
/// Operands:
///
/// Stack: **=>**
TryStart,

/// Pops value converts it to boolean and pushes it back.
///
/// Operands:
Expand Down Expand Up @@ -1770,6 +1763,8 @@ generate_impl! {
Reserved59 => Reserved,
/// Reserved [`Opcode`].
Reserved60 => Reserved,
/// Reserved [`Opcode`].
Reserved61 => Reserved,
}
}

Expand Down

0 comments on commit 8ab2742

Please sign in to comment.