Skip to content

Commit

Permalink
LibJS: Add a debug_position helper to the Bytecode Interpreter
Browse files Browse the repository at this point in the history
This also changes argument_list_evaluation's dbgln to use it.
  • Loading branch information
Hendiadyoin1 authored and alimpfard committed Dec 3, 2022
1 parent b86f1c2 commit 8c4717f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Userland/Libraries/LibJS/Bytecode/Interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class Interpreter {
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,
Expand Down
3 changes: 1 addition & 2 deletions Userland/Libraries/LibJS/Bytecode/Op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 8c4717f

Please sign in to comment.