< prev index next >

src/share/vm/runtime/vframe.cpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 172           print_locked_object_class_name(st, o, "waiting on");
 173         }
 174       }
 175     } else if (thread()->current_park_blocker() != NULL) {
 176       oop obj = thread()->current_park_blocker();
 177       Klass* k = obj->klass();
 178       st->print_cr("\t- %s <" INTPTR_FORMAT "> (a %s)", "parking to wait for ", (address)obj, k->external_name());
 179     }
 180   }
 181 
 182 
 183   // Print out all monitors that we have locked or are trying to lock
 184   GrowableArray<MonitorInfo*>* mons = monitors();
 185   if (!mons->is_empty()) {
 186     bool found_first_monitor = false;
 187     for (int index = (mons->length()-1); index >= 0; index--) {
 188       MonitorInfo* monitor = mons->at(index);
 189       if (monitor->eliminated() && is_compiled_frame()) { // Eliminated in compiled code
 190         if (monitor->owner_is_scalar_replaced()) {
 191           Klass* k = java_lang_Class::as_Klass(monitor->owner_klass());

 192           st->print("\t- eliminated <owner is scalar replaced> (a %s)", k->external_name());
 193         } else {
 194           oop obj = monitor->owner();
 195           if (obj != NULL) {
 196             print_locked_object_class_name(st, obj, "eliminated");
 197           }
 198         }
 199         continue;
 200       }
 201       if (monitor->owner() != NULL) {
 202         // the monitor is associated with an object, i.e., it is locked
 203 
 204         // First, assume we have the monitor locked. If we haven't found an
 205         // owned monitor before and this is the first frame, then we need to
 206         // see if we have completed the lock or we are blocked trying to
 207         // acquire it - we can only be blocked if the monitor is inflated
 208 

 209         const char *lock_state = "locked"; // assume we have the monitor locked
 210         if (!found_first_monitor && frame_count == 0) {
 211           markOop mark = monitor->owner()->mark();
 212           if (mark->has_monitor() &&
 213               ( // we have marked ourself as pending on this monitor
 214                 mark->monitor() == thread()->current_pending_monitor() ||
 215                 // we are not the owner of this monitor
 216                 !mark->monitor()->is_entered(thread())
 217               )) {
 218             lock_state = "waiting to lock";



 219           }






 220         }
 221 
 222         found_first_monitor = true;
 223         print_locked_object_class_name(st, monitor->owner(), lock_state);
 224       }
 225     }
 226   }
 227 }
 228 
 229 // ------------- interpretedVFrame --------------
 230 
 231 u_char* interpretedVFrame::bcp() const {
 232   return fr().interpreter_frame_bcp();
 233 }
 234 
 235 void interpretedVFrame::set_bcp(u_char* bcp) {
 236   fr().interpreter_frame_set_bcp(bcp);
 237 }
 238 
 239 intptr_t* interpretedVFrame::locals_addr_at(int offset) const {
 240   assert(fr().is_interpreted_frame(), "frame should be an interpreted frame");
 241   return fr().interpreter_frame_local_at(offset);
 242 }
 243 


 560   method()->print_value();
 561   tty->cr();
 562   tty->print_cr("\tbci:    %d", bci());
 563 
 564   print_stack_values("locals",      locals());
 565   print_stack_values("expressions", expressions());
 566 
 567   GrowableArray<MonitorInfo*>* list = monitors();
 568   if (list->is_empty()) return;
 569   tty->print_cr("\tmonitor list:");
 570   for (int index = (list->length()-1); index >= 0; index--) {
 571     MonitorInfo* monitor = list->at(index);
 572     tty->print("\t  obj\t");
 573     if (monitor->owner_is_scalar_replaced()) {
 574       Klass* k = java_lang_Class::as_Klass(monitor->owner_klass());
 575       tty->print("( is scalar replaced %s)", k->external_name());
 576     } else if (monitor->owner() == NULL) {
 577       tty->print("( null )");
 578     } else {
 579       monitor->owner()->print_value();
 580       tty->print("(" INTPTR_FORMAT ")", (address)monitor->owner());
 581     }
 582     if (monitor->eliminated() && is_compiled_frame())
 583       tty->print(" ( lock is eliminated )");



 584     tty->cr();
 585     tty->print("\t  ");
 586     monitor->lock()->print_on(tty);
 587     tty->cr();
 588   }
 589 }
 590 
 591 
 592 void javaVFrame::print_value() const {
 593   Method*    m = method();
 594   InstanceKlass*     k = m->method_holder();
 595   tty->print_cr("frame( sp=" INTPTR_FORMAT ", unextended_sp=" INTPTR_FORMAT ", fp=" INTPTR_FORMAT ", pc=" INTPTR_FORMAT ")",
 596                 _fr.sp(),  _fr.unextended_sp(), _fr.fp(), _fr.pc());
 597   tty->print("%s.%s", k->internal_name(), m->name()->as_C_string());
 598 
 599   if (!m->is_native()) {
 600     Symbol*  source_name = k->source_file_name();
 601     int        line_number = m->line_number_from_bci(bci());
 602     if (source_name != NULL && (line_number != -1)) {
 603       tty->print("(%s:%d)", source_name->as_C_string(), line_number);


   1 /*
   2  * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 172           print_locked_object_class_name(st, o, "waiting on");
 173         }
 174       }
 175     } else if (thread()->current_park_blocker() != NULL) {
 176       oop obj = thread()->current_park_blocker();
 177       Klass* k = obj->klass();
 178       st->print_cr("\t- %s <" INTPTR_FORMAT "> (a %s)", "parking to wait for ", (address)obj, k->external_name());
 179     }
 180   }
 181 
 182 
 183   // Print out all monitors that we have locked or are trying to lock
 184   GrowableArray<MonitorInfo*>* mons = monitors();
 185   if (!mons->is_empty()) {
 186     bool found_first_monitor = false;
 187     for (int index = (mons->length()-1); index >= 0; index--) {
 188       MonitorInfo* monitor = mons->at(index);
 189       if (monitor->eliminated() && is_compiled_frame()) { // Eliminated in compiled code
 190         if (monitor->owner_is_scalar_replaced()) {
 191           Klass* k = java_lang_Class::as_Klass(monitor->owner_klass());
 192           // format below for lockbits matches this one.
 193           st->print("\t- eliminated <owner is scalar replaced> (a %s)", k->external_name());
 194         } else {
 195           oop obj = monitor->owner();
 196           if (obj != NULL) {
 197             print_locked_object_class_name(st, obj, "eliminated");
 198           }
 199         }
 200         continue;
 201       }
 202       if (monitor->owner() != NULL) {
 203         // the monitor is associated with an object, i.e., it is locked
 204 
 205         // First, assume we have the monitor locked. If we haven't found an
 206         // owned monitor before and this is the first frame, then we need to
 207         // see if we have completed the lock or we are blocked trying to
 208         // acquire it - we can only be blocked if the monitor is inflated
 209 
 210         markOop mark = NULL;
 211         const char *lock_state = "locked"; // assume we have the monitor locked
 212         if (!found_first_monitor && frame_count == 0) {
 213           mark = monitor->owner()->mark();
 214           if (mark->has_monitor() &&
 215               ( // we have marked ourself as pending on this monitor
 216                 mark->monitor() == thread()->current_pending_monitor() ||
 217                 // we are not the owner of this monitor
 218                 !mark->monitor()->is_entered(thread())
 219               )) {
 220             lock_state = "waiting to lock";
 221           } else {
 222             mark = NULL; // Disable printing below
 223           }
 224         }
 225         print_locked_object_class_name(st, monitor->owner(), lock_state);
 226         if (Verbose && mark != NULL) {
 227           // match with format above, replacing "-" with " ".
 228           st->print("\t  lockbits=");
 229           mark->print_on(st);
 230           st->cr();
 231         }
 232 
 233         found_first_monitor = true;

 234       }
 235     }
 236   }
 237 }
 238 
 239 // ------------- interpretedVFrame --------------
 240 
 241 u_char* interpretedVFrame::bcp() const {
 242   return fr().interpreter_frame_bcp();
 243 }
 244 
 245 void interpretedVFrame::set_bcp(u_char* bcp) {
 246   fr().interpreter_frame_set_bcp(bcp);
 247 }
 248 
 249 intptr_t* interpretedVFrame::locals_addr_at(int offset) const {
 250   assert(fr().is_interpreted_frame(), "frame should be an interpreted frame");
 251   return fr().interpreter_frame_local_at(offset);
 252 }
 253 


 570   method()->print_value();
 571   tty->cr();
 572   tty->print_cr("\tbci:    %d", bci());
 573 
 574   print_stack_values("locals",      locals());
 575   print_stack_values("expressions", expressions());
 576 
 577   GrowableArray<MonitorInfo*>* list = monitors();
 578   if (list->is_empty()) return;
 579   tty->print_cr("\tmonitor list:");
 580   for (int index = (list->length()-1); index >= 0; index--) {
 581     MonitorInfo* monitor = list->at(index);
 582     tty->print("\t  obj\t");
 583     if (monitor->owner_is_scalar_replaced()) {
 584       Klass* k = java_lang_Class::as_Klass(monitor->owner_klass());
 585       tty->print("( is scalar replaced %s)", k->external_name());
 586     } else if (monitor->owner() == NULL) {
 587       tty->print("( null )");
 588     } else {
 589       monitor->owner()->print_value();
 590       tty->print("(owner=" INTPTR_FORMAT ")", (address)monitor->owner());
 591     }
 592     if (monitor->eliminated())
 593         if(is_compiled_frame())
 594             tty->print(" ( lock is eliminated in compiled frame )");
 595         else
 596             tty->print(" ( lock is eliminated, frame not compiled )");
 597     tty->cr();
 598     tty->print("\t  ");
 599     monitor->lock()->print_on(tty);
 600     tty->cr();
 601   }
 602 }
 603 
 604 
 605 void javaVFrame::print_value() const {
 606   Method*    m = method();
 607   InstanceKlass*     k = m->method_holder();
 608   tty->print_cr("frame( sp=" INTPTR_FORMAT ", unextended_sp=" INTPTR_FORMAT ", fp=" INTPTR_FORMAT ", pc=" INTPTR_FORMAT ")",
 609                 _fr.sp(),  _fr.unextended_sp(), _fr.fp(), _fr.pc());
 610   tty->print("%s.%s", k->internal_name(), m->name()->as_C_string());
 611 
 612   if (!m->is_native()) {
 613     Symbol*  source_name = k->source_file_name();
 614     int        line_number = m->line_number_from_bci(bci());
 615     if (source_name != NULL && (line_number != -1)) {
 616       tty->print("(%s:%d)", source_name->as_C_string(), line_number);


< prev index next >