Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Fix performance bottleneck in VM #1973

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion boa_engine/src/vm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl Context {
opcode
};

let _timer = Profiler::global().start_event(&format!("INST - {}", opcode.as_str()), "vm");
let _timer = Profiler::global().start_event(opcode.as_instruction_str(), "vm");
jasonwilliams marked this conversation as resolved.
Show resolved Hide resolved

match opcode {
Opcode::Nop => {}
Expand Down
131 changes: 131 additions & 0 deletions boa_engine/src/vm/opcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,137 @@ impl Opcode {
Opcode::Nop => "Nop",
}
}

pub fn as_instruction_str(self) -> &'static str {
pdogr marked this conversation as resolved.
Show resolved Hide resolved
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)]
Expand Down