From 48a8022cf6986e7e1a54d9fc506e3f78cc1d7d98 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 9 Jun 2021 09:19:34 +0200 Subject: [PATCH] LibJS: Move Bytecode::Instruction::execute() to the Op.h header ..and make sure it always gets inlined in the interpreter loop. --- .../Libraries/LibJS/Bytecode/Interpreter.cpp | 1 + Userland/Libraries/LibJS/Bytecode/Op.cpp | 15 --------------- Userland/Libraries/LibJS/Bytecode/Op.h | 19 +++++++++++++++++++ 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp index 1b528c004a..42f0fae921 100644 --- a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include namespace JS::Bytecode { diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp index ce4903c8e2..da41a5b279 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp @@ -16,21 +16,6 @@ namespace JS::Bytecode { -void Instruction::execute(Bytecode::Interpreter& interpreter) const -{ -#define __BYTECODE_OP(op) \ - case Instruction::Type::op: \ - return static_cast(*this).execute(interpreter); - - switch (type()) { - ENUMERATE_BYTECODE_OPS(__BYTECODE_OP) - default: - VERIFY_NOT_REACHED(); - } - -#undef __BYTECODE_OP -} - String Instruction::to_string() const { #define __BYTECODE_OP(op) \ diff --git a/Userland/Libraries/LibJS/Bytecode/Op.h b/Userland/Libraries/LibJS/Bytecode/Op.h index 769999e302..bd7e82e5c6 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.h +++ b/Userland/Libraries/LibJS/Bytecode/Op.h @@ -374,3 +374,22 @@ public: }; } + +namespace JS::Bytecode { + +ALWAYS_INLINE void Instruction::execute(Bytecode::Interpreter& interpreter) const +{ +#define __BYTECODE_OP(op) \ + case Instruction::Type::op: \ + return static_cast(*this).execute(interpreter); + + switch (type()) { + ENUMERATE_BYTECODE_OPS(__BYTECODE_OP) + default: + VERIFY_NOT_REACHED(); + } + +#undef __BYTECODE_OP +} + +}