comparison src/share/vm/runtime/deoptimization.cpp @ 3464:be4ca325525a

Merge.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 27 Jul 2011 17:32:44 -0700
parents 132aa6f2bbc0 3d2ab563047a
children bc95d122df79
comparison
equal deleted inserted replaced
3239:7c4b4daac19b 3464:be4ca325525a
88 88
89 bool DeoptimizationMarker::_is_active = false; 89 bool DeoptimizationMarker::_is_active = false;
90 90
91 Deoptimization::UnrollBlock::UnrollBlock(int size_of_deoptimized_frame, 91 Deoptimization::UnrollBlock::UnrollBlock(int size_of_deoptimized_frame,
92 int caller_adjustment, 92 int caller_adjustment,
93 int caller_actual_parameters,
93 int number_of_frames, 94 int number_of_frames,
94 intptr_t* frame_sizes, 95 intptr_t* frame_sizes,
95 address* frame_pcs, 96 address* frame_pcs,
96 BasicType return_type) { 97 BasicType return_type) {
97 _size_of_deoptimized_frame = size_of_deoptimized_frame; 98 _size_of_deoptimized_frame = size_of_deoptimized_frame;
98 _caller_adjustment = caller_adjustment; 99 _caller_adjustment = caller_adjustment;
100 _caller_actual_parameters = caller_actual_parameters;
99 _number_of_frames = number_of_frames; 101 _number_of_frames = number_of_frames;
100 _frame_sizes = frame_sizes; 102 _frame_sizes = frame_sizes;
101 _frame_pcs = frame_pcs; 103 _frame_pcs = frame_pcs;
102 _register_block = NEW_C_HEAP_ARRAY(intptr_t, RegisterMap::reg_count * 2); 104 _register_block = NEW_C_HEAP_ARRAY(intptr_t, RegisterMap::reg_count * 2);
103 _return_type = return_type; 105 _return_type = return_type;
190 // Now get the deoptee with a valid map 192 // Now get the deoptee with a valid map
191 frame deoptee = stub_frame.sender(&map); 193 frame deoptee = stub_frame.sender(&map);
192 // Set the deoptee nmethod 194 // Set the deoptee nmethod
193 assert(thread->deopt_nmethod() == NULL, "Pending deopt!"); 195 assert(thread->deopt_nmethod() == NULL, "Pending deopt!");
194 thread->set_deopt_nmethod(deoptee.cb()->as_nmethod_or_null()); 196 thread->set_deopt_nmethod(deoptee.cb()->as_nmethod_or_null());
197
198 if (VerifyStack) {
199 thread->validate_frame_layout();
200 }
195 201
196 // Create a growable array of VFrames where each VFrame represents an inlined 202 // Create a growable array of VFrames where each VFrame represents an inlined
197 // Java frame. This storage is allocated with the usual system arena. 203 // Java frame. This storage is allocated with the usual system arena.
198 assert(deoptee.is_compiled_frame(), "Wrong frame type"); 204 assert(deoptee.is_compiled_frame(), "Wrong frame type");
199 GrowableArray<compiledVFrame*>* chunk = new GrowableArray<compiledVFrame*>(10); 205 GrowableArray<compiledVFrame*>* chunk = new GrowableArray<compiledVFrame*>(10);
371 // activation be put back on the expression stack of the caller for reexecution 377 // activation be put back on the expression stack of the caller for reexecution
372 if (JvmtiExport::can_pop_frame() && thread->popframe_forcing_deopt_reexecution()) { 378 if (JvmtiExport::can_pop_frame() && thread->popframe_forcing_deopt_reexecution()) {
373 popframe_extra_args = in_words(thread->popframe_preserved_args_size_in_words()); 379 popframe_extra_args = in_words(thread->popframe_preserved_args_size_in_words());
374 } 380 }
375 381
382 // Find the current pc for sender of the deoptee. Since the sender may have been deoptimized
383 // itself since the deoptee vframeArray was created we must get a fresh value of the pc rather
384 // than simply use array->sender.pc(). This requires us to walk the current set of frames
385 //
386 frame deopt_sender = stub_frame.sender(&dummy_map); // First is the deoptee frame
387 deopt_sender = deopt_sender.sender(&dummy_map); // Now deoptee caller
388
389 // It's possible that the number of paramters at the call site is
390 // different than number of arguments in the callee when method
391 // handles are used. If the caller is interpreted get the real
392 // value so that the proper amount of space can be added to it's
393 // frame.
394 int caller_actual_parameters = callee_parameters;
395 if (deopt_sender.is_interpreted_frame()) {
396 methodHandle method = deopt_sender.interpreter_frame_method();
397 Bytecode_invoke cur = Bytecode_invoke_check(method,
398 deopt_sender.interpreter_frame_bci());
399 Symbol* signature = method->constants()->signature_ref_at(cur.index());
400 ArgumentSizeComputer asc(signature);
401 caller_actual_parameters = asc.size() + (cur.has_receiver() ? 1 : 0);
402 }
403
376 // 404 //
377 // frame_sizes/frame_pcs[0] oldest frame (int or c2i) 405 // frame_sizes/frame_pcs[0] oldest frame (int or c2i)
378 // frame_sizes/frame_pcs[1] next oldest frame (int) 406 // frame_sizes/frame_pcs[1] next oldest frame (int)
379 // frame_sizes/frame_pcs[n] youngest frame (int) 407 // frame_sizes/frame_pcs[n] youngest frame (int)
380 // 408 //
389 // 417 //
390 for (int index = 0; index < array->frames(); index++ ) { 418 for (int index = 0; index < array->frames(); index++ ) {
391 // frame[number_of_frames - 1 ] = on_stack_size(youngest) 419 // frame[number_of_frames - 1 ] = on_stack_size(youngest)
392 // frame[number_of_frames - 2 ] = on_stack_size(sender(youngest)) 420 // frame[number_of_frames - 2 ] = on_stack_size(sender(youngest))
393 // frame[number_of_frames - 3 ] = on_stack_size(sender(sender(youngest))) 421 // frame[number_of_frames - 3 ] = on_stack_size(sender(sender(youngest)))
394 frame_sizes[number_of_frames - 1 - index] = BytesPerWord * array->element(index)->on_stack_size(callee_parameters, 422 int caller_parms = callee_parameters;
423 if (index == array->frames() - 1) {
424 // Use the value from the interpreted caller
425 caller_parms = caller_actual_parameters;
426 }
427 frame_sizes[number_of_frames - 1 - index] = BytesPerWord * array->element(index)->on_stack_size(caller_parms,
428 callee_parameters,
395 callee_locals, 429 callee_locals,
396 index == 0, 430 index == 0,
397 popframe_extra_args); 431 popframe_extra_args);
398 // This pc doesn't have to be perfect just good enough to identify the frame 432 // This pc doesn't have to be perfect just good enough to identify the frame
399 // as interpreted so the skeleton frame will be walkable 433 // as interpreted so the skeleton frame will be walkable
416 } 450 }
417 451
418 // Compute information for handling adapters and adjusting the frame size of the caller. 452 // Compute information for handling adapters and adjusting the frame size of the caller.
419 int caller_adjustment = 0; 453 int caller_adjustment = 0;
420 454
421 // Find the current pc for sender of the deoptee. Since the sender may have been deoptimized
422 // itself since the deoptee vframeArray was created we must get a fresh value of the pc rather
423 // than simply use array->sender.pc(). This requires us to walk the current set of frames
424 //
425 frame deopt_sender = stub_frame.sender(&dummy_map); // First is the deoptee frame
426 deopt_sender = deopt_sender.sender(&dummy_map); // Now deoptee caller
427
428 // Compute the amount the oldest interpreter frame will have to adjust 455 // Compute the amount the oldest interpreter frame will have to adjust
429 // its caller's stack by. If the caller is a compiled frame then 456 // its caller's stack by. If the caller is a compiled frame then
430 // we pretend that the callee has no parameters so that the 457 // we pretend that the callee has no parameters so that the
431 // extension counts for the full amount of locals and not just 458 // extension counts for the full amount of locals and not just
432 // locals-parms. This is because without a c2i adapter the parm 459 // locals-parms. This is because without a c2i adapter the parm
437 // QQQ I'd rather see this pushed down into last_frame_adjust 464 // QQQ I'd rather see this pushed down into last_frame_adjust
438 // and have it take the sender (aka caller). 465 // and have it take the sender (aka caller).
439 466
440 if (deopt_sender.is_compiled_frame()) { 467 if (deopt_sender.is_compiled_frame()) {
441 caller_adjustment = last_frame_adjust(0, callee_locals); 468 caller_adjustment = last_frame_adjust(0, callee_locals);
442 } else if (callee_locals > callee_parameters) { 469 } else if (callee_locals > caller_actual_parameters) {
443 // The caller frame may need extending to accommodate 470 // The caller frame may need extending to accommodate
444 // non-parameter locals of the first unpacked interpreted frame. 471 // non-parameter locals of the first unpacked interpreted frame.
445 // Compute that adjustment. 472 // Compute that adjustment.
446 caller_adjustment = last_frame_adjust(callee_parameters, callee_locals); 473 caller_adjustment = last_frame_adjust(caller_actual_parameters, callee_locals);
447 } 474 }
448
449 475
450 // If the sender is deoptimized the we must retrieve the address of the handler 476 // If the sender is deoptimized the we must retrieve the address of the handler
451 // since the frame will "magically" show the original pc before the deopt 477 // since the frame will "magically" show the original pc before the deopt
452 // and we'd undo the deopt. 478 // and we'd undo the deopt.
453 479
457 assert(CodeCache::find_blob_unsafe(frame_pcs[0]) != NULL, "bad pc"); 483 assert(CodeCache::find_blob_unsafe(frame_pcs[0]) != NULL, "bad pc");
458 #endif // SHARK 484 #endif // SHARK
459 485
460 UnrollBlock* info = new UnrollBlock(array->frame_size() * BytesPerWord, 486 UnrollBlock* info = new UnrollBlock(array->frame_size() * BytesPerWord,
461 caller_adjustment * BytesPerWord, 487 caller_adjustment * BytesPerWord,
488 caller_actual_parameters,
462 number_of_frames, 489 number_of_frames,
463 frame_sizes, 490 frame_sizes,
464 frame_pcs, 491 frame_pcs,
465 return_type); 492 return_type);
466 // On some platforms, we need a way to pass fp to the unpacking code 493 // On some platforms, we need a way to pass fp to the unpacking code
554 #endif 581 #endif
555 582
556 UnrollBlock* info = array->unroll_block(); 583 UnrollBlock* info = array->unroll_block();
557 584
558 // Unpack the interpreter frames and any adapter frame (c2 only) we might create. 585 // Unpack the interpreter frames and any adapter frame (c2 only) we might create.
559 array->unpack_to_stack(stub_frame, exec_mode); 586 array->unpack_to_stack(stub_frame, exec_mode, info->caller_actual_parameters());
560 587
561 BasicType bt = info->return_type(); 588 BasicType bt = info->return_type();
562 589
563 // If we have an exception pending, claim that the return type is an oop 590 // If we have an exception pending, claim that the return type is an oop
564 // so the deopt_blob does not overwrite the exception_oop. 591 // so the deopt_blob does not overwrite the exception_oop.
570 cleanup_deopt_info(thread, array); 597 cleanup_deopt_info(thread, array);
571 598
572 #ifndef PRODUCT 599 #ifndef PRODUCT
573 if (VerifyStack) { 600 if (VerifyStack) {
574 ResourceMark res_mark; 601 ResourceMark res_mark;
602
603 thread->validate_frame_layout();
575 604
576 // Verify that the just-unpacked frames match the interpreter's 605 // Verify that the just-unpacked frames match the interpreter's
577 // notions of expression stack and locals 606 // notions of expression stack and locals
578 vframeArray* cur_array = thread->vframe_array_last(); 607 vframeArray* cur_array = thread->vframe_array_last();
579 RegisterMap rm(thread, false); 608 RegisterMap rm(thread, false);
1775 "unreached", 1804 "unreached",
1776 "unhandled", 1805 "unhandled",
1777 "constraint", 1806 "constraint",
1778 "div0_check", 1807 "div0_check",
1779 "age", 1808 "age",
1780 "predicate" 1809 "predicate",
1810 "loop_limit_check"
1781 }; 1811 };
1782 const char* Deoptimization::_trap_action_name[Action_LIMIT] = { 1812 const char* Deoptimization::_trap_action_name[Action_LIMIT] = {
1783 // Note: Keep this in sync. with enum DeoptAction. 1813 // Note: Keep this in sync. with enum DeoptAction.
1784 "none", 1814 "none",
1785 "maybe_recompile", 1815 "maybe_recompile",