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 method()->mask_for(bci(), &oop_mask); 400 const int mask_len = oop_mask.number_of_entries(); 401 402 // If the method is native, method()->max_locals() is not telling the truth. 403 // For our purposes, max locals instead equals the size of parameters. 404 const int max_locals = method()->is_native() ? 405 method()->size_of_parameters() : method()->max_locals(); 406 407 assert(mask_len >= max_locals, "invariant"); 408 409 const int length = expressions ? mask_len - max_locals : max_locals; 410 assert(length >= 0, "invariant"); 411 412 StackValueCollection* const result = new StackValueCollection(length); 413 414 if (0 == length) { 415 return result; 416 } 417 418 if (expressions) { 419 stack_expressions(result, length, max_locals, oop_mask, fr()); 420 } else { 421 stack_locals(result, length, oop_mask, fr()); 422 } 423 424 assert(length == result->size(), "invariant"); 425 426 return result; 427 } 428 429 void interpretedVFrame::set_locals(StackValueCollection* values) const { 430 if (values == NULL || values->size() == 0) return; 431 432 // If the method is native, max_locals is not telling the truth. 433 // maxlocals then equals the size of parameters 434 const int max_locals = method()->is_native() ? 435 method()->size_of_parameters() : method()->max_locals(); 436 437 assert(max_locals == values->size(), "Mismatch between actual stack format and supplied data"); 438 439 // handle locals 440 for (int i = 0; i < max_locals; i++) { 441 // Find stack location 442 intptr_t *addr = locals_addr_at(i); 443 444 // Depending on oop/int put it in the right package 445 const StackValue* const sv = values->at(i); 446 assert(sv != NULL, "sanity check"); 447 if (sv->type() == T_OBJECT) { 448 *(oop *) addr = (sv->get_obj())(); 449 } else { // integer 450 *addr = sv->get_int(); 451 } 452 } 453 } 454 455 // ------------- cChunk -------------- 456 457 entryVFrame::entryVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread) 458 : externalVFrame(fr, reg_map, thread) {} 459 460 #ifdef ASSERT 461 void vframeStreamCommon::found_bad_method_frame() const { 462 // 6379830 Cut point for an assertion that occasionally fires when 463 // we are using the performance analyzer. 464 // Disable this assert when testing the analyzer with fastdebug. 465 // -XX:SuppressErrorAt=vframe.cpp:XXX (XXX=following line number) 466 fatal("invalid bci or invalid scope desc"); 467 } 468 #endif 469 470 // top-frame will be skipped 471 vframeStream::vframeStream(JavaThread* thread, frame top_frame, 472 bool stop_at_java_call_stub) : vframeStreamCommon(thread) { 473 _stop_at_java_call_stub = stop_at_java_call_stub; 474 475 // skip top frame, as it may not be at safepoint 476 _frame = top_frame.sender(&_reg_map); 477 while (!fill_from_frame()) { 478 _frame = _frame.sender(&_reg_map); 479 } 480 } 481 482 483 // Step back n frames, skip any pseudo frames in between. 484 // This function is used in Class.forName, Class.newInstance, Method.Invoke, 485 // AccessController.doPrivileged. 486 void vframeStreamCommon::security_get_caller_frame(int depth) { 487 assert(depth >= 0, "invalid depth: %d", depth); 488 for (int n = 0; !at_end(); security_next()) { 489 if (!method()->is_ignored_by_security_stack_walk()) { 490 if (n == depth) { 491 // We have reached the desired depth; return. 492 return; 493 } 494 n++; // this is a non-skipped frame; count it against the depth 495 } 496 } 497 // NOTE: At this point there were not enough frames on the stack 498 // to walk to depth. Callers of this method have to check for at_end. 499 } 500 501 502 void vframeStreamCommon::security_next() { 503 if (method()->is_prefixed_native()) { 504 skip_prefixed_method_and_wrappers(); // calls next() 505 } else { 506 next(); 507 } 508 } 509 510 511 void vframeStreamCommon::skip_prefixed_method_and_wrappers() { 512 ResourceMark rm; 513 HandleMark hm; 514 515 int method_prefix_count = 0; 516 char** method_prefixes = JvmtiExport::get_all_native_method_prefixes(&method_prefix_count); 517 Klass* prefixed_klass = method()->method_holder(); 518 const char* prefixed_name = method()->name()->as_C_string(); 519 size_t prefixed_name_len = strlen(prefixed_name); 520 int prefix_index = method_prefix_count-1; 521 522 while (!at_end()) { 523 next(); 524 if (method()->method_holder() != prefixed_klass) { 525 break; // classes don't match, can't be a wrapper 526 } 527 const char* name = method()->name()->as_C_string(); 528 size_t name_len = strlen(name); 529 size_t prefix_len = prefixed_name_len - name_len; 530 if (prefix_len <= 0 || strcmp(name, prefixed_name + prefix_len) != 0) { 531 break; // prefixed name isn't prefixed version of method name, can't be a wrapper 532 } 533 for (; prefix_index >= 0; --prefix_index) { 534 const char* possible_prefix = method_prefixes[prefix_index]; 535 size_t possible_prefix_len = strlen(possible_prefix); 536 if (possible_prefix_len == prefix_len && 537 strncmp(possible_prefix, prefixed_name, prefix_len) == 0) { 538 break; // matching prefix found 539 } 540 } 541 if (prefix_index < 0) { 542 break; // didn't find the prefix, can't be a wrapper 543 } 544 prefixed_name = name; 545 prefixed_name_len = name_len; 546 } 547 } 548 549 550 void vframeStreamCommon::skip_reflection_related_frames() { 551 while (!at_end() && 552 (method()->method_holder()->is_subclass_of(SystemDictionary::reflect_MethodAccessorImpl_klass()) || 553 method()->method_holder()->is_subclass_of(SystemDictionary::reflect_ConstructorAccessorImpl_klass()))) { 554 next(); 555 } 556 } 557 558 559 #ifndef PRODUCT 560 void vframe::print() { 561 if (WizardMode) _fr.print_value_on(tty,NULL); 562 } 563 564 565 void vframe::print_value() const { 566 ((vframe*)this)->print(); 567 } 568 569 570 void entryVFrame::print_value() const { 571 ((entryVFrame*)this)->print(); 572 } 573 574 void entryVFrame::print() { 575 vframe::print(); 576 tty->print_cr("C Chunk inbetween Java"); 577 tty->print_cr("C link " INTPTR_FORMAT, p2i(_fr.link())); 578 } 579 580 581 // ------------- javaVFrame -------------- 582 583 static void print_stack_values(const char* title, StackValueCollection* values) { 584 if (values->is_empty()) return; 585 tty->print_cr("\t%s:", title); 586 values->print(); 587 } 588 589 590 void javaVFrame::print() { 591 ResourceMark rm; 592 vframe::print(); 593 tty->print("\t"); 594 method()->print_value(); 595 tty->cr(); 596 tty->print_cr("\tbci: %d", bci()); 597 598 print_stack_values("locals", locals()); 599 print_stack_values("expressions", expressions()); 600 601 GrowableArray<MonitorInfo*>* list = monitors(); 602 if (list->is_empty()) return; 603 tty->print_cr("\tmonitor list:"); 604 for (int index = (list->length()-1); index >= 0; index--) { 605 MonitorInfo* monitor = list->at(index); 606 tty->print("\t obj\t"); 607 if (monitor->owner_is_scalar_replaced()) { 608 Klass* k = java_lang_Class::as_Klass(monitor->owner_klass()); 609 tty->print("( is scalar replaced %s)", k->external_name()); 610 } else if (monitor->owner() == NULL) { 611 tty->print("( null )"); 612 } else { 613 monitor->owner()->print_value(); 614 tty->print("(owner=" INTPTR_FORMAT ")", p2i(monitor->owner())); 615 } 616 if (monitor->eliminated()) { 617 if(is_compiled_frame()) { 618 tty->print(" ( lock is eliminated in compiled frame )"); 619 } else { 620 tty->print(" ( lock is eliminated, frame not compiled )"); 621 } 622 } 623 tty->cr(); 624 tty->print("\t "); 625 monitor->lock()->print_on(tty); 626 tty->cr(); 627 } 628 } 629 630 631 void javaVFrame::print_value() const { 632 Method* m = method(); 633 InstanceKlass* k = m->method_holder(); 634 tty->print_cr("frame( sp=" INTPTR_FORMAT ", unextended_sp=" INTPTR_FORMAT ", fp=" INTPTR_FORMAT ", pc=" INTPTR_FORMAT ")", 635 p2i(_fr.sp()), p2i(_fr.unextended_sp()), p2i(_fr.fp()), p2i(_fr.pc())); 636 tty->print("%s.%s", k->internal_name(), m->name()->as_C_string()); 637 638 if (!m->is_native()) { 639 Symbol* source_name = k->source_file_name(); 640 int line_number = m->line_number_from_bci(bci()); 641 if (source_name != NULL && (line_number != -1)) { 642 tty->print("(%s:%d)", source_name->as_C_string(), line_number); 643 } 644 } else { 645 tty->print("(Native Method)"); 646 } 647 // Check frame size and print warning if it looks suspiciously large 648 if (fr().sp() != NULL) { 649 RegisterMap map = *register_map(); 650 uint size = fr().frame_size(&map); 651 #ifdef _LP64 652 if (size > 8*K) warning("SUSPICIOUSLY LARGE FRAME (%d)", size); 653 #else 654 if (size > 4*K) warning("SUSPICIOUSLY LARGE FRAME (%d)", size); 655 #endif 656 } 657 } 658 659 660 bool javaVFrame::structural_compare(javaVFrame* other) { 661 // Check static part 662 if (method() != other->method()) return false; 663 if (bci() != other->bci()) return false; 664 665 // Check locals 666 StackValueCollection *locs = locals(); 667 StackValueCollection *other_locs = other->locals(); 668 assert(locs->size() == other_locs->size(), "sanity check"); 669 int i; 670 for(i = 0; i < locs->size(); i++) { 671 // it might happen the compiler reports a conflict and 672 // the interpreter reports a bogus int. 673 if ( is_compiled_frame() && locs->at(i)->type() == T_CONFLICT) continue; 674 if (other->is_compiled_frame() && other_locs->at(i)->type() == T_CONFLICT) continue; 675 676 if (!locs->at(i)->equal(other_locs->at(i))) 677 return false; 678 } 679 680 // Check expressions 681 StackValueCollection* exprs = expressions(); 682 StackValueCollection* other_exprs = other->expressions(); 683 assert(exprs->size() == other_exprs->size(), "sanity check"); 684 for(i = 0; i < exprs->size(); i++) { 685 if (!exprs->at(i)->equal(other_exprs->at(i))) 686 return false; 687 } 688 689 return true; 690 } 691 692 693 void javaVFrame::print_activation(int index) const { 694 // frame number and method 695 tty->print("%2d - ", index); 696 ((vframe*)this)->print_value(); 697 tty->cr(); 698 699 if (WizardMode) { 700 ((vframe*)this)->print(); 701 tty->cr(); 702 } 703 } 704 705 706 void javaVFrame::verify() const { 707 } 708 709 710 void interpretedVFrame::verify() const { 711 } 712 713 714 // ------------- externalVFrame -------------- 715 716 void externalVFrame::print() { 717 _fr.print_value_on(tty,NULL); 718 } 719 720 721 void externalVFrame::print_value() const { 722 ((vframe*)this)->print(); 723 } 724 #endif // PRODUCT