Browse Source

[perf][vm] (#1973)

This Pull Request fixes/closes #1972 .

It changes the following:
- remove `format!` macro in `execute_instruction` and replace by `&'static str`
pull/1978/head
pd 3 years ago
parent
commit
4133801220
  1. 2
      boa_engine/src/vm/mod.rs
  2. 132
      boa_engine/src/vm/opcode.rs

2
boa_engine/src/vm/mod.rs

@ -137,7 +137,7 @@ impl Context {
opcode opcode
}; };
let _timer = Profiler::global().start_event(&format!("INST - {}", opcode.as_str()), "vm"); let _timer = Profiler::global().start_event(opcode.as_instruction_str(), "vm");
match opcode { match opcode {
Opcode::Nop => {} Opcode::Nop => {}

132
boa_engine/src/vm/opcode.rs

@ -1066,6 +1066,138 @@ impl Opcode {
Opcode::Nop => "Nop", Opcode::Nop => "Nop",
} }
} }
/// Name of the profiler event for this opcode
pub fn as_instruction_str(self) -> &'static str {
match self {
Opcode::Pop => "INST - Pop",
Opcode::Dup => "INST - Dup",
Opcode::Swap => "INST - Swap",
Opcode::PushZero => "INST - PushZero",
Opcode::PushOne => "INST - PushOne",
Opcode::PushInt8 => "INST - PushInt8",
Opcode::PushInt16 => "INST - PushInt16",
Opcode::PushInt32 => "INST - PushInt32",
Opcode::PushRational => "INST - PushRational",
Opcode::PushNaN => "INST - PushNaN",
Opcode::PushPositiveInfinity => "INST - PushPositiveInfinity",
Opcode::PushNegativeInfinity => "INST - PushNegativeInfinity",
Opcode::PushNull => "INST - PushNull",
Opcode::PushTrue => "INST - PushTrue",
Opcode::PushFalse => "INST - PushFalse",
Opcode::PushUndefined => "INST - PushUndefined",
Opcode::PushLiteral => "INST - PushLiteral",
Opcode::PushEmptyObject => "INST - PushEmptyObject",
Opcode::PushNewArray => "INST - PushNewArray",
Opcode::PushValueToArray => "INST - PushValueToArray",
Opcode::PushElisionToArray => "INST - PushElisionToArray",
Opcode::PushIteratorToArray => "INST - PushIteratorToArray",
Opcode::Add => "INST - Add",
Opcode::Sub => "INST - Sub",
Opcode::Div => "INST - Div",
Opcode::Mul => "INST - Mul",
Opcode::Mod => "INST - Mod",
Opcode::Pow => "INST - Pow",
Opcode::ShiftRight => "INST - ShiftRight",
Opcode::ShiftLeft => "INST - ShiftLeft",
Opcode::UnsignedShiftRight => "INST - UnsignedShiftRight",
Opcode::BitOr => "INST - BitOr",
Opcode::BitAnd => "INST - BitAnd",
Opcode::BitXor => "INST - BitXor",
Opcode::BitNot => "INST - BitNot",
Opcode::In => "INST - In",
Opcode::Eq => "INST - Eq",
Opcode::StrictEq => "INST - StrictEq",
Opcode::NotEq => "INST - NotEq",
Opcode::StrictNotEq => "INST - StrictNotEq",
Opcode::GreaterThan => "INST - GreaterThan",
Opcode::GreaterThanOrEq => "INST - GreaterThanOrEq",
Opcode::LessThan => "INST - LessThan",
Opcode::LessThanOrEq => "INST - LessThanOrEq",
Opcode::InstanceOf => "INST - InstanceOf",
Opcode::TypeOf => "INST - TypeOf",
Opcode::Void => "INST - Void",
Opcode::LogicalNot => "INST - LogicalNot",
Opcode::LogicalAnd => "INST - LogicalAnd",
Opcode::LogicalOr => "INST - LogicalOr",
Opcode::Coalesce => "INST - Coalesce",
Opcode::Pos => "INST - Pos",
Opcode::Neg => "INST - Neg",
Opcode::Inc => "INST - Inc",
Opcode::IncPost => "INST - IncPost",
Opcode::Dec => "INST - Dec",
Opcode::DecPost => "INST - DecPost",
Opcode::DefInitArg => "INST - DefInitArg",
Opcode::DefVar => "INST - DefVar",
Opcode::DefInitVar => "INST - DefInitVar",
Opcode::DefLet => "INST - DefLet",
Opcode::DefInitLet => "INST - DefInitLet",
Opcode::DefInitConst => "INST - DefInitConst",
Opcode::GetName => "INST - GetName",
Opcode::GetNameOrUndefined => "INST - GetNameOrUndefined",
Opcode::SetName => "INST - SetName",
Opcode::GetPropertyByName => "INST - GetPropertyByName",
Opcode::GetPropertyByValue => "INST - GetPropertyByValue",
Opcode::SetPropertyByName => "INST - SetPropertyByName",
Opcode::DefineOwnPropertyByName => "INST - DefineOwnPropertyByName",
Opcode::SetPropertyByValue => "INST - SetPropertyByValue",
Opcode::DefineOwnPropertyByValue => "INST - DefineOwnPropertyByValue",
Opcode::SetPropertyGetterByName => "INST - SetPropertyGetterByName",
Opcode::SetPropertyGetterByValue => "INST - SetPropertyGetterByValue",
Opcode::SetPropertySetterByName => "INST - SetPropertySetterByName",
Opcode::SetPropertySetterByValue => "INST - SetPropertySetterByValue",
Opcode::DeletePropertyByName => "INST - DeletePropertyByName",
Opcode::DeletePropertyByValue => "INST - DeletePropertyByValue",
Opcode::CopyDataProperties => "INST - CopyDataProperties",
Opcode::Jump => "INST - Jump",
Opcode::JumpIfFalse => "INST - JumpIfFalse",
Opcode::JumpIfNotUndefined => "INST - JumpIfNotUndefined",
Opcode::Throw => "INST - Throw",
Opcode::TryStart => "INST - TryStart",
Opcode::TryEnd => "INST - TryEnd",
Opcode::CatchStart => "INST - CatchStart",
Opcode::CatchEnd => "INST - CatchEnd",
Opcode::CatchEnd2 => "INST - CatchEnd2",
Opcode::FinallyStart => "INST - FinallyStart",
Opcode::FinallyEnd => "INST - FinallyEnd",
Opcode::FinallySetJump => "INST - FinallySetJump",
Opcode::ToBoolean => "INST - ToBoolean",
Opcode::This => "INST - This",
Opcode::Case => "INST - Case",
Opcode::Default => "INST - Default",
Opcode::GetFunction => "INST - GetFunction",
Opcode::GetGenerator => "INST - GetGenerator",
Opcode::Call => "INST - Call",
Opcode::CallWithRest => "INST - CallWithRest",
Opcode::New => "INST - New",
Opcode::NewWithRest => "INST - NewWithRest",
Opcode::Return => "INST - Return",
Opcode::PushDeclarativeEnvironment => "INST - PushDeclarativeEnvironment",
Opcode::PushFunctionEnvironment => "INST - PushFunctionEnvironment",
Opcode::PopEnvironment => "INST - PopEnvironment",
Opcode::LoopStart => "INST - LoopStart",
Opcode::LoopContinue => "INST - LoopContinue",
Opcode::LoopEnd => "INST - LoopEnd",
Opcode::ForInLoopInitIterator => "INST - ForInLoopInitIterator",
Opcode::InitIterator => "INST - InitIterator",
Opcode::IteratorNext => "INST - IteratorNext",
Opcode::IteratorNextFull => "INST - IteratorNextFull",
Opcode::IteratorClose => "INST - IteratorClose",
Opcode::IteratorToArray => "INST - IteratorToArray",
Opcode::ForInLoopNext => "INST - ForInLoopNext",
Opcode::ConcatToString => "INST - ConcatToString",
Opcode::RequireObjectCoercible => "INST - RequireObjectCoercible",
Opcode::ValueNotNullOrUndefined => "INST - ValueNotNullOrUndefined",
Opcode::RestParameterInit => "INST - FunctionRestParameter",
Opcode::RestParameterPop => "INST - RestParameterPop",
Opcode::PopOnReturnAdd => "INST - PopOnReturnAdd",
Opcode::PopOnReturnSub => "INST - PopOnReturnSub",
Opcode::Yield => "INST - Yield",
Opcode::GeneratorNext => "INST - GeneratorNext",
Opcode::GeneratorNextDelegate => "INST - GeneratorNextDelegate",
Opcode::Nop => "INST - Nop",
}
}
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]

Loading…
Cancel
Save