From 810a2976269e256ccdc20df8eadbb25ea266569b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 10 May 2024 07:43:31 +0200 Subject: [PATCH] LibJS/Bytecode: Remove Instruction::execute() Just make sure everyone calls the instruction-specific execute_impl() instead. :^) --- .../Libraries/LibJS/Bytecode/Instruction.h | 1 - .../Libraries/LibJS/Bytecode/Interpreter.cpp | 6 +++--- Userland/Libraries/LibJS/Bytecode/Op.h | 19 ------------------- 3 files changed, 3 insertions(+), 23 deletions(-) diff --git a/Userland/Libraries/LibJS/Bytecode/Instruction.h b/Userland/Libraries/LibJS/Bytecode/Instruction.h index 4e33356e54..7cfd3fee44 100644 --- a/Userland/Libraries/LibJS/Bytecode/Instruction.h +++ b/Userland/Libraries/LibJS/Bytecode/Instruction.h @@ -148,7 +148,6 @@ public: Type type() const { return m_type; } size_t length() const; ByteString to_byte_string(Bytecode::Executable const&) const; - ThrowCompletionOr execute(Bytecode::Interpreter&) const; void visit_labels(Function visitor); static void destroy(Instruction&); diff --git a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp index 75ab350437..b8b0c02277 100644 --- a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -630,7 +630,7 @@ FLATTEN_ON_CLANG void Interpreter::run_bytecode(size_t entry_point) handle_Await: { auto& instruction = *reinterpret_cast(&bytecode[program_counter]); - auto result = instruction.execute(*this); + auto result = instruction.execute_impl(*this); if (result.is_error()) { if (handle_exception(program_counter, *result.throw_completion().value()) == HandleExceptionResponse::ExitFromExecutable) @@ -642,7 +642,7 @@ FLATTEN_ON_CLANG void Interpreter::run_bytecode(size_t entry_point) handle_Return: { auto& instruction = *reinterpret_cast(&bytecode[program_counter]); - auto result = instruction.execute(*this); + auto result = instruction.execute_impl(*this); if (result.is_error()) { if (handle_exception(program_counter, *result.throw_completion().value()) == HandleExceptionResponse::ExitFromExecutable) @@ -654,7 +654,7 @@ FLATTEN_ON_CLANG void Interpreter::run_bytecode(size_t entry_point) handle_Yield: { auto& instruction = *reinterpret_cast(&bytecode[program_counter]); - auto result = instruction.execute(*this); + auto result = instruction.execute_impl(*this); if (result.is_error()) { if (handle_exception(program_counter, *result.throw_completion().value()) == HandleExceptionResponse::ExitFromExecutable) diff --git a/Userland/Libraries/LibJS/Bytecode/Op.h b/Userland/Libraries/LibJS/Bytecode/Op.h index 6d42873fe2..38e56c4a2a 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.h +++ b/Userland/Libraries/LibJS/Bytecode/Op.h @@ -2052,22 +2052,3 @@ private: }; } - -namespace JS::Bytecode { - -ALWAYS_INLINE ThrowCompletionOr Instruction::execute(Bytecode::Interpreter& interpreter) const -{ -#define __BYTECODE_OP(op) \ - case Instruction::Type::op: \ - return static_cast(*this).execute_impl(interpreter); - - switch (type()) { - ENUMERATE_BYTECODE_OPS(__BYTECODE_OP) - default: - VERIFY_NOT_REACHED(); - } - -#undef __BYTECODE_OP -} - -}