From 1fba8c286fdd0b4c818efb78f17faa0749580fc2 Mon Sep 17 00:00:00 2001 From: Haled Odat <8566042+HalidOdat@users.noreply.github.com> Date: Sat, 30 Sep 2023 13:38:39 +0200 Subject: [PATCH] Apply review --- boa_engine/src/bytecompiler/mod.rs | 8 +++---- boa_engine/src/vm/code_block.rs | 4 ++-- boa_engine/src/vm/flowgraph/mod.rs | 4 ++-- boa_engine/src/vm/opcode/binary_ops/mod.rs | 4 ++-- boa_engine/src/vm/opcode/call/mod.rs | 8 +++---- boa_engine/src/vm/opcode/concat/mod.rs | 4 ++-- .../src/vm/opcode/control_flow/throw.rs | 4 ++-- boa_engine/src/vm/opcode/copy/mod.rs | 4 ++-- .../src/vm/opcode/define/class/getter.rs | 8 +++---- .../src/vm/opcode/define/class/method.rs | 8 +++---- .../src/vm/opcode/define/class/setter.rs | 8 +++---- boa_engine/src/vm/opcode/define/mod.rs | 12 +++++----- .../src/vm/opcode/define/own_property.rs | 4 ++-- boa_engine/src/vm/opcode/delete/mod.rs | 8 +++---- boa_engine/src/vm/opcode/environment/mod.rs | 4 ++-- boa_engine/src/vm/opcode/get/function.rs | 16 ++++++------- boa_engine/src/vm/opcode/get/generator.rs | 8 +++---- boa_engine/src/vm/opcode/get/name.rs | 16 ++++++------- boa_engine/src/vm/opcode/get/private.rs | 4 ++-- boa_engine/src/vm/opcode/get/property.rs | 4 ++-- boa_engine/src/vm/opcode/mod.rs | 24 +++++++++---------- boa_engine/src/vm/opcode/modifier.rs | 20 ++++++++-------- boa_engine/src/vm/opcode/new/mod.rs | 4 ++-- boa_engine/src/vm/opcode/nop/mod.rs | 4 ++-- boa_engine/src/vm/opcode/push/class/field.rs | 4 ++-- .../src/vm/opcode/push/class/private.rs | 12 +++++----- boa_engine/src/vm/opcode/push/literal.rs | 4 ++-- boa_engine/src/vm/opcode/set/name.rs | 8 +++---- boa_engine/src/vm/opcode/set/private.rs | 20 ++++++++-------- boa_engine/src/vm/opcode/set/property.rs | 12 +++++----- boa_engine/src/vm/opcode/templates/mod.rs | 4 ++-- 31 files changed, 128 insertions(+), 128 deletions(-) diff --git a/boa_engine/src/bytecompiler/mod.rs b/boa_engine/src/bytecompiler/mod.rs index 6e3ecd4488e..90fc0ada5e4 100644 --- a/boa_engine/src/bytecompiler/mod.rs +++ b/boa_engine/src/bytecompiler/mod.rs @@ -480,8 +480,8 @@ impl<'ctx, 'host> ByteCompiler<'ctx, 'host> { match varying_kind { VaryingOperandKind::U8 => {} - VaryingOperandKind::U16 => self.emit_opcode(Opcode::ModifierU16), - VaryingOperandKind::U32 => self.emit_opcode(Opcode::ModifierU32), + VaryingOperandKind::U16 => self.emit_opcode(Opcode::U16Operands), + VaryingOperandKind::U32 => self.emit_opcode(Opcode::U32Operands), } 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::ModifierU16); + self.emit_opcode(Opcode::U16Operands); self.emit_opcode(opcode); self.emit_u16(operand); } else { - self.emit_opcode(Opcode::ModifierU32); + self.emit_opcode(Opcode::U32Operands); self.emit_opcode(opcode); self.emit_u32(operand); } diff --git a/boa_engine/src/vm/code_block.rs b/boa_engine/src/vm/code_block.rs index 076b0af8408..005a8d19985 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::ModifierU16 - | Instruction::ModifierU32 + Instruction::U16Operands + | Instruction::U32Operands | Instruction::Reserved1 | Instruction::Reserved2 | Instruction::Reserved3 diff --git a/boa_engine/src/vm/flowgraph/mod.rs b/boa_engine/src/vm/flowgraph/mod.rs index 6d2dc2f85e4..02c5fbbcd71 100644 --- a/boa_engine/src/vm/flowgraph/mod.rs +++ b/boa_engine/src/vm/flowgraph/mod.rs @@ -465,8 +465,8 @@ impl CodeBlock { Instruction::Return => { graph.add_node(previous_pc, NodeShape::Diamond, label.into(), Color::Red); } - Instruction::ModifierU16 - | Instruction::ModifierU32 + Instruction::U16Operands + | Instruction::U32Operands | Instruction::Reserved1 | Instruction::Reserved2 | Instruction::Reserved3 diff --git a/boa_engine/src/vm/opcode/binary_ops/mod.rs b/boa_engine/src/vm/opcode/binary_ops/mod.rs index ce2a03f5e1b..dbaeedbc817 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 bde5c569c50..453965713a5 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let argument_count = context.vm.read::() as usize; Self::operation(context, argument_count) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let argument_count = context.vm.read::() as usize; Self::operation(context, argument_count) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 17a8049bd93..5ebb102f8c3 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let value_count = context.vm.read::() as usize; Self::operation(context, value_count) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 e2f38381db7..df09c646e72 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 8024d9fda78..d90ebd80c9c 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(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 u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 50bb7d61645..de85969bc00 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 703b7342e0e..13bd7677108 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 b68e9f70308..76056176293 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 e7ff1c00ef5..cf77d02dce3 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 4ca769b828f..91daaf92b40 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 8b26ebed9d4..ddeb0ec1d60 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 6611225664a..bd04b9db40d 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let value_count = context.vm.read::() as usize; Self::operation(context, value_count) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 becdd587e1b..0c403bbc1fe 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; let method = context.vm.read::() != 0; Self::operation(context, index, method) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; let method = context.vm.read::() != 0; Self::operation(context, index, method) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 32e6c2e4609..83b99347d7a 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 d62020d7252..31812939706 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 ec3235facc2..1ba7518d386 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 a3f5a196326..c3ba937e03c 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 e662e2de2cf..04563ddcc8f 100644 --- a/boa_engine/src/vm/opcode/mod.rs +++ b/boa_engine/src/vm/opcode/mod.rs @@ -424,8 +424,8 @@ macro_rules! generate_opcodes { const EXECUTE_FNS: [fn(&mut Context<'_>) -> JsResult; Self::MAX] = [ $( $mapping)?)>::execute),*, - $( $mapping)?)>::u16_execute),*, - $( $mapping)?)>::u32_execute),* + $( $mapping)?)>::execute_with_u16_operands),*, + $( $mapping)?)>::execute_with_u32_operands),* ]; pub(super) fn execute(self, context: &mut Context<'_>) -> JsResult { @@ -530,16 +530,16 @@ pub(crate) trait Operation { /// 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) + /// By default if not implemented will call [`Reserved::u16_execute()`] which panics. + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { + Reserved::execute_with_u16_operands(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) + /// By default if not implemented will call [`Reserved::u32_execute()`] which panics. + fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { + Reserved::execute_with_u32_operands(context) } } @@ -2049,14 +2049,14 @@ generate_opcodes! { /// Operands: opcode (operands if any). /// /// Stack: The stack changes based on the opcode that is being prefixed. - ModifierU16, + U16Operands, /// 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. - ModifierU32, + U32Operands, /// Reserved [`Opcode`]. Reserved1 => Reserved, @@ -2228,13 +2228,13 @@ impl Iterator for InstructionIterator<'_> { let instruction = Instruction::from_bytecode(self.bytes, &mut self.pc, VaryingOperandKind::U8); - if instruction == Instruction::ModifierU16 { + if instruction == Instruction::U16Operands { return Some(( start_pc, VaryingOperandKind::U16, Instruction::from_bytecode(self.bytes, &mut self.pc, VaryingOperandKind::U16), )); - } else if instruction == Instruction::ModifierU32 { + } else if instruction == Instruction::U32Operands { return Some(( start_pc, VaryingOperandKind::U32, diff --git a/boa_engine/src/vm/opcode/modifier.rs b/boa_engine/src/vm/opcode/modifier.rs index 27d3bfa34ed..96999ea40cd 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}; -/// `ModifierU16` implements the Opcode Operation for `Opcode::ModifierU16` +/// `U16Operands` implements the Opcode Operation for `Opcode::U16Operands` /// /// Operation: /// - [`Opcode`] prefix operand modifier, makes all varying operands of an instruction [`u16`] sized. #[derive(Debug, Clone, Copy)] -pub(crate) struct ModifierU16; +pub(crate) struct U16Operands; -impl Operation for ModifierU16 { - const NAME: &'static str = "ModifierU16"; - const INSTRUCTION: &'static str = "INST - ModifierU16"; +impl Operation for U16Operands { + const NAME: &'static str = "U16Operands"; + const INSTRUCTION: &'static str = "INST - U16Operands"; fn execute(context: &mut Context<'_>) -> JsResult { let opcode = context.vm.read::() as usize; @@ -20,16 +20,16 @@ impl Operation for ModifierU16 { } } -/// `ModifierU32` implements the Opcode Operation for `Opcode::ModifierU32` +/// `U32Operands` implements the Opcode Operation for `Opcode::U32Operands` /// /// Operation: /// - [`Opcode`] prefix operand modifier, makes all varying operands of an instruction [`u32`] sized. #[derive(Debug, Clone, Copy)] -pub(crate) struct ModifierU32; +pub(crate) struct U32Operands; -impl Operation for ModifierU32 { - const NAME: &'static str = "ModifierU32"; - const INSTRUCTION: &'static str = "INST - ModifierU32"; +impl Operation for U32Operands { + const NAME: &'static str = "U32Operands"; + const INSTRUCTION: &'static str = "INST - U32Operands"; 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 6f992dd1607..cf68063f35f 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let argument_count = context.vm.read::() as usize; Self::operation(context, argument_count) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 fb36191cac1..8fd95297256 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 u16_execute(_: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(_: &mut Context<'_>) -> JsResult { unreachable!("Reserved.U16 opcodes are unreachable!") } - fn u32_execute(_: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(_: &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 b24d52066ac..99b73d398d0 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 a5b57f3be39..15e26fcbf89 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 dade39b85a8..396f21cd8b3 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 48e750574af..d292d56bbd8 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 4e12fa8881a..73104230b06 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 80ad6b39504..8a3bdbeb208 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let index = context.vm.read::() as usize; Self::operation(context, index) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(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 63e628b307a..ebb58fa7648 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 u16_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u16_operands(context: &mut Context<'_>) -> JsResult { let count = u32::from(context.vm.read::()); let site = context.vm.read::(); Self::operation(context, count, site) } - fn u32_execute(context: &mut Context<'_>) -> JsResult { + fn execute_with_u32_operands(context: &mut Context<'_>) -> JsResult { let count = context.vm.read::(); let site = context.vm.read::(); Self::operation(context, count, site)