frame.cpp revision 2062:3582bf76420e
1/* 2 * Copyright (c) 1997, 2011, 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 "gc_interface/collectedHeap.inline.hpp" 27#include "interpreter/interpreter.hpp" 28#include "interpreter/oopMapCache.hpp" 29#include "memory/resourceArea.hpp" 30#include "memory/universe.inline.hpp" 31#include "oops/markOop.hpp" 32#include "oops/methodDataOop.hpp" 33#include "oops/methodOop.hpp" 34#include "oops/oop.inline.hpp" 35#include "oops/oop.inline2.hpp" 36#include "runtime/frame.inline.hpp" 37#include "runtime/handles.inline.hpp" 38#include "runtime/javaCalls.hpp" 39#include "runtime/monitorChunk.hpp" 40#include "runtime/sharedRuntime.hpp" 41#include "runtime/signature.hpp" 42#include "runtime/stubCodeGenerator.hpp" 43#include "runtime/stubRoutines.hpp" 44#include "utilities/decoder.hpp" 45 46#ifdef TARGET_ARCH_x86 47# include "nativeInst_x86.hpp" 48#endif 49#ifdef TARGET_ARCH_sparc 50# include "nativeInst_sparc.hpp" 51#endif 52#ifdef TARGET_ARCH_zero 53# include "nativeInst_zero.hpp" 54#endif 55 56RegisterMap::RegisterMap(JavaThread *thread, bool update_map) { 57 _thread = thread; 58 _update_map = update_map; 59 clear(); 60 debug_only(_update_for_id = NULL;) 61#ifndef PRODUCT 62 for (int i = 0; i < reg_count ; i++ ) _location[i] = NULL; 63#endif /* PRODUCT */ 64} 65 66RegisterMap::RegisterMap(const RegisterMap* map) { 67 assert(map != this, "bad initialization parameter"); 68 assert(map != NULL, "RegisterMap must be present"); 69 _thread = map->thread(); 70 _update_map = map->update_map(); 71 _include_argument_oops = map->include_argument_oops(); 72 debug_only(_update_for_id = map->_update_for_id;) 73 pd_initialize_from(map); 74 if (update_map()) { 75 for(int i = 0; i < location_valid_size; i++) { 76 LocationValidType bits = !update_map() ? 0 : map->_location_valid[i]; 77 _location_valid[i] = bits; 78 // for whichever bits are set, pull in the corresponding map->_location 79 int j = i*location_valid_type_size; 80 while (bits != 0) { 81 if ((bits & 1) != 0) { 82 assert(0 <= j && j < reg_count, "range check"); 83 _location[j] = map->_location[j]; 84 } 85 bits >>= 1; 86 j += 1; 87 } 88 } 89 } 90} 91 92void RegisterMap::clear() { 93 set_include_argument_oops(true); 94 if (_update_map) { 95 for(int i = 0; i < location_valid_size; i++) { 96 _location_valid[i] = 0; 97 } 98 pd_clear(); 99 } else { 100 pd_initialize(); 101 } 102} 103 104#ifndef PRODUCT 105 106void RegisterMap::print_on(outputStream* st) const { 107 st->print_cr("Register map"); 108 for(int i = 0; i < reg_count; i++) { 109 110 VMReg r = VMRegImpl::as_VMReg(i); 111 intptr_t* src = (intptr_t*) location(r); 112 if (src != NULL) { 113 114 r->print_on(st); 115 st->print(" [" INTPTR_FORMAT "] = ", src); 116 if (((uintptr_t)src & (sizeof(*src)-1)) != 0) { 117 st->print_cr("<misaligned>"); 118 } else { 119 st->print_cr(INTPTR_FORMAT, *src); 120 } 121 } 122 } 123} 124 125void RegisterMap::print() const { 126 print_on(tty); 127} 128 129#endif 130// This returns the pc that if you were in the debugger you'd see. Not 131// the idealized value in the frame object. This undoes the magic conversion 132// that happens for deoptimized frames. In addition it makes the value the 133// hardware would want to see in the native frame. The only user (at this point) 134// is deoptimization. It likely no one else should ever use it. 135 136address frame::raw_pc() const { 137 if (is_deoptimized_frame()) { 138 nmethod* nm = cb()->as_nmethod_or_null(); 139 if (nm->is_method_handle_return(pc())) 140 return nm->deopt_mh_handler_begin() - pc_return_offset; 141 else 142 return nm->deopt_handler_begin() - pc_return_offset; 143 } else { 144 return (pc() - pc_return_offset); 145 } 146} 147 148// Change the pc in a frame object. This does not change the actual pc in 149// actual frame. To do that use patch_pc. 150// 151void frame::set_pc(address newpc ) { 152#ifdef ASSERT 153 if (_cb != NULL && _cb->is_nmethod()) { 154 assert(!((nmethod*)_cb)->is_deopt_pc(_pc), "invariant violation"); 155 } 156#endif // ASSERT 157 158 // Unsafe to use the is_deoptimzed tester after changing pc 159 _deopt_state = unknown; 160 _pc = newpc; 161 _cb = CodeCache::find_blob_unsafe(_pc); 162 163} 164 165// type testers 166bool frame::is_deoptimized_frame() const { 167 assert(_deopt_state != unknown, "not answerable"); 168 return _deopt_state == is_deoptimized; 169} 170 171bool frame::is_native_frame() const { 172 return (_cb != NULL && 173 _cb->is_nmethod() && 174 ((nmethod*)_cb)->is_native_method()); 175} 176 177bool frame::is_java_frame() const { 178 if (is_interpreted_frame()) return true; 179 if (is_compiled_frame()) return true; 180 return false; 181} 182 183 184bool frame::is_compiled_frame() const { 185 if (_cb != NULL && 186 _cb->is_nmethod() && 187 ((nmethod*)_cb)->is_java_method()) { 188 return true; 189 } 190 return false; 191} 192 193 194bool frame::is_runtime_frame() const { 195 return (_cb != NULL && _cb->is_runtime_stub()); 196} 197 198bool frame::is_safepoint_blob_frame() const { 199 return (_cb != NULL && _cb->is_safepoint_stub()); 200} 201 202// testers 203 204bool frame::is_first_java_frame() const { 205 RegisterMap map(JavaThread::current(), false); // No update 206 frame s; 207 for (s = sender(&map); !(s.is_java_frame() || s.is_first_frame()); s = s.sender(&map)); 208 return s.is_first_frame(); 209} 210 211 212bool frame::entry_frame_is_first() const { 213 return entry_frame_call_wrapper()->anchor()->last_Java_sp() == NULL; 214} 215 216 217bool frame::should_be_deoptimized() const { 218 if (_deopt_state == is_deoptimized || 219 !is_compiled_frame() ) return false; 220 assert(_cb != NULL && _cb->is_nmethod(), "must be an nmethod"); 221 nmethod* nm = (nmethod *)_cb; 222 if (TraceDependencies) { 223 tty->print("checking (%s) ", nm->is_marked_for_deoptimization() ? "true" : "false"); 224 nm->print_value_on(tty); 225 tty->cr(); 226 } 227 228 if( !nm->is_marked_for_deoptimization() ) 229 return false; 230 231 // If at the return point, then the frame has already been popped, and 232 // only the return needs to be executed. Don't deoptimize here. 233 return !nm->is_at_poll_return(pc()); 234} 235 236bool frame::can_be_deoptimized() const { 237 if (!is_compiled_frame()) return false; 238 nmethod* nm = (nmethod*)_cb; 239 240 if( !nm->can_be_deoptimized() ) 241 return false; 242 243 return !nm->is_at_poll_return(pc()); 244} 245 246void frame::deoptimize(JavaThread* thread) { 247 // Schedule deoptimization of an nmethod activation with this frame. 248 assert(_cb != NULL && _cb->is_nmethod(), "must be"); 249 nmethod* nm = (nmethod*)_cb; 250 251 // This is a fix for register window patching race 252 if (NeedsDeoptSuspend && Thread::current() != thread) { 253 assert(SafepointSynchronize::is_at_safepoint(), 254 "patching other threads for deopt may only occur at a safepoint"); 255 256 // It is possible especially with DeoptimizeALot/DeoptimizeRandom that 257 // we could see the frame again and ask for it to be deoptimized since 258 // it might move for a long time. That is harmless and we just ignore it. 259 if (id() == thread->must_deopt_id()) { 260 assert(thread->is_deopt_suspend(), "lost suspension"); 261 return; 262 } 263 264 // We are at a safepoint so the target thread can only be 265 // in 4 states: 266 // blocked - no problem 267 // blocked_trans - no problem (i.e. could have woken up from blocked 268 // during a safepoint). 269 // native - register window pc patching race 270 // native_trans - momentary state 271 // 272 // We could just wait out a thread in native_trans to block. 273 // Then we'd have all the issues that the safepoint code has as to 274 // whether to spin or block. It isn't worth it. Just treat it like 275 // native and be done with it. 276 // 277 // Examine the state of the thread at the start of safepoint since 278 // threads that were in native at the start of the safepoint could 279 // come to a halt during the safepoint, changing the current value 280 // of the safepoint_state. 281 JavaThreadState state = thread->safepoint_state()->orig_thread_state(); 282 if (state == _thread_in_native || state == _thread_in_native_trans) { 283 // Since we are at a safepoint the target thread will stop itself 284 // before it can return to java as long as we remain at the safepoint. 285 // Therefore we can put an additional request for the thread to stop 286 // no matter what no (like a suspend). This will cause the thread 287 // to notice it needs to do the deopt on its own once it leaves native. 288 // 289 // The only reason we must do this is because on machine with register 290 // windows we have a race with patching the return address and the 291 // window coming live as the thread returns to the Java code (but still 292 // in native mode) and then blocks. It is only this top most frame 293 // that is at risk. So in truth we could add an additional check to 294 // see if this frame is one that is at risk. 295 RegisterMap map(thread, false); 296 frame at_risk = thread->last_frame().sender(&map); 297 if (id() == at_risk.id()) { 298 thread->set_must_deopt_id(id()); 299 thread->set_deopt_suspend(); 300 return; 301 } 302 } 303 } // NeedsDeoptSuspend 304 305 306 // If the call site is a MethodHandle call site use the MH deopt 307 // handler. 308 address deopt = nm->is_method_handle_return(pc()) ? 309 nm->deopt_mh_handler_begin() : 310 nm->deopt_handler_begin(); 311 312 // Save the original pc before we patch in the new one 313 nm->set_original_pc(this, pc()); 314 patch_pc(thread, deopt); 315 316#ifdef ASSERT 317 { 318 RegisterMap map(thread, false); 319 frame check = thread->last_frame(); 320 while (id() != check.id()) { 321 check = check.sender(&map); 322 } 323 assert(check.is_deoptimized_frame(), "missed deopt"); 324 } 325#endif // ASSERT 326} 327 328frame frame::java_sender() const { 329 RegisterMap map(JavaThread::current(), false); 330 frame s; 331 for (s = sender(&map); !(s.is_java_frame() || s.is_first_frame()); s = s.sender(&map)) ; 332 guarantee(s.is_java_frame(), "tried to get caller of first java frame"); 333 return s; 334} 335 336frame frame::real_sender(RegisterMap* map) const { 337 frame result = sender(map); 338 while (result.is_runtime_frame()) { 339 result = result.sender(map); 340 } 341 return result; 342} 343 344// Note: called by profiler - NOT for current thread 345frame frame::profile_find_Java_sender_frame(JavaThread *thread) { 346// If we don't recognize this frame, walk back up the stack until we do 347 RegisterMap map(thread, false); 348 frame first_java_frame = frame(); 349 350 // Find the first Java frame on the stack starting with input frame 351 if (is_java_frame()) { 352 // top frame is compiled frame or deoptimized frame 353 first_java_frame = *this; 354 } else if (safe_for_sender(thread)) { 355 for (frame sender_frame = sender(&map); 356 sender_frame.safe_for_sender(thread) && !sender_frame.is_first_frame(); 357 sender_frame = sender_frame.sender(&map)) { 358 if (sender_frame.is_java_frame()) { 359 first_java_frame = sender_frame; 360 break; 361 } 362 } 363 } 364 return first_java_frame; 365} 366 367// Interpreter frames 368 369 370void frame::interpreter_frame_set_locals(intptr_t* locs) { 371 assert(is_interpreted_frame(), "Not an interpreted frame"); 372 *interpreter_frame_locals_addr() = locs; 373} 374 375methodOop frame::interpreter_frame_method() const { 376 assert(is_interpreted_frame(), "interpreted frame expected"); 377 methodOop m = *interpreter_frame_method_addr(); 378 assert(m->is_perm(), "bad methodOop in interpreter frame"); 379 assert(m->is_method(), "not a methodOop"); 380 return m; 381} 382 383void frame::interpreter_frame_set_method(methodOop method) { 384 assert(is_interpreted_frame(), "interpreted frame expected"); 385 *interpreter_frame_method_addr() = method; 386} 387 388void frame::interpreter_frame_set_bcx(intptr_t bcx) { 389 assert(is_interpreted_frame(), "Not an interpreted frame"); 390 if (ProfileInterpreter) { 391 bool formerly_bci = is_bci(interpreter_frame_bcx()); 392 bool is_now_bci = is_bci(bcx); 393 *interpreter_frame_bcx_addr() = bcx; 394 395 intptr_t mdx = interpreter_frame_mdx(); 396 397 if (mdx != 0) { 398 if (formerly_bci) { 399 if (!is_now_bci) { 400 // The bcx was just converted from bci to bcp. 401 // Convert the mdx in parallel. 402 methodDataOop mdo = interpreter_frame_method()->method_data(); 403 assert(mdo != NULL, ""); 404 int mdi = mdx - 1; // We distinguish valid mdi from zero by adding one. 405 address mdp = mdo->di_to_dp(mdi); 406 interpreter_frame_set_mdx((intptr_t)mdp); 407 } 408 } else { 409 if (is_now_bci) { 410 // The bcx was just converted from bcp to bci. 411 // Convert the mdx in parallel. 412 methodDataOop mdo = interpreter_frame_method()->method_data(); 413 assert(mdo != NULL, ""); 414 int mdi = mdo->dp_to_di((address)mdx); 415 interpreter_frame_set_mdx((intptr_t)mdi + 1); // distinguish valid from 0. 416 } 417 } 418 } 419 } else { 420 *interpreter_frame_bcx_addr() = bcx; 421 } 422} 423 424jint frame::interpreter_frame_bci() const { 425 assert(is_interpreted_frame(), "interpreted frame expected"); 426 intptr_t bcx = interpreter_frame_bcx(); 427 return is_bci(bcx) ? bcx : interpreter_frame_method()->bci_from((address)bcx); 428} 429 430void frame::interpreter_frame_set_bci(jint bci) { 431 assert(is_interpreted_frame(), "interpreted frame expected"); 432 assert(!is_bci(interpreter_frame_bcx()), "should not set bci during GC"); 433 interpreter_frame_set_bcx((intptr_t)interpreter_frame_method()->bcp_from(bci)); 434} 435 436address frame::interpreter_frame_bcp() const { 437 assert(is_interpreted_frame(), "interpreted frame expected"); 438 intptr_t bcx = interpreter_frame_bcx(); 439 return is_bci(bcx) ? interpreter_frame_method()->bcp_from(bcx) : (address)bcx; 440} 441 442void frame::interpreter_frame_set_bcp(address bcp) { 443 assert(is_interpreted_frame(), "interpreted frame expected"); 444 assert(!is_bci(interpreter_frame_bcx()), "should not set bcp during GC"); 445 interpreter_frame_set_bcx((intptr_t)bcp); 446} 447 448void frame::interpreter_frame_set_mdx(intptr_t mdx) { 449 assert(is_interpreted_frame(), "Not an interpreted frame"); 450 assert(ProfileInterpreter, "must be profiling interpreter"); 451 *interpreter_frame_mdx_addr() = mdx; 452} 453 454address frame::interpreter_frame_mdp() const { 455 assert(ProfileInterpreter, "must be profiling interpreter"); 456 assert(is_interpreted_frame(), "interpreted frame expected"); 457 intptr_t bcx = interpreter_frame_bcx(); 458 intptr_t mdx = interpreter_frame_mdx(); 459 460 assert(!is_bci(bcx), "should not access mdp during GC"); 461 return (address)mdx; 462} 463 464void frame::interpreter_frame_set_mdp(address mdp) { 465 assert(is_interpreted_frame(), "interpreted frame expected"); 466 if (mdp == NULL) { 467 // Always allow the mdp to be cleared. 468 interpreter_frame_set_mdx((intptr_t)mdp); 469 } 470 intptr_t bcx = interpreter_frame_bcx(); 471 assert(!is_bci(bcx), "should not set mdp during GC"); 472 interpreter_frame_set_mdx((intptr_t)mdp); 473} 474 475BasicObjectLock* frame::next_monitor_in_interpreter_frame(BasicObjectLock* current) const { 476 assert(is_interpreted_frame(), "Not an interpreted frame"); 477#ifdef ASSERT 478 interpreter_frame_verify_monitor(current); 479#endif 480 BasicObjectLock* next = (BasicObjectLock*) (((intptr_t*) current) + interpreter_frame_monitor_size()); 481 return next; 482} 483 484BasicObjectLock* frame::previous_monitor_in_interpreter_frame(BasicObjectLock* current) const { 485 assert(is_interpreted_frame(), "Not an interpreted frame"); 486#ifdef ASSERT 487// // This verification needs to be checked before being enabled 488// interpreter_frame_verify_monitor(current); 489#endif 490 BasicObjectLock* previous = (BasicObjectLock*) (((intptr_t*) current) - interpreter_frame_monitor_size()); 491 return previous; 492} 493 494// Interpreter locals and expression stack locations. 495 496intptr_t* frame::interpreter_frame_local_at(int index) const { 497 const int n = Interpreter::local_offset_in_bytes(index)/wordSize; 498 return &((*interpreter_frame_locals_addr())[n]); 499} 500 501intptr_t* frame::interpreter_frame_expression_stack_at(jint offset) const { 502 const int i = offset * interpreter_frame_expression_stack_direction(); 503 const int n = i * Interpreter::stackElementWords; 504 return &(interpreter_frame_expression_stack()[n]); 505} 506 507jint frame::interpreter_frame_expression_stack_size() const { 508 // Number of elements on the interpreter expression stack 509 // Callers should span by stackElementWords 510 int element_size = Interpreter::stackElementWords; 511 if (frame::interpreter_frame_expression_stack_direction() < 0) { 512 return (interpreter_frame_expression_stack() - 513 interpreter_frame_tos_address() + 1)/element_size; 514 } else { 515 return (interpreter_frame_tos_address() - 516 interpreter_frame_expression_stack() + 1)/element_size; 517 } 518} 519 520 521// (frame::interpreter_frame_sender_sp accessor is in frame_<arch>.cpp) 522 523const char* frame::print_name() const { 524 if (is_native_frame()) return "Native"; 525 if (is_interpreted_frame()) return "Interpreted"; 526 if (is_compiled_frame()) { 527 if (is_deoptimized_frame()) return "Deoptimized"; 528 return "Compiled"; 529 } 530 if (sp() == NULL) return "Empty"; 531 return "C"; 532} 533 534void frame::print_value_on(outputStream* st, JavaThread *thread) const { 535 NOT_PRODUCT(address begin = pc()-40;) 536 NOT_PRODUCT(address end = NULL;) 537 538 st->print("%s frame (sp=" INTPTR_FORMAT " unextended sp=" INTPTR_FORMAT, print_name(), sp(), unextended_sp()); 539 if (sp() != NULL) 540 st->print(", fp=" INTPTR_FORMAT ", pc=" INTPTR_FORMAT, fp(), pc()); 541 542 if (StubRoutines::contains(pc())) { 543 st->print_cr(")"); 544 st->print("("); 545 StubCodeDesc* desc = StubCodeDesc::desc_for(pc()); 546 st->print("~Stub::%s", desc->name()); 547 NOT_PRODUCT(begin = desc->begin(); end = desc->end();) 548 } else if (Interpreter::contains(pc())) { 549 st->print_cr(")"); 550 st->print("("); 551 InterpreterCodelet* desc = Interpreter::codelet_containing(pc()); 552 if (desc != NULL) { 553 st->print("~"); 554 desc->print(); 555 NOT_PRODUCT(begin = desc->code_begin(); end = desc->code_end();) 556 } else { 557 st->print("~interpreter"); 558 } 559 } 560 st->print_cr(")"); 561 562 if (_cb != NULL) { 563 st->print(" "); 564 _cb->print_value_on(st); 565 st->cr(); 566#ifndef PRODUCT 567 if (end == NULL) { 568 begin = _cb->code_begin(); 569 end = _cb->code_end(); 570 } 571#endif 572 } 573 NOT_PRODUCT(if (WizardMode && Verbose) Disassembler::decode(begin, end);) 574} 575 576 577void frame::print_on(outputStream* st) const { 578 print_value_on(st,NULL); 579 if (is_interpreted_frame()) { 580 interpreter_frame_print_on(st); 581 } 582} 583 584 585void frame::interpreter_frame_print_on(outputStream* st) const { 586#ifndef PRODUCT 587 assert(is_interpreted_frame(), "Not an interpreted frame"); 588 jint i; 589 for (i = 0; i < interpreter_frame_method()->max_locals(); i++ ) { 590 intptr_t x = *interpreter_frame_local_at(i); 591 st->print(" - local [" INTPTR_FORMAT "]", x); 592 st->fill_to(23); 593 st->print_cr("; #%d", i); 594 } 595 for (i = interpreter_frame_expression_stack_size() - 1; i >= 0; --i ) { 596 intptr_t x = *interpreter_frame_expression_stack_at(i); 597 st->print(" - stack [" INTPTR_FORMAT "]", x); 598 st->fill_to(23); 599 st->print_cr("; #%d", i); 600 } 601 // locks for synchronization 602 for (BasicObjectLock* current = interpreter_frame_monitor_end(); 603 current < interpreter_frame_monitor_begin(); 604 current = next_monitor_in_interpreter_frame(current)) { 605 st->print(" - obj ["); 606 current->obj()->print_value_on(st); 607 st->print_cr("]"); 608 st->print(" - lock ["); 609 current->lock()->print_on(st); 610 st->print_cr("]"); 611 } 612 // monitor 613 st->print_cr(" - monitor[" INTPTR_FORMAT "]", interpreter_frame_monitor_begin()); 614 // bcp 615 st->print(" - bcp [" INTPTR_FORMAT "]", interpreter_frame_bcp()); 616 st->fill_to(23); 617 st->print_cr("; @%d", interpreter_frame_bci()); 618 // locals 619 st->print_cr(" - locals [" INTPTR_FORMAT "]", interpreter_frame_local_at(0)); 620 // method 621 st->print(" - method [" INTPTR_FORMAT "]", (address)interpreter_frame_method()); 622 st->fill_to(23); 623 st->print("; "); 624 interpreter_frame_method()->print_name(st); 625 st->cr(); 626#endif 627} 628 629// Return whether the frame is in the VM or os indicating a Hotspot problem. 630// Otherwise, it's likely a bug in the native library that the Java code calls, 631// hopefully indicating where to submit bugs. 632static void print_C_frame(outputStream* st, char* buf, int buflen, address pc) { 633 // C/C++ frame 634 bool in_vm = os::address_is_in_vm(pc); 635 st->print(in_vm ? "V" : "C"); 636 637 int offset; 638 bool found; 639 640 // libname 641 found = os::dll_address_to_library_name(pc, buf, buflen, &offset); 642 if (found) { 643 // skip directory names 644 const char *p1, *p2; 645 p1 = buf; 646 int len = (int)strlen(os::file_separator()); 647 while ((p2 = strstr(p1, os::file_separator())) != NULL) p1 = p2 + len; 648 st->print(" [%s+0x%x]", p1, offset); 649 } else { 650 st->print(" " PTR_FORMAT, pc); 651 } 652 653 // function name - os::dll_address_to_function_name() may return confusing 654 // names if pc is within jvm.dll or libjvm.so, because JVM only has 655 // JVM_xxxx and a few other symbols in the dynamic symbol table. Do this 656 // only for native libraries. 657 if (!in_vm || Decoder::can_decode_C_frame_in_vm()) { 658 found = os::dll_address_to_function_name(pc, buf, buflen, &offset); 659 660 if (found) { 661 st->print(" %s+0x%x", buf, offset); 662 } 663 } 664} 665 666// frame::print_on_error() is called by fatal error handler. Notice that we may 667// crash inside this function if stack frame is corrupted. The fatal error 668// handler can catch and handle the crash. Here we assume the frame is valid. 669// 670// First letter indicates type of the frame: 671// J: Java frame (compiled) 672// j: Java frame (interpreted) 673// V: VM frame (C/C++) 674// v: Other frames running VM generated code (e.g. stubs, adapters, etc.) 675// C: C/C++ frame 676// 677// We don't need detailed frame type as that in frame::print_name(). "C" 678// suggests the problem is in user lib; everything else is likely a VM bug. 679 680void frame::print_on_error(outputStream* st, char* buf, int buflen, bool verbose) const { 681 if (_cb != NULL) { 682 if (Interpreter::contains(pc())) { 683 methodOop m = this->interpreter_frame_method(); 684 if (m != NULL) { 685 m->name_and_sig_as_C_string(buf, buflen); 686 st->print("j %s", buf); 687 st->print("+%d", this->interpreter_frame_bci()); 688 } else { 689 st->print("j " PTR_FORMAT, pc()); 690 } 691 } else if (StubRoutines::contains(pc())) { 692 StubCodeDesc* desc = StubCodeDesc::desc_for(pc()); 693 if (desc != NULL) { 694 st->print("v ~StubRoutines::%s", desc->name()); 695 } else { 696 st->print("v ~StubRoutines::" PTR_FORMAT, pc()); 697 } 698 } else if (_cb->is_buffer_blob()) { 699 st->print("v ~BufferBlob::%s", ((BufferBlob *)_cb)->name()); 700 } else if (_cb->is_nmethod()) { 701 methodOop m = ((nmethod *)_cb)->method(); 702 if (m != NULL) { 703 m->name_and_sig_as_C_string(buf, buflen); 704 st->print("J %s", buf); 705 } else { 706 st->print("J " PTR_FORMAT, pc()); 707 } 708 } else if (_cb->is_runtime_stub()) { 709 st->print("v ~RuntimeStub::%s", ((RuntimeStub *)_cb)->name()); 710 } else if (_cb->is_deoptimization_stub()) { 711 st->print("v ~DeoptimizationBlob"); 712 } else if (_cb->is_exception_stub()) { 713 st->print("v ~ExceptionBlob"); 714 } else if (_cb->is_safepoint_stub()) { 715 st->print("v ~SafepointBlob"); 716 } else { 717 st->print("v blob " PTR_FORMAT, pc()); 718 } 719 } else { 720 print_C_frame(st, buf, buflen, pc()); 721 } 722} 723 724 725/* 726 The interpreter_frame_expression_stack_at method in the case of SPARC needs the 727 max_stack value of the method in order to compute the expression stack address. 728 It uses the methodOop in order to get the max_stack value but during GC this 729 methodOop value saved on the frame is changed by reverse_and_push and hence cannot 730 be used. So we save the max_stack value in the FrameClosure object and pass it 731 down to the interpreter_frame_expression_stack_at method 732*/ 733class InterpreterFrameClosure : public OffsetClosure { 734 private: 735 frame* _fr; 736 OopClosure* _f; 737 int _max_locals; 738 int _max_stack; 739 740 public: 741 InterpreterFrameClosure(frame* fr, int max_locals, int max_stack, 742 OopClosure* f) { 743 _fr = fr; 744 _max_locals = max_locals; 745 _max_stack = max_stack; 746 _f = f; 747 } 748 749 void offset_do(int offset) { 750 oop* addr; 751 if (offset < _max_locals) { 752 addr = (oop*) _fr->interpreter_frame_local_at(offset); 753 assert((intptr_t*)addr >= _fr->sp(), "must be inside the frame"); 754 _f->do_oop(addr); 755 } else { 756 addr = (oop*) _fr->interpreter_frame_expression_stack_at((offset - _max_locals)); 757 // In case of exceptions, the expression stack is invalid and the esp will be reset to express 758 // this condition. Therefore, we call f only if addr is 'inside' the stack (i.e., addr >= esp for Intel). 759 bool in_stack; 760 if (frame::interpreter_frame_expression_stack_direction() > 0) { 761 in_stack = (intptr_t*)addr <= _fr->interpreter_frame_tos_address(); 762 } else { 763 in_stack = (intptr_t*)addr >= _fr->interpreter_frame_tos_address(); 764 } 765 if (in_stack) { 766 _f->do_oop(addr); 767 } 768 } 769 } 770 771 int max_locals() { return _max_locals; } 772 frame* fr() { return _fr; } 773}; 774 775 776class InterpretedArgumentOopFinder: public SignatureInfo { 777 private: 778 OopClosure* _f; // Closure to invoke 779 int _offset; // TOS-relative offset, decremented with each argument 780 bool _has_receiver; // true if the callee has a receiver 781 frame* _fr; 782 783 void set(int size, BasicType type) { 784 _offset -= size; 785 if (type == T_OBJECT || type == T_ARRAY) oop_offset_do(); 786 } 787 788 void oop_offset_do() { 789 oop* addr; 790 addr = (oop*)_fr->interpreter_frame_tos_at(_offset); 791 _f->do_oop(addr); 792 } 793 794 public: 795 InterpretedArgumentOopFinder(Symbol* signature, bool has_receiver, frame* fr, OopClosure* f) : SignatureInfo(signature), _has_receiver(has_receiver) { 796 // compute size of arguments 797 int args_size = ArgumentSizeComputer(signature).size() + (has_receiver ? 1 : 0); 798 assert(!fr->is_interpreted_frame() || 799 args_size <= fr->interpreter_frame_expression_stack_size(), 800 "args cannot be on stack anymore"); 801 // initialize InterpretedArgumentOopFinder 802 _f = f; 803 _fr = fr; 804 _offset = args_size; 805 } 806 807 void oops_do() { 808 if (_has_receiver) { 809 --_offset; 810 oop_offset_do(); 811 } 812 iterate_parameters(); 813 } 814}; 815 816 817// Entry frame has following form (n arguments) 818// +-----------+ 819// sp -> | last arg | 820// +-----------+ 821// : ::: : 822// +-----------+ 823// (sp+n)->| first arg| 824// +-----------+ 825 826 827 828// visits and GC's all the arguments in entry frame 829class EntryFrameOopFinder: public SignatureInfo { 830 private: 831 bool _is_static; 832 int _offset; 833 frame* _fr; 834 OopClosure* _f; 835 836 void set(int size, BasicType type) { 837 assert (_offset >= 0, "illegal offset"); 838 if (type == T_OBJECT || type == T_ARRAY) oop_at_offset_do(_offset); 839 _offset -= size; 840 } 841 842 void oop_at_offset_do(int offset) { 843 assert (offset >= 0, "illegal offset"); 844 oop* addr = (oop*) _fr->entry_frame_argument_at(offset); 845 _f->do_oop(addr); 846 } 847 848 public: 849 EntryFrameOopFinder(frame* frame, Symbol* signature, bool is_static) : SignatureInfo(signature) { 850 _f = NULL; // will be set later 851 _fr = frame; 852 _is_static = is_static; 853 _offset = ArgumentSizeComputer(signature).size() - 1; // last parameter is at index 0 854 } 855 856 void arguments_do(OopClosure* f) { 857 _f = f; 858 if (!_is_static) oop_at_offset_do(_offset+1); // do the receiver 859 iterate_parameters(); 860 } 861 862}; 863 864oop* frame::interpreter_callee_receiver_addr(Symbol* signature) { 865 ArgumentSizeComputer asc(signature); 866 int size = asc.size(); 867 return (oop *)interpreter_frame_tos_at(size); 868} 869 870 871void frame::oops_interpreted_do(OopClosure* f, const RegisterMap* map, bool query_oop_map_cache) { 872 assert(is_interpreted_frame(), "Not an interpreted frame"); 873 assert(map != NULL, "map must be set"); 874 Thread *thread = Thread::current(); 875 methodHandle m (thread, interpreter_frame_method()); 876 jint bci = interpreter_frame_bci(); 877 878 assert(Universe::heap()->is_in(m()), "must be valid oop"); 879 assert(m->is_method(), "checking frame value"); 880 assert((m->is_native() && bci == 0) || (!m->is_native() && bci >= 0 && bci < m->code_size()), "invalid bci value"); 881 882 // Handle the monitor elements in the activation 883 for ( 884 BasicObjectLock* current = interpreter_frame_monitor_end(); 885 current < interpreter_frame_monitor_begin(); 886 current = next_monitor_in_interpreter_frame(current) 887 ) { 888#ifdef ASSERT 889 interpreter_frame_verify_monitor(current); 890#endif 891 current->oops_do(f); 892 } 893 894 // process fixed part 895 f->do_oop((oop*)interpreter_frame_method_addr()); 896 f->do_oop((oop*)interpreter_frame_cache_addr()); 897 898 // Hmm what about the mdp? 899#ifdef CC_INTERP 900 // Interpreter frame in the midst of a call have a methodOop within the 901 // object. 902 interpreterState istate = get_interpreterState(); 903 if (istate->msg() == BytecodeInterpreter::call_method) { 904 f->do_oop((oop*)&istate->_result._to_call._callee); 905 } 906 907#endif /* CC_INTERP */ 908 909#if !defined(PPC) || defined(ZERO) 910 if (m->is_native()) { 911#ifdef CC_INTERP 912 f->do_oop((oop*)&istate->_oop_temp); 913#else 914 f->do_oop((oop*)( fp() + interpreter_frame_oop_temp_offset )); 915#endif /* CC_INTERP */ 916 } 917#else // PPC 918 if (m->is_native() && m->is_static()) { 919 f->do_oop(interpreter_frame_mirror_addr()); 920 } 921#endif // PPC 922 923 int max_locals = m->is_native() ? m->size_of_parameters() : m->max_locals(); 924 925 Symbol* signature = NULL; 926 bool has_receiver = false; 927 928 // Process a callee's arguments if we are at a call site 929 // (i.e., if we are at an invoke bytecode) 930 // This is used sometimes for calling into the VM, not for another 931 // interpreted or compiled frame. 932 if (!m->is_native()) { 933 Bytecode_invoke call = Bytecode_invoke_check(m, bci); 934 if (call.is_valid()) { 935 signature = call.signature(); 936 has_receiver = call.has_receiver(); 937 if (map->include_argument_oops() && 938 interpreter_frame_expression_stack_size() > 0) { 939 ResourceMark rm(thread); // is this right ??? 940 // we are at a call site & the expression stack is not empty 941 // => process callee's arguments 942 // 943 // Note: The expression stack can be empty if an exception 944 // occurred during method resolution/execution. In all 945 // cases we empty the expression stack completely be- 946 // fore handling the exception (the exception handling 947 // code in the interpreter calls a blocking runtime 948 // routine which can cause this code to be executed). 949 // (was bug gri 7/27/98) 950 oops_interpreted_arguments_do(signature, has_receiver, f); 951 } 952 } 953 } 954 955 InterpreterFrameClosure blk(this, max_locals, m->max_stack(), f); 956 957 // process locals & expression stack 958 InterpreterOopMap mask; 959 if (query_oop_map_cache) { 960 m->mask_for(bci, &mask); 961 } else { 962 OopMapCache::compute_one_oop_map(m, bci, &mask); 963 } 964 mask.iterate_oop(&blk); 965} 966 967 968void frame::oops_interpreted_arguments_do(Symbol* signature, bool has_receiver, OopClosure* f) { 969 InterpretedArgumentOopFinder finder(signature, has_receiver, this, f); 970 finder.oops_do(); 971} 972 973void frame::oops_code_blob_do(OopClosure* f, CodeBlobClosure* cf, const RegisterMap* reg_map) { 974 assert(_cb != NULL, "sanity check"); 975 if (_cb->oop_maps() != NULL) { 976 OopMapSet::oops_do(this, reg_map, f); 977 978 // Preserve potential arguments for a callee. We handle this by dispatching 979 // on the codeblob. For c2i, we do 980 if (reg_map->include_argument_oops()) { 981 _cb->preserve_callee_argument_oops(*this, reg_map, f); 982 } 983 } 984 // In cases where perm gen is collected, GC will want to mark 985 // oops referenced from nmethods active on thread stacks so as to 986 // prevent them from being collected. However, this visit should be 987 // restricted to certain phases of the collection only. The 988 // closure decides how it wants nmethods to be traced. 989 if (cf != NULL) 990 cf->do_code_blob(_cb); 991} 992 993class CompiledArgumentOopFinder: public SignatureInfo { 994 protected: 995 OopClosure* _f; 996 int _offset; // the current offset, incremented with each argument 997 bool _has_receiver; // true if the callee has a receiver 998 frame _fr; 999 RegisterMap* _reg_map; 1000 int _arg_size; 1001 VMRegPair* _regs; // VMReg list of arguments 1002 1003 void set(int size, BasicType type) { 1004 if (type == T_OBJECT || type == T_ARRAY) handle_oop_offset(); 1005 _offset += size; 1006 } 1007 1008 virtual void handle_oop_offset() { 1009 // Extract low order register number from register array. 1010 // In LP64-land, the high-order bits are valid but unhelpful. 1011 VMReg reg = _regs[_offset].first(); 1012 oop *loc = _fr.oopmapreg_to_location(reg, _reg_map); 1013 _f->do_oop(loc); 1014 } 1015 1016 public: 1017 CompiledArgumentOopFinder(Symbol* signature, bool has_receiver, OopClosure* f, frame fr, const RegisterMap* reg_map) 1018 : SignatureInfo(signature) { 1019 1020 // initialize CompiledArgumentOopFinder 1021 _f = f; 1022 _offset = 0; 1023 _has_receiver = has_receiver; 1024 _fr = fr; 1025 _reg_map = (RegisterMap*)reg_map; 1026 _arg_size = ArgumentSizeComputer(signature).size() + (has_receiver ? 1 : 0); 1027 1028 int arg_size; 1029 _regs = SharedRuntime::find_callee_arguments(signature, has_receiver, &arg_size); 1030 assert(arg_size == _arg_size, "wrong arg size"); 1031 } 1032 1033 void oops_do() { 1034 if (_has_receiver) { 1035 handle_oop_offset(); 1036 _offset++; 1037 } 1038 iterate_parameters(); 1039 } 1040}; 1041 1042void frame::oops_compiled_arguments_do(Symbol* signature, bool has_receiver, const RegisterMap* reg_map, OopClosure* f) { 1043 ResourceMark rm; 1044 CompiledArgumentOopFinder finder(signature, has_receiver, f, *this, reg_map); 1045 finder.oops_do(); 1046} 1047 1048 1049// Get receiver out of callers frame, i.e. find parameter 0 in callers 1050// frame. Consult ADLC for where parameter 0 is to be found. Then 1051// check local reg_map for it being a callee-save register or argument 1052// register, both of which are saved in the local frame. If not found 1053// there, it must be an in-stack argument of the caller. 1054// Note: caller.sp() points to callee-arguments 1055oop frame::retrieve_receiver(RegisterMap* reg_map) { 1056 frame caller = *this; 1057 1058 // First consult the ADLC on where it puts parameter 0 for this signature. 1059 VMReg reg = SharedRuntime::name_for_receiver(); 1060 oop r = *caller.oopmapreg_to_location(reg, reg_map); 1061 assert( Universe::heap()->is_in_or_null(r), "bad receiver" ); 1062 return r; 1063} 1064 1065 1066oop* frame::oopmapreg_to_location(VMReg reg, const RegisterMap* reg_map) const { 1067 if(reg->is_reg()) { 1068 // If it is passed in a register, it got spilled in the stub frame. 1069 return (oop *)reg_map->location(reg); 1070 } else { 1071 int sp_offset_in_bytes = reg->reg2stack() * VMRegImpl::stack_slot_size; 1072 return (oop*)(((address)unextended_sp()) + sp_offset_in_bytes); 1073 } 1074} 1075 1076BasicLock* frame::get_native_monitor() { 1077 nmethod* nm = (nmethod*)_cb; 1078 assert(_cb != NULL && _cb->is_nmethod() && nm->method()->is_native(), 1079 "Should not call this unless it's a native nmethod"); 1080 int byte_offset = in_bytes(nm->native_basic_lock_sp_offset()); 1081 assert(byte_offset >= 0, "should not see invalid offset"); 1082 return (BasicLock*) &sp()[byte_offset / wordSize]; 1083} 1084 1085oop frame::get_native_receiver() { 1086 nmethod* nm = (nmethod*)_cb; 1087 assert(_cb != NULL && _cb->is_nmethod() && nm->method()->is_native(), 1088 "Should not call this unless it's a native nmethod"); 1089 int byte_offset = in_bytes(nm->native_receiver_sp_offset()); 1090 assert(byte_offset >= 0, "should not see invalid offset"); 1091 oop owner = ((oop*) sp())[byte_offset / wordSize]; 1092 assert( Universe::heap()->is_in(owner), "bad receiver" ); 1093 return owner; 1094} 1095 1096void frame::oops_entry_do(OopClosure* f, const RegisterMap* map) { 1097 assert(map != NULL, "map must be set"); 1098 if (map->include_argument_oops()) { 1099 // must collect argument oops, as nobody else is doing it 1100 Thread *thread = Thread::current(); 1101 methodHandle m (thread, entry_frame_call_wrapper()->callee_method()); 1102 EntryFrameOopFinder finder(this, m->signature(), m->is_static()); 1103 finder.arguments_do(f); 1104 } 1105 // Traverse the Handle Block saved in the entry frame 1106 entry_frame_call_wrapper()->oops_do(f); 1107} 1108 1109 1110void frame::oops_do_internal(OopClosure* f, CodeBlobClosure* cf, RegisterMap* map, bool use_interpreter_oop_map_cache) { 1111#ifndef PRODUCT 1112 // simulate GC crash here to dump java thread in error report 1113 if (CrashGCForDumpingJavaThread) { 1114 char *t = NULL; 1115 *t = 'c'; 1116 } 1117#endif 1118 if (is_interpreted_frame()) { 1119 oops_interpreted_do(f, map, use_interpreter_oop_map_cache); 1120 } else if (is_entry_frame()) { 1121 oops_entry_do(f, map); 1122 } else if (CodeCache::contains(pc())) { 1123 oops_code_blob_do(f, cf, map); 1124#ifdef SHARK 1125 } else if (is_fake_stub_frame()) { 1126 // nothing to do 1127#endif // SHARK 1128 } else { 1129 ShouldNotReachHere(); 1130 } 1131} 1132 1133void frame::nmethods_do(CodeBlobClosure* cf) { 1134 if (_cb != NULL && _cb->is_nmethod()) { 1135 cf->do_code_blob(_cb); 1136 } 1137} 1138 1139 1140void frame::gc_prologue() { 1141 if (is_interpreted_frame()) { 1142 // set bcx to bci to become methodOop position independent during GC 1143 interpreter_frame_set_bcx(interpreter_frame_bci()); 1144 } 1145} 1146 1147 1148void frame::gc_epilogue() { 1149 if (is_interpreted_frame()) { 1150 // set bcx back to bcp for interpreter 1151 interpreter_frame_set_bcx((intptr_t)interpreter_frame_bcp()); 1152 } 1153 // call processor specific epilog function 1154 pd_gc_epilog(); 1155} 1156 1157 1158# ifdef ENABLE_ZAP_DEAD_LOCALS 1159 1160void frame::CheckValueClosure::do_oop(oop* p) { 1161 if (CheckOopishValues && Universe::heap()->is_in_reserved(*p)) { 1162 warning("value @ " INTPTR_FORMAT " looks oopish (" INTPTR_FORMAT ") (thread = " INTPTR_FORMAT ")", p, (address)*p, Thread::current()); 1163 } 1164} 1165frame::CheckValueClosure frame::_check_value; 1166 1167 1168void frame::CheckOopClosure::do_oop(oop* p) { 1169 if (*p != NULL && !(*p)->is_oop()) { 1170 warning("value @ " INTPTR_FORMAT " should be an oop (" INTPTR_FORMAT ") (thread = " INTPTR_FORMAT ")", p, (address)*p, Thread::current()); 1171 } 1172} 1173frame::CheckOopClosure frame::_check_oop; 1174 1175void frame::check_derived_oop(oop* base, oop* derived) { 1176 _check_oop.do_oop(base); 1177} 1178 1179 1180void frame::ZapDeadClosure::do_oop(oop* p) { 1181 if (TraceZapDeadLocals) tty->print_cr("zapping @ " INTPTR_FORMAT " containing " INTPTR_FORMAT, p, (address)*p); 1182 // Need cast because on _LP64 the conversion to oop is ambiguous. Constant 1183 // can be either long or int. 1184 *p = (oop)(int)0xbabebabe; 1185} 1186frame::ZapDeadClosure frame::_zap_dead; 1187 1188void frame::zap_dead_locals(JavaThread* thread, const RegisterMap* map) { 1189 assert(thread == Thread::current(), "need to synchronize to do this to another thread"); 1190 // Tracing - part 1 1191 if (TraceZapDeadLocals) { 1192 ResourceMark rm(thread); 1193 tty->print_cr("--------------------------------------------------------------------------------"); 1194 tty->print("Zapping dead locals in "); 1195 print_on(tty); 1196 tty->cr(); 1197 } 1198 // Zapping 1199 if (is_entry_frame ()) zap_dead_entry_locals (thread, map); 1200 else if (is_interpreted_frame()) zap_dead_interpreted_locals(thread, map); 1201 else if (is_compiled_frame()) zap_dead_compiled_locals (thread, map); 1202 1203 else 1204 // could be is_runtime_frame 1205 // so remove error: ShouldNotReachHere(); 1206 ; 1207 // Tracing - part 2 1208 if (TraceZapDeadLocals) { 1209 tty->cr(); 1210 } 1211} 1212 1213 1214void frame::zap_dead_interpreted_locals(JavaThread *thread, const RegisterMap* map) { 1215 // get current interpreter 'pc' 1216 assert(is_interpreted_frame(), "Not an interpreted frame"); 1217 methodOop m = interpreter_frame_method(); 1218 int bci = interpreter_frame_bci(); 1219 1220 int max_locals = m->is_native() ? m->size_of_parameters() : m->max_locals(); 1221 1222 // process dynamic part 1223 InterpreterFrameClosure value_blk(this, max_locals, m->max_stack(), 1224 &_check_value); 1225 InterpreterFrameClosure oop_blk(this, max_locals, m->max_stack(), 1226 &_check_oop ); 1227 InterpreterFrameClosure dead_blk(this, max_locals, m->max_stack(), 1228 &_zap_dead ); 1229 1230 // get frame map 1231 InterpreterOopMap mask; 1232 m->mask_for(bci, &mask); 1233 mask.iterate_all( &oop_blk, &value_blk, &dead_blk); 1234} 1235 1236 1237void frame::zap_dead_compiled_locals(JavaThread* thread, const RegisterMap* reg_map) { 1238 1239 ResourceMark rm(thread); 1240 assert(_cb != NULL, "sanity check"); 1241 if (_cb->oop_maps() != NULL) { 1242 OopMapSet::all_do(this, reg_map, &_check_oop, check_derived_oop, &_check_value); 1243 } 1244} 1245 1246 1247void frame::zap_dead_entry_locals(JavaThread*, const RegisterMap*) { 1248 if (TraceZapDeadLocals) warning("frame::zap_dead_entry_locals unimplemented"); 1249} 1250 1251 1252void frame::zap_dead_deoptimized_locals(JavaThread*, const RegisterMap*) { 1253 if (TraceZapDeadLocals) warning("frame::zap_dead_deoptimized_locals unimplemented"); 1254} 1255 1256# endif // ENABLE_ZAP_DEAD_LOCALS 1257 1258void frame::verify(const RegisterMap* map) { 1259 // for now make sure receiver type is correct 1260 if (is_interpreted_frame()) { 1261 methodOop method = interpreter_frame_method(); 1262 guarantee(method->is_method(), "method is wrong in frame::verify"); 1263 if (!method->is_static()) { 1264 // fetch the receiver 1265 oop* p = (oop*) interpreter_frame_local_at(0); 1266 // make sure we have the right receiver type 1267 } 1268 } 1269 COMPILER2_PRESENT(assert(DerivedPointerTable::is_empty(), "must be empty before verify");) 1270 oops_do_internal(&VerifyOopClosure::verify_oop, NULL, (RegisterMap*)map, false); 1271} 1272 1273 1274#ifdef ASSERT 1275bool frame::verify_return_pc(address x) { 1276 if (StubRoutines::returns_to_call_stub(x)) { 1277 return true; 1278 } 1279 if (CodeCache::contains(x)) { 1280 return true; 1281 } 1282 if (Interpreter::contains(x)) { 1283 return true; 1284 } 1285 return false; 1286} 1287#endif 1288 1289 1290#ifdef ASSERT 1291void frame::interpreter_frame_verify_monitor(BasicObjectLock* value) const { 1292 assert(is_interpreted_frame(), "Not an interpreted frame"); 1293 // verify that the value is in the right part of the frame 1294 address low_mark = (address) interpreter_frame_monitor_end(); 1295 address high_mark = (address) interpreter_frame_monitor_begin(); 1296 address current = (address) value; 1297 1298 const int monitor_size = frame::interpreter_frame_monitor_size(); 1299 guarantee((high_mark - current) % monitor_size == 0 , "Misaligned top of BasicObjectLock*"); 1300 guarantee( high_mark > current , "Current BasicObjectLock* higher than high_mark"); 1301 1302 guarantee((current - low_mark) % monitor_size == 0 , "Misaligned bottom of BasicObjectLock*"); 1303 guarantee( current >= low_mark , "Current BasicObjectLock* below than low_mark"); 1304} 1305#endif 1306 1307 1308//----------------------------------------------------------------------------------- 1309// StackFrameStream implementation 1310 1311StackFrameStream::StackFrameStream(JavaThread *thread, bool update) : _reg_map(thread, update) { 1312 assert(thread->has_last_Java_frame(), "sanity check"); 1313 _fr = thread->last_frame(); 1314 _is_done = false; 1315} 1316