--- old/src/share/vm/opto/callnode.cpp 2014-03-20 11:29:01.601234408 +0100 +++ new/src/share/vm/opto/callnode.cpp 2014-03-20 11:29:01.056180720 +0100 @@ -607,6 +607,45 @@ } } +// Mirror the stack size calculation in the deopt code +// How much stack space would we need at this point in the program in +// case of deoptimization? +int JVMState::interpreter_frame_size() const { + const JVMState* jvms = this; + int size = 0; + int callee_parameters = 0; + int callee_locals = 0; + int popframe_extra_args = 0; + + if (JvmtiExport::can_pop_frame()) { + ciMethod* method = this->method(); + int bci = this->bci(); + popframe_extra_args = MAX2(-method->get_stack_effect_if_at_invoke(bci), 0); + } + + while (jvms != NULL) { + int locks = jvms->nof_monitors(); + int temps = jvms->stk_size(); + bool is_top_frame = (jvms->caller() == NULL); + ciMethod* method = jvms->method(); + + int frame_size = BytesPerWord * Interpreter::size_activation(method->max_stack(), + temps + callee_parameters, + popframe_extra_args, + locks, + callee_parameters, + callee_locals, + is_top_frame); + size += frame_size; + + callee_parameters = method->size_of_parameters(); + callee_locals = method->max_locals(); + popframe_extra_args = 0; + jvms = jvms->caller(); + } + return size + Deoptimization::last_frame_adjust(0, callee_locals) * BytesPerWord; +} + //============================================================================= uint CallNode::cmp( const Node &n ) const { return _tf == ((CallNode&)n)._tf && _jvms == ((CallNode&)n)._jvms; }