Skip to content

Commit

Permalink
Remove unneeded opcode
Browse files Browse the repository at this point in the history
  • Loading branch information
raskad committed Dec 3, 2021
1 parent 2b797a4 commit 1b05e64
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 31 deletions.
7 changes: 0 additions & 7 deletions boa/src/bytecompiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,6 @@ impl ByteCompiler {
PropertyName::Computed(name_node) => {
self.compile_stmt(name_node, true);
self.compile_stmt(node, true);
self.emit_opcode(Opcode::Swap2);
self.emit_opcode(Opcode::DefineOwnPropertyByValue);
}
},
Expand All @@ -706,7 +705,6 @@ impl ByteCompiler {
PropertyName::Computed(name_node) => {
self.compile_stmt(name_node, true);
self.compile_stmt(&func.clone().into(), true);
self.emit_opcode(Opcode::Swap2);
self.emit_opcode(Opcode::SetPropertyGetterByValue);
}
},
Expand All @@ -720,7 +718,6 @@ impl ByteCompiler {
PropertyName::Computed(name_node) => {
self.compile_stmt(name_node, true);
self.compile_stmt(&func.clone().into(), true);
self.emit_opcode(Opcode::Swap2);
self.emit_opcode(Opcode::SetPropertySetterByValue);
}
},
Expand All @@ -734,7 +731,6 @@ impl ByteCompiler {
PropertyName::Computed(name_node) => {
self.compile_stmt(name_node, true);
self.compile_stmt(&func.clone().into(), true);
self.emit_opcode(Opcode::Swap2);
self.emit_opcode(Opcode::DefineOwnPropertyByValue);
}
},
Expand All @@ -750,7 +746,6 @@ impl ByteCompiler {
PropertyName::Computed(name_node) => {
self.compile_stmt(name_node, true);
self.emit_opcode(Opcode::PushUndefined);
self.emit_opcode(Opcode::Swap2);
self.emit_opcode(Opcode::DefineOwnPropertyByValue);
}
}
Expand All @@ -767,7 +762,6 @@ impl ByteCompiler {
PropertyName::Computed(name_node) => {
self.compile_stmt(name_node, true);
self.emit_opcode(Opcode::PushUndefined);
self.emit_opcode(Opcode::Swap2);
self.emit_opcode(Opcode::DefineOwnPropertyByValue);
}
}
Expand All @@ -784,7 +778,6 @@ impl ByteCompiler {
PropertyName::Computed(name_node) => {
self.compile_stmt(name_node, true);
self.emit_opcode(Opcode::PushUndefined);
self.emit_opcode(Opcode::Swap2);
self.emit_opcode(Opcode::DefineOwnPropertyByValue);
}
}
Expand Down
1 change: 0 additions & 1 deletion boa/src/vm/code_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ impl CodeBlock {
Opcode::Pop
| Opcode::Dup
| Opcode::Swap
| Opcode::Swap2
| Opcode::PushZero
| Opcode::PushOne
| Opcode::PushNaN
Expand Down
21 changes: 6 additions & 15 deletions boa/src/vm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,6 @@ impl Context {
self.vm.push(first);
self.vm.push(second);
}
Opcode::Swap2 => {
let first = self.vm.pop();
let second = self.vm.pop();
let third = self.vm.pop();

self.vm.push(first);
self.vm.push(second);
self.vm.push(third);
}
Opcode::PushUndefined => self.vm.push(JsValue::undefined()),
Opcode::PushNull => self.vm.push(JsValue::null()),
Opcode::PushTrue => self.vm.push(true),
Expand Down Expand Up @@ -523,9 +514,9 @@ impl Context {
)?;
}
Opcode::DefineOwnPropertyByValue => {
let object = self.vm.pop();
let key = self.vm.pop();
let value = self.vm.pop();
let key = self.vm.pop();
let object = self.vm.pop();
let object = if let Some(object) = object.as_object() {
object.clone()
} else {
Expand Down Expand Up @@ -571,9 +562,9 @@ impl Context {
)?;
}
Opcode::SetPropertyGetterByValue => {
let object = self.vm.pop();
let key = self.vm.pop();
let value = self.vm.pop();
let key = self.vm.pop();
let object = self.vm.pop();
let object = object.to_object(self)?;
let name = key.to_property_key(self)?;
let set = object
Expand Down Expand Up @@ -617,9 +608,9 @@ impl Context {
)?;
}
Opcode::SetPropertySetterByValue => {
let object = self.vm.pop();
let key = self.vm.pop();
let value = self.vm.pop();
let key = self.vm.pop();
let object = self.vm.pop();
let object = object.to_object(self)?;
let name = key.to_property_key(self)?;
let get = object
Expand Down
8 changes: 0 additions & 8 deletions boa/src/vm/opcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ pub enum Opcode {
/// Stack: v1, v2 **=>** v2, v1
Swap,

/// Swap the top value and the third value of the stack.
///
/// Operands:
///
/// Stack: v1, v2, v3 **=>** v3, v2, v1
Swap2,

/// Push integer `0` on the stack.
///
/// Operands:
Expand Down Expand Up @@ -800,7 +793,6 @@ impl Opcode {
Opcode::Pop => "Pop",
Opcode::Dup => "Dup",
Opcode::Swap => "Swap",
Opcode::Swap2 => "Swap2",
Opcode::PushZero => "PushZero",
Opcode::PushOne => "PushOne",
Opcode::PushInt8 => "PushInt8",
Expand Down

0 comments on commit 1b05e64

Please sign in to comment.