changeset 4668:3dbcd1013cc8

added flag PrintDeoptimizationDetails changes so that TraceDeoptimization only prints basic information added nicer formatting for printing interpreter stack frames
author Christian Haeubl <christian.haeubl@oracle.com>
date Tue, 21 Feb 2012 16:05:46 -0800
parents 35b2cae45dc5
children a6d18567b2ff
files src/cpu/x86/vm/frame_x86.cpp src/cpu/x86/vm/frame_x86.hpp src/cpu/x86/vm/frame_x86.inline.hpp src/share/vm/runtime/basicLock.hpp src/share/vm/runtime/deoptimization.cpp src/share/vm/runtime/frame.cpp src/share/vm/runtime/frame.hpp src/share/vm/runtime/globals.hpp src/share/vm/runtime/vframe.cpp src/share/vm/runtime/vframeArray.cpp src/share/vm/runtime/vframe_hp.cpp
diffstat 11 files changed, 80 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/src/cpu/x86/vm/frame_x86.cpp	Tue Feb 21 14:27:25 2012 -0800
+++ b/src/cpu/x86/vm/frame_x86.cpp	Tue Feb 21 16:05:46 2012 -0800
@@ -301,6 +301,11 @@
   ptr_at_put(interpreter_frame_sender_sp_offset, (intptr_t) sender_sp);
 }
 
+intptr_t** frame::interpreter_frame_sender_sp_addr() const {
+  assert(is_interpreted_frame(), "interpreted frame expected");
+  return (intptr_t**) addr_at(interpreter_frame_sender_sp_offset);
+}
+
 
 // monitor elements
 
--- a/src/cpu/x86/vm/frame_x86.hpp	Tue Feb 21 14:27:25 2012 -0800
+++ b/src/cpu/x86/vm/frame_x86.hpp	Tue Feb 21 16:05:46 2012 -0800
@@ -197,6 +197,7 @@
 
   // expression stack tos if we are nested in a java call
   intptr_t* interpreter_frame_last_sp() const;
+  intptr_t** interpreter_frame_last_sp_addr() const;
 
   // helper to update a map with callee-saved RBP
   static void update_map_with_saved_link(RegisterMap* map, intptr_t** link_addr);
--- a/src/cpu/x86/vm/frame_x86.inline.hpp	Tue Feb 21 14:27:25 2012 -0800
+++ b/src/cpu/x86/vm/frame_x86.inline.hpp	Tue Feb 21 16:05:46 2012 -0800
@@ -131,8 +131,9 @@
 
 
 
-inline intptr_t* frame::link() const              { return (intptr_t*) *(intptr_t **)addr_at(link_offset); }
-inline void      frame::set_link(intptr_t* addr)  { *(intptr_t **)addr_at(link_offset) = addr; }
+inline intptr_t*  frame::link() const              { return (intptr_t*) *(intptr_t **)addr_at(link_offset); }
+inline intptr_t** frame::link_addr() const         { return (intptr_t **)addr_at(link_offset); }
+inline void       frame::set_link(intptr_t* addr)  { *(intptr_t **)addr_at(link_offset) = addr; }
 
 
 inline intptr_t* frame::unextended_sp() const     { return _unextended_sp; }
@@ -208,6 +209,10 @@
   return *(intptr_t**)addr_at(interpreter_frame_last_sp_offset);
 }
 
+inline intptr_t** frame::interpreter_frame_last_sp_addr() const {
+  return (intptr_t**)addr_at(interpreter_frame_last_sp_offset);
+}
+
 inline intptr_t* frame::interpreter_frame_bcx_addr() const {
   return (intptr_t*)addr_at(interpreter_frame_bcx_offset);
 }
--- a/src/share/vm/runtime/basicLock.hpp	Tue Feb 21 14:27:25 2012 -0800
+++ b/src/share/vm/runtime/basicLock.hpp	Tue Feb 21 16:05:46 2012 -0800
@@ -63,6 +63,7 @@
  public:
   // Manipulation
   oop      obj() const                                { return _obj;  }
+  oop*     obj_addr()                                 { return &_obj; }
   void set_obj(oop obj)                               { _obj = obj; }
   BasicLock* lock()                                   { return &_lock; }
 
--- a/src/share/vm/runtime/deoptimization.cpp	Tue Feb 21 14:27:25 2012 -0800
+++ b/src/share/vm/runtime/deoptimization.cpp	Tue Feb 21 16:05:46 2012 -0800
@@ -176,7 +176,7 @@
   // the vframeArray is created.
   //
 
-  if (TraceDeoptimization) {
+  if (PrintDeoptimizationDetails) {
     tty->print_cr("fetching unroll info");
   }
 
@@ -236,7 +236,7 @@
         assert(result == NULL || result->is_oop(), "must be oop");
         return_value = Handle(thread, result);
         assert(Universe::heap()->is_in_or_null(result), "must be heap pointer");
-        if (TraceDeoptimization) {
+        if (PrintDeoptimizationDetails) {
           tty->print_cr("SAVED OOP RESULT " INTPTR_FORMAT " in thread " INTPTR_FORMAT, result, thread);
         }
       }
@@ -249,7 +249,7 @@
       if (reallocated) {
         reassign_fields(&deoptee, &map, objects);
 #ifndef PRODUCT
-        if (TraceDeoptimization) {
+        if (PrintDeoptimizationDetails) {
           ttyLocker ttyl;
           tty->print_cr("REALLOC OBJECTS in thread " INTPTR_FORMAT, thread);
           print_objects(objects);
@@ -272,7 +272,7 @@
         if (monitors->is_nonempty()) {
           relock_objects(monitors, thread);
 #ifndef PRODUCT
-          if (TraceDeoptimization) {
+          if (PrintDeoptimizationDetails) {
             ttyLocker ttyl;
             for (int j = 0; j < monitors->length(); j++) {
               MonitorInfo* mi = monitors->at(j);
@@ -497,7 +497,7 @@
   info->set_initial_info((intptr_t) array->sender().initial_deoptimization_info());
 
   if (array->frames() > 1) {
-    if (VerifyStack && TraceDeoptimization) {
+    if (PrintDeoptimizationDetails) {
       tty->print_cr("Deoptimizing method containing inlining");
     }
   }
@@ -577,7 +577,7 @@
   vframeArray* array = thread->vframe_array_head();
 
 #ifndef PRODUCT
-  if (TraceDeoptimization) {
+  if (PrintDeoptimizationDetails) {
     tty->print_cr("DEOPT UNPACKING thread " INTPTR_FORMAT " vframeArray " INTPTR_FORMAT " mode %d", thread, array, exec_mode);
   }
 #endif
@@ -920,7 +920,7 @@
     KlassHandle k(((ConstantOopReadValue*) sv->klass())->value()());
     Handle obj = sv->value();
     assert(obj.not_null(), "reallocation was missed");
-    if (TraceDeoptimization) {
+    if (PrintDeoptimizationDetails) {
       tty->print_cr("reassign fields for object of type %s!", k->name()->as_C_string());
     }
 
@@ -990,7 +990,7 @@
 vframeArray* Deoptimization::create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray<compiledVFrame*>* chunk) {
 
 #ifndef PRODUCT
-  if (TraceDeoptimization) {
+  if (PrintDeoptimizationDetails) {
     ttyLocker ttyl;
     tty->print("DEOPT PACKING thread " INTPTR_FORMAT " ", thread);
     fr.print_on(tty);
@@ -1036,7 +1036,7 @@
   Events::log("# vframes = %d", (intptr_t)chunk->length());
 
 #ifndef PRODUCT
-  if (TraceDeoptimization) {
+  if (PrintDeoptimizationDetails) {
     ttyLocker ttyl;
     tty->print_cr("     Created vframeArray " INTPTR_FORMAT, array);
   }
@@ -1284,7 +1284,7 @@
     Bytecodes::Code trap_bc     = trap_method->java_code_at(trap_bci);
 
     if (trap_scope->rethrow_exception()) {
-      if (TraceDeoptimization) {
+      if (PrintDeoptimizationDetails) {
         tty->print_cr("Exception to be rethrown in the interpreter for method %s::%s at bci %d", instanceKlass::cast(trap_method->method_holder())->name()->as_C_string(), trap_method->name()->as_C_string(), trap_bci);
       }
       GrowableArray<ScopeValue*>* expressions = trap_scope->expressions();
--- a/src/share/vm/runtime/frame.cpp	Tue Feb 21 14:27:25 2012 -0800
+++ b/src/share/vm/runtime/frame.cpp	Tue Feb 21 16:05:46 2012 -0800
@@ -605,43 +605,63 @@
 #ifndef PRODUCT
   assert(is_interpreted_frame(), "Not an interpreted frame");
   jint i;
-  for (i = 0; i < interpreter_frame_method()->max_locals(); i++ ) {
-    intptr_t x = *interpreter_frame_local_at(i);
-    st->print(" - local  [" INTPTR_FORMAT "]", x);
-    st->fill_to(23);
-    st->print_cr("; #%d", i);
-  }
+  st->print_cr(" - sp                                  = " INTPTR_FORMAT, sp());
+  // expressions
   for (i = interpreter_frame_expression_stack_size() - 1; i >= 0; --i ) {
-    intptr_t x = *interpreter_frame_expression_stack_at(i);
-    st->print(" - stack  [" INTPTR_FORMAT "]", x);
-    st->fill_to(23);
+    intptr_t* x = interpreter_frame_expression_stack_at(i);
+    st->print(" - stack         at " INTPTR_FORMAT " = " INTPTR_FORMAT, x, *x);
+    st->fill_to(70);
     st->print_cr("; #%d", i);
   }
   // locks for synchronization
+  st->print_cr(" - monitorend                          = " INTPTR_FORMAT, interpreter_frame_monitor_end());
   for (BasicObjectLock* current = interpreter_frame_monitor_end();
        current < interpreter_frame_monitor_begin();
        current = next_monitor_in_interpreter_frame(current)) {
-    st->print(" - obj    [");
-    current->obj()->print_value_on(st);
-    st->print_cr("]");
-    st->print(" - lock   [");
+    st->print (" - lock          at " INTPTR_FORMAT " = ", current->lock());
     current->lock()->print_on(st);
-    st->print_cr("]");
+    st->cr();
+    st->print (" - obj           at " INTPTR_FORMAT " = " INTPTR_FORMAT " ", current->obj_addr(), *current->obj_addr());
+    current->obj()->print_value_on(st);
+    st->cr();
   }
-  // monitor
-  st->print_cr(" - monitor[" INTPTR_FORMAT "]", interpreter_frame_monitor_begin());
-  // bcp
-  st->print(" - bcp    [" INTPTR_FORMAT "]", interpreter_frame_bcp());
-  st->fill_to(23);
+  st->print_cr(" - monitorbegin                        = " INTPTR_FORMAT, interpreter_frame_monitor_begin());
+  
+  // bcp/bcx
+  st->print   (" - bcp           at " INTPTR_FORMAT " = " INTPTR_FORMAT, interpreter_frame_bcx_addr(), interpreter_frame_bcp());
+  st->fill_to(70);
   st->print_cr("; @%d", interpreter_frame_bci());
   // locals
-  st->print_cr(" - locals [" INTPTR_FORMAT "]", interpreter_frame_local_at(0));
+  st->print_cr(" - locals        at " INTPTR_FORMAT " = " INTPTR_FORMAT, interpreter_frame_locals_addr(), *interpreter_frame_locals_addr());
+  // constant pool cache
+  st->print_cr(" - constant pool at " INTPTR_FORMAT " = " INTPTR_FORMAT, interpreter_frame_cache_addr(), *interpreter_frame_cache_addr());
+  // method data
+  st->print_cr(" - method data   at " INTPTR_FORMAT " = " INTPTR_FORMAT, interpreter_frame_mdx_addr(), *interpreter_frame_mdx_addr());
   // method
-  st->print(" - method [" INTPTR_FORMAT "]", (address)interpreter_frame_method());
-  st->fill_to(23);
+  st->print   (" - method        at " INTPTR_FORMAT " = " INTPTR_FORMAT, interpreter_frame_method_addr(), *interpreter_frame_method_addr());
+  st->fill_to(70);
   st->print("; ");
   interpreter_frame_method()->print_name(st);
   st->cr();
+  // last sp
+  st->print_cr(" - last sp       at " INTPTR_FORMAT " = " INTPTR_FORMAT, interpreter_frame_last_sp_addr(), *interpreter_frame_last_sp_addr());
+  // sender sp
+  st->print_cr(" - sender sp     at " INTPTR_FORMAT " = " INTPTR_FORMAT, interpreter_frame_sender_sp_addr(), *interpreter_frame_sender_sp_addr());
+  // old fp
+  st->print_cr(" - old fp        at " INTPTR_FORMAT " = " INTPTR_FORMAT, link_addr(), *link_addr());
+  // return address
+  st->print_cr(" - return pc     at " INTPTR_FORMAT " = " INTPTR_FORMAT, sender_pc_addr(), *sender_pc_addr());
+
+  // locals
+  for (i = interpreter_frame_method()->max_locals() - 1; i >= 0; i--) {
+    intptr_t* x = interpreter_frame_local_at(i);
+    st->print (" - local         at " INTPTR_FORMAT " = " INTPTR_FORMAT, x, *x);
+    st->fill_to(70);
+    st->print_cr("; #%d", i);
+  }
+
+  // fp
+  st->print_cr(" - fp                                  = " INTPTR_FORMAT, fp());
 #endif
 }
 
--- a/src/share/vm/runtime/frame.hpp	Tue Feb 21 14:27:25 2012 -0800
+++ b/src/share/vm/runtime/frame.hpp	Tue Feb 21 16:05:46 2012 -0800
@@ -206,6 +206,7 @@
  public:
   // Link (i.e., the pointer to the previous frame)
   intptr_t* link() const;
+  intptr_t** link_addr() const;
   void set_link(intptr_t* addr);
 
   // Return address
@@ -296,6 +297,7 @@
   jint  interpreter_frame_expression_stack_size() const;
 
   intptr_t* interpreter_frame_sender_sp() const;
+  intptr_t** interpreter_frame_sender_sp_addr() const;
 
 #ifndef CC_INTERP
   // template based interpreter deoptimization support
--- a/src/share/vm/runtime/globals.hpp	Tue Feb 21 14:27:25 2012 -0800
+++ b/src/share/vm/runtime/globals.hpp	Tue Feb 21 16:05:46 2012 -0800
@@ -2976,6 +2976,9 @@
   product(bool, TraceDeoptimization, false,                                 \
           "Trace deoptimization")                                           \
                                                                             \
+  product(bool, PrintDeoptimizationDetails, false,                          \
+          "Print more information about deoptimization")                    \
+                                                                            \
   develop(bool, DebugDeoptimization, false,                                 \
           "Tracing various information while debugging deoptimization")     \
                                                                             \
--- a/src/share/vm/runtime/vframe.cpp	Tue Feb 21 14:27:25 2012 -0800
+++ b/src/share/vm/runtime/vframe.cpp	Tue Feb 21 16:05:46 2012 -0800
@@ -266,7 +266,7 @@
 
   // Get oopmap describing oops and int for current bci
   InterpreterOopMap oop_mask;
-  if (TraceDeoptimization && Verbose) {
+  if (PrintDeoptimizationDetails) {
     methodHandle m_h(thread(), method());
     OopMapCache::compute_one_oop_map(m_h, bci(), &oop_mask);
   } else {
@@ -333,7 +333,7 @@
 
   InterpreterOopMap oop_mask;
   // Get oopmap describing oops and int for current bci
-  if (TraceDeoptimization && Verbose) {
+  if (PrintDeoptimizationDetails) {
     methodHandle m_h(method());
     OopMapCache::compute_one_oop_map(m_h, bci(), &oop_mask);
   } else {
--- a/src/share/vm/runtime/vframeArray.cpp	Tue Feb 21 14:27:25 2012 -0800
+++ b/src/share/vm/runtime/vframeArray.cpp	Tue Feb 21 16:05:46 2012 -0800
@@ -317,7 +317,7 @@
     }
   }
   
-  if (TraceDeoptimization) {
+  if (PrintDeoptimizationDetails) {
     tty->print_cr("Expressions size: %d", expressions()->size());
   }
 
@@ -333,7 +333,7 @@
       case T_INT:
         *addr = value->get_int();
 #ifndef PRODUCT
-        if (TraceDeoptimization) {
+        if (PrintDeoptimizationDetails) {
           tty->print_cr("Reconstructed expression %d (INT): %d", i, (int)(*addr));
         }
 #endif
@@ -341,7 +341,7 @@
       case T_OBJECT:
         *addr = value->get_int(T_OBJECT);
 #ifndef PRODUCT
-        if (TraceDeoptimization) {
+        if (PrintDeoptimizationDetails) {
           tty->print("Reconstructed expression %d (OBJECT): ", i);
           oop o = (oop)(*addr);
           if (o == NULL) {
@@ -370,7 +370,7 @@
       case T_INT:
         *addr = value->get_int();
 #ifndef PRODUCT
-        if (TraceDeoptimization) {
+        if (PrintDeoptimizationDetails) {
           tty->print_cr("Reconstructed local %d (INT): %d", i, (int)(*addr));
         }
 #endif
@@ -378,7 +378,7 @@
       case T_OBJECT:
         *addr = value->get_int(T_OBJECT);
 #ifndef PRODUCT
-        if (TraceDeoptimization) {
+        if (PrintDeoptimizationDetails) {
           tty->print("Reconstructed local %d (OBJECT): ", i);
           oop o = (oop)(*addr);
           if (o == NULL) {
@@ -429,18 +429,13 @@
   }
 
 #ifndef PRODUCT
-  if (TraceDeoptimization && Verbose) {
+  if (PrintDeoptimizationDetails) {
     ttyLocker ttyl;
     tty->print_cr("[%d Interpreted Frame]", ++unpack_counter);
     iframe()->print_on(tty);
     RegisterMap map(thread);
     vframe* f = vframe::new_vframe(iframe(), &map, thread);
     f->print();
-
-    tty->print_cr("locals size     %d", locals()->size());
-    tty->print_cr("expression size %d", expressions()->size());
-
-    method()->print_value();
     tty->cr();
     // method()->print_codes();
   } else if (TraceDeoptimization) {
--- a/src/share/vm/runtime/vframe_hp.cpp	Tue Feb 21 14:27:25 2012 -0800
+++ b/src/share/vm/runtime/vframe_hp.cpp	Tue Feb 21 16:05:46 2012 -0800
@@ -70,7 +70,7 @@
     }
   }
 
-  if (TraceDeoptimization) {
+  if (PrintDeoptimizationDetails) {
     tty->print_cr("bci=%d length=%d", this->bci(), length);
     tty->print_cr(err_msg("method name = %s", this->method()->name()->as_C_string()));
     tty->print_cr("relative pc=%d", this->fr().pc() - this->nm()->code_begin());