diff options
author | Hendiadyoin1 <leon.a@serenityos.org> | 2022-11-08 19:41:23 +0100 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2022-12-03 17:07:30 +0330 |
commit | 8c4717fc6e2df02804942c75f6aa2efbe93c1ecc (patch) | |
tree | 07c09f294aa2c6358c2a51968d9de83376030a68 /Userland/Libraries/LibJS/Bytecode | |
parent | b86f1c2fe7b304f44c72533a6e08ecf615f0fc90 (diff) | |
download | serenity-8c4717fc6e2df02804942c75f6aa2efbe93c1ecc.zip |
LibJS: Add a debug_position helper to the Bytecode Interpreter
This also changes argument_list_evaluation's dbgln to use it.
Diffstat (limited to 'Userland/Libraries/LibJS/Bytecode')
-rw-r--r-- | Userland/Libraries/LibJS/Bytecode/Interpreter.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Bytecode/Op.cpp | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/Userland/Libraries/LibJS/Bytecode/Interpreter.h b/Userland/Libraries/LibJS/Bytecode/Interpreter.h index 5ad350f561..04ac116607 100644 --- a/Userland/Libraries/LibJS/Bytecode/Interpreter.h +++ b/Userland/Libraries/LibJS/Bytecode/Interpreter.h @@ -68,6 +68,10 @@ public: Executable const& current_executable() { return *m_current_executable; } BasicBlock const& current_block() const { return *m_current_block; } size_t pc() const { return m_pc ? m_pc->offset() : 0; } + String debug_position() + { + return String::formatted("{}:{:2}:{:4x}", m_current_executable->name, m_current_block->name(), pc()); + } enum class OptimizationLevel { None, diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp index bf22532338..38a6ea1bab 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp @@ -577,8 +577,7 @@ static MarkedVector<Value> argument_list_evaluation(Bytecode::Interpreter& inter auto arguments = interpreter.accumulator(); if (!(arguments.is_object() && is<Array>(arguments.as_object()))) { - dbgln("Call arguments are not an array, but: {}", arguments.to_string_without_side_effects()); - dbgln("PC: {}[{:4x}]", interpreter.current_block().name(), interpreter.pc()); + dbgln("[{}] Call arguments are not an array, but: {}", interpreter.debug_position(), arguments.to_string_without_side_effects()); interpreter.current_executable().dump(); VERIFY_NOT_REACHED(); } |