diff --git a/boa_engine/src/bytecompiler/mod.rs b/boa_engine/src/bytecompiler/mod.rs index 57b44595827..6e3ecd4488e 100644 --- a/boa_engine/src/bytecompiler/mod.rs +++ b/boa_engine/src/bytecompiler/mod.rs @@ -465,23 +465,23 @@ impl<'ctx, 'host> ByteCompiler<'ctx, 'host> { } pub(crate) fn emit(&mut self, opcode: Opcode, operands: &[Operand]) { - let mut varying_kind = VaryingOperandKind::Short; + let mut varying_kind = VaryingOperandKind::U8; for operand in operands { if let Operand::Varying(operand) = *operand { if u8::try_from(operand).is_ok() { } else if u16::try_from(operand).is_ok() { - varying_kind = VaryingOperandKind::Half; + varying_kind = VaryingOperandKind::U16; } else { - varying_kind = VaryingOperandKind::Wide; + varying_kind = VaryingOperandKind::U32; break; } } } match varying_kind { - VaryingOperandKind::Short => {} - VaryingOperandKind::Half => self.emit_opcode(Opcode::Half), - VaryingOperandKind::Wide => self.emit_opcode(Opcode::Wide), + VaryingOperandKind::U8 => {} + VaryingOperandKind::U16 => self.emit_opcode(Opcode::ModifierU16), + VaryingOperandKind::U32 => self.emit_opcode(Opcode::ModifierU32), } self.emit_opcode(opcode); for operand in operands { @@ -497,11 +497,11 @@ impl<'ctx, 'host> ByteCompiler<'ctx, 'host> { self.emit_opcode(opcode); self.emit_u8(operand); } else if let Ok(operand) = u16::try_from(operand) { - self.emit_opcode(Opcode::Half); + self.emit_opcode(Opcode::ModifierU16); self.emit_opcode(opcode); self.emit_u16(operand); } else { - self.emit_opcode(Opcode::Wide); + self.emit_opcode(Opcode::ModifierU32); self.emit_opcode(opcode); self.emit_u32(operand); } @@ -519,9 +519,9 @@ impl<'ctx, 'host> ByteCompiler<'ctx, 'host> { Operand::I64(v) => self.emit_i64(v), Operand::U64(v) => self.emit_u64(v), Operand::Varying(v) => match varying_kind { - VaryingOperandKind::Short => self.emit_u8(v as u8), - VaryingOperandKind::Half => self.emit_u16(v as u16), - VaryingOperandKind::Wide => self.emit_u32(v), + VaryingOperandKind::U8 => self.emit_u8(v as u8), + VaryingOperandKind::U16 => self.emit_u16(v as u16), + VaryingOperandKind::U32 => self.emit_u32(v), }, } } diff --git a/boa_engine/src/vm/code_block.rs b/boa_engine/src/vm/code_block.rs index a6555d8259f..076b0af8408 100644 --- a/boa_engine/src/vm/code_block.rs +++ b/boa_engine/src/vm/code_block.rs @@ -574,8 +574,8 @@ impl CodeBlock { | Instruction::SetReturnValue | Instruction::Nop => String::new(), - Instruction::Half - | Instruction::Wide + Instruction::ModifierU16 + | Instruction::ModifierU32 | Instruction::Reserved1 | Instruction::Reserved2 | Instruction::Reserved3 @@ -676,9 +676,9 @@ impl ToInternedString for CodeBlock { }; let varying_operand_kind = match varying_operand_kind { - super::VaryingOperandKind::Short => "", - super::VaryingOperandKind::Half => ".Half", - super::VaryingOperandKind::Wide => ".Wide", + super::VaryingOperandKind::U8 => "", + super::VaryingOperandKind::U16 => ".U16", + super::VaryingOperandKind::U32 => ".U32", }; f.push_str(&format!( diff --git a/boa_engine/src/vm/flowgraph/mod.rs b/boa_engine/src/vm/flowgraph/mod.rs index 029fea2c899..6d2dc2f85e4 100644 --- a/boa_engine/src/vm/flowgraph/mod.rs +++ b/boa_engine/src/vm/flowgraph/mod.rs @@ -18,10 +18,6 @@ use super::{Instruction, InstructionIterator}; impl CodeBlock { /// Output the [`CodeBlock`] VM instructions into a [`Graph`]. - /// - /// # Panics - /// - /// TODO: #[allow(clippy::match_same_arms)] pub fn to_graph(&self, interner: &Interner, graph: &mut SubGraph) { // Have to remove any invalid graph chars like `<` or `>`. @@ -469,8 +465,8 @@ impl CodeBlock { Instruction::Return => { graph.add_node(previous_pc, NodeShape::Diamond, label.into(), Color::Red); } - Instruction::Half - | Instruction::Wide + Instruction::ModifierU16 + | Instruction::ModifierU32 | Instruction::Reserved1 | Instruction::Reserved2 | Instruction::Reserved3 diff --git a/boa_engine/src/vm/mod.rs b/boa_engine/src/vm/mod.rs index 0d071218b26..ee3b2e8f7c1 100644 --- a/boa_engine/src/vm/mod.rs +++ b/boa_engine/src/vm/mod.rs @@ -32,11 +32,11 @@ mod runtime_limits; #[cfg(feature = "flowgraph")] pub mod flowgraph; +pub(crate) use opcode::{Instruction, InstructionIterator, Opcode, VaryingOperandKind}; pub use runtime_limits::RuntimeLimits; pub use { call_frame::{CallFrame, GeneratorResumeKind}, code_block::CodeBlock, - opcode::{Instruction, InstructionIterator, Opcode, VaryingOperand, VaryingOperandKind}, }; pub(crate) use { @@ -283,9 +283,9 @@ impl Context<'_> { }; let varying_operand_kind = match varying_operand_kind { - VaryingOperandKind::Short => "", - VaryingOperandKind::Half => ".Half", - VaryingOperandKind::Wide => ".Wide", + VaryingOperandKind::U8 => "", + VaryingOperandKind::U16 => ".U16", + VaryingOperandKind::U32 => ".U32", }; println!( diff --git a/boa_engine/src/vm/opcode/binary_ops/mod.rs b/boa_engine/src/vm/opcode/binary_ops/mod.rs index 30a934b682b..ce2a03f5e1b 100644 --- a/boa_engine/src/vm/opcode/binary_ops/mod.rs +++ b/boa_engine/src/vm/opcode/binary_ops/mod.rs @@ -143,12 +143,12 @@ impl Operation for InPrivate { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } diff --git a/boa_engine/src/vm/opcode/call/mod.rs b/boa_engine/src/vm/opcode/call/mod.rs index dc7eb9beb8b..bde5c569c50 100644 --- a/boa_engine/src/vm/opcode/call/mod.rs +++ b/boa_engine/src/vm/opcode/call/mod.rs @@ -80,12 +80,12 @@ impl Operation for CallEval { Self::operation(context, argument_count as usize) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let argument_count = context.vm.read::() as usize; Self::operation(context, argument_count) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let argument_count = context.vm.read::(); Self::operation(context, argument_count as usize) } @@ -221,12 +221,12 @@ impl Operation for Call { Self::operation(context, argument_count as usize) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let argument_count = context.vm.read::() as usize; Self::operation(context, argument_count) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let argument_count = context.vm.read::(); Self::operation(context, argument_count as usize) } diff --git a/boa_engine/src/vm/opcode/concat/mod.rs b/boa_engine/src/vm/opcode/concat/mod.rs index 3dfa81678db..17a8049bd93 100644 --- a/boa_engine/src/vm/opcode/concat/mod.rs +++ b/boa_engine/src/vm/opcode/concat/mod.rs @@ -37,12 +37,12 @@ impl Operation for ConcatToString { Self::operation(context, value_count) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let value_count = context.vm.read::() as usize; Self::operation(context, value_count) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let value_count = context.vm.read::() as usize; Self::operation(context, value_count) } diff --git a/boa_engine/src/vm/opcode/control_flow/throw.rs b/boa_engine/src/vm/opcode/control_flow/throw.rs index b6a16b3aa24..e2f38381db7 100644 --- a/boa_engine/src/vm/opcode/control_flow/throw.rs +++ b/boa_engine/src/vm/opcode/control_flow/throw.rs @@ -139,12 +139,12 @@ impl Operation for ThrowNewTypeError { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } diff --git a/boa_engine/src/vm/opcode/copy/mod.rs b/boa_engine/src/vm/opcode/copy/mod.rs index 66108f1feb8..8024d9fda78 100644 --- a/boa_engine/src/vm/opcode/copy/mod.rs +++ b/boa_engine/src/vm/opcode/copy/mod.rs @@ -50,13 +50,13 @@ impl Operation for CopyDataProperties { Self::operation(context, excluded_key_count, excluded_key_count_computed) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let excluded_key_count = context.vm.read::() as usize; let excluded_key_count_computed = context.vm.read::() as usize; Self::operation(context, excluded_key_count, excluded_key_count_computed) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let excluded_key_count = context.vm.read::() as usize; let excluded_key_count_computed = context.vm.read::() as usize; Self::operation(context, excluded_key_count, excluded_key_count_computed) diff --git a/boa_engine/src/vm/opcode/define/class/getter.rs b/boa_engine/src/vm/opcode/define/class/getter.rs index 65cb26db3c4..50bb7d61645 100644 --- a/boa_engine/src/vm/opcode/define/class/getter.rs +++ b/boa_engine/src/vm/opcode/define/class/getter.rs @@ -59,12 +59,12 @@ impl Operation for DefineClassStaticGetterByName { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -129,12 +129,12 @@ impl Operation for DefineClassGetterByName { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } diff --git a/boa_engine/src/vm/opcode/define/class/method.rs b/boa_engine/src/vm/opcode/define/class/method.rs index cc8df4ea5d9..703b7342e0e 100644 --- a/boa_engine/src/vm/opcode/define/class/method.rs +++ b/boa_engine/src/vm/opcode/define/class/method.rs @@ -55,12 +55,12 @@ impl Operation for DefineClassStaticMethodByName { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -121,12 +121,12 @@ impl Operation for DefineClassMethodByName { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } diff --git a/boa_engine/src/vm/opcode/define/class/setter.rs b/boa_engine/src/vm/opcode/define/class/setter.rs index 8319f62aed3..b68e9f70308 100644 --- a/boa_engine/src/vm/opcode/define/class/setter.rs +++ b/boa_engine/src/vm/opcode/define/class/setter.rs @@ -60,12 +60,12 @@ impl Operation for DefineClassStaticSetterByName { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -132,12 +132,12 @@ impl Operation for DefineClassSetterByName { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } diff --git a/boa_engine/src/vm/opcode/define/mod.rs b/boa_engine/src/vm/opcode/define/mod.rs index 0b980ea1de3..e7ff1c00ef5 100644 --- a/boa_engine/src/vm/opcode/define/mod.rs +++ b/boa_engine/src/vm/opcode/define/mod.rs @@ -44,12 +44,12 @@ impl Operation for DefVar { Self::operation(context, index as usize) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } @@ -88,12 +88,12 @@ impl Operation for DefInitVar { Self::operation(context, index as usize) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } @@ -130,12 +130,12 @@ impl Operation for PutLexicalValue { Self::operation(context, index as usize) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } diff --git a/boa_engine/src/vm/opcode/define/own_property.rs b/boa_engine/src/vm/opcode/define/own_property.rs index c06f2169be9..4ca769b828f 100644 --- a/boa_engine/src/vm/opcode/define/own_property.rs +++ b/boa_engine/src/vm/opcode/define/own_property.rs @@ -44,12 +44,12 @@ impl Operation for DefineOwnPropertyByName { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } diff --git a/boa_engine/src/vm/opcode/delete/mod.rs b/boa_engine/src/vm/opcode/delete/mod.rs index d774889964f..8b26ebed9d4 100644 --- a/boa_engine/src/vm/opcode/delete/mod.rs +++ b/boa_engine/src/vm/opcode/delete/mod.rs @@ -36,12 +36,12 @@ impl Operation for DeletePropertyByName { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -103,12 +103,12 @@ impl Operation for DeleteName { Self::operation(context, index as usize) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } diff --git a/boa_engine/src/vm/opcode/environment/mod.rs b/boa_engine/src/vm/opcode/environment/mod.rs index 730b7eed2b9..6611225664a 100644 --- a/boa_engine/src/vm/opcode/environment/mod.rs +++ b/boa_engine/src/vm/opcode/environment/mod.rs @@ -157,12 +157,12 @@ impl Operation for SuperCall { Self::operation(context, value_count) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let value_count = context.vm.read::() as usize; Self::operation(context, value_count) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let value_count = context.vm.read::() as usize; Self::operation(context, value_count) } diff --git a/boa_engine/src/vm/opcode/get/function.rs b/boa_engine/src/vm/opcode/get/function.rs index 30322b40d4f..becdd587e1b 100644 --- a/boa_engine/src/vm/opcode/get/function.rs +++ b/boa_engine/src/vm/opcode/get/function.rs @@ -29,12 +29,12 @@ impl Operation for GetArrowFunction { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -66,12 +66,12 @@ impl Operation for GetAsyncArrowFunction { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -108,13 +108,13 @@ impl Operation for GetFunction { Self::operation(context, index, method) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; let method = context.vm.read::() != 0; Self::operation(context, index, method) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; let method = context.vm.read::() != 0; Self::operation(context, index, method) @@ -152,13 +152,13 @@ impl Operation for GetFunctionAsync { Self::operation(context, index, method) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; let method = context.vm.read::() != 0; Self::operation(context, index, method) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; let method = context.vm.read::() != 0; Self::operation(context, index, method) diff --git a/boa_engine/src/vm/opcode/get/generator.rs b/boa_engine/src/vm/opcode/get/generator.rs index 0616d5672f5..32e6c2e4609 100644 --- a/boa_engine/src/vm/opcode/get/generator.rs +++ b/boa_engine/src/vm/opcode/get/generator.rs @@ -29,12 +29,12 @@ impl Operation for GetGenerator { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -66,12 +66,12 @@ impl Operation for GetGeneratorAsync { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } diff --git a/boa_engine/src/vm/opcode/get/name.rs b/boa_engine/src/vm/opcode/get/name.rs index b7c0f7afd9d..d62020d7252 100644 --- a/boa_engine/src/vm/opcode/get/name.rs +++ b/boa_engine/src/vm/opcode/get/name.rs @@ -37,12 +37,12 @@ impl Operation for GetName { Self::operation(context, index as usize) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } @@ -75,12 +75,12 @@ impl Operation for GetLocator { Self::operation(context, index as usize) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } @@ -121,12 +121,12 @@ impl Operation for GetNameAndLocator { Self::operation(context, index as usize) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } @@ -175,12 +175,12 @@ impl Operation for GetNameOrUndefined { Self::operation(context, index as usize) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } diff --git a/boa_engine/src/vm/opcode/get/private.rs b/boa_engine/src/vm/opcode/get/private.rs index 2152800d822..ec3235facc2 100644 --- a/boa_engine/src/vm/opcode/get/private.rs +++ b/boa_engine/src/vm/opcode/get/private.rs @@ -37,12 +37,12 @@ impl Operation for GetPrivateField { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } diff --git a/boa_engine/src/vm/opcode/get/property.rs b/boa_engine/src/vm/opcode/get/property.rs index f8bb88e024b..a3f5a196326 100644 --- a/boa_engine/src/vm/opcode/get/property.rs +++ b/boa_engine/src/vm/opcode/get/property.rs @@ -38,12 +38,12 @@ impl Operation for GetPropertyByName { Self::operation(context, index as usize) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } diff --git a/boa_engine/src/vm/opcode/mod.rs b/boa_engine/src/vm/opcode/mod.rs index dd65c8aed7d..e662e2de2cf 100644 --- a/boa_engine/src/vm/opcode/mod.rs +++ b/boa_engine/src/vm/opcode/mod.rs @@ -126,17 +126,15 @@ where /// Represents a varying operand kind. #[derive(Default, Debug, Clone, Copy)] -#[allow(missing_docs)] -pub enum VaryingOperandKind { +pub(crate) enum VaryingOperandKind { #[default] - Short, - Half, - Wide, + U8, + U16, + U32, } #[derive(Debug, Clone, Copy)] -#[allow(missing_docs)] -pub struct VaryingOperand { +pub(crate) struct VaryingOperand { kind: VaryingOperandKind, value: u32, } @@ -147,35 +145,34 @@ impl PartialEq for VaryingOperand { } } -#[allow(missing_docs)] impl VaryingOperand { #[must_use] - pub fn short(value: u8) -> Self { + pub(crate) fn u8(value: u8) -> Self { Self { - kind: VaryingOperandKind::Short, + kind: VaryingOperandKind::U8, value: u32::from(value), } } #[must_use] - pub fn half(value: u16) -> Self { + pub(crate) fn u16(value: u16) -> Self { Self { - kind: VaryingOperandKind::Half, + kind: VaryingOperandKind::U16, value: u32::from(value), } } #[must_use] - pub const fn wide(value: u32) -> Self { + pub(crate) const fn u32(value: u32) -> Self { Self { - kind: VaryingOperandKind::Wide, + kind: VaryingOperandKind::U32, value, } } #[must_use] - pub const fn value(self) -> u32 { + pub(crate) const fn value(self) -> u32 { self.value } #[must_use] - pub const fn kind(self) -> VaryingOperandKind { + pub(crate) const fn kind(self) -> VaryingOperandKind { self.kind } } @@ -188,16 +185,16 @@ trait BytecodeConversion: Sized { impl BytecodeConversion for VaryingOperand { fn to_bytecode(&self, bytes: &mut Vec) { match self.kind() { - VaryingOperandKind::Short => u8::to_bytecode(&(self.value() as u8), bytes), - VaryingOperandKind::Half => u16::to_bytecode(&(self.value() as u16), bytes), - VaryingOperandKind::Wide => u32::to_bytecode(&self.value(), bytes), + VaryingOperandKind::U8 => u8::to_bytecode(&(self.value() as u8), bytes), + VaryingOperandKind::U16 => u16::to_bytecode(&(self.value() as u16), bytes), + VaryingOperandKind::U32 => u32::to_bytecode(&self.value(), bytes), } } fn from_bytecode(bytes: &[u8], pc: &mut usize, varying_kind: VaryingOperandKind) -> Self { match varying_kind { - VaryingOperandKind::Short => Self::short(u8::from_bytecode(bytes, pc, varying_kind)), - VaryingOperandKind::Half => Self::half(u16::from_bytecode(bytes, pc, varying_kind)), - VaryingOperandKind::Wide => Self::wide(u32::from_bytecode(bytes, pc, varying_kind)), + VaryingOperandKind::U8 => Self::u8(u8::from_bytecode(bytes, pc, varying_kind)), + VaryingOperandKind::U16 => Self::u16(u16::from_bytecode(bytes, pc, varying_kind)), + VaryingOperandKind::U32 => Self::u32(u32::from_bytecode(bytes, pc, varying_kind)), } } } @@ -378,7 +375,7 @@ macro_rules! generate_opcodes { /// The opcodes of the vm. #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[repr(u8)] - pub enum Opcode { + pub(crate) enum Opcode { $( $(#[$inner $($args)*])* $Variant @@ -409,7 +406,7 @@ macro_rules! generate_opcodes { /// Name of this opcode. #[must_use] - pub const fn as_str(self) -> &'static str { + pub(crate) const fn as_str(self) -> &'static str { Self::NAMES[self as usize] } @@ -421,14 +418,14 @@ macro_rules! generate_opcodes { /// Name of the profiler event for this opcode. #[must_use] - pub const fn as_instruction_str(self) -> &'static str { + pub(crate) const fn as_instruction_str(self) -> &'static str { Self::INSTRUCTIONS[self as usize] } const EXECUTE_FNS: [fn(&mut Context<'_>) -> JsResult; Self::MAX] = [ $( $mapping)?)>::execute),*, - $( $mapping)?)>::half_execute),*, - $( $mapping)?)>::wide_execute),* + $( $mapping)?)>::u16_execute),*, + $( $mapping)?)>::u32_execute),* ]; pub(super) fn execute(self, context: &mut Context<'_>) -> JsResult { @@ -443,13 +440,12 @@ macro_rules! generate_opcodes { // be a part of `Instruction`. #[derive(Debug, Clone, PartialEq)] #[repr(u8)] - pub enum Instruction { + pub(crate) enum Instruction { $( $(#[$inner $($args)*])* $Variant $({ $( $(#[$fieldinner $($fieldargs)*])* - #[allow(missing_docs)] $FieldName : $FieldType ),* })? @@ -459,7 +455,8 @@ macro_rules! generate_opcodes { impl Instruction { /// Convert [`Instruction`] to compact bytecode. #[inline] - pub fn to_bytecode(&self, bytes: &mut Vec) { + #[allow(dead_code)] + pub(crate) fn to_bytecode(&self, bytes: &mut Vec) { match self { $( Self::$Variant $({ @@ -481,7 +478,7 @@ macro_rules! generate_opcodes { /// If the provided bytecode is not valid. #[inline] #[must_use] - pub fn from_bytecode(bytes: &[u8], pc: &mut usize, varying_kind: VaryingOperandKind) -> Self { + pub(crate) fn from_bytecode(bytes: &[u8], pc: &mut usize, varying_kind: VaryingOperandKind) -> Self { let opcode = bytes[*pc].into(); *pc += 1; match opcode { @@ -508,7 +505,7 @@ macro_rules! generate_opcodes { /// Get the [`Opcode`] of the [`Instruction`]. #[inline] #[must_use] - pub const fn opcode(&self) -> Opcode { + pub(crate) const fn opcode(&self) -> Opcode { match self { $( Self::$Variant $({ $( $FieldName: _ ),* })? => Opcode::$Variant @@ -528,14 +525,21 @@ pub(crate) trait Operation { const NAME: &'static str; const INSTRUCTION: &'static str; + /// Execute opcode with [`VaryingOperandKind::U8`] sized [`VaryingOperand`]s. fn execute(context: &mut Context<'_>) -> JsResult; - fn half_execute(context: &mut Context<'_>) -> JsResult { - Reserved::half_execute(context) + /// Execute opcode with [`VaryingOperandKind::U16`] sized [`VaryingOperand`]s. + /// + /// By default if not implemented will call [`Reserved::u16_execute()`] that panics. + fn u16_execute(context: &mut Context<'_>) -> JsResult { + Reserved::u16_execute(context) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { - Reserved::wide_execute(context) + /// Execute opcode with [`VaryingOperandKind::U32`] sized [`VaryingOperand`]s. + /// + /// By default if not implemented will call [`Reserved::u32_execute()`] that panics. + fn u32_execute(context: &mut Context<'_>) -> JsResult { + Reserved::u32_execute(context) } } @@ -2040,19 +2044,19 @@ generate_opcodes! { /// Stack: **=>** Nop, - /// Half [`Opcode`] prefix operand modifier, makes all ([`VaryingOperand`])s of an instruction [`u16`] sized. + /// Opcode prefix modifier, makes all [`VaryingOperand`]s of an instruction [`u16`] sized. /// /// Operands: opcode (operands if any). /// /// Stack: The stack changes based on the opcode that is being prefixed. - Half, + ModifierU16, - /// Wide [`Opcode`] prefix operand modifier, makes all ([`VaryingOperand`])s of an instruction [`u32`] sized. + /// Opcode prefix modifier, [`Opcode`] prefix operand modifier, makes all [`VaryingOperand`]s of an instruction [`u32`] sized. /// /// Operands: opcode (operands if any). /// /// Stack: The stack changes based on the opcode that is being prefixed. - Wide, + ModifierU32, /// Reserved [`Opcode`]. Reserved1 => Reserved, @@ -2184,7 +2188,7 @@ pub(crate) enum BindingOpcode { /// Iterator over the instructions in the compact bytecode. #[derive(Debug, Clone)] -pub struct InstructionIterator<'bytecode> { +pub(crate) struct InstructionIterator<'bytecode> { bytes: &'bytecode [u8], pc: usize, } @@ -2193,20 +2197,20 @@ impl<'bytecode> InstructionIterator<'bytecode> { /// Create a new [`InstructionIterator`] from bytecode array. #[inline] #[must_use] - pub const fn new(bytes: &'bytecode [u8]) -> Self { + pub(crate) const fn new(bytes: &'bytecode [u8]) -> Self { Self { bytes, pc: 0 } } /// Create a new [`InstructionIterator`] from bytecode array at pc. #[inline] #[must_use] - pub const fn with_pc(bytes: &'bytecode [u8], pc: usize) -> Self { + pub(crate) const fn with_pc(bytes: &'bytecode [u8], pc: usize) -> Self { Self { bytes, pc } } /// Return the current program counter. #[must_use] - pub const fn pc(&self) -> usize { + pub(crate) const fn pc(&self) -> usize { self.pc } } @@ -2222,23 +2226,23 @@ impl Iterator for InstructionIterator<'_> { } let instruction = - Instruction::from_bytecode(self.bytes, &mut self.pc, VaryingOperandKind::Short); + Instruction::from_bytecode(self.bytes, &mut self.pc, VaryingOperandKind::U8); - if instruction == Instruction::Half { + if instruction == Instruction::ModifierU16 { return Some(( start_pc, - VaryingOperandKind::Half, - Instruction::from_bytecode(self.bytes, &mut self.pc, VaryingOperandKind::Half), + VaryingOperandKind::U16, + Instruction::from_bytecode(self.bytes, &mut self.pc, VaryingOperandKind::U16), )); - } else if instruction == Instruction::Wide { + } else if instruction == Instruction::ModifierU32 { return Some(( start_pc, - VaryingOperandKind::Wide, - Instruction::from_bytecode(self.bytes, &mut self.pc, VaryingOperandKind::Wide), + VaryingOperandKind::U32, + Instruction::from_bytecode(self.bytes, &mut self.pc, VaryingOperandKind::U32), )); } - Some((start_pc, VaryingOperandKind::Short, instruction)) + Some((start_pc, VaryingOperandKind::U8, instruction)) } } diff --git a/boa_engine/src/vm/opcode/modifier.rs b/boa_engine/src/vm/opcode/modifier.rs index 651ba8442cf..27d3bfa34ed 100644 --- a/boa_engine/src/vm/opcode/modifier.rs +++ b/boa_engine/src/vm/opcode/modifier.rs @@ -2,16 +2,16 @@ use crate::{vm::CompletionType, Context, JsResult}; use super::{Opcode, Operation}; -/// `Half` implements the Opcode Operation for `Opcode::Half` +/// `ModifierU16` implements the Opcode Operation for `Opcode::ModifierU16` /// /// Operation: /// - [`Opcode`] prefix operand modifier, makes all varying operands of an instruction [`u16`] sized. #[derive(Debug, Clone, Copy)] -pub(crate) struct Half; +pub(crate) struct ModifierU16; -impl Operation for Half { - const NAME: &'static str = "Half"; - const INSTRUCTION: &'static str = "INST - Half"; +impl Operation for ModifierU16 { + const NAME: &'static str = "ModifierU16"; + const INSTRUCTION: &'static str = "INST - ModifierU16"; fn execute(context: &mut Context<'_>) -> JsResult { let opcode = context.vm.read::() as usize; @@ -20,16 +20,16 @@ impl Operation for Half { } } -/// `Wide` implements the Opcode Operation for `Opcode::Wide` +/// `ModifierU32` implements the Opcode Operation for `Opcode::ModifierU32` /// /// Operation: -/// - [`Opcode`] prefix operand modifier, makes all varying operands of an instruction [`u16`] sized. +/// - [`Opcode`] prefix operand modifier, makes all varying operands of an instruction [`u32`] sized. #[derive(Debug, Clone, Copy)] -pub(crate) struct Wide; +pub(crate) struct ModifierU32; -impl Operation for Wide { - const NAME: &'static str = "Wide"; - const INSTRUCTION: &'static str = "INST - Wide"; +impl Operation for ModifierU32 { + const NAME: &'static str = "ModifierU32"; + const INSTRUCTION: &'static str = "INST - ModifierU32"; fn execute(context: &mut Context<'_>) -> JsResult { let opcode = context.vm.read::() as usize; diff --git a/boa_engine/src/vm/opcode/new/mod.rs b/boa_engine/src/vm/opcode/new/mod.rs index fd6b9c8ac34..6f992dd1607 100644 --- a/boa_engine/src/vm/opcode/new/mod.rs +++ b/boa_engine/src/vm/opcode/new/mod.rs @@ -56,12 +56,12 @@ impl Operation for New { Self::operation(context, argument_count) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let argument_count = context.vm.read::() as usize; Self::operation(context, argument_count) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let argument_count = context.vm.read::() as usize; Self::operation(context, argument_count) } diff --git a/boa_engine/src/vm/opcode/nop/mod.rs b/boa_engine/src/vm/opcode/nop/mod.rs index c327ae4fd29..fb36191cac1 100644 --- a/boa_engine/src/vm/opcode/nop/mod.rs +++ b/boa_engine/src/vm/opcode/nop/mod.rs @@ -34,11 +34,11 @@ impl Operation for Reserved { unreachable!("Reserved opcodes are unreachable!") } - fn half_execute(_: &mut Context<'_>) -> JsResult { - unreachable!("Half.Reserved opcodes are unreachable!") + fn u16_execute(_: &mut Context<'_>) -> JsResult { + unreachable!("Reserved.U16 opcodes are unreachable!") } - fn wide_execute(_: &mut Context<'_>) -> JsResult { - unreachable!("Wide.Reserved opcodes are unreachable!") + fn u32_execute(_: &mut Context<'_>) -> JsResult { + unreachable!("Reserved.U32 opcodes are unreachable!") } } diff --git a/boa_engine/src/vm/opcode/push/class/field.rs b/boa_engine/src/vm/opcode/push/class/field.rs index 5ae934be0c8..b24d52066ac 100644 --- a/boa_engine/src/vm/opcode/push/class/field.rs +++ b/boa_engine/src/vm/opcode/push/class/field.rs @@ -93,12 +93,12 @@ impl Operation for PushClassFieldPrivate { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } diff --git a/boa_engine/src/vm/opcode/push/class/private.rs b/boa_engine/src/vm/opcode/push/class/private.rs index 60963e8be39..a5b57f3be39 100644 --- a/boa_engine/src/vm/opcode/push/class/private.rs +++ b/boa_engine/src/vm/opcode/push/class/private.rs @@ -62,12 +62,12 @@ impl Operation for PushClassPrivateMethod { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -118,12 +118,12 @@ impl Operation for PushClassPrivateGetter { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -174,12 +174,12 @@ impl Operation for PushClassPrivateSetter { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } diff --git a/boa_engine/src/vm/opcode/push/literal.rs b/boa_engine/src/vm/opcode/push/literal.rs index d086bb42e74..dade39b85a8 100644 --- a/boa_engine/src/vm/opcode/push/literal.rs +++ b/boa_engine/src/vm/opcode/push/literal.rs @@ -28,12 +28,12 @@ impl Operation for PushLiteral { Self::operation(context, index as usize) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } diff --git a/boa_engine/src/vm/opcode/set/name.rs b/boa_engine/src/vm/opcode/set/name.rs index 7a58c6015c7..48e750574af 100644 --- a/boa_engine/src/vm/opcode/set/name.rs +++ b/boa_engine/src/vm/opcode/set/name.rs @@ -33,12 +33,12 @@ impl Operation for ThrowMutateImmutable { Self::operation(context, index as usize) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } @@ -79,12 +79,12 @@ impl Operation for SetName { Self::operation(context, index as usize) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } diff --git a/boa_engine/src/vm/opcode/set/private.rs b/boa_engine/src/vm/opcode/set/private.rs index 2c25cf0143a..4e12fa8881a 100644 --- a/boa_engine/src/vm/opcode/set/private.rs +++ b/boa_engine/src/vm/opcode/set/private.rs @@ -42,12 +42,12 @@ impl Operation for SetPrivateField { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -87,12 +87,12 @@ impl Operation for DefinePrivateField { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -151,12 +151,12 @@ impl Operation for SetPrivateMethod { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -206,12 +206,12 @@ impl Operation for SetPrivateSetter { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -261,12 +261,12 @@ impl Operation for SetPrivateGetter { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } diff --git a/boa_engine/src/vm/opcode/set/property.rs b/boa_engine/src/vm/opcode/set/property.rs index dc488cd10ee..80ad6b39504 100644 --- a/boa_engine/src/vm/opcode/set/property.rs +++ b/boa_engine/src/vm/opcode/set/property.rs @@ -47,12 +47,12 @@ impl Operation for SetPropertyByName { Self::operation(context, index as usize) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::(); Self::operation(context, index as usize) } @@ -203,12 +203,12 @@ impl Operation for SetPropertyGetterByName { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } @@ -291,12 +291,12 @@ impl Operation for SetPropertySetterByName { Self::operation(context, index) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } diff --git a/boa_engine/src/vm/opcode/templates/mod.rs b/boa_engine/src/vm/opcode/templates/mod.rs index b8f1acf42da..63e628b307a 100644 --- a/boa_engine/src/vm/opcode/templates/mod.rs +++ b/boa_engine/src/vm/opcode/templates/mod.rs @@ -108,13 +108,13 @@ impl Operation for TemplateCreate { Self::operation(context, count, site) } - fn half_execute(context: &mut Context<'_>) -> JsResult { + fn u16_execute(context: &mut Context<'_>) -> JsResult { let count = u32::from(context.vm.read::()); let site = context.vm.read::(); Self::operation(context, count, site) } - fn wide_execute(context: &mut Context<'_>) -> JsResult { + fn u32_execute(context: &mut Context<'_>) -> JsResult { let count = context.vm.read::(); let site = context.vm.read::(); Self::operation(context, count, site)