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