Refactoring only: Extracted method to print deopt location.
authorsvenpanne@chromium.org <svenpanne@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 20 Dec 2012 11:53:42 +0000 (11:53 +0000)
committersvenpanne@chromium.org <svenpanne@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 20 Dec 2012 11:53:42 +0000 (11:53 +0000)
Review URL: https://codereview.chromium.org/11640041

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13251 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/deoptimizer.cc
src/objects.cc
src/objects.h

index 7018346..2cfba59 100644 (file)
@@ -529,26 +529,7 @@ Deoptimizer::Deoptimizer(Isolate* isolate,
   if (type == EAGER) {
     ASSERT(from == NULL);
     compiled_code_ = function_->code();
-    if (FLAG_trace_deopt && FLAG_code_comments) {
-      // Print instruction associated with this bailout.
-      const char* last_comment = NULL;
-      int mask = RelocInfo::ModeMask(RelocInfo::COMMENT)
-          | RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY);
-      for (RelocIterator it(compiled_code_, mask); !it.done(); it.next()) {
-        RelocInfo* info = it.rinfo();
-        if (info->rmode() == RelocInfo::COMMENT) {
-          last_comment = reinterpret_cast<const char*>(info->data());
-        }
-        if (info->rmode() == RelocInfo::RUNTIME_ENTRY) {
-          unsigned id = Deoptimizer::GetDeoptimizationId(
-              info->target_address(), Deoptimizer::EAGER);
-          if (id == bailout_id && last_comment != NULL) {
-            PrintF("            %s\n", last_comment);
-            break;
-          }
-        }
-      }
-    }
+    if (FLAG_trace_deopt) compiled_code_->PrintDeoptLocation(bailout_id);
   } else if (type == LAZY) {
     compiled_code_ = isolate->deoptimizer_data()->FindDeoptimizingCode(from);
     if (compiled_code_ == NULL) {
index 5f87a26..e43a94a 100644 (file)
@@ -9138,6 +9138,25 @@ Code* Code::GetCodeAgeStub(Age age, MarkingParity parity) {
 }
 
 
+void Code::PrintDeoptLocation(int bailout_id) {
+  const char* last_comment = NULL;
+  int mask = RelocInfo::ModeMask(RelocInfo::COMMENT)
+      | RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY);
+  for (RelocIterator it(this, mask); !it.done(); it.next()) {
+    RelocInfo* info = it.rinfo();
+    if (info->rmode() == RelocInfo::COMMENT) {
+      last_comment = reinterpret_cast<const char*>(info->data());
+    } else if (last_comment != NULL &&
+               bailout_id == Deoptimizer::GetDeoptimizationId(
+                   info->target_address(), Deoptimizer::EAGER)) {
+      CHECK(info->rmode() == RelocInfo::RUNTIME_ENTRY);
+      PrintF("            %s\n", last_comment);
+      return;
+    }
+  }
+}
+
+
 #ifdef ENABLE_DISASSEMBLER
 
 void DeoptimizationInputData::DeoptimizationInputDataPrint(FILE* out) {
index 83a05ad..8fe7fa7 100644 (file)
@@ -4528,6 +4528,8 @@ class Code: public HeapObject {
   static bool IsYoungSequence(byte* sequence);
   bool IsOld();
 
+  void PrintDeoptLocation(int bailout_id);
+
   // Max loop nesting marker used to postpose OSR. We don't take loop
   // nesting that is deeper than 5 levels into account.
   static const int kMaxLoopNestingMarker = 6;