LibJS: Move bytecode debug spam behind JS_BYTECODE_DEBUG :^)

This commit is contained in:
Andreas Kling 2021-06-07 15:17:37 +02:00
parent e7d69c5d3c
commit 7cbe4daa7c
4 changed files with 23 additions and 11 deletions

View file

@ -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

View file

@ -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)

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Debug.h>
#include <LibJS/Bytecode/Block.h>
#include <LibJS/Bytecode/Instruction.h>
#include <LibJS/Bytecode/Interpreter.h>
@ -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();

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Debug.h>
#include <AK/Function.h>
#include <LibJS/AST.h>
#include <LibJS/Bytecode/Block.h>
@ -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<Interpreter> local_interpreter;