1 /*
   2  * Copyright (c) 1997, 2017, 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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/javaClasses.hpp"
  27 #include "classfile/systemDictionary.hpp"
  28 #include "classfile/vmSymbols.hpp"
  29 #include "code/codeCache.hpp"
  30 #include "code/debugInfoRec.hpp"
  31 #include "code/nmethod.hpp"
  32 #include "code/pcDesc.hpp"
  33 #include "code/scopeDesc.hpp"
  34 #include "interpreter/interpreter.hpp"
  35 #include "interpreter/oopMapCache.hpp"
  36 #include "memory/resourceArea.hpp"
  37 #include "oops/instanceKlass.hpp"
  38 #include "oops/oop.inline.hpp"
  39 #include "runtime/handles.inline.hpp"
  40 #include "runtime/objectMonitor.hpp"
  41 #include "runtime/objectMonitor.inline.hpp"
  42 #include "runtime/signature.hpp"
  43 #include "runtime/stubRoutines.hpp"
  44 #include "runtime/synchronizer.hpp"
  45 #include "runtime/vframe.hpp"
  46 #include "runtime/vframeArray.hpp"
  47 #include "runtime/vframe_hp.hpp"
  48 
  49 vframe::vframe(const frame* fr, const RegisterMap* reg_map, JavaThread* thread)
  50 : _reg_map(reg_map), _thread(thread) {
  51   assert(fr != NULL, "must have frame");
  52   _fr = *fr;
  53 }
  54 
  55 vframe::vframe(const frame* fr, JavaThread* thread)
  56 : _reg_map(thread), _thread(thread) {
  57   assert(fr != NULL, "must have frame");
  58   _fr = *fr;
  59 }
  60 
  61 vframe* vframe::new_vframe(const frame* f, const RegisterMap* reg_map, JavaThread* thread) {
  62   // Interpreter frame
  63   if (f->is_interpreted_frame()) {
  64     return new interpretedVFrame(f, reg_map, thread);
  65   }
  66 
  67   // Compiled frame
  68   CodeBlob* cb = f->cb();
  69   if (cb != NULL) {
  70     if (cb->is_compiled()) {
  71       CompiledMethod* nm = (CompiledMethod*)cb;
  72       return new compiledVFrame(f, reg_map, thread, nm);
  73     }
  74 
  75     if (f->is_runtime_frame()) {
  76       // Skip this frame and try again.
  77       RegisterMap temp_map = *reg_map;
  78       frame s = f->sender(&temp_map);
  79       return new_vframe(&s, &temp_map, thread);
  80     }
  81   }
  82 
  83   // External frame
  84   return new externalVFrame(f, reg_map, thread);
  85 }
  86 
  87 vframe* vframe::sender() const {
  88   RegisterMap temp_map = *register_map();
  89   assert(is_top(), "just checking");
  90   if (_fr.is_entry_frame() && _fr.is_first_frame()) return NULL;
  91   frame s = _fr.real_sender(&temp_map);
  92   if (s.is_first_frame()) return NULL;
  93   return vframe::new_vframe(&s, &temp_map, thread());
  94 }
  95 
  96 vframe* vframe::top() const {
  97   vframe* vf = (vframe*) this;
  98   while (!vf->is_top()) vf = vf->sender();
  99   return vf;
 100 }
 101 
 102 
 103 javaVFrame* vframe::java_sender() const {
 104   vframe* f = sender();
 105   while (f != NULL) {
 106     if (f->is_java_frame()) return javaVFrame::cast(f);
 107     f = f->sender();
 108   }
 109   return NULL;
 110 }
 111 
 112 // ------------- javaVFrame --------------
 113 
 114 GrowableArray<MonitorInfo*>* javaVFrame::locked_monitors() {
 115   assert(SafepointSynchronize::is_at_safepoint() || JavaThread::current() == thread(),
 116          "must be at safepoint or it's a java frame of the current thread");
 117 
 118   GrowableArray<MonitorInfo*>* mons = monitors();
 119   GrowableArray<MonitorInfo*>* result = new GrowableArray<MonitorInfo*>(mons->length());
 120   if (mons->is_empty()) return result;
 121 
 122   bool found_first_monitor = false;
 123   ObjectMonitor *pending_monitor = thread()->current_pending_monitor();
 124   ObjectMonitor *waiting_monitor = thread()->current_waiting_monitor();
 125   oop pending_obj = (pending_monitor != NULL ? (oop) pending_monitor->object() : (oop) NULL);
 126   oop waiting_obj = (waiting_monitor != NULL ? (oop) waiting_monitor->object() : (oop) NULL);
 127 
 128   for (int index = (mons->length()-1); index >= 0; index--) {
 129     MonitorInfo* monitor = mons->at(index);
 130     if (monitor->eliminated() && is_compiled_frame()) continue; // skip eliminated monitor
 131     oop obj = monitor->owner();
 132     if (obj == NULL) continue; // skip unowned monitor
 133     //
 134     // Skip the monitor that the thread is blocked to enter or waiting on
 135     //
 136     if (!found_first_monitor && (obj == pending_obj || obj == waiting_obj)) {
 137       continue;
 138     }
 139     found_first_monitor = true;
 140     result->append(monitor);
 141   }
 142   return result;
 143 }
 144 
 145 void javaVFrame::print_locked_object_class_name(outputStream* st, Handle obj, const char* lock_state) {
 146   if (obj.not_null()) {
 147     st->print("\t- %s <" INTPTR_FORMAT "> ", lock_state, p2i(obj()));
 148     if (obj->klass() == SystemDictionary::Class_klass()) {
 149       st->print_cr("(a java.lang.Class for %s)", java_lang_Class::as_external_name(obj()));
 150     } else {
 151       Klass* k = obj->klass();
 152       st->print_cr("(a %s)", k->external_name());
 153     }
 154   }
 155 }
 156 
 157 void javaVFrame::print_lock_info_on(outputStream* st, int frame_count) {
 158   Thread* THREAD = Thread::current();
 159   ResourceMark rm(THREAD);
 160 
 161   // If this is the first frame and it is java.lang.Object.wait(...)
 162   // then print out the receiver. Locals are not always available,
 163   // e.g., compiled native frames have no scope so there are no locals.
 164   if (frame_count == 0) {
 165     if (method()->name() == vmSymbols::wait_name() &&
 166         method()->method_holder()->name() == vmSymbols::java_lang_Object()) {
 167       const char *wait_state = "waiting on"; // assume we are waiting
 168       // If earlier in the output we reported java.lang.Thread.State ==
 169       // "WAITING (on object monitor)" and now we report "waiting on", then
 170       // we are still waiting for notification or timeout. Otherwise if
 171       // we earlier reported java.lang.Thread.State == "BLOCKED (on object
 172       // monitor)", then we are actually waiting to re-lock the monitor.
 173       // At this level we can't distinguish the two cases to report
 174       // "waited on" rather than "waiting on" for the second case.
 175       StackValueCollection* locs = locals();
 176       if (!locs->is_empty()) {
 177         StackValue* sv = locs->at(0);
 178         if (sv->type() == T_OBJECT) {
 179           Handle o = locs->at(0)->get_obj();
 180           print_locked_object_class_name(st, o, wait_state);
 181         }
 182       } else {
 183         st->print_cr("\t- %s <no object reference available>", wait_state);
 184       }
 185     } else if (thread()->current_park_blocker() != NULL) {
 186       oop obj = thread()->current_park_blocker();
 187       Klass* k = obj->klass();
 188       st->print_cr("\t- %s <" INTPTR_FORMAT "> (a %s)", "parking to wait for ", p2i(obj), k->external_name());
 189     }
 190   }
 191 
 192   // Print out all monitors that we have locked, or are trying to lock,
 193   // including re-locking after being notified or timing out in a wait().
 194   GrowableArray<MonitorInfo*>* mons = monitors();
 195   if (!mons->is_empty()) {
 196     bool found_first_monitor = false;
 197     for (int index = (mons->length()-1); index >= 0; index--) {
 198       MonitorInfo* monitor = mons->at(index);
 199       if (monitor->eliminated() && is_compiled_frame()) { // Eliminated in compiled code
 200         if (monitor->owner_is_scalar_replaced()) {
 201           Klass* k = java_lang_Class::as_Klass(monitor->owner_klass());
 202           // format below for lockbits matches this one.
 203           st->print("\t- eliminated <owner is scalar replaced> (a %s)", k->external_name());
 204         } else {
 205           Handle obj(THREAD, monitor->owner());
 206           if (obj() != NULL) {
 207             print_locked_object_class_name(st, obj, "eliminated");
 208           }
 209         }
 210         continue;
 211       }
 212       if (monitor->owner() != NULL) {
 213         // the monitor is associated with an object, i.e., it is locked
 214 
 215         markOop mark = NULL;
 216         const char *lock_state = "locked"; // assume we have the monitor locked
 217         if (!found_first_monitor && frame_count == 0) {
 218           // If this is the first frame and we haven't found an owned
 219           // monitor before, then we need to see if we have completed
 220           // the lock or if we are blocked trying to acquire it. Only
 221           // an inflated monitor that is first on the monitor list in
 222           // the first frame can block us on a monitor enter.
 223           mark = monitor->owner()->mark();
 224           if (mark->has_monitor() &&
 225               ( // we have marked ourself as pending on this monitor
 226                 mark->monitor() == thread()->current_pending_monitor() ||
 227                 // we are not the owner of this monitor
 228                 !mark->monitor()->is_entered(thread())
 229               )) {
 230             lock_state = "waiting to lock";
 231           } else {
 232             // We own the monitor which is not as interesting so
 233             // disable the extra printing below.
 234             mark = NULL;
 235           }
 236         } else if (frame_count != 0) {
 237           // This is not the first frame so we either own this monitor
 238           // or we owned the monitor before and called wait(). Because
 239           // wait() could have been called on any monitor in a lower
 240           // numbered frame on the stack, we have to check all the
 241           // monitors on the list for this frame.
 242           mark = monitor->owner()->mark();
 243           if (mark->has_monitor() &&
 244               ( // we have marked ourself as pending on this monitor
 245                 mark->monitor() == thread()->current_pending_monitor() ||
 246                 // we are not the owner of this monitor
 247                 !mark->monitor()->is_entered(thread())
 248               )) {
 249             lock_state = "waiting to re-lock in wait()";
 250           } else {
 251             // We own the monitor which is not as interesting so
 252             // disable the extra printing below.
 253             mark = NULL;
 254           }
 255         }
 256         print_locked_object_class_name(st, Handle(THREAD, monitor->owner()), lock_state);
 257         if (ObjectMonitor::Knob_Verbose && mark != NULL) {
 258           st->print("\t- lockbits=");
 259           mark->print_on(st);
 260           st->cr();
 261         }
 262 
 263         found_first_monitor = true;
 264       }
 265     }
 266   }
 267 }
 268 
 269 // ------------- interpretedVFrame --------------
 270 
 271 u_char* interpretedVFrame::bcp() const {
 272   return fr().interpreter_frame_bcp();
 273 }
 274 
 275 void interpretedVFrame::set_bcp(u_char* bcp) {
 276   fr().interpreter_frame_set_bcp(bcp);
 277 }
 278 
 279 intptr_t* interpretedVFrame::locals_addr_at(int offset) const {
 280   assert(fr().is_interpreted_frame(), "frame should be an interpreted frame");
 281   return fr().interpreter_frame_local_at(offset);
 282 }
 283 
 284 
 285 GrowableArray<MonitorInfo*>* interpretedVFrame::monitors() const {
 286   GrowableArray<MonitorInfo*>* result = new GrowableArray<MonitorInfo*>(5);
 287   for (BasicObjectLock* current = (fr().previous_monitor_in_interpreter_frame(fr().interpreter_frame_monitor_begin()));
 288        current >= fr().interpreter_frame_monitor_end();
 289        current = fr().previous_monitor_in_interpreter_frame(current)) {
 290     result->push(new MonitorInfo(current->obj(), current->lock(), false, false));
 291   }
 292   return result;
 293 }
 294 
 295 int interpretedVFrame::bci() const {
 296   return method()->bci_from(bcp());
 297 }
 298 
 299 Method* interpretedVFrame::method() const {
 300   return fr().interpreter_frame_method();
 301 }
 302 
 303 static StackValue* create_stack_value_from_oop_map(const InterpreterOopMap& oop_mask,
 304                                                    int index,
 305                                                    const intptr_t* const addr) {
 306 
 307   assert(index >= 0 &&
 308          index < oop_mask.number_of_entries(), "invariant");
 309 
 310   // categorize using oop_mask
 311   if (oop_mask.is_oop(index)) {
 312     // reference (oop) "r"
 313     Handle h(Thread::current(), addr != NULL ? (*(oop*)addr) : (oop)NULL);
 314     return new StackValue(h);
 315   }
 316   // value (integer) "v"
 317   return new StackValue(addr != NULL ? *addr : 0);
 318 }
 319 
 320 static bool is_in_expression_stack(const frame& fr, const intptr_t* const addr) {
 321   assert(addr != NULL, "invariant");
 322 
 323   // Ensure to be 'inside' the expresion stack (i.e., addr >= sp for Intel).
 324   // In case of exceptions, the expression stack is invalid and the sp
 325   // will be reset to express this condition.
 326   if (frame::interpreter_frame_expression_stack_direction() > 0) {
 327     return addr <= fr.interpreter_frame_tos_address();
 328   }
 329 
 330   return addr >= fr.interpreter_frame_tos_address();
 331 }
 332 
 333 static void stack_locals(StackValueCollection* result,
 334                          int length,
 335                          const InterpreterOopMap& oop_mask,
 336                          const frame& fr) {
 337 
 338   assert(result != NULL, "invariant");
 339 
 340   for (int i = 0; i < length; ++i) {
 341     const intptr_t* const addr = fr.interpreter_frame_local_at(i);
 342     assert(addr != NULL, "invariant");
 343     assert(addr >= fr.sp(), "must be inside the frame");
 344 
 345     StackValue* const sv = create_stack_value_from_oop_map(oop_mask, i, addr);
 346     assert(sv != NULL, "sanity check");
 347 
 348     result->add(sv);
 349   }
 350 }
 351 
 352 static void stack_expressions(StackValueCollection* result,
 353                               int length,
 354                               int max_locals,
 355                               const InterpreterOopMap& oop_mask,
 356                               const frame& fr) {
 357 
 358   assert(result != NULL, "invariant");
 359 
 360   for (int i = 0; i < length; ++i) {
 361     const intptr_t* addr = fr.interpreter_frame_expression_stack_at(i);
 362     assert(addr != NULL, "invariant");
 363     if (!is_in_expression_stack(fr, addr)) {
 364       // Need to ensure no bogus escapes.
 365       addr = NULL;
 366     }
 367 
 368     StackValue* const sv = create_stack_value_from_oop_map(oop_mask,
 369                                                            i + max_locals,
 370                                                            addr);
 371     assert(sv != NULL, "sanity check");
 372 
 373     result->add(sv);
 374   }
 375 }
 376 
 377 StackValueCollection* interpretedVFrame::locals() const {
 378   return stack_data(false);
 379 }
 380 
 381 StackValueCollection* interpretedVFrame::expressions() const {
 382   return stack_data(true);
 383 }
 384 
 385 /*
 386  * Worker routine for fetching references and/or values
 387  * for a particular bci in the interpretedVFrame.
 388  *
 389  * Returns data for either "locals" or "expressions",
 390  * using bci relative oop_map (oop_mask) information.
 391  *
 392  * @param expressions  bool switch controlling what data to return
 393                        (false == locals / true == expression)
 394  *
 395  */
 396 StackValueCollection* interpretedVFrame::stack_data(bool expressions) const {
 397 
 398   InterpreterOopMap oop_mask;
 399   // oopmap for current bci
 400   if ((TraceDeoptimization && Verbose) JVMCI_ONLY( || PrintDeoptimizationDetails)) {
 401     methodHandle m_h(Thread::current(), method());
 402     OopMapCache::compute_one_oop_map(m_h, bci(), &oop_mask);
 403   } else {
 404     method()->mask_for(bci(), &oop_mask);
 405   }
 406 
 407   const int mask_len = oop_mask.number_of_entries();
 408 
 409   // If the method is native, method()->max_locals() is not telling the truth.
 410   // For our purposes, max locals instead equals the size of parameters.
 411   const int max_locals = method()->is_native() ?
 412     method()->size_of_parameters() : method()->max_locals();
 413 
 414   assert(mask_len >= max_locals, "invariant");
 415 
 416   const int length = expressions ? mask_len - max_locals : max_locals;
 417   assert(length >= 0, "invariant");
 418 
 419   StackValueCollection* const result = new StackValueCollection(length);
 420 
 421   if (0 == length) {
 422     return result;
 423   }
 424 
 425   if (expressions) {
 426     stack_expressions(result, length, max_locals, oop_mask, fr());
 427   } else {
 428     stack_locals(result, length, oop_mask, fr());
 429   }
 430 
 431   assert(length == result->size(), "invariant");
 432 
 433   return result;
 434 }
 435 
 436 void interpretedVFrame::set_locals(StackValueCollection* values) const {
 437   if (values == NULL || values->size() == 0) return;
 438 
 439   // If the method is native, max_locals is not telling the truth.
 440   // maxlocals then equals the size of parameters
 441   const int max_locals = method()->is_native() ?
 442     method()->size_of_parameters() : method()->max_locals();
 443 
 444   assert(max_locals == values->size(), "Mismatch between actual stack format and supplied data");
 445 
 446   // handle locals
 447   for (int i = 0; i < max_locals; i++) {
 448     // Find stack location
 449     intptr_t *addr = locals_addr_at(i);
 450 
 451     // Depending on oop/int put it in the right package
 452     const StackValue* const sv = values->at(i);
 453     assert(sv != NULL, "sanity check");
 454     if (sv->type() == T_OBJECT) {
 455       *(oop *) addr = (sv->get_obj())();
 456     } else {                   // integer
 457       *addr = sv->get_int();
 458     }
 459   }
 460 }
 461 
 462 // ------------- cChunk --------------
 463 
 464 entryVFrame::entryVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread)
 465 : externalVFrame(fr, reg_map, thread) {}
 466 
 467 #ifdef ASSERT
 468 void vframeStreamCommon::found_bad_method_frame() const {
 469   // 6379830 Cut point for an assertion that occasionally fires when
 470   // we are using the performance analyzer.
 471   // Disable this assert when testing the analyzer with fastdebug.
 472   // -XX:SuppressErrorAt=vframe.cpp:XXX (XXX=following line number)
 473   fatal("invalid bci or invalid scope desc");
 474 }
 475 #endif
 476 
 477 // top-frame will be skipped
 478 vframeStream::vframeStream(JavaThread* thread, frame top_frame,
 479   bool stop_at_java_call_stub) : vframeStreamCommon(thread) {
 480   _stop_at_java_call_stub = stop_at_java_call_stub;
 481 
 482   // skip top frame, as it may not be at safepoint
 483   _frame  = top_frame.sender(&_reg_map);
 484   while (!fill_from_frame()) {
 485     _frame = _frame.sender(&_reg_map);
 486   }
 487 }
 488 
 489 
 490 // Step back n frames, skip any pseudo frames in between.
 491 // This function is used in Class.forName, Class.newInstance, Method.Invoke,
 492 // AccessController.doPrivileged.
 493 void vframeStreamCommon::security_get_caller_frame(int depth) {
 494   assert(depth >= 0, "invalid depth: %d", depth);
 495   for (int n = 0; !at_end(); security_next()) {
 496     if (!method()->is_ignored_by_security_stack_walk()) {
 497       if (n == depth) {
 498         // We have reached the desired depth; return.
 499         return;
 500       }
 501       n++;  // this is a non-skipped frame; count it against the depth
 502     }
 503   }
 504   // NOTE: At this point there were not enough frames on the stack
 505   // to walk to depth.  Callers of this method have to check for at_end.
 506 }
 507 
 508 
 509 void vframeStreamCommon::security_next() {
 510   if (method()->is_prefixed_native()) {
 511     skip_prefixed_method_and_wrappers();  // calls next()
 512   } else {
 513     next();
 514   }
 515 }
 516 
 517 
 518 void vframeStreamCommon::skip_prefixed_method_and_wrappers() {
 519   ResourceMark rm;
 520   HandleMark hm;
 521 
 522   int    method_prefix_count = 0;
 523   char** method_prefixes = JvmtiExport::get_all_native_method_prefixes(&method_prefix_count);
 524   Klass* prefixed_klass = method()->method_holder();
 525   const char* prefixed_name = method()->name()->as_C_string();
 526   size_t prefixed_name_len = strlen(prefixed_name);
 527   int prefix_index = method_prefix_count-1;
 528 
 529   while (!at_end()) {
 530     next();
 531     if (method()->method_holder() != prefixed_klass) {
 532       break; // classes don't match, can't be a wrapper
 533     }
 534     const char* name = method()->name()->as_C_string();
 535     size_t name_len = strlen(name);
 536     size_t prefix_len = prefixed_name_len - name_len;
 537     if (prefix_len <= 0 || strcmp(name, prefixed_name + prefix_len) != 0) {
 538       break; // prefixed name isn't prefixed version of method name, can't be a wrapper
 539     }
 540     for (; prefix_index >= 0; --prefix_index) {
 541       const char* possible_prefix = method_prefixes[prefix_index];
 542       size_t possible_prefix_len = strlen(possible_prefix);
 543       if (possible_prefix_len == prefix_len &&
 544           strncmp(possible_prefix, prefixed_name, prefix_len) == 0) {
 545         break; // matching prefix found
 546       }
 547     }
 548     if (prefix_index < 0) {
 549       break; // didn't find the prefix, can't be a wrapper
 550     }
 551     prefixed_name = name;
 552     prefixed_name_len = name_len;
 553   }
 554 }
 555 
 556 
 557 void vframeStreamCommon::skip_reflection_related_frames() {
 558   while (!at_end() &&
 559           (method()->method_holder()->is_subclass_of(SystemDictionary::reflect_MethodAccessorImpl_klass()) ||
 560            method()->method_holder()->is_subclass_of(SystemDictionary::reflect_ConstructorAccessorImpl_klass()))) {
 561     next();
 562   }
 563 }
 564 
 565 
 566 #ifndef PRODUCT
 567 void vframe::print() {
 568   if (WizardMode) _fr.print_value_on(tty,NULL);
 569 }
 570 
 571 
 572 void vframe::print_value() const {
 573   ((vframe*)this)->print();
 574 }
 575 
 576 
 577 void entryVFrame::print_value() const {
 578   ((entryVFrame*)this)->print();
 579 }
 580 
 581 void entryVFrame::print() {
 582   vframe::print();
 583   tty->print_cr("C Chunk inbetween Java");
 584   tty->print_cr("C     link " INTPTR_FORMAT, p2i(_fr.link()));
 585 }
 586 
 587 
 588 // ------------- javaVFrame --------------
 589 
 590 static void print_stack_values(const char* title, StackValueCollection* values) {
 591   if (values->is_empty()) return;
 592   tty->print_cr("\t%s:", title);
 593   values->print();
 594 }
 595 
 596 
 597 void javaVFrame::print() {
 598   ResourceMark rm;
 599   vframe::print();
 600   tty->print("\t");
 601   method()->print_value();
 602   tty->cr();
 603   tty->print_cr("\tbci:    %d", bci());
 604 
 605   print_stack_values("locals",      locals());
 606   print_stack_values("expressions", expressions());
 607 
 608   GrowableArray<MonitorInfo*>* list = monitors();
 609   if (list->is_empty()) return;
 610   tty->print_cr("\tmonitor list:");
 611   for (int index = (list->length()-1); index >= 0; index--) {
 612     MonitorInfo* monitor = list->at(index);
 613     tty->print("\t  obj\t");
 614     if (monitor->owner_is_scalar_replaced()) {
 615       Klass* k = java_lang_Class::as_Klass(monitor->owner_klass());
 616       tty->print("( is scalar replaced %s)", k->external_name());
 617     } else if (monitor->owner() == NULL) {
 618       tty->print("( null )");
 619     } else {
 620       monitor->owner()->print_value();
 621       tty->print("(owner=" INTPTR_FORMAT ")", p2i(monitor->owner()));
 622     }
 623     if (monitor->eliminated()) {
 624       if(is_compiled_frame()) {
 625         tty->print(" ( lock is eliminated in compiled frame )");
 626       } else {
 627         tty->print(" ( lock is eliminated, frame not compiled )");
 628       }
 629     }
 630     tty->cr();
 631     tty->print("\t  ");
 632     monitor->lock()->print_on(tty);
 633     tty->cr();
 634   }
 635 }
 636 
 637 
 638 void javaVFrame::print_value() const {
 639   Method*    m = method();
 640   InstanceKlass*     k = m->method_holder();
 641   tty->print_cr("frame( sp=" INTPTR_FORMAT ", unextended_sp=" INTPTR_FORMAT ", fp=" INTPTR_FORMAT ", pc=" INTPTR_FORMAT ")",
 642                 p2i(_fr.sp()),  p2i(_fr.unextended_sp()), p2i(_fr.fp()), p2i(_fr.pc()));
 643   tty->print("%s.%s", k->internal_name(), m->name()->as_C_string());
 644 
 645   if (!m->is_native()) {
 646     Symbol*  source_name = k->source_file_name();
 647     int        line_number = m->line_number_from_bci(bci());
 648     if (source_name != NULL && (line_number != -1)) {
 649       tty->print("(%s:%d)", source_name->as_C_string(), line_number);
 650     }
 651   } else {
 652     tty->print("(Native Method)");
 653   }
 654   // Check frame size and print warning if it looks suspiciously large
 655   if (fr().sp() != NULL) {
 656     RegisterMap map = *register_map();
 657     uint size = fr().frame_size(&map);
 658 #ifdef _LP64
 659     if (size > 8*K) warning("SUSPICIOUSLY LARGE FRAME (%d)", size);
 660 #else
 661     if (size > 4*K) warning("SUSPICIOUSLY LARGE FRAME (%d)", size);
 662 #endif
 663   }
 664 }
 665 
 666 
 667 bool javaVFrame::structural_compare(javaVFrame* other) {
 668   // Check static part
 669   if (method() != other->method()) return false;
 670   if (bci()    != other->bci())    return false;
 671 
 672   // Check locals
 673   StackValueCollection *locs = locals();
 674   StackValueCollection *other_locs = other->locals();
 675   assert(locs->size() == other_locs->size(), "sanity check");
 676   int i;
 677   for(i = 0; i < locs->size(); i++) {
 678     // it might happen the compiler reports a conflict and
 679     // the interpreter reports a bogus int.
 680     if (       is_compiled_frame() &&       locs->at(i)->type() == T_CONFLICT) continue;
 681     if (other->is_compiled_frame() && other_locs->at(i)->type() == T_CONFLICT) continue;
 682 
 683     if (!locs->at(i)->equal(other_locs->at(i)))
 684       return false;
 685   }
 686 
 687   // Check expressions
 688   StackValueCollection* exprs = expressions();
 689   StackValueCollection* other_exprs = other->expressions();
 690   assert(exprs->size() == other_exprs->size(), "sanity check");
 691   for(i = 0; i < exprs->size(); i++) {
 692     if (!exprs->at(i)->equal(other_exprs->at(i)))
 693       return false;
 694   }
 695 
 696   return true;
 697 }
 698 
 699 
 700 void javaVFrame::print_activation(int index) const {
 701   // frame number and method
 702   tty->print("%2d - ", index);
 703   ((vframe*)this)->print_value();
 704   tty->cr();
 705 
 706   if (WizardMode) {
 707     ((vframe*)this)->print();
 708     tty->cr();
 709   }
 710 }
 711 
 712 
 713 void javaVFrame::verify() const {
 714 }
 715 
 716 
 717 void interpretedVFrame::verify() const {
 718 }
 719 
 720 
 721 // ------------- externalVFrame --------------
 722 
 723 void externalVFrame::print() {
 724   _fr.print_value_on(tty,NULL);
 725 }
 726 
 727 
 728 void externalVFrame::print_value() const {
 729   ((vframe*)this)->print();
 730 }
 731 #endif // PRODUCT