Changed the disassembler formatting

Changed the formatting of the comment in the disassembler output to contain
more information on code targets.
Review URL: http://codereview.chromium.org/3099

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@327 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
sgjesse@chromium.org 2008-09-17 12:38:50 +00:00
parent cd50f9f865
commit 390b5cb185
3 changed files with 73 additions and 40 deletions

View File

@ -197,25 +197,41 @@ static int DecodeIt(FILE* f,
out.AddPadding(' ', kRelocInfoPosition); out.AddPadding(' ', kRelocInfoPosition);
} }
if (is_position(relocinfo.rmode())) { RelocMode rmode = relocinfo.rmode();
if (is_position(rmode)) {
if (is_statement_position(rmode)) {
out.AddFormatted(" ;; debug: statement %d", relocinfo.data()); out.AddFormatted(" ;; debug: statement %d", relocinfo.data());
} else if (relocinfo.rmode() == embedded_object) { } else {
out.AddFormatted(" ;; debug: position %d", relocinfo.data());
}
} else if (rmode == embedded_object) {
HeapStringAllocator allocator; HeapStringAllocator allocator;
StringStream accumulator(&allocator); StringStream accumulator(&allocator);
relocinfo.target_object()->ShortPrint(&accumulator); relocinfo.target_object()->ShortPrint(&accumulator);
SmartPointer<char> obj_name = accumulator.ToCString(); SmartPointer<char> obj_name = accumulator.ToCString();
out.AddFormatted(" ;; object: %s", *obj_name); out.AddFormatted(" ;; object: %s", *obj_name);
} else if (relocinfo.rmode() == external_reference) { } else if (rmode == external_reference) {
const char* reference_name = const char* reference_name =
ref_encoder.NameOfAddress(*relocinfo.target_reference_address()); ref_encoder.NameOfAddress(*relocinfo.target_reference_address());
out.AddFormatted(" ;; external reference (%s)", reference_name); out.AddFormatted(" ;; external reference (%s)", reference_name);
} else { } else if (is_code_target(rmode)) {
out.AddFormatted(" ;; %s", out.AddFormatted(" ;; code:");
RelocInfo::RelocModeName(relocinfo.rmode())); if (rmode == js_construct_call) {
if (is_code_target(relocinfo.rmode())) { out.AddFormatted(" constructor,");
}
Code* code = Debug::GetCodeTarget(relocinfo.target_address()); Code* code = Debug::GetCodeTarget(relocinfo.target_address());
Code::Kind kind = code->kind(); Code::Kind kind = code->kind();
if (kind == Code::STUB) { if (code->is_inline_cache_stub()) {
if (rmode == code_target_context) {
out.AddFormatted(" contextual,");
}
InlineCacheState ic_state = code->ic_state();
out.AddFormatted(" %s, %s", Code::Kind2String(kind),
Code::ICState2String(ic_state));
if (kind == Code::CALL_IC) {
out.AddFormatted(", argc = %d", code->arguments_count());
}
} else if (kind == Code::STUB) {
// Reverse lookup required as the minor key cannot be retrieved // Reverse lookup required as the minor key cannot be retrieved
// from the code object. // from the code object.
Object* obj = Heap::code_stubs()->SlowReverseLookup(code); Object* obj = Heap::code_stubs()->SlowReverseLookup(code);
@ -225,27 +241,28 @@ static int DecodeIt(FILE* f,
uint32_t key = Smi::cast(obj)->value(); uint32_t key = Smi::cast(obj)->value();
uint32_t minor_key = CodeStub::MinorKeyFromKey(key); uint32_t minor_key = CodeStub::MinorKeyFromKey(key);
ASSERT(code->major_key() == CodeStub::MajorKeyFromKey(key)); ASSERT(code->major_key() == CodeStub::MajorKeyFromKey(key));
out.AddFormatted(" (%s, %s, ", out.AddFormatted(" %s, %s, ",
Code::Kind2String(kind), Code::Kind2String(kind),
CodeStub::MajorName(code->major_key())); CodeStub::MajorName(code->major_key()));
switch (code->major_key()) { switch (code->major_key()) {
case CodeStub::CallFunction: case CodeStub::CallFunction:
out.AddFormatted("argc = %d)", minor_key); out.AddFormatted("argc = %d", minor_key);
break; break;
case CodeStub::Runtime: { case CodeStub::Runtime: {
const char* name = const char* name =
RuntimeStub::GetNameFromMinorKey(minor_key); RuntimeStub::GetNameFromMinorKey(minor_key);
out.AddFormatted("%s)", name); out.AddFormatted("%s", name);
break; break;
} }
default: default:
out.AddFormatted("minor: %d)", minor_key); out.AddFormatted("minor: %d", minor_key);
} }
} }
} else { } else {
out.AddFormatted(" (%s)", Code::Kind2String(kind)); out.AddFormatted(" %s", Code::Kind2String(kind));
}
} }
} else {
out.AddFormatted(" ;; %s", RelocInfo::RelocModeName(rmode));
} }
} }
out.AddString("\n"); out.AddString("\n");

View File

@ -4197,6 +4197,21 @@ const char* Code::Kind2String(Kind kind) {
} }
const char* Code::ICState2String(InlineCacheState state) {
switch (state) {
case UNINITIALIZED: return "UNINITIALIZED";
case PREMONOMORPHIC: return "PREMONOMORPHIC";
case MONOMORPHIC: return "MONOMORPHIC";
case MONOMORPHIC_PROTOTYPE_FAILURE: return "MONOMORPHIC_PROTOTYPE_FAILURE";
case MEGAMORPHIC: return "MEGAMORPHIC";
case DEBUG_BREAK: return "DEBUG_BREAK";
case DEBUG_PREPARE_STEP_IN: return "DEBUG_PREPARE_STEP_IN";
}
UNREACHABLE();
return NULL;
}
void Code::Disassemble() { void Code::Disassemble() {
PrintF("kind = %s", Kind2String(kind())); PrintF("kind = %s", Kind2String(kind()));

View File

@ -2063,6 +2063,7 @@ class Code: public HeapObject {
#ifdef ENABLE_DISASSEMBLER #ifdef ENABLE_DISASSEMBLER
// Printing // Printing
static const char* Kind2String(Kind kind); static const char* Kind2String(Kind kind);
static const char* ICState2String(InlineCacheState state);
void Disassemble(); void Disassemble();
#endif // ENABLE_DISASSEMBLER #endif // ENABLE_DISASSEMBLER