From 7cbe4daa7ca7ceb4b41d0787445a5372436d85ad Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 7 Jun 2021 15:17:37 +0200 Subject: [PATCH] LibJS: Move bytecode debug spam behind JS_BYTECODE_DEBUG :^) --- AK/Debug.h.in | 4 ++++ Meta/CMake/all_the_debug_macros.cmake | 1 + .../Libraries/LibJS/Bytecode/Interpreter.cpp | 22 +++++++++++-------- .../LibJS/Runtime/ScriptFunction.cpp | 7 ++++-- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/AK/Debug.h.in b/AK/Debug.h.in index 278c1fd5752..3af90f4caa8 100644 --- a/AK/Debug.h.in +++ b/AK/Debug.h.in @@ -226,6 +226,10 @@ #cmakedefine01 JPG_DEBUG #endif +#ifndef JS_BYTECODE_DEBUG +#cmakedefine01 JS_BYTECODE_DEBUG +#endif + #ifndef KEYBOARD_SHORTCUTS_DEBUG #cmakedefine01 KEYBOARD_SHORTCUTS_DEBUG #endif diff --git a/Meta/CMake/all_the_debug_macros.cmake b/Meta/CMake/all_the_debug_macros.cmake index 8919fc2377b..3c7acc1960e 100644 --- a/Meta/CMake/all_the_debug_macros.cmake +++ b/Meta/CMake/all_the_debug_macros.cmake @@ -88,6 +88,7 @@ set(IRQ_DEBUG ON) set(ITEM_RECTS_DEBUG ON) set(JOB_DEBUG ON) set(JPG_DEBUG ON) +set(JS_BYTECODE_DEBUG ON) set(KEYBOARD_DEBUG ON) set(KEYBOARD_SHORTCUTS_DEBUG ON) set(KMALLOC_DEBUG ON) diff --git a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp index 79d97b73bd8..349032e0b72 100644 --- a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include #include @@ -34,7 +35,7 @@ Interpreter::~Interpreter() Value Interpreter::run(Bytecode::Block const& block) { - dbgln("Bytecode::Interpreter will run block {:p}", &block); + dbgln_if(JS_BYTECODE_DEBUG, "Bytecode::Interpreter will run block {:p}", &block); CallFrame global_call_frame; if (vm().call_stack().is_empty()) { @@ -65,14 +66,17 @@ Value Interpreter::run(Bytecode::Block const& block) ++pc; } - dbgln("Bytecode::Interpreter did run block {:p}", &block); - for (size_t i = 0; i < registers().size(); ++i) { - String value_string; - if (registers()[i].is_empty()) - value_string = "(empty)"; - else - value_string = registers()[i].to_string_without_side_effects(); - dbgln("[{:3}] {}", i, value_string); + dbgln_if(JS_BYTECODE_DEBUG, "Bytecode::Interpreter did run block {:p}", &block); + + if constexpr (JS_BYTECODE_DEBUG) { + for (size_t i = 0; i < registers().size(); ++i) { + String value_string; + if (registers()[i].is_empty()) + value_string = "(empty)"; + else + value_string = registers()[i].to_string_without_side_effects(); + dbgln("[{:3}] {}", i, value_string); + } } m_register_windows.take_last(); diff --git a/Userland/Libraries/LibJS/Runtime/ScriptFunction.cpp b/Userland/Libraries/LibJS/Runtime/ScriptFunction.cpp index 4e4cf9698ba..9447544d407 100644 --- a/Userland/Libraries/LibJS/Runtime/ScriptFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/ScriptFunction.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include #include @@ -152,8 +153,10 @@ Value ScriptFunction::execute_function_body() prepare_arguments(); auto block = Bytecode::Generator::generate(m_body); VERIFY(block); - dbgln("Compiled Bytecode::Block for function '{}':", m_name); - block->dump(); + if constexpr (JS_BYTECODE_DEBUG) { + dbgln("Compiled Bytecode::Block for function '{}':", m_name); + block->dump(); + } return bytecode_interpreter->run(*block); } else { OwnPtr local_interpreter;