src/share/vm/runtime/deoptimization.cpp

changeset 2868
2e038ad0c1d0
parent 2620
4f148718983e
child 2877
bad7ecd0b6ed
     1.1 --- a/src/share/vm/runtime/deoptimization.cpp	Mon May 02 10:51:36 2011 -0700
     1.2 +++ b/src/share/vm/runtime/deoptimization.cpp	Mon May 02 18:53:37 2011 -0700
     1.3 @@ -189,6 +189,10 @@
     1.4    assert(thread->deopt_nmethod() == NULL, "Pending deopt!");
     1.5    thread->set_deopt_nmethod(deoptee.cb()->as_nmethod_or_null());
     1.6  
     1.7 +  if (VerifyStack) {
     1.8 +    thread->validate_frame_layout();
     1.9 +  }
    1.10 +
    1.11    // Create a growable array of VFrames where each VFrame represents an inlined
    1.12    // Java frame.  This storage is allocated with the usual system arena.
    1.13    assert(deoptee.is_compiled_frame(), "Wrong frame type");
    1.14 @@ -421,6 +425,21 @@
    1.15    frame deopt_sender = stub_frame.sender(&dummy_map); // First is the deoptee frame
    1.16    deopt_sender = deopt_sender.sender(&dummy_map);     // Now deoptee caller
    1.17  
    1.18 +  // It's possible that the number of paramters at the call site is
    1.19 +  // different than number of arguments in the callee when method
    1.20 +  // handles are used.  If the caller is interpreted get the real
    1.21 +  // value so that the proper amount of space can be added to it's
    1.22 +  // frame.
    1.23 +  int sender_callee_parameters = callee_parameters;
    1.24 +  if (deopt_sender.is_interpreted_frame()) {
    1.25 +    methodHandle method = deopt_sender.interpreter_frame_method();
    1.26 +    Bytecode_invoke cur = Bytecode_invoke_check(method,
    1.27 +                                                deopt_sender.interpreter_frame_bci());
    1.28 +    Symbol* signature = method->constants()->signature_ref_at(cur.index());
    1.29 +    ArgumentSizeComputer asc(signature);
    1.30 +    sender_callee_parameters = asc.size() + cur.has_receiver() ? 1 : 0;
    1.31 +  }
    1.32 +
    1.33    // Compute the amount the oldest interpreter frame will have to adjust
    1.34    // its caller's stack by. If the caller is a compiled frame then
    1.35    // we pretend that the callee has no parameters so that the
    1.36 @@ -435,14 +454,13 @@
    1.37  
    1.38    if (deopt_sender.is_compiled_frame()) {
    1.39      caller_adjustment = last_frame_adjust(0, callee_locals);
    1.40 -  } else if (callee_locals > callee_parameters) {
    1.41 +  } else if (callee_locals > sender_callee_parameters) {
    1.42      // The caller frame may need extending to accommodate
    1.43      // non-parameter locals of the first unpacked interpreted frame.
    1.44      // Compute that adjustment.
    1.45 -    caller_adjustment = last_frame_adjust(callee_parameters, callee_locals);
    1.46 +    caller_adjustment = last_frame_adjust(sender_callee_parameters, callee_locals);
    1.47    }
    1.48  
    1.49 -
    1.50    // If the sender is deoptimized the we must retrieve the address of the handler
    1.51    // since the frame will "magically" show the original pc before the deopt
    1.52    // and we'd undo the deopt.
    1.53 @@ -569,6 +587,8 @@
    1.54    if (VerifyStack) {
    1.55      ResourceMark res_mark;
    1.56  
    1.57 +    thread->validate_frame_layout();
    1.58 +
    1.59      // Verify that the just-unpacked frames match the interpreter's
    1.60      // notions of expression stack and locals
    1.61      vframeArray* cur_array = thread->vframe_array_last();

mercurial