Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Unified Diff: src/disassembler.cc

Issue 7618040: Version 3.5.5. (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/d8.js ('k') | src/elements.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/disassembler.cc
===================================================================
--- src/disassembler.cc (revision 8931)
+++ src/disassembler.cc (working copy)
@@ -97,14 +97,17 @@
}
-static void DumpBuffer(FILE* f, char* buff) {
+static void DumpBuffer(FILE* f, StringBuilder* out) {
if (f == NULL) {
- PrintF("%s", buff);
+ PrintF("%s\n", out->Finalize());
} else {
- fprintf(f, "%s", buff);
+ fprintf(f, "%s\n", out->Finalize());
}
+ out->Reset();
}
+
+
static const int kOutBufferSize = 2048 + String::kMaxShortPrintLength;
static const int kRelocInfoPosition = 57;
@@ -119,6 +122,7 @@
v8::internal::EmbeddedVector<char, 128> decode_buffer;
v8::internal::EmbeddedVector<char, kOutBufferSize> out_buffer;
+ StringBuilder out(out_buffer.start(), out_buffer.length());
byte* pc = begin;
disasm::Disassembler d(converter);
RelocIterator* it = NULL;
@@ -181,17 +185,12 @@
}
}
- StringBuilder out(out_buffer.start(), out_buffer.length());
-
// Comments.
for (int i = 0; i < comments.length(); i++) {
- out.AddFormatted(" %s\n", comments[i]);
+ out.AddFormatted(" %s", comments[i]);
+ DumpBuffer(f, &out);
}
- // Write out comments, resets outp so that we can format the next line.
- DumpBuffer(f, out.Finalize());
- out.Reset();
-
// Instruction address and instruction offset.
out.AddFormatted("%p %4d ", prev_pc, prev_pc - begin);
@@ -209,7 +208,7 @@
out.AddPadding(' ', kRelocInfoPosition - out.position());
} else {
// Additional reloc infos are printed on separate lines.
- out.AddFormatted("\n");
+ DumpBuffer(f, &out);
out.AddPadding(' ', kRelocInfoPosition);
}
@@ -299,11 +298,20 @@
out.AddFormatted(" ;; %s", RelocInfo::RelocModeName(rmode));
}
}
- out.AddString("\n");
- DumpBuffer(f, out.Finalize());
- out.Reset();
+ DumpBuffer(f, &out);
}
+ // Emit comments following the last instruction (if any).
+ if (it != NULL) {
+ for ( ; !it->done(); it->next()) {
+ if (RelocInfo::IsComment(it->rinfo()->rmode())) {
+ out.AddFormatted(" %s",
+ reinterpret_cast<const char*>(it->rinfo()->data()));
+ DumpBuffer(f, &out);
+ }
+ }
+ }
+
delete it;
return static_cast<int>(pc - begin);
}
« no previous file with comments | « src/d8.js ('k') | src/elements.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698