Commit 390b5cb1 authored by sgjesse@chromium.org's avatar sgjesse@chromium.org

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
parent cd50f9f8
...@@ -197,55 +197,72 @@ static int DecodeIt(FILE* f, ...@@ -197,55 +197,72 @@ static int DecodeIt(FILE* f,
out.AddPadding(' ', kRelocInfoPosition); out.AddPadding(' ', kRelocInfoPosition);
} }
if (is_position(relocinfo.rmode())) { RelocMode rmode = relocinfo.rmode();
out.AddFormatted(" ;; debug: statement %d", relocinfo.data()); if (is_position(rmode)) {
} else if (relocinfo.rmode() == embedded_object) { if (is_statement_position(rmode)) {
out.AddFormatted(" ;; debug: statement %d", relocinfo.data());
} 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::Kind kind = code->kind(); Code* code = Debug::GetCodeTarget(relocinfo.target_address());
if (kind == Code::STUB) { Code::Kind kind = code->kind();
// Reverse lookup required as the minor key cannot be retrieved if (code->is_inline_cache_stub()) {
// from the code object. if (rmode == code_target_context) {
Object* obj = Heap::code_stubs()->SlowReverseLookup(code); out.AddFormatted(" contextual,");
if (obj != Heap::undefined_value()) { }
ASSERT(obj->IsSmi()); InlineCacheState ic_state = code->ic_state();
// Get the STUB key and extract major and minor key. out.AddFormatted(" %s, %s", Code::Kind2String(kind),
uint32_t key = Smi::cast(obj)->value(); Code::ICState2String(ic_state));
uint32_t minor_key = CodeStub::MinorKeyFromKey(key); if (kind == Code::CALL_IC) {
ASSERT(code->major_key() == CodeStub::MajorKeyFromKey(key)); out.AddFormatted(", argc = %d", code->arguments_count());
out.AddFormatted(" (%s, %s, ", }
Code::Kind2String(kind), } else if (kind == Code::STUB) {
CodeStub::MajorName(code->major_key())); // Reverse lookup required as the minor key cannot be retrieved
switch (code->major_key()) { // from the code object.
case CodeStub::CallFunction: Object* obj = Heap::code_stubs()->SlowReverseLookup(code);
out.AddFormatted("argc = %d)", minor_key); if (obj != Heap::undefined_value()) {
break; ASSERT(obj->IsSmi());
case CodeStub::Runtime: { // Get the STUB key and extract major and minor key.
const char* name = uint32_t key = Smi::cast(obj)->value();
RuntimeStub::GetNameFromMinorKey(minor_key); uint32_t minor_key = CodeStub::MinorKeyFromKey(key);
out.AddFormatted("%s)", name); ASSERT(code->major_key() == CodeStub::MajorKeyFromKey(key));
break; out.AddFormatted(" %s, %s, ",
} Code::Kind2String(kind),
default: CodeStub::MajorName(code->major_key()));
out.AddFormatted("minor: %d)", minor_key); switch (code->major_key()) {
case CodeStub::CallFunction:
out.AddFormatted("argc = %d", minor_key);
break;
case CodeStub::Runtime: {
const char* name =
RuntimeStub::GetNameFromMinorKey(minor_key);
out.AddFormatted("%s", name);
break;
} }
default:
out.AddFormatted("minor: %d", minor_key);
} }
} else {
out.AddFormatted(" (%s)", Code::Kind2String(kind));
} }
} else {
out.AddFormatted(" %s", Code::Kind2String(kind));
} }
} else {
out.AddFormatted(" ;; %s", RelocInfo::RelocModeName(rmode));
} }
} }
out.AddString("\n"); out.AddString("\n");
......
...@@ -4197,6 +4197,21 @@ const char* Code::Kind2String(Kind kind) { ...@@ -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()));
......
...@@ -2063,6 +2063,7 @@ class Code: public HeapObject { ...@@ -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
......
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