Commit ee30626d authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[interpreter] Print name together with bytecode handler.

This prints the mnemonic of the bytecode that a bytecode handler belongs
to, whenever the handler is disassembled (not just during tracing). This
can be helpful when debugging code in GDB or with the snapshot where the
tracing is not available.

R=rmcilroy@chromium.org

Review URL: https://codereview.chromium.org/1806883002

Cr-Commit-Position: refs/heads/master@{#34826}
parent 65dcd255
......@@ -37,11 +37,11 @@ void Interpreter::Initialize() {
InterpreterAssembler assembler(isolate_, &zone, Bytecode::k##Name); \
Do##Name(&assembler); \
Handle<Code> code = assembler.GenerateCode(); \
TraceCodegen(code, #Name); \
dispatch_table_[Bytecodes::ToByte(Bytecode::k##Name)] = *code; \
TraceCodegen(code); \
LOG_CODE_EVENT(isolate_, \
CodeCreateEvent(Logger::BYTECODE_HANDLER_TAG, \
AbstractCode::cast(*code), #Name)); \
dispatch_table_[Bytecodes::ToByte(Bytecode::k##Name)] = *code; \
}
BYTECODE_LIST(GENERATE_CODE)
#undef GENERATE_CODE
......@@ -116,16 +116,28 @@ bool Interpreter::IsDispatchTableInitialized() {
return dispatch_table_[0] != nullptr;
}
void Interpreter::TraceCodegen(Handle<Code> code, const char* name) {
void Interpreter::TraceCodegen(Handle<Code> code) {
#ifdef ENABLE_DISASSEMBLER
if (FLAG_trace_ignition_codegen) {
OFStream os(stdout);
code->Disassemble(name, os);
code->Disassemble(nullptr, os);
os << std::flush;
}
#endif // ENABLE_DISASSEMBLER
}
const char* Interpreter::LookupNameOfBytecodeHandler(Code* code) {
#ifdef ENABLE_DISASSEMBLER
#define RETURN_NAME(Name, ...) \
if (dispatch_table_[Bytecodes::ToByte(Bytecode::k##Name)] == code) { \
return #Name; \
}
BYTECODE_LIST(RETURN_NAME)
#undef RETURN_NAME
#endif // ENABLE_DISASSEMBLER
return nullptr;
}
// LdaZero
//
// Load literal '0' into the accumulator.
......
......@@ -45,7 +45,9 @@ class Interpreter {
// GC support.
void IterateDispatchTable(ObjectVisitor* v);
void TraceCodegen(Handle<Code> code, const char* name);
// Disassembler support (only useful with ENABLE_DISASSEMBLER defined).
void TraceCodegen(Handle<Code> code);
const char* LookupNameOfBytecodeHandler(Code* code);
Address dispatch_table_address() {
return reinterpret_cast<Address>(&dispatch_table_[0]);
......
......@@ -34,6 +34,7 @@
#include "src/ic/ic.h"
#include "src/identity-map.h"
#include "src/interpreter/bytecode-array-iterator.h"
#include "src/interpreter/interpreter.h"
#include "src/interpreter/source-position-table.h"
#include "src/isolate-inl.h"
#include "src/keys.h"
......@@ -14815,11 +14816,16 @@ void Code::Disassemble(const char* name, std::ostream& os) { // NOLINT
os << "compare_operation = " << Token::Name(stub.op()) << "\n";
}
}
if ((name != NULL) && (name[0] != '\0')) {
if ((name != nullptr) && (name[0] != '\0')) {
os << "name = " << name << "\n";
} else if (kind() == BUILTIN) {
name = GetIsolate()->builtins()->Lookup(instruction_start());
if (name != NULL) {
if (name != nullptr) {
os << "name = " << name << "\n";
}
} else if (kind() == BYTECODE_HANDLER) {
name = GetIsolate()->interpreter()->LookupNameOfBytecodeHandler(this);
if (name != nullptr) {
os << "name = " << name << "\n";
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment