Skip to content

Commit

Permalink
Remove Cell and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Jun 11, 2023
1 parent a76cbb2 commit bda8fcd
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 34 deletions.
2 changes: 1 addition & 1 deletion boa_engine/src/bytecompiler/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl FunctionCompiler {
if compiler
.bytecode
.last()
.filter(|last| **last == (Opcode::Return as u8).into())
.filter(|last| **last == Opcode::Return as u8)
.is_none()
{
compiler.emit_opcode(Opcode::PushUndefined);
Expand Down
12 changes: 6 additions & 6 deletions boa_engine/src/bytecompiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ pub struct ByteCompiler<'ctx, 'host> {
pub(crate) params: FormalParameterList,

/// Bytecode
pub(crate) bytecode: Vec<Cell<u8>>,
pub(crate) bytecode: Vec<u8>,

/// Literals
pub(crate) literals: Vec<JsValue>,
Expand Down Expand Up @@ -429,23 +429,23 @@ impl<'ctx, 'host> ByteCompiler<'ctx, 'host> {
}

fn emit_u64(&mut self, value: u64) {
self.bytecode.extend(value.to_ne_bytes().map(Cell::new));
self.bytecode.extend(value.to_ne_bytes());
}

fn emit_u32(&mut self, value: u32) {
self.bytecode.extend(value.to_ne_bytes().map(Cell::new));
self.bytecode.extend(value.to_ne_bytes());
}

fn emit_u16(&mut self, value: u16) {
self.bytecode.extend(value.to_ne_bytes().map(Cell::new));
self.bytecode.extend(value.to_ne_bytes());
}

pub(crate) fn emit_opcode(&mut self, opcode: Opcode) {
self.emit_u8(opcode as u8);
}

fn emit_u8(&mut self, value: u8) {
self.bytecode.push(Cell::new(value));
self.bytecode.push(value);
}

fn emit_push_integer(&mut self, value: i32) {
Expand Down Expand Up @@ -550,7 +550,7 @@ impl<'ctx, 'host> ByteCompiler<'ctx, 'host> {
let Label { index } = label;

let index = index as usize;
let bytes = target.to_ne_bytes().map(Cell::new);
let bytes = target.to_ne_bytes();

// This is done to avoid unneeded bounds checks.
assert!(self.bytecode.len() > index + U32_SIZE && usize::MAX - U32_SIZE >= index);
Expand Down
6 changes: 3 additions & 3 deletions boa_engine/src/vm/code_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ pub struct CodeBlock {

/// Bytecode
#[unsafe_ignore_trace]
pub(crate) bytecode: Box<[Cell<u8>]>,
pub(crate) bytecode: Box<[u8]>,

/// Literals
pub(crate) literals: Box<[JsValue]>,
Expand Down Expand Up @@ -318,7 +318,7 @@ impl CodeBlock {
/// Returns an empty `String` if no operands are present.
#[cfg(any(feature = "trace", feature = "flowgraph"))]
pub(crate) fn instruction_operands(&self, pc: &mut usize, interner: &Interner) -> String {
let opcode: Opcode = self.bytecode[*pc].get().into();
let opcode: Opcode = self.bytecode[*pc].into();
*pc += size_of::<Opcode>();
match opcode {
Opcode::SetFunctionName => {
Expand Down Expand Up @@ -705,7 +705,7 @@ impl ToInternedString for CodeBlock {
let mut pc = 0;
let mut count = 0;
while pc < self.bytecode.len() {
let opcode: Opcode = self.bytecode[pc].get().into();
let opcode: Opcode = self.bytecode[pc].into();
let opcode = opcode.as_str();
let previous_pc = pc;
let operands = self.instruction_operands(&mut pc, interner);
Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/vm/flowgraph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl CodeBlock {

let mut pc = 0;
while pc < self.bytecode.len() {
let opcode: Opcode = self.bytecode[pc].get().into();
let opcode: Opcode = self.bytecode[pc].into();
let opcode_str = opcode.as_str();
let previous_pc = pc;

Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/vm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl Context<'_> {
let frame = self.vm.frame_mut();

let pc = frame.pc;
let opcode = Opcode::from(frame.code_block.bytecode[pc as usize].get());
let opcode = Opcode::from(frame.code_block.bytecode[pc as usize]);
frame.pc += 1;
opcode
};
Expand Down
14 changes: 0 additions & 14 deletions boa_engine/src/vm/opcode/get/property.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ impl Operation for GetPropertyByName {
if slot.is_cachable() {
let object_borrowed = object.borrow();
if ic.matches(object_borrowed.shape()) {
// println!(
// "GET: T: \"{}\" {}: {:?}",
// ic.name.to_std_string_escaped(),
// slot.index,
// slot.attributes
// );
let mut result = if slot.attributes.contains(SlotAttributes::PROTOTYPE) {
let prototype = object
.borrow()
Expand Down Expand Up @@ -70,14 +64,6 @@ impl Operation for GetPropertyByName {

slot = *context.slot();

// println!(
// "GET: F: \"{}\" {}: {:?} - {}",
// key,
// slot.index,
// slot.attributes,
// result.type_of()
// );

// Cache the property.
if slot.attributes.is_cachable() {
let ic = &context.vm.frame().code_block.ic[ic_index];
Expand Down
8 changes: 0 additions & 8 deletions boa_engine/src/vm/opcode/set/property.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ impl Operation for SetPropertyByName {
if slot.is_cachable() {
let object_borrowed = object.borrow();
if ic.matches(object_borrowed.shape()) {
// println!(
// "SET: T: \"{}\" {}: {:?}",
// ic.name.to_std_string_escaped(),
// slot.index,
// slot.attributes
// );
let slot_index = slot.index as usize;

if slot.attributes.is_accessor_descriptor() {
Expand Down Expand Up @@ -97,8 +91,6 @@ impl Operation for SetPropertyByName {

slot = *context.slot();

// println!("SET: F: \"{}\" {}: {:?}", name, slot.index, slot.attributes);

// Cache the property.
if succeeded && slot.is_cachable() {
let ic = &context.vm.frame().code_block.ic[ic_index];
Expand Down

0 comments on commit bda8fcd

Please sign in to comment.