changeset 18225:40074f6ac788

Record frame state for deopts with +LogCompilation
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Fri, 31 Oct 2014 11:25:32 -0700
parents bfa20550f0a8
children 6eda3b299460
files src/share/vm/runtime/deoptimization.cpp src/share/vm/runtime/thread.cpp
diffstat 2 files changed, 18 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/runtime/deoptimization.cpp	Fri Oct 31 11:24:02 2014 -0700
+++ b/src/share/vm/runtime/deoptimization.cpp	Fri Oct 31 11:25:32 2014 -0700
@@ -1231,6 +1231,24 @@
   // Patch the nmethod so that when execution returns to it we will
   // deopt the execution state and return to the interpreter.
   fr.deoptimize(thread);
+
+  if (LogCompilation && xtty != NULL) {
+    nmethod* nm = fr.cb()->as_nmethod_or_null();
+    assert(nm != NULL, "only nmethods can deopt");
+
+    ttyLocker ttyl;
+    xtty->begin_head("deoptimized thread='" UINTX_FORMAT "' compile_id='%d'",
+               thread->osthread()->thread_id(), nm != NULL ? nm->compile_id() : -1);
+    nm->log_identity(xtty);
+    xtty->end_head();
+    for (ScopeDesc* sd = nm->scope_desc_at(fr.pc()); ; sd = sd->sender()) {
+      xtty->begin_elem("jvms bci='%d'", sd->bci());
+      xtty->method(sd->method());
+      xtty->end_elem();
+      if (sd->is_top())  break;
+    }
+    xtty->tail("deoptimized");
+  }
 }
 
 void Deoptimization::deoptimize(JavaThread* thread, frame fr, RegisterMap *map) {
--- a/src/share/vm/runtime/thread.cpp	Fri Oct 31 11:24:02 2014 -0700
+++ b/src/share/vm/runtime/thread.cpp	Fri Oct 31 11:25:32 2014 -0700
@@ -2750,12 +2750,6 @@
   StackFrameStream fst(this, UseBiasedLocking);
   for(; !fst.is_done(); fst.next()) {
     if (fst.current()->should_be_deoptimized()) {
-      if (LogCompilation && xtty != NULL) {
-        nmethod* nm = fst.current()->cb()->as_nmethod_or_null();
-        xtty->elem("deoptimized thread='" UINTX_FORMAT "' compile_id='%d'",
-                   this->name(), nm != NULL ? nm->compile_id() : -1);
-      }
-
       Deoptimization::deoptimize(this, *fst.current(), fst.register_map());
     }
   }