1 /* 2 * Copyright (c) 1997, 2022, 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 "compiler/oopMap.hpp" 27 #include "interpreter/interpreter.hpp" 28 #include "memory/resourceArea.hpp" 29 #include "memory/universe.hpp" 30 #include "oops/markWord.hpp" 31 #include "oops/method.hpp" 32 #include "oops/oop.inline.hpp" 33 #include "prims/methodHandles.hpp" 34 #include "runtime/continuation.hpp" 35 #include "runtime/frame.inline.hpp" 36 #include "runtime/handles.inline.hpp" 37 #include "runtime/javaCalls.hpp" 38 #include "runtime/monitorChunk.hpp" 39 #include "runtime/signature.hpp" 40 #include "runtime/stackWatermarkSet.hpp" 41 #include "runtime/stubCodeGenerator.hpp" 42 #include "runtime/stubRoutines.hpp" 43 #include "vmreg_x86.inline.hpp" 44 #include "utilities/formatBuffer.hpp" 45 #ifdef COMPILER1 46 #include "c1/c1_Runtime1.hpp" 47 #include "runtime/vframeArray.hpp" 48 #endif 49 50 #ifdef ASSERT 51 void RegisterMap::check_location_valid() { 52 } 53 #endif 54 55 // Profiling/safepoint support 56 57 bool frame::safe_for_sender(JavaThread *thread) { 58 if (is_heap_frame()) { 59 return true; 60 } 61 address sp = (address)_sp; 62 address fp = (address)_fp; 63 address unextended_sp = (address)_unextended_sp; 64 65 // consider stack guards when trying to determine "safe" stack pointers 66 // sp must be within the usable part of the stack (not in guards) 67 if (!thread->is_in_usable_stack(sp)) { 68 return false; 69 } 70 71 // unextended sp must be within the stack and above or equal sp 72 if (!thread->is_in_stack_range_incl(unextended_sp, sp)) { 73 return false; 74 } 75 76 // an fp must be within the stack and above (but not equal) sp 77 // second evaluation on fp+ is added to handle situation where fp is -1 78 bool fp_safe = thread->is_in_stack_range_excl(fp, sp) && 79 thread->is_in_full_stack_checked(fp + (return_addr_offset * sizeof(void*))); 80 81 // We know sp/unextended_sp are safe only fp is questionable here 82 83 // If the current frame is known to the code cache then we can attempt to 84 // construct the sender and do some validation of it. This goes a long way 85 // toward eliminating issues when we get in frame construction code 86 87 if (_cb != NULL ) { 88 89 // First check if frame is complete and tester is reliable 90 // Unfortunately we can only check frame complete for runtime stubs and nmethod 91 // other generic buffer blobs are more problematic so we just assume they are 92 // ok. adapter blobs never have a frame complete and are never ok. 93 94 if (!_cb->is_frame_complete_at(_pc)) { 95 if (_cb->is_compiled() || _cb->is_adapter_blob() || _cb->is_runtime_stub()) { 96 return false; 97 } 98 } 99 100 // Could just be some random pointer within the codeBlob 101 if (!_cb->code_contains(_pc)) { 102 return false; 103 } 104 105 // Entry frame checks 106 if (is_entry_frame()) { 107 // an entry frame must have a valid fp. 108 return fp_safe && is_entry_frame_valid(thread); 109 } else if (is_upcall_stub_frame()) { 110 return fp_safe; 111 } 112 113 intptr_t* sender_sp = NULL; 114 intptr_t* sender_unextended_sp = NULL; 115 address sender_pc = NULL; 116 intptr_t* saved_fp = NULL; 117 118 if (is_interpreted_frame()) { 119 // fp must be safe 120 if (!fp_safe) { 121 return false; 122 } 123 124 sender_pc = (address) this->fp()[return_addr_offset]; 125 // for interpreted frames, the value below is the sender "raw" sp, 126 // which can be different from the sender unextended sp (the sp seen 127 // by the sender) because of current frame local variables 128 sender_sp = (intptr_t*) addr_at(sender_sp_offset); 129 sender_unextended_sp = (intptr_t*) this->fp()[interpreter_frame_sender_sp_offset]; 130 saved_fp = (intptr_t*) this->fp()[link_offset]; 131 132 } else { 133 // must be some sort of compiled/runtime frame 134 // fp does not have to be safe (although it could be check for c1?) 135 136 // check for a valid frame_size, otherwise we are unlikely to get a valid sender_pc 137 if (_cb->frame_size() <= 0) { 138 return false; 139 } 140 141 sender_sp = _unextended_sp + _cb->frame_size(); 142 // Is sender_sp safe? 143 if (!thread->is_in_full_stack_checked((address)sender_sp)) { 144 return false; 145 } 146 // On Intel the return_address is always the word on the stack 147 sender_pc = (address) *(sender_sp-1); 148 // Note: frame::sender_sp_offset is only valid for compiled frame 149 intptr_t** saved_fp_addr = (intptr_t**) (sender_sp - frame::sender_sp_offset); 150 saved_fp = *saved_fp_addr; 151 152 // Repair the sender sp if this is a method with scalarized inline type args 153 sender_sp = repair_sender_sp(sender_sp, saved_fp_addr); 154 sender_unextended_sp = sender_sp; 155 } 156 if (Continuation::is_return_barrier_entry(sender_pc)) { 157 // If our sender_pc is the return barrier, then our "real" sender is the continuation entry 158 frame s = Continuation::continuation_bottom_sender(thread, *this, sender_sp); 159 sender_sp = s.sp(); 160 sender_pc = s.pc(); 161 } 162 163 // If the potential sender is the interpreter then we can do some more checking 164 if (Interpreter::contains(sender_pc)) { 165 166 // ebp is always saved in a recognizable place in any code we generate. However 167 // only if the sender is interpreted/call_stub (c1 too?) are we certain that the saved ebp 168 // is really a frame pointer. 169 170 if (!thread->is_in_stack_range_excl((address)saved_fp, (address)sender_sp)) { 171 return false; 172 } 173 174 // construct the potential sender 175 176 frame sender(sender_sp, sender_unextended_sp, saved_fp, sender_pc); 177 178 return sender.is_interpreted_frame_valid(thread); 179 180 } 181 182 // We must always be able to find a recognizable pc 183 CodeBlob* sender_blob = CodeCache::find_blob(sender_pc); 184 if (sender_pc == NULL || sender_blob == NULL) { 185 return false; 186 } 187 188 // Could just be some random pointer within the codeBlob 189 if (!sender_blob->code_contains(sender_pc)) { 190 return false; 191 } 192 193 // We should never be able to see an adapter if the current frame is something from code cache 194 if (sender_blob->is_adapter_blob()) { 195 return false; 196 } 197 198 // Could be the call_stub 199 if (StubRoutines::returns_to_call_stub(sender_pc)) { 200 if (!thread->is_in_stack_range_excl((address)saved_fp, (address)sender_sp)) { 201 return false; 202 } 203 204 // construct the potential sender 205 206 frame sender(sender_sp, sender_unextended_sp, saved_fp, sender_pc); 207 208 // Validate the JavaCallWrapper an entry frame must have 209 address jcw = (address)sender.entry_frame_call_wrapper(); 210 211 return thread->is_in_stack_range_excl(jcw, (address)sender.fp()); 212 } else if (sender_blob->is_upcall_stub()) { 213 return false; 214 } 215 216 CompiledMethod* nm = sender_blob->as_compiled_method_or_null(); 217 if (nm != NULL) { 218 if (nm->is_deopt_mh_entry(sender_pc) || nm->is_deopt_entry(sender_pc) || 219 nm->method()->is_method_handle_intrinsic()) { 220 return false; 221 } 222 } 223 224 // If the frame size is 0 something (or less) is bad because every nmethod has a non-zero frame size 225 // because the return address counts against the callee's frame. 226 227 if (sender_blob->frame_size() <= 0) { 228 assert(!sender_blob->is_compiled(), "should count return address at least"); 229 return false; 230 } 231 232 // We should never be able to see anything here except an nmethod. If something in the 233 // code cache (current frame) is called by an entity within the code cache that entity 234 // should not be anything but the call stub (already covered), the interpreter (already covered) 235 // or an nmethod. 236 237 if (!sender_blob->is_compiled()) { 238 return false; 239 } 240 241 // Could put some more validation for the potential non-interpreted sender 242 // frame we'd create by calling sender if I could think of any. Wait for next crash in forte... 243 244 // One idea is seeing if the sender_pc we have is one that we'd expect to call to current cb 245 246 // We've validated the potential sender that would be created 247 return true; 248 } 249 250 // Must be native-compiled frame. Since sender will try and use fp to find 251 // linkages it must be safe 252 253 if (!fp_safe) { 254 return false; 255 } 256 257 // Will the pc we fetch be non-zero (which we'll find at the oldest frame) 258 259 if ( (address) this->fp()[return_addr_offset] == NULL) return false; 260 261 262 // could try and do some more potential verification of native frame if we could think of some... 263 264 return true; 265 266 } 267 268 269 void frame::patch_pc(Thread* thread, address pc) { 270 assert(_cb == CodeCache::find_blob(pc), "unexpected pc"); 271 address* pc_addr = &(((address*) sp())[-1]); 272 273 if (TracePcPatching) { 274 tty->print_cr("patch_pc at address " INTPTR_FORMAT " [" INTPTR_FORMAT " -> " INTPTR_FORMAT "]", 275 p2i(pc_addr), p2i(*pc_addr), p2i(pc)); 276 } 277 // Either the return address is the original one or we are going to 278 // patch in the same address that's already there. 279 280 assert(!Continuation::is_return_barrier_entry(*pc_addr), "return barrier"); 281 282 assert(_pc == *pc_addr || pc == *pc_addr || *pc_addr == 0, ""); 283 DEBUG_ONLY(address old_pc = _pc;) 284 *pc_addr = pc; 285 _pc = pc; // must be set before call to get_deopt_original_pc 286 address original_pc = CompiledMethod::get_deopt_original_pc(this); 287 if (original_pc != NULL) { 288 assert(original_pc == old_pc, "expected original PC to be stored before patching"); 289 _deopt_state = is_deoptimized; 290 _pc = original_pc; 291 } else { 292 _deopt_state = not_deoptimized; 293 } 294 assert(!is_compiled_frame() || !_cb->as_compiled_method()->is_deopt_entry(_pc), "must be"); 295 296 #ifdef ASSERT 297 { 298 frame f(this->sp(), this->unextended_sp(), this->fp(), pc); 299 assert(f.is_deoptimized_frame() == this->is_deoptimized_frame() && f.pc() == this->pc() && f.raw_pc() == this->raw_pc(), 300 "must be (f.is_deoptimized_frame(): %d this->is_deoptimized_frame(): %d " 301 "f.pc(): " INTPTR_FORMAT " this->pc(): " INTPTR_FORMAT " f.raw_pc(): " INTPTR_FORMAT " this->raw_pc(): " INTPTR_FORMAT ")", 302 f.is_deoptimized_frame(), this->is_deoptimized_frame(), p2i(f.pc()), p2i(this->pc()), p2i(f.raw_pc()), p2i(this->raw_pc())); 303 } 304 #endif 305 } 306 307 intptr_t* frame::entry_frame_argument_at(int offset) const { 308 // convert offset to index to deal with tsi 309 int index = (Interpreter::expr_offset_in_bytes(offset)/wordSize); 310 // Entry frame's arguments are always in relation to unextended_sp() 311 return &unextended_sp()[index]; 312 } 313 314 // sender_sp 315 316 intptr_t* frame::interpreter_frame_sender_sp() const { 317 assert(is_interpreted_frame(), "interpreted frame expected"); 318 return (intptr_t*) at(interpreter_frame_sender_sp_offset); 319 } 320 321 void frame::set_interpreter_frame_sender_sp(intptr_t* sender_sp) { 322 assert(is_interpreted_frame(), "interpreted frame expected"); 323 ptr_at_put(interpreter_frame_sender_sp_offset, (intptr_t) sender_sp); 324 } 325 326 327 // monitor elements 328 329 BasicObjectLock* frame::interpreter_frame_monitor_begin() const { 330 return (BasicObjectLock*) addr_at(interpreter_frame_monitor_block_bottom_offset); 331 } 332 333 BasicObjectLock* frame::interpreter_frame_monitor_end() const { 334 BasicObjectLock* result = (BasicObjectLock*) at(interpreter_frame_monitor_block_top_offset); 335 // make sure the pointer points inside the frame 336 assert(sp() <= (intptr_t*) result, "monitor end should be above the stack pointer"); 337 assert((intptr_t*) result < fp(), "monitor end should be strictly below the frame pointer: result: " INTPTR_FORMAT " fp: " INTPTR_FORMAT, p2i(result), p2i(fp())); 338 return result; 339 } 340 341 void frame::interpreter_frame_set_monitor_end(BasicObjectLock* value) { 342 *((BasicObjectLock**)addr_at(interpreter_frame_monitor_block_top_offset)) = value; 343 } 344 345 // Used by template based interpreter deoptimization 346 void frame::interpreter_frame_set_last_sp(intptr_t* sp) { 347 *((intptr_t**)addr_at(interpreter_frame_last_sp_offset)) = sp; 348 } 349 350 frame frame::sender_for_entry_frame(RegisterMap* map) const { 351 assert(map != NULL, "map must be set"); 352 // Java frame called from C; skip all C frames and return top C 353 // frame of that chunk as the sender 354 JavaFrameAnchor* jfa = entry_frame_call_wrapper()->anchor(); 355 assert(!entry_frame_is_first(), "next Java fp must be non zero"); 356 assert(jfa->last_Java_sp() > sp(), "must be above this frame on stack"); 357 // Since we are walking the stack now this nested anchor is obviously walkable 358 // even if it wasn't when it was stacked. 359 jfa->make_walkable(); 360 map->clear(); 361 assert(map->include_argument_oops(), "should be set by clear"); 362 frame fr(jfa->last_Java_sp(), jfa->last_Java_fp(), jfa->last_Java_pc()); 363 364 return fr; 365 } 366 367 UpcallStub::FrameData* UpcallStub::frame_data_for_frame(const frame& frame) const { 368 assert(frame.is_upcall_stub_frame(), "wrong frame"); 369 // need unextended_sp here, since normal sp is wrong for interpreter callees 370 return reinterpret_cast<UpcallStub::FrameData*>( 371 reinterpret_cast<address>(frame.unextended_sp()) + in_bytes(_frame_data_offset)); 372 } 373 374 bool frame::upcall_stub_frame_is_first() const { 375 assert(is_upcall_stub_frame(), "must be optimzed entry frame"); 376 UpcallStub* blob = _cb->as_upcall_stub(); 377 JavaFrameAnchor* jfa = blob->jfa_for_frame(*this); 378 return jfa->last_Java_sp() == NULL; 379 } 380 381 frame frame::sender_for_upcall_stub_frame(RegisterMap* map) const { 382 assert(map != NULL, "map must be set"); 383 UpcallStub* blob = _cb->as_upcall_stub(); 384 // Java frame called from C; skip all C frames and return top C 385 // frame of that chunk as the sender 386 JavaFrameAnchor* jfa = blob->jfa_for_frame(*this); 387 assert(!upcall_stub_frame_is_first(), "must have a frame anchor to go back to"); 388 assert(jfa->last_Java_sp() > sp(), "must be above this frame on stack"); 389 // Since we are walking the stack now this nested anchor is obviously walkable 390 // even if it wasn't when it was stacked. 391 jfa->make_walkable(); 392 map->clear(); 393 assert(map->include_argument_oops(), "should be set by clear"); 394 frame fr(jfa->last_Java_sp(), jfa->last_Java_fp(), jfa->last_Java_pc()); 395 396 return fr; 397 } 398 399 //------------------------------------------------------------------------------ 400 // frame::verify_deopt_original_pc 401 // 402 // Verifies the calculated original PC of a deoptimization PC for the 403 // given unextended SP. 404 #ifdef ASSERT 405 void frame::verify_deopt_original_pc(CompiledMethod* nm, intptr_t* unextended_sp) { 406 frame fr; 407 408 // This is ugly but it's better than to change {get,set}_original_pc 409 // to take an SP value as argument. And it's only a debugging 410 // method anyway. 411 fr._unextended_sp = unextended_sp; 412 413 address original_pc = nm->get_original_pc(&fr); 414 assert(nm->insts_contains_inclusive(original_pc), 415 "original PC must be in the main code section of the compiled method (or must be immediately following it) original_pc: " INTPTR_FORMAT " unextended_sp: " INTPTR_FORMAT " name: %s", p2i(original_pc), p2i(unextended_sp), nm->name()); 416 } 417 #endif 418 419 //------------------------------------------------------------------------------ 420 // frame::adjust_unextended_sp 421 #ifdef ASSERT 422 void frame::adjust_unextended_sp() { 423 // On x86, sites calling method handle intrinsics and lambda forms are treated 424 // as any other call site. Therefore, no special action is needed when we are 425 // returning to any of these call sites. 426 427 if (_cb != NULL) { 428 CompiledMethod* sender_cm = _cb->as_compiled_method_or_null(); 429 if (sender_cm != NULL) { 430 // If the sender PC is a deoptimization point, get the original PC. 431 if (sender_cm->is_deopt_entry(_pc) || 432 sender_cm->is_deopt_mh_entry(_pc)) { 433 verify_deopt_original_pc(sender_cm, _unextended_sp); 434 } 435 } 436 } 437 } 438 #endif 439 440 //------------------------------------------------------------------------------ 441 // frame::sender_for_interpreter_frame 442 frame frame::sender_for_interpreter_frame(RegisterMap* map) const { 443 // SP is the raw SP from the sender after adapter or interpreter 444 // extension. 445 intptr_t* sender_sp = this->sender_sp(); 446 447 // This is the sp before any possible extension (adapter/locals). 448 intptr_t* unextended_sp = interpreter_frame_sender_sp(); 449 intptr_t* sender_fp = link(); 450 451 #if COMPILER2_OR_JVMCI 452 if (map->update_map()) { 453 update_map_with_saved_link(map, (intptr_t**) addr_at(link_offset)); 454 } 455 #endif // COMPILER2_OR_JVMCI 456 457 address sender_pc = this->sender_pc(); 458 459 if (Continuation::is_return_barrier_entry(sender_pc)) { 460 if (map->walk_cont()) { // about to walk into an h-stack 461 return Continuation::top_frame(*this, map); 462 } else { 463 return Continuation::continuation_bottom_sender(map->thread(), *this, sender_sp); 464 } 465 } 466 467 return frame(sender_sp, unextended_sp, sender_fp, sender_pc); 468 } 469 470 bool frame::is_interpreted_frame_valid(JavaThread* thread) const { 471 assert(is_interpreted_frame(), "Not an interpreted frame"); 472 // These are reasonable sanity checks 473 if (fp() == 0 || (intptr_t(fp()) & (wordSize-1)) != 0) { 474 return false; 475 } 476 if (sp() == 0 || (intptr_t(sp()) & (wordSize-1)) != 0) { 477 return false; 478 } 479 if (fp() + interpreter_frame_initial_sp_offset < sp()) { 480 return false; 481 } 482 // These are hacks to keep us out of trouble. 483 // The problem with these is that they mask other problems 484 if (fp() <= sp()) { // this attempts to deal with unsigned comparison above 485 return false; 486 } 487 488 // do some validation of frame elements 489 // first the method 490 491 Method* m = *interpreter_frame_method_addr(); 492 493 // validate the method we'd find in this potential sender 494 if (!Method::is_valid_method(m)) return false; 495 496 // stack frames shouldn't be much larger than max_stack elements 497 // this test requires the use the unextended_sp which is the sp as seen by 498 // the current frame, and not sp which is the "raw" pc which could point 499 // further because of local variables of the callee method inserted after 500 // method arguments 501 if (fp() - unextended_sp() > 1024 + m->max_stack()*Interpreter::stackElementSize) { 502 return false; 503 } 504 505 // validate bci/bcp 506 507 address bcp = interpreter_frame_bcp(); 508 if (m->validate_bci_from_bcp(bcp) < 0) { 509 return false; 510 } 511 512 // validate ConstantPoolCache* 513 ConstantPoolCache* cp = *interpreter_frame_cache_addr(); 514 if (MetaspaceObj::is_valid(cp) == false) return false; 515 516 // validate locals 517 518 address locals = (address) *interpreter_frame_locals_addr(); 519 return thread->is_in_stack_range_incl(locals, (address)fp()); 520 } 521 522 BasicType frame::interpreter_frame_result(oop* oop_result, jvalue* value_result) { 523 assert(is_interpreted_frame(), "interpreted frame expected"); 524 Method* method = interpreter_frame_method(); 525 BasicType type = method->result_type(); 526 527 intptr_t* tos_addr; 528 if (method->is_native()) { 529 // Prior to calling into the runtime to report the method_exit the possible 530 // return value is pushed to the native stack. If the result is a jfloat/jdouble 531 // then ST0 is saved before EAX/EDX. See the note in generate_native_result 532 tos_addr = (intptr_t*)sp(); 533 if (type == T_FLOAT || type == T_DOUBLE) { 534 // QQQ seems like this code is equivalent on the two platforms 535 #ifdef AMD64 536 // This is times two because we do a push(ltos) after pushing XMM0 537 // and that takes two interpreter stack slots. 538 tos_addr += 2 * Interpreter::stackElementWords; 539 #else 540 tos_addr += 2; 541 #endif // AMD64 542 } 543 } else { 544 tos_addr = (intptr_t*)interpreter_frame_tos_address(); 545 } 546 547 switch (type) { 548 case T_OBJECT : 549 case T_PRIMITIVE_OBJECT: 550 case T_ARRAY : { 551 oop obj; 552 if (method->is_native()) { 553 obj = cast_to_oop(at(interpreter_frame_oop_temp_offset)); 554 } else { 555 oop* obj_p = (oop*)tos_addr; 556 obj = (obj_p == NULL) ? (oop)NULL : *obj_p; 557 } 558 assert(Universe::is_in_heap_or_null(obj), "sanity check"); 559 *oop_result = obj; 560 break; 561 } 562 case T_BOOLEAN : value_result->z = *(jboolean*)tos_addr; break; 563 case T_BYTE : value_result->b = *(jbyte*)tos_addr; break; 564 case T_CHAR : value_result->c = *(jchar*)tos_addr; break; 565 case T_SHORT : value_result->s = *(jshort*)tos_addr; break; 566 case T_INT : value_result->i = *(jint*)tos_addr; break; 567 case T_LONG : value_result->j = *(jlong*)tos_addr; break; 568 case T_FLOAT : { 569 #ifdef AMD64 570 value_result->f = *(jfloat*)tos_addr; 571 #else 572 if (method->is_native()) { 573 jdouble d = *(jdouble*)tos_addr; // Result was in ST0 so need to convert to jfloat 574 value_result->f = (jfloat)d; 575 } else { 576 value_result->f = *(jfloat*)tos_addr; 577 } 578 #endif // AMD64 579 break; 580 } 581 case T_DOUBLE : value_result->d = *(jdouble*)tos_addr; break; 582 case T_VOID : /* Nothing to do */ break; 583 default : ShouldNotReachHere(); 584 } 585 586 return type; 587 } 588 589 intptr_t* frame::interpreter_frame_tos_at(jint offset) const { 590 int index = (Interpreter::expr_offset_in_bytes(offset)/wordSize); 591 return &interpreter_frame_tos_address()[index]; 592 } 593 594 #ifndef PRODUCT 595 596 #define DESCRIBE_FP_OFFSET(name) \ 597 values.describe(frame_no, fp() + frame::name##_offset, #name, 1) 598 599 void frame::describe_pd(FrameValues& values, int frame_no) { 600 if (is_interpreted_frame()) { 601 DESCRIBE_FP_OFFSET(interpreter_frame_sender_sp); 602 DESCRIBE_FP_OFFSET(interpreter_frame_last_sp); 603 DESCRIBE_FP_OFFSET(interpreter_frame_method); 604 DESCRIBE_FP_OFFSET(interpreter_frame_mirror); 605 DESCRIBE_FP_OFFSET(interpreter_frame_mdp); 606 DESCRIBE_FP_OFFSET(interpreter_frame_cache); 607 DESCRIBE_FP_OFFSET(interpreter_frame_locals); 608 DESCRIBE_FP_OFFSET(interpreter_frame_bcp); 609 DESCRIBE_FP_OFFSET(interpreter_frame_initial_sp); 610 #ifdef AMD64 611 } else if (is_entry_frame()) { 612 // This could be more descriptive if we use the enum in 613 // stubGenerator to map to real names but it's most important to 614 // claim these frame slots so the error checking works. 615 for (int i = 0; i < entry_frame_after_call_words; i++) { 616 values.describe(frame_no, fp() - i, err_msg("call_stub word fp - %d", i)); 617 } 618 #endif // AMD64 619 } 620 621 if (is_java_frame() || Continuation::is_continuation_enterSpecial(*this)) { 622 intptr_t* ret_pc_loc; 623 intptr_t* fp_loc; 624 if (is_interpreted_frame()) { 625 ret_pc_loc = fp() + return_addr_offset; 626 fp_loc = fp(); 627 } else { 628 ret_pc_loc = real_fp() - return_addr_offset; 629 fp_loc = real_fp() - sender_sp_offset; 630 } 631 address ret_pc = *(address*)ret_pc_loc; 632 values.describe(frame_no, ret_pc_loc, 633 Continuation::is_return_barrier_entry(ret_pc) ? "return address (return barrier)" : "return address"); 634 values.describe(-1, fp_loc, "saved fp", 0); // "unowned" as value belongs to sender 635 } 636 } 637 638 #endif // !PRODUCT 639 640 intptr_t *frame::initial_deoptimization_info() { 641 // used to reset the saved FP 642 return fp(); 643 } 644 645 #ifndef PRODUCT 646 // This is a generic constructor which is only used by pns() in debug.cpp. 647 frame::frame(void* sp, void* fp, void* pc) { 648 init((intptr_t*)sp, (intptr_t*)fp, (address)pc); 649 } 650 651 #endif 652 653 // Check for a method with scalarized inline type arguments that needs 654 // a stack repair and return the repaired sender stack pointer. 655 intptr_t* frame::repair_sender_sp(intptr_t* sender_sp, intptr_t** saved_fp_addr) const { 656 CompiledMethod* cm = _cb->as_compiled_method_or_null(); 657 if (cm != NULL && cm->needs_stack_repair()) { 658 // The stack increment resides just below the saved rbp on the stack 659 // and does not account for the return address. 660 intptr_t* real_frame_size_addr = (intptr_t*) (saved_fp_addr - 1); 661 int real_frame_size = ((*real_frame_size_addr) + wordSize) / wordSize; 662 assert(real_frame_size >= _cb->frame_size() && real_frame_size <= 1000000, "invalid frame size"); 663 sender_sp = unextended_sp() + real_frame_size; 664 } 665 return sender_sp; 666 } 667 668 void JavaFrameAnchor::make_walkable() { 669 // last frame set? 670 if (last_Java_sp() == NULL) return; 671 // already walkable? 672 if (walkable()) return; 673 vmassert(last_Java_pc() == NULL, "already walkable"); 674 _last_Java_pc = (address)_last_Java_sp[-1]; 675 vmassert(walkable(), "something went wrong"); 676 }