1.1 --- a/src/share/vm/runtime/deoptimization.cpp Mon May 09 19:45:52 2011 -0700 1.2 +++ b/src/share/vm/runtime/deoptimization.cpp Thu May 12 10:29:02 2011 -0700 1.3 @@ -90,12 +90,14 @@ 1.4 1.5 Deoptimization::UnrollBlock::UnrollBlock(int size_of_deoptimized_frame, 1.6 int caller_adjustment, 1.7 + int caller_actual_parameters, 1.8 int number_of_frames, 1.9 intptr_t* frame_sizes, 1.10 address* frame_pcs, 1.11 BasicType return_type) { 1.12 _size_of_deoptimized_frame = size_of_deoptimized_frame; 1.13 _caller_adjustment = caller_adjustment; 1.14 + _caller_actual_parameters = caller_actual_parameters; 1.15 _number_of_frames = number_of_frames; 1.16 _frame_sizes = frame_sizes; 1.17 _frame_pcs = frame_pcs; 1.18 @@ -373,6 +375,28 @@ 1.19 popframe_extra_args = in_words(thread->popframe_preserved_args_size_in_words()); 1.20 } 1.21 1.22 + // Find the current pc for sender of the deoptee. Since the sender may have been deoptimized 1.23 + // itself since the deoptee vframeArray was created we must get a fresh value of the pc rather 1.24 + // than simply use array->sender.pc(). This requires us to walk the current set of frames 1.25 + // 1.26 + frame deopt_sender = stub_frame.sender(&dummy_map); // First is the deoptee frame 1.27 + deopt_sender = deopt_sender.sender(&dummy_map); // Now deoptee caller 1.28 + 1.29 + // It's possible that the number of paramters at the call site is 1.30 + // different than number of arguments in the callee when method 1.31 + // handles are used. If the caller is interpreted get the real 1.32 + // value so that the proper amount of space can be added to it's 1.33 + // frame. 1.34 + int caller_actual_parameters = callee_parameters; 1.35 + if (deopt_sender.is_interpreted_frame()) { 1.36 + methodHandle method = deopt_sender.interpreter_frame_method(); 1.37 + Bytecode_invoke cur = Bytecode_invoke_check(method, 1.38 + deopt_sender.interpreter_frame_bci()); 1.39 + Symbol* signature = method->constants()->signature_ref_at(cur.index()); 1.40 + ArgumentSizeComputer asc(signature); 1.41 + caller_actual_parameters = asc.size() + (cur.has_receiver() ? 1 : 0); 1.42 + } 1.43 + 1.44 // 1.45 // frame_sizes/frame_pcs[0] oldest frame (int or c2i) 1.46 // frame_sizes/frame_pcs[1] next oldest frame (int) 1.47 @@ -391,7 +415,13 @@ 1.48 // frame[number_of_frames - 1 ] = on_stack_size(youngest) 1.49 // frame[number_of_frames - 2 ] = on_stack_size(sender(youngest)) 1.50 // frame[number_of_frames - 3 ] = on_stack_size(sender(sender(youngest))) 1.51 - frame_sizes[number_of_frames - 1 - index] = BytesPerWord * array->element(index)->on_stack_size(callee_parameters, 1.52 + int caller_parms = callee_parameters; 1.53 + if (index == array->frames() - 1) { 1.54 + // Use the value from the interpreted caller 1.55 + caller_parms = caller_actual_parameters; 1.56 + } 1.57 + frame_sizes[number_of_frames - 1 - index] = BytesPerWord * array->element(index)->on_stack_size(caller_parms, 1.58 + callee_parameters, 1.59 callee_locals, 1.60 index == 0, 1.61 popframe_extra_args); 1.62 @@ -418,28 +448,6 @@ 1.63 // Compute information for handling adapters and adjusting the frame size of the caller. 1.64 int caller_adjustment = 0; 1.65 1.66 - // Find the current pc for sender of the deoptee. Since the sender may have been deoptimized 1.67 - // itself since the deoptee vframeArray was created we must get a fresh value of the pc rather 1.68 - // than simply use array->sender.pc(). This requires us to walk the current set of frames 1.69 - // 1.70 - frame deopt_sender = stub_frame.sender(&dummy_map); // First is the deoptee frame 1.71 - deopt_sender = deopt_sender.sender(&dummy_map); // Now deoptee caller 1.72 - 1.73 - // It's possible that the number of paramters at the call site is 1.74 - // different than number of arguments in the callee when method 1.75 - // handles are used. If the caller is interpreted get the real 1.76 - // value so that the proper amount of space can be added to it's 1.77 - // frame. 1.78 - int sender_callee_parameters = callee_parameters; 1.79 - if (deopt_sender.is_interpreted_frame()) { 1.80 - methodHandle method = deopt_sender.interpreter_frame_method(); 1.81 - Bytecode_invoke cur = Bytecode_invoke_check(method, 1.82 - deopt_sender.interpreter_frame_bci()); 1.83 - Symbol* signature = method->constants()->signature_ref_at(cur.index()); 1.84 - ArgumentSizeComputer asc(signature); 1.85 - sender_callee_parameters = asc.size() + (cur.has_receiver() ? 1 : 0); 1.86 - } 1.87 - 1.88 // Compute the amount the oldest interpreter frame will have to adjust 1.89 // its caller's stack by. If the caller is a compiled frame then 1.90 // we pretend that the callee has no parameters so that the 1.91 @@ -454,11 +462,11 @@ 1.92 1.93 if (deopt_sender.is_compiled_frame()) { 1.94 caller_adjustment = last_frame_adjust(0, callee_locals); 1.95 - } else if (callee_locals > sender_callee_parameters) { 1.96 + } else if (callee_locals > caller_actual_parameters) { 1.97 // The caller frame may need extending to accommodate 1.98 // non-parameter locals of the first unpacked interpreted frame. 1.99 // Compute that adjustment. 1.100 - caller_adjustment = last_frame_adjust(sender_callee_parameters, callee_locals); 1.101 + caller_adjustment = last_frame_adjust(caller_actual_parameters, callee_locals); 1.102 } 1.103 1.104 // If the sender is deoptimized the we must retrieve the address of the handler 1.105 @@ -473,6 +481,7 @@ 1.106 1.107 UnrollBlock* info = new UnrollBlock(array->frame_size() * BytesPerWord, 1.108 caller_adjustment * BytesPerWord, 1.109 + caller_actual_parameters, 1.110 number_of_frames, 1.111 frame_sizes, 1.112 frame_pcs, 1.113 @@ -570,7 +579,7 @@ 1.114 UnrollBlock* info = array->unroll_block(); 1.115 1.116 // Unpack the interpreter frames and any adapter frame (c2 only) we might create. 1.117 - array->unpack_to_stack(stub_frame, exec_mode); 1.118 + array->unpack_to_stack(stub_frame, exec_mode, info->caller_actual_parameters()); 1.119 1.120 BasicType bt = info->return_type(); 1.121