1 /* 2 * Copyright (c) 1997, 2018, 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/vmSymbols.hpp" 27 #include "code/vmreg.inline.hpp" 28 #include "interpreter/bytecode.hpp" 29 #include "interpreter/interpreter.hpp" 30 #include "memory/allocation.inline.hpp" 31 #include "memory/resourceArea.hpp" 32 #include "memory/universe.hpp" 33 #include "oops/methodData.hpp" 34 #include "oops/oop.inline.hpp" 35 #include "prims/jvmtiThreadState.hpp" 36 #include "runtime/frame.inline.hpp" 37 #include "runtime/handles.inline.hpp" 38 #include "runtime/monitorChunk.hpp" 39 #include "runtime/sharedRuntime.hpp" 40 #include "runtime/vframe.hpp" 41 #include "runtime/vframeArray.hpp" 42 #include "runtime/vframe_hp.hpp" 43 #include "utilities/copy.hpp" 44 #include "utilities/events.hpp" 45 #ifdef COMPILER2 46 #include "opto/runtime.hpp" 47 #endif 48 49 int vframeArrayElement:: bci(void) const { return (_bci == SynchronizationEntryBCI ? 0 : _bci); } 50 51 void vframeArrayElement::free_monitors(JavaThread* jt) { 52 if (_monitors != NULL) { 53 MonitorChunk* chunk = _monitors; 54 _monitors = NULL; 55 jt->remove_monitor_chunk(chunk); 56 delete chunk; 57 } 58 } 59 60 void vframeArrayElement::fill_in(compiledVFrame* vf, bool realloc_failures) { 61 62 // Copy the information from the compiled vframe to the 63 // interpreter frame we will be creating to replace vf 64 65 _method = vf->method(); 66 _bci = vf->raw_bci(); 67 _reexecute = vf->should_reexecute(); 68 #ifdef ASSERT 69 _removed_monitors = false; 70 #endif 71 72 int index; 73 74 // Get the monitors off-stack 75 76 GrowableArray<MonitorInfo*>* list = vf->monitors(); 77 if (list->is_empty()) { 78 _monitors = NULL; 79 } else { 80 81 // Allocate monitor chunk 82 _monitors = new MonitorChunk(list->length()); 83 vf->thread()->add_monitor_chunk(_monitors); 84 85 // Migrate the BasicLocks from the stack to the monitor chunk 86 for (index = 0; index < list->length(); index++) { 87 MonitorInfo* monitor = list->at(index); 88 assert(!monitor->owner_is_scalar_replaced() || realloc_failures, "object should be reallocated already"); 89 BasicObjectLock* dest = _monitors->at(index); 90 if (monitor->owner_is_scalar_replaced()) { 91 dest->set_obj(NULL); 92 } else { 93 assert(monitor->owner() == NULL || (!monitor->owner()->is_unlocked() && !monitor->owner()->has_bias_pattern()), "object must be null or locked, and unbiased"); 94 dest->set_obj(monitor->owner()); 95 monitor->lock()->move_to(monitor->owner(), dest->lock()); 96 } 97 } 98 } 99 100 // Convert the vframe locals and expressions to off stack 101 // values. Because we will not gc all oops can be converted to 102 // intptr_t (i.e. a stack slot) and we are fine. This is 103 // good since we are inside a HandleMark and the oops in our 104 // collection would go away between packing them here and 105 // unpacking them in unpack_on_stack. 106 107 // First the locals go off-stack 108 109 // FIXME this seems silly it creates a StackValueCollection 110 // in order to get the size to then copy them and 111 // convert the types to intptr_t size slots. Seems like it 112 // could do it in place... Still uses less memory than the 113 // old way though 114 115 StackValueCollection *locs = vf->locals(); 116 _locals = new StackValueCollection(locs->size()); 117 for(index = 0; index < locs->size(); index++) { 118 StackValue* value = locs->at(index); 119 switch(value->type()) { 120 case T_OBJECT: 121 assert(!value->obj_is_scalar_replaced() || realloc_failures, "object should be reallocated already"); 122 // preserve object type 123 _locals->add( new StackValue(cast_from_oop<intptr_t>((value->get_obj()())), T_OBJECT )); 124 break; 125 case T_CONFLICT: 126 // A dead local. Will be initialized to null/zero. 127 _locals->add( new StackValue()); 128 break; 129 case T_INT: 130 _locals->add( new StackValue(value->get_int())); 131 break; 132 default: 133 ShouldNotReachHere(); 134 } 135 } 136 137 // Now the expressions off-stack 138 // Same silliness as above 139 140 StackValueCollection *exprs = vf->expressions(); 141 _expressions = new StackValueCollection(exprs->size()); 142 for(index = 0; index < exprs->size(); index++) { 143 StackValue* value = exprs->at(index); 144 switch(value->type()) { 145 case T_OBJECT: 146 assert(!value->obj_is_scalar_replaced() || realloc_failures, "object should be reallocated already"); 147 // preserve object type 148 _expressions->add( new StackValue(cast_from_oop<intptr_t>((value->get_obj()())), T_OBJECT )); 149 break; 150 case T_CONFLICT: 151 // A dead stack element. Will be initialized to null/zero. 152 // This can occur when the compiler emits a state in which stack 153 // elements are known to be dead (because of an imminent exception). 154 _expressions->add( new StackValue()); 155 break; 156 case T_INT: 157 _expressions->add( new StackValue(value->get_int())); 158 break; 159 default: 160 ShouldNotReachHere(); 161 } 162 } 163 } 164 165 int unpack_counter = 0; 166 167 void vframeArrayElement::unpack_on_stack(int caller_actual_parameters, 168 int callee_parameters, 169 int callee_locals, 170 frame* caller, 171 bool is_top_frame, 172 bool is_bottom_frame, 173 int exec_mode) { 174 JavaThread* thread = (JavaThread*) Thread::current(); 175 176 bool realloc_failure_exception = thread->frames_to_pop_failed_realloc() > 0; 177 178 // Look at bci and decide on bcp and continuation pc 179 address bcp; 180 // C++ interpreter doesn't need a pc since it will figure out what to do when it 181 // begins execution 182 address pc; 183 bool use_next_mdp = false; // true if we should use the mdp associated with the next bci 184 // rather than the one associated with bcp 185 if (raw_bci() == SynchronizationEntryBCI) { 186 // We are deoptimizing while hanging in prologue code for synchronized method 187 bcp = method()->bcp_from(0); // first byte code 188 pc = Interpreter::deopt_entry(vtos, 0); // step = 0 since we don't skip current bytecode 189 } else if (should_reexecute()) { //reexecute this bytecode 190 assert(is_top_frame, "reexecute allowed only for the top frame"); 191 bcp = method()->bcp_from(bci()); 192 pc = Interpreter::deopt_reexecute_entry(method(), bcp); 193 } else { 194 bcp = method()->bcp_from(bci()); 195 pc = Interpreter::deopt_continue_after_entry(method(), bcp, callee_parameters, is_top_frame); 196 use_next_mdp = true; 197 } 198 assert(Bytecodes::is_defined(*bcp), "must be a valid bytecode"); 199 200 // Monitorenter and pending exceptions: 201 // 202 // For Compiler2, there should be no pending exception when deoptimizing at monitorenter 203 // because there is no safepoint at the null pointer check (it is either handled explicitly 204 // or prior to the monitorenter) and asynchronous exceptions are not made "pending" by the 205 // runtime interface for the slow case (see JRT_ENTRY_FOR_MONITORENTER). If an asynchronous 206 // exception was processed, the bytecode pointer would have to be extended one bytecode beyond 207 // the monitorenter to place it in the proper exception range. 208 // 209 // For Compiler1, deoptimization can occur while throwing a NullPointerException at monitorenter, 210 // in which case bcp should point to the monitorenter since it is within the exception's range. 211 // 212 // For realloc failure exception we just pop frames, skip the guarantee. 213 214 assert(*bcp != Bytecodes::_monitorenter || is_top_frame, "a _monitorenter must be a top frame"); 215 assert(thread->deopt_compiled_method() != NULL, "compiled method should be known"); 216 guarantee(realloc_failure_exception || !(thread->deopt_compiled_method()->is_compiled_by_c2() && 217 *bcp == Bytecodes::_monitorenter && 218 exec_mode == Deoptimization::Unpack_exception), 219 "shouldn't get exception during monitorenter"); 220 221 int popframe_preserved_args_size_in_bytes = 0; 222 int popframe_preserved_args_size_in_words = 0; 223 if (is_top_frame) { 224 JvmtiThreadState *state = thread->jvmti_thread_state(); 225 if (JvmtiExport::can_pop_frame() && 226 (thread->has_pending_popframe() || thread->popframe_forcing_deopt_reexecution())) { 227 if (thread->has_pending_popframe()) { 228 // Pop top frame after deoptimization 229 #ifndef CC_INTERP 230 pc = Interpreter::remove_activation_preserving_args_entry(); 231 #else 232 // Do an uncommon trap type entry. c++ interpreter will know 233 // to pop frame and preserve the args 234 pc = Interpreter::deopt_entry(vtos, 0); 235 use_next_mdp = false; 236 #endif 237 } else { 238 // Reexecute invoke in top frame 239 pc = Interpreter::deopt_entry(vtos, 0); 240 use_next_mdp = false; 241 popframe_preserved_args_size_in_bytes = in_bytes(thread->popframe_preserved_args_size()); 242 // Note: the PopFrame-related extension of the expression stack size is done in 243 // Deoptimization::fetch_unroll_info_helper 244 popframe_preserved_args_size_in_words = in_words(thread->popframe_preserved_args_size_in_words()); 245 } 246 } else if (!realloc_failure_exception && JvmtiExport::can_force_early_return() && state != NULL && state->is_earlyret_pending()) { 247 // Force early return from top frame after deoptimization 248 #ifndef CC_INTERP 249 pc = Interpreter::remove_activation_early_entry(state->earlyret_tos()); 250 #endif 251 } else { 252 if (realloc_failure_exception && JvmtiExport::can_force_early_return() && state != NULL && state->is_earlyret_pending()) { 253 state->clr_earlyret_pending(); 254 state->set_earlyret_oop(NULL); 255 state->clr_earlyret_value(); 256 } 257 // Possibly override the previous pc computation of the top (youngest) frame 258 switch (exec_mode) { 259 case Deoptimization::Unpack_deopt: 260 // use what we've got 261 break; 262 case Deoptimization::Unpack_exception: 263 // exception is pending 264 pc = SharedRuntime::raw_exception_handler_for_return_address(thread, pc); 265 // [phh] We're going to end up in some handler or other, so it doesn't 266 // matter what mdp we point to. See exception_handler_for_exception() 267 // in interpreterRuntime.cpp. 268 break; 269 case Deoptimization::Unpack_uncommon_trap: 270 case Deoptimization::Unpack_reexecute: 271 // redo last byte code 272 pc = Interpreter::deopt_entry(vtos, 0); 273 use_next_mdp = false; 274 break; 275 default: 276 ShouldNotReachHere(); 277 } 278 } 279 } 280 281 // Setup the interpreter frame 282 283 assert(method() != NULL, "method must exist"); 284 int temps = expressions()->size(); 285 286 int locks = monitors() == NULL ? 0 : monitors()->number_of_monitors(); 287 288 Interpreter::layout_activation(method(), 289 temps + callee_parameters, 290 popframe_preserved_args_size_in_words, 291 locks, 292 caller_actual_parameters, 293 callee_parameters, 294 callee_locals, 295 caller, 296 iframe(), 297 is_top_frame, 298 is_bottom_frame); 299 300 iframe()->interpreter_frame_set_vt_alloc_ptr((intptr_t*)thread->vt_alloc_ptr()); 301 302 // Update the pc in the frame object and overwrite the temporary pc 303 // we placed in the skeletal frame now that we finally know the 304 // exact interpreter address we should use. 305 306 _frame.patch_pc(thread, pc); 307 308 assert (!method()->is_synchronized() || locks > 0 || _removed_monitors || raw_bci() == SynchronizationEntryBCI, "synchronized methods must have monitors"); 309 310 BasicObjectLock* top = iframe()->interpreter_frame_monitor_begin(); 311 for (int index = 0; index < locks; index++) { 312 top = iframe()->previous_monitor_in_interpreter_frame(top); 313 BasicObjectLock* src = _monitors->at(index); 314 top->set_obj(src->obj()); 315 src->lock()->move_to(src->obj(), top->lock()); 316 } 317 if (ProfileInterpreter) { 318 iframe()->interpreter_frame_set_mdp(0); // clear out the mdp. 319 } 320 iframe()->interpreter_frame_set_bcp(bcp); 321 if (ProfileInterpreter) { 322 MethodData* mdo = method()->method_data(); 323 if (mdo != NULL) { 324 int bci = iframe()->interpreter_frame_bci(); 325 if (use_next_mdp) ++bci; 326 address mdp = mdo->bci_to_dp(bci); 327 iframe()->interpreter_frame_set_mdp(mdp); 328 } 329 } 330 331 if (PrintDeoptimizationDetails) { 332 tty->print_cr("Expressions size: %d", expressions()->size()); 333 } 334 335 // Unpack expression stack 336 // If this is an intermediate frame (i.e. not top frame) then this 337 // only unpacks the part of the expression stack not used by callee 338 // as parameters. The callee parameters are unpacked as part of the 339 // callee locals. 340 int i; 341 for(i = 0; i < expressions()->size(); i++) { 342 StackValue *value = expressions()->at(i); 343 intptr_t* addr = iframe()->interpreter_frame_expression_stack_at(i); 344 switch(value->type()) { 345 case T_INT: 346 *addr = value->get_int(); 347 #ifndef PRODUCT 348 if (PrintDeoptimizationDetails) { 349 tty->print_cr("Reconstructed expression %d (INT): %d", i, (int)(*addr)); 350 } 351 #endif 352 break; 353 case T_OBJECT: 354 *addr = value->get_int(T_OBJECT); 355 #ifndef PRODUCT 356 if (PrintDeoptimizationDetails) { 357 tty->print("Reconstructed expression %d (OBJECT): ", i); 358 oop o = (oop)(address)(*addr); 359 if (o == NULL) { 360 tty->print_cr("NULL"); 361 } else { 362 ResourceMark rm; 363 tty->print_raw_cr(o->klass()->name()->as_C_string()); 364 } 365 } 366 #endif 367 break; 368 case T_CONFLICT: 369 // A dead stack slot. Initialize to null in case it is an oop. 370 *addr = NULL_WORD; 371 break; 372 default: 373 ShouldNotReachHere(); 374 } 375 } 376 377 378 // Unpack the locals 379 for(i = 0; i < locals()->size(); i++) { 380 StackValue *value = locals()->at(i); 381 intptr_t* addr = iframe()->interpreter_frame_local_at(i); 382 switch(value->type()) { 383 case T_INT: 384 *addr = value->get_int(); 385 #ifndef PRODUCT 386 if (PrintDeoptimizationDetails) { 387 tty->print_cr("Reconstructed local %d (INT): %d", i, (int)(*addr)); 388 } 389 #endif 390 break; 391 case T_OBJECT: 392 *addr = value->get_int(T_OBJECT); 393 #ifndef PRODUCT 394 if (PrintDeoptimizationDetails) { 395 tty->print("Reconstructed local %d (OBJECT): ", i); 396 oop o = (oop)(address)(*addr); 397 if (o == NULL) { 398 tty->print_cr("NULL"); 399 } else { 400 ResourceMark rm; 401 tty->print_raw_cr(o->klass()->name()->as_C_string()); 402 } 403 } 404 #endif 405 break; 406 case T_CONFLICT: 407 // A dead location. If it is an oop then we need a NULL to prevent GC from following it 408 *addr = NULL_WORD; 409 break; 410 default: 411 ShouldNotReachHere(); 412 } 413 } 414 415 if (is_top_frame && JvmtiExport::can_pop_frame() && thread->popframe_forcing_deopt_reexecution()) { 416 // An interpreted frame was popped but it returns to a deoptimized 417 // frame. The incoming arguments to the interpreted activation 418 // were preserved in thread-local storage by the 419 // remove_activation_preserving_args_entry in the interpreter; now 420 // we put them back into the just-unpacked interpreter frame. 421 // Note that this assumes that the locals arena grows toward lower 422 // addresses. 423 if (popframe_preserved_args_size_in_words != 0) { 424 void* saved_args = thread->popframe_preserved_args(); 425 assert(saved_args != NULL, "must have been saved by interpreter"); 426 #ifdef ASSERT 427 assert(popframe_preserved_args_size_in_words <= 428 iframe()->interpreter_frame_expression_stack_size()*Interpreter::stackElementWords, 429 "expression stack size should have been extended"); 430 #endif // ASSERT 431 int top_element = iframe()->interpreter_frame_expression_stack_size()-1; 432 intptr_t* base; 433 if (frame::interpreter_frame_expression_stack_direction() < 0) { 434 base = iframe()->interpreter_frame_expression_stack_at(top_element); 435 } else { 436 base = iframe()->interpreter_frame_expression_stack(); 437 } 438 Copy::conjoint_jbytes(saved_args, 439 base, 440 popframe_preserved_args_size_in_bytes); 441 thread->popframe_free_preserved_args(); 442 } 443 } 444 445 #ifndef PRODUCT 446 if (PrintDeoptimizationDetails) { 447 ttyLocker ttyl; 448 tty->print_cr("[%d Interpreted Frame]", ++unpack_counter); 449 iframe()->print_on(tty); 450 RegisterMap map(thread); 451 vframe* f = vframe::new_vframe(iframe(), &map, thread); 452 f->print(); 453 454 tty->print_cr("locals size %d", locals()->size()); 455 tty->print_cr("expression size %d", expressions()->size()); 456 457 method()->print_value(); 458 tty->cr(); 459 // method()->print_codes(); 460 } else if (TraceDeoptimization) { 461 tty->print(" "); 462 method()->print_value(); 463 Bytecodes::Code code = Bytecodes::java_code_at(method(), bcp); 464 int bci = method()->bci_from(bcp); 465 tty->print(" - %s", Bytecodes::name(code)); 466 tty->print(" @ bci %d ", bci); 467 tty->print_cr("sp = " PTR_FORMAT, p2i(iframe()->sp())); 468 } 469 #endif // PRODUCT 470 471 // The expression stack and locals are in the resource area don't leave 472 // a dangling pointer in the vframeArray we leave around for debug 473 // purposes 474 475 _locals = _expressions = NULL; 476 477 } 478 479 int vframeArrayElement::on_stack_size(int callee_parameters, 480 int callee_locals, 481 bool is_top_frame, 482 int popframe_extra_stack_expression_els) const { 483 assert(method()->max_locals() == locals()->size(), "just checking"); 484 int locks = monitors() == NULL ? 0 : monitors()->number_of_monitors(); 485 int temps = expressions()->size(); 486 return Interpreter::size_activation(method()->max_stack(), 487 temps + callee_parameters, 488 popframe_extra_stack_expression_els, 489 locks, 490 callee_parameters, 491 callee_locals, 492 is_top_frame); 493 } 494 495 496 intptr_t* vframeArray::unextended_sp() const { 497 return _original.unextended_sp(); 498 } 499 500 vframeArray* vframeArray::allocate(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk, 501 RegisterMap *reg_map, frame sender, frame caller, frame self, 502 bool realloc_failures) { 503 504 // Allocate the vframeArray 505 vframeArray * result = (vframeArray*) AllocateHeap(sizeof(vframeArray) + // fixed part 506 sizeof(vframeArrayElement) * (chunk->length() - 1), // variable part 507 mtCompiler); 508 result->_frames = chunk->length(); 509 result->_owner_thread = thread; 510 result->_sender = sender; 511 result->_caller = caller; 512 result->_original = self; 513 result->set_unroll_block(NULL); // initialize it 514 result->fill_in(thread, frame_size, chunk, reg_map, realloc_failures); 515 return result; 516 } 517 518 void vframeArray::fill_in(JavaThread* thread, 519 int frame_size, 520 GrowableArray<compiledVFrame*>* chunk, 521 const RegisterMap *reg_map, 522 bool realloc_failures) { 523 // Set owner first, it is used when adding monitor chunks 524 525 _frame_size = frame_size; 526 for(int i = 0; i < chunk->length(); i++) { 527 element(i)->fill_in(chunk->at(i), realloc_failures); 528 } 529 530 // Copy registers for callee-saved registers 531 if (reg_map != NULL) { 532 for(int i = 0; i < RegisterMap::reg_count; i++) { 533 #ifdef AMD64 534 // The register map has one entry for every int (32-bit value), so 535 // 64-bit physical registers have two entries in the map, one for 536 // each half. Ignore the high halves of 64-bit registers, just like 537 // frame::oopmapreg_to_location does. 538 // 539 // [phh] FIXME: this is a temporary hack! This code *should* work 540 // correctly w/o this hack, possibly by changing RegisterMap::pd_location 541 // in frame_amd64.cpp and the values of the phantom high half registers 542 // in amd64.ad. 543 // if (VMReg::Name(i) < SharedInfo::stack0 && is_even(i)) { 544 intptr_t* src = (intptr_t*) reg_map->location(VMRegImpl::as_VMReg(i)); 545 _callee_registers[i] = src != NULL ? *src : NULL_WORD; 546 // } else { 547 // jint* src = (jint*) reg_map->location(VMReg::Name(i)); 548 // _callee_registers[i] = src != NULL ? *src : NULL_WORD; 549 // } 550 #else 551 jint* src = (jint*) reg_map->location(VMRegImpl::as_VMReg(i)); 552 _callee_registers[i] = src != NULL ? *src : NULL_WORD; 553 #endif 554 if (src == NULL) { 555 set_location_valid(i, false); 556 } else { 557 set_location_valid(i, true); 558 jint* dst = (jint*) register_location(i); 559 *dst = *src; 560 } 561 } 562 } 563 } 564 565 void vframeArray::unpack_to_stack(frame &unpack_frame, int exec_mode, int caller_actual_parameters) { 566 // stack picture 567 // unpack_frame 568 // [new interpreter frames ] (frames are skeletal but walkable) 569 // caller_frame 570 // 571 // This routine fills in the missing data for the skeletal interpreter frames 572 // in the above picture. 573 574 // Find the skeletal interpreter frames to unpack into 575 JavaThread* THREAD = JavaThread::current(); 576 RegisterMap map(THREAD, false); 577 // Get the youngest frame we will unpack (last to be unpacked) 578 frame me = unpack_frame.sender(&map); 579 int index; 580 for (index = 0; index < frames(); index++ ) { 581 *element(index)->iframe() = me; 582 // Get the caller frame (possibly skeletal) 583 me = me.sender(&map); 584 } 585 586 // Do the unpacking of interpreter frames; the frame at index 0 represents the top activation, so it has no callee 587 // Unpack the frames from the oldest (frames() -1) to the youngest (0) 588 frame* caller_frame = &me; 589 for (index = frames() - 1; index >= 0 ; index--) { 590 vframeArrayElement* elem = element(index); // caller 591 int callee_parameters, callee_locals; 592 if (index == 0) { 593 callee_parameters = callee_locals = 0; 594 } else { 595 methodHandle caller = elem->method(); 596 methodHandle callee = element(index - 1)->method(); 597 Bytecode_invoke inv(caller, elem->bci()); 598 // invokedynamic instructions don't have a class but obviously don't have a MemberName appendix. 599 // NOTE: Use machinery here that avoids resolving of any kind. 600 const bool has_member_arg = 601 !inv.is_invokedynamic() && MethodHandles::has_member_arg(inv.klass(), inv.name()); 602 callee_parameters = callee->size_of_parameters() + (has_member_arg ? 1 : 0); 603 callee_locals = callee->max_locals(); 604 } 605 elem->unpack_on_stack(caller_actual_parameters, 606 callee_parameters, 607 callee_locals, 608 caller_frame, 609 index == 0, 610 index == frames() - 1, 611 exec_mode); 612 if (index == frames() - 1) { 613 Deoptimization::unwind_callee_save_values(elem->iframe(), this); 614 } 615 caller_frame = elem->iframe(); 616 caller_actual_parameters = callee_parameters; 617 } 618 deallocate_monitor_chunks(); 619 } 620 621 void vframeArray::deallocate_monitor_chunks() { 622 JavaThread* jt = JavaThread::current(); 623 for (int index = 0; index < frames(); index++ ) { 624 element(index)->free_monitors(jt); 625 } 626 } 627 628 #ifndef PRODUCT 629 630 bool vframeArray::structural_compare(JavaThread* thread, GrowableArray<compiledVFrame*>* chunk) { 631 if (owner_thread() != thread) return false; 632 int index = 0; 633 #if 0 // FIXME can't do this comparison 634 635 // Compare only within vframe array. 636 for (deoptimizedVFrame* vf = deoptimizedVFrame::cast(vframe_at(first_index())); vf; vf = vf->deoptimized_sender_or_null()) { 637 if (index >= chunk->length() || !vf->structural_compare(chunk->at(index))) return false; 638 index++; 639 } 640 if (index != chunk->length()) return false; 641 #endif 642 643 return true; 644 } 645 646 #endif 647 648 address vframeArray::register_location(int i) const { 649 assert(0 <= i && i < RegisterMap::reg_count, "index out of bounds"); 650 return (address) & _callee_registers[i]; 651 } 652 653 654 #ifndef PRODUCT 655 656 // Printing 657 658 // Note: we cannot have print_on as const, as we allocate inside the method 659 void vframeArray::print_on_2(outputStream* st) { 660 st->print_cr(" - sp: " INTPTR_FORMAT, p2i(sp())); 661 st->print(" - thread: "); 662 Thread::current()->print(); 663 st->print_cr(" - frame size: %d", frame_size()); 664 for (int index = 0; index < frames() ; index++ ) { 665 element(index)->print(st); 666 } 667 } 668 669 void vframeArrayElement::print(outputStream* st) { 670 st->print_cr(" - interpreter_frame -> sp: " INTPTR_FORMAT, p2i(iframe()->sp())); 671 } 672 673 void vframeArray::print_value_on(outputStream* st) const { 674 st->print_cr("vframeArray [%d] ", frames()); 675 } 676 677 678 #endif