comparison src/share/vm/runtime/deoptimization.cpp @ 3369:3d2ab563047a

7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method Reviewed-by: kvn, coleenp
author never
date Thu, 12 May 2011 10:29:02 -0700
parents dcfb3dede009
children be4ca325525a 5432047c7db7
comparison
equal deleted inserted replaced
3365:3cfb240033d1 3369:3d2ab563047a
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;
371 // activation be put back on the expression stack of the caller for reexecution 373 // activation be put back on the expression stack of the caller for reexecution
372 if (JvmtiExport::can_pop_frame() && thread->popframe_forcing_deopt_reexecution()) { 374 if (JvmtiExport::can_pop_frame() && thread->popframe_forcing_deopt_reexecution()) {
373 popframe_extra_args = in_words(thread->popframe_preserved_args_size_in_words()); 375 popframe_extra_args = in_words(thread->popframe_preserved_args_size_in_words());
374 } 376 }
375 377
378 // Find the current pc for sender of the deoptee. Since the sender may have been deoptimized
379 // itself since the deoptee vframeArray was created we must get a fresh value of the pc rather
380 // than simply use array->sender.pc(). This requires us to walk the current set of frames
381 //
382 frame deopt_sender = stub_frame.sender(&dummy_map); // First is the deoptee frame
383 deopt_sender = deopt_sender.sender(&dummy_map); // Now deoptee caller
384
385 // It's possible that the number of paramters at the call site is
386 // different than number of arguments in the callee when method
387 // handles are used. If the caller is interpreted get the real
388 // value so that the proper amount of space can be added to it's
389 // frame.
390 int caller_actual_parameters = callee_parameters;
391 if (deopt_sender.is_interpreted_frame()) {
392 methodHandle method = deopt_sender.interpreter_frame_method();
393 Bytecode_invoke cur = Bytecode_invoke_check(method,
394 deopt_sender.interpreter_frame_bci());
395 Symbol* signature = method->constants()->signature_ref_at(cur.index());
396 ArgumentSizeComputer asc(signature);
397 caller_actual_parameters = asc.size() + (cur.has_receiver() ? 1 : 0);
398 }
399
376 // 400 //
377 // frame_sizes/frame_pcs[0] oldest frame (int or c2i) 401 // frame_sizes/frame_pcs[0] oldest frame (int or c2i)
378 // frame_sizes/frame_pcs[1] next oldest frame (int) 402 // frame_sizes/frame_pcs[1] next oldest frame (int)
379 // frame_sizes/frame_pcs[n] youngest frame (int) 403 // frame_sizes/frame_pcs[n] youngest frame (int)
380 // 404 //
389 // 413 //
390 for (int index = 0; index < array->frames(); index++ ) { 414 for (int index = 0; index < array->frames(); index++ ) {
391 // frame[number_of_frames - 1 ] = on_stack_size(youngest) 415 // frame[number_of_frames - 1 ] = on_stack_size(youngest)
392 // frame[number_of_frames - 2 ] = on_stack_size(sender(youngest)) 416 // frame[number_of_frames - 2 ] = on_stack_size(sender(youngest))
393 // frame[number_of_frames - 3 ] = on_stack_size(sender(sender(youngest))) 417 // 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, 418 int caller_parms = callee_parameters;
419 if (index == array->frames() - 1) {
420 // Use the value from the interpreted caller
421 caller_parms = caller_actual_parameters;
422 }
423 frame_sizes[number_of_frames - 1 - index] = BytesPerWord * array->element(index)->on_stack_size(caller_parms,
424 callee_parameters,
395 callee_locals, 425 callee_locals,
396 index == 0, 426 index == 0,
397 popframe_extra_args); 427 popframe_extra_args);
398 // This pc doesn't have to be perfect just good enough to identify the frame 428 // 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 429 // as interpreted so the skeleton frame will be walkable
416 } 446 }
417 447
418 // Compute information for handling adapters and adjusting the frame size of the caller. 448 // Compute information for handling adapters and adjusting the frame size of the caller.
419 int caller_adjustment = 0; 449 int caller_adjustment = 0;
420 450
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 // It's possible that the number of paramters at the call site is
429 // different than number of arguments in the callee when method
430 // handles are used. If the caller is interpreted get the real
431 // value so that the proper amount of space can be added to it's
432 // frame.
433 int sender_callee_parameters = callee_parameters;
434 if (deopt_sender.is_interpreted_frame()) {
435 methodHandle method = deopt_sender.interpreter_frame_method();
436 Bytecode_invoke cur = Bytecode_invoke_check(method,
437 deopt_sender.interpreter_frame_bci());
438 Symbol* signature = method->constants()->signature_ref_at(cur.index());
439 ArgumentSizeComputer asc(signature);
440 sender_callee_parameters = asc.size() + (cur.has_receiver() ? 1 : 0);
441 }
442
443 // Compute the amount the oldest interpreter frame will have to adjust 451 // Compute the amount the oldest interpreter frame will have to adjust
444 // its caller's stack by. If the caller is a compiled frame then 452 // its caller's stack by. If the caller is a compiled frame then
445 // we pretend that the callee has no parameters so that the 453 // we pretend that the callee has no parameters so that the
446 // extension counts for the full amount of locals and not just 454 // extension counts for the full amount of locals and not just
447 // locals-parms. This is because without a c2i adapter the parm 455 // locals-parms. This is because without a c2i adapter the parm
452 // QQQ I'd rather see this pushed down into last_frame_adjust 460 // QQQ I'd rather see this pushed down into last_frame_adjust
453 // and have it take the sender (aka caller). 461 // and have it take the sender (aka caller).
454 462
455 if (deopt_sender.is_compiled_frame()) { 463 if (deopt_sender.is_compiled_frame()) {
456 caller_adjustment = last_frame_adjust(0, callee_locals); 464 caller_adjustment = last_frame_adjust(0, callee_locals);
457 } else if (callee_locals > sender_callee_parameters) { 465 } else if (callee_locals > caller_actual_parameters) {
458 // The caller frame may need extending to accommodate 466 // The caller frame may need extending to accommodate
459 // non-parameter locals of the first unpacked interpreted frame. 467 // non-parameter locals of the first unpacked interpreted frame.
460 // Compute that adjustment. 468 // Compute that adjustment.
461 caller_adjustment = last_frame_adjust(sender_callee_parameters, callee_locals); 469 caller_adjustment = last_frame_adjust(caller_actual_parameters, callee_locals);
462 } 470 }
463 471
464 // If the sender is deoptimized the we must retrieve the address of the handler 472 // If the sender is deoptimized the we must retrieve the address of the handler
465 // since the frame will "magically" show the original pc before the deopt 473 // since the frame will "magically" show the original pc before the deopt
466 // and we'd undo the deopt. 474 // and we'd undo the deopt.
471 assert(CodeCache::find_blob_unsafe(frame_pcs[0]) != NULL, "bad pc"); 479 assert(CodeCache::find_blob_unsafe(frame_pcs[0]) != NULL, "bad pc");
472 #endif // SHARK 480 #endif // SHARK
473 481
474 UnrollBlock* info = new UnrollBlock(array->frame_size() * BytesPerWord, 482 UnrollBlock* info = new UnrollBlock(array->frame_size() * BytesPerWord,
475 caller_adjustment * BytesPerWord, 483 caller_adjustment * BytesPerWord,
484 caller_actual_parameters,
476 number_of_frames, 485 number_of_frames,
477 frame_sizes, 486 frame_sizes,
478 frame_pcs, 487 frame_pcs,
479 return_type); 488 return_type);
480 // On some platforms, we need a way to pass fp to the unpacking code 489 // On some platforms, we need a way to pass fp to the unpacking code
568 #endif 577 #endif
569 578
570 UnrollBlock* info = array->unroll_block(); 579 UnrollBlock* info = array->unroll_block();
571 580
572 // Unpack the interpreter frames and any adapter frame (c2 only) we might create. 581 // Unpack the interpreter frames and any adapter frame (c2 only) we might create.
573 array->unpack_to_stack(stub_frame, exec_mode); 582 array->unpack_to_stack(stub_frame, exec_mode, info->caller_actual_parameters());
574 583
575 BasicType bt = info->return_type(); 584 BasicType bt = info->return_type();
576 585
577 // If we have an exception pending, claim that the return type is an oop 586 // If we have an exception pending, claim that the return type is an oop
578 // so the deopt_blob does not overwrite the exception_oop. 587 // so the deopt_blob does not overwrite the exception_oop.