Reviewers: jarin, stichnot, jvoung,

Message:
Pretty printing improvements pulled out from the register allocation work.

I believe this also updates all offset printouts to hex, consistently. I have chosen not to offer a flag for "decimal vs hex" for offsets - happy to add one,
if we feel we need it.

Description:
Decompiler improvements.

The main motivation is simplifying profiling activities:

1) Use hex instead of decimal for offsets, just like perf does. This
affects --print-opt-code

2) When printing block information, indicate loop information: if
block is header, where the end is; if block is in a loop, where the
loop starts. This affects --code-comments.

Using --print-opt-code --code-comments, and cross-referencing with data
obtained from perf, one may now find the block a hotspot belongs to
without needing to do hex2dec/dec2hex conversions. Once found, loop info
is available locally, on the block.

BUG=

Please review this at https://codereview.chromium.org/1177123002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+25, -8 lines):
  M src/compiler/code-generator.cc
  M src/disassembler.cc


Index: src/compiler/code-generator.cc
diff --git a/src/compiler/code-generator.cc b/src/compiler/code-generator.cc
index 6be3f14f386333b58a58af85e6867cb2d74aa594..667dc73b8ae7253bd59670bf3af059e42b2a6e04 100644
--- a/src/compiler/code-generator.cc
+++ b/src/compiler/code-generator.cc
@@ -98,12 +98,29 @@ Handle<Code> CodeGenerator::GenerateCode() {
       if (FLAG_code_comments) {
         // TODO(titzer): these code comments are a giant memory leak.
         Vector<char> buffer = Vector<char>::New(200);
- SNPrintF(buffer, "-- B%d start%s%s%s%s --", block->rpo_number().ToInt(),
-                 block->IsDeferred() ? " (deferred)" : "",
-                 block->needs_frame() ? "" : " (no frame)",
-                 block->must_construct_frame() ? " (construct frame)" : "",
- block->must_deconstruct_frame() ? " (deconstruct frame)" : "");
-        masm()->RecordComment(buffer.start());
+        auto buffer_start = buffer.start();
+
+        int next = SNPrintF(
+            buffer, "-- B%d start%s%s%s%s", block->rpo_number().ToInt(),
+            block->IsDeferred() ? " (deferred)" : "",
+            block->needs_frame() ? "" : " (no frame)",
+            block->must_construct_frame() ? " (construct frame)" : "",
+            block->must_deconstruct_frame() ? " (deconstruct frame)" : "");
+
+        buffer = buffer.SubVector(next, buffer.length());
+
+        if (block->IsLoopHeader()) {
+          next =
+ SNPrintF(buffer, " (loop up to %d)", block->loop_end().ToInt());
+          buffer = buffer.SubVector(next, buffer.length());
+        }
+        if (block->loop_header().IsValid()) {
+          next =
+ SNPrintF(buffer, " (in loop %d)", block->loop_header().ToInt());
+          buffer = buffer.SubVector(next, buffer.length());
+        }
+        SNPrintF(buffer, " --");
+        masm()->RecordComment(buffer_start);
       }
       masm()->bind(GetLabel(current_block_));
       for (int i = block->code_start(); i < block->code_end(); ++i) {
Index: src/disassembler.cc
diff --git a/src/disassembler.cc b/src/disassembler.cc
index 9ec2f42377ba7de4b2f090d5855811ce1641ac12..68c1ca1a7f3d11a02bfe94b6b5f8e40c4c6ee2a2 100644
--- a/src/disassembler.cc
+++ b/src/disassembler.cc
@@ -43,7 +43,7 @@ const char* V8NameConverter::NameOfAddress(byte* pc) const {
     int offs = static_cast<int>(pc - code_->instruction_start());
     // print as code offset, if it seems reasonable
     if (0 <= offs && offs < code_->instruction_size()) {
-      SNPrintF(v8_buffer_, "%d  (%p)", offs, pc);
+      SNPrintF(v8_buffer_, "%x  (%p)", offs, pc);
       return v8_buffer_.start();
     }
   }
@@ -146,7 +146,7 @@ static int DecodeIt(Isolate* isolate, std::ostream* os,
     }

     // Instruction address and instruction offset.
-    out.AddFormatted("%p  %4d  ", prev_pc, prev_pc - begin);
+    out.AddFormatted("%p  %4x  ", prev_pc, prev_pc - begin);

     // Instruction.
     out.AddFormatted("%s", decode_buffer.start());


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to