mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-27 03:37:53 +00:00
LibJS/Bytecode: Display local variable names in bytecode dumps
Instead of displaying locals as "locN", we now show them as "name~N". This makes it a lot easier to follow bytecode dumps, especially in longer functions. Note that we keep displaying the local index, to avoid confusion in case there are multiple separate locals with the same name in one executable.
This commit is contained in:
committed by
Andreas Kling
parent
88d134a4da
commit
0aa8cb7dac
@@ -53,8 +53,7 @@ static ByteString format_operand(StringView name, Operand operand, Bytecode::Exe
|
||||
}
|
||||
break;
|
||||
case Operand::Type::Local:
|
||||
// FIXME: Show local name.
|
||||
builder.appendff("\033[34mloc{}\033[0m", operand.index());
|
||||
builder.appendff("\033[34m{}~{}\033[0m", executable.local_variable_names[operand.index() - executable.local_index_base], operand.index() - executable.local_index_base);
|
||||
break;
|
||||
case Operand::Type::Constant: {
|
||||
builder.append("\033[36m"sv);
|
||||
@@ -708,9 +707,9 @@ Interpreter::ResultAndReturnRegister Interpreter::run_executable(Executable& exe
|
||||
VERIFY(!vm().execution_context_stack().is_empty());
|
||||
|
||||
auto& running_execution_context = vm().running_execution_context();
|
||||
u32 registers_and_contants_count = executable.number_of_registers + executable.constants.size();
|
||||
if (running_execution_context.registers_and_constants_and_locals.size() < registers_and_contants_count)
|
||||
running_execution_context.registers_and_constants_and_locals.resize(registers_and_contants_count);
|
||||
u32 registers_and_constants_and_locals_count = executable.number_of_registers + executable.constants.size() + executable.local_variable_names.size();
|
||||
if (running_execution_context.registers_and_constants_and_locals.size() < registers_and_constants_and_locals_count)
|
||||
running_execution_context.registers_and_constants_and_locals.resize(registers_and_constants_and_locals_count);
|
||||
|
||||
TemporaryChange restore_running_execution_context { m_running_execution_context, &running_execution_context };
|
||||
TemporaryChange restore_arguments { m_arguments, running_execution_context.arguments.span() };
|
||||
|
||||
Reference in New Issue
Block a user