src/cpu/x86/vm/templateInterpreter_x86_32.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/cpu/x86/vm

src/cpu/x86/vm/templateInterpreter_x86_32.cpp

Print this page
rev 6086 : 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
Summary: make compiled code bang the stack by the worst case size of the interpreter frame at deoptimization points.
Reviewed-by:


1669 }
1670 
1671 // How much stack a method activation needs in words.
1672 int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
1673 
1674   const int stub_code = 4;  // see generate_call_stub
1675   // Save space for one monitor to get into the interpreted method in case
1676   // the method is synchronized
1677   int monitor_size    = method->is_synchronized() ?
1678                                 1*frame::interpreter_frame_monitor_size() : 0;
1679 
1680   // total overhead size: entry_size + (saved rbp, thru expr stack bottom).
1681   // be sure to change this if you add/subtract anything to/from the overhead area
1682   const int overhead_size = -frame::interpreter_frame_initial_sp_offset;
1683 
1684   const int method_stack = (method->max_locals() + method->max_stack()) *
1685                            Interpreter::stackElementWords;
1686   return overhead_size + method_stack + stub_code;
1687 }
1688 
1689 // asm based interpreter deoptimization helpers
1690 
1691 int AbstractInterpreter::layout_activation(Method* method,
1692                                            int tempcount,
1693                                            int popframe_extra_args,
1694                                            int moncount,
1695                                            int caller_actual_parameters,
1696                                            int callee_param_count,
1697                                            int callee_locals,
1698                                            frame* caller,
1699                                            frame* interpreter_frame,
1700                                            bool is_top_frame,
1701                                            bool is_bottom_frame) {
1702   // Note: This calculation must exactly parallel the frame setup
1703   // in AbstractInterpreterGenerator::generate_method_entry.
1704   // If interpreter_frame!=NULL, set up the method, locals, and monitors.
1705   // The frame interpreter_frame, if not NULL, is guaranteed to be the right size,
1706   // as determined by a previous call to this method.
1707   // It is also guaranteed to be walkable even though it is in a skeletal state
1708   // NOTE: return size is in words not bytes
1709 
1710   // fixed size of an interpreter frame:
1711   int max_locals = method->max_locals() * Interpreter::stackElementWords;
1712   int extra_locals = (method->max_locals() - method->size_of_parameters()) *
1713                      Interpreter::stackElementWords;
1714 
1715   int overhead = frame::sender_sp_offset - frame::interpreter_frame_initial_sp_offset;
1716 
1717   // Our locals were accounted for by the caller (or last_frame_adjust on the transistion)
1718   // Since the callee parameters already account for the callee's params we only need to account for
1719   // the extra locals.
1720 
1721 
1722   int size = overhead +
1723          ((callee_locals - callee_param_count)*Interpreter::stackElementWords) +
1724          (moncount*frame::interpreter_frame_monitor_size()) +
1725          tempcount*Interpreter::stackElementWords + popframe_extra_args;
1726 
1727   if (interpreter_frame != NULL) {
1728 #ifdef ASSERT
1729     if (!EnableInvokeDynamic)
1730       // @@@ FIXME: Should we correct interpreter_frame_sender_sp in the calling sequences?
1731       // Probably, since deoptimization doesn't work yet.
1732       assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable");
1733     assert(caller->sp() == interpreter_frame->sender_sp(), "Frame not properly walkable(2)");
1734 #endif
1735 
1736     interpreter_frame->interpreter_frame_set_method(method);
1737     // NOTE the difference in using sender_sp and interpreter_frame_sender_sp
1738     // interpreter_frame_sender_sp is the original sp of the caller (the unextended_sp)
1739     // and sender_sp is fp+8
1740     intptr_t* locals = interpreter_frame->sender_sp() + max_locals - 1;
1741 
1742 #ifdef ASSERT
1743     if (caller->is_interpreted_frame()) {
1744       assert(locals < caller->fp() + frame::interpreter_frame_initial_sp_offset, "bad placement");
1745     }
1746 #endif
1747 
1748     interpreter_frame->interpreter_frame_set_locals(locals);
1749     BasicObjectLock* montop = interpreter_frame->interpreter_frame_monitor_begin();
1750     BasicObjectLock* monbot = montop - moncount;
1751     interpreter_frame->interpreter_frame_set_monitor_end(monbot);
1752 
1753     // Set last_sp
1754     intptr_t*  rsp = (intptr_t*) monbot  -
1755                      tempcount*Interpreter::stackElementWords -
1756                      popframe_extra_args;
1757     interpreter_frame->interpreter_frame_set_last_sp(rsp);
1758 
1759     // All frames but the initial (oldest) interpreter frame we fill in have a
1760     // value for sender_sp that allows walking the stack but isn't
1761     // truly correct. Correct the value here.
1762 
1763     if (extra_locals != 0 &&
1764         interpreter_frame->sender_sp() == interpreter_frame->interpreter_frame_sender_sp() ) {
1765       interpreter_frame->set_interpreter_frame_sender_sp(caller->sp() + extra_locals);
1766     }
1767     *interpreter_frame->interpreter_frame_cache_addr() =
1768       method->constants()->cache();
1769   }
1770   return size;
1771 }
1772 
1773 
1774 //------------------------------------------------------------------------------------------------------------------------
1775 // Exceptions
1776 
1777 void TemplateInterpreterGenerator::generate_throw_exception() {
1778   // Entry point in previous activation (i.e., if the caller was interpreted)
1779   Interpreter::_rethrow_exception_entry = __ pc();
1780   const Register thread = rcx;
1781 
1782   // Restore sp to interpreter_frame_last_sp even though we are going
1783   // to empty the expression stack for the exception processing.
1784   __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), NULL_WORD);
1785   // rax,: exception
1786   // rdx: return address/pc that threw exception
1787   __ restore_bcp();                              // rsi points to call/send
1788   __ restore_locals();
1789 
1790   // Entry point for exceptions thrown within interpreter code
1791   Interpreter::_throw_exception_entry = __ pc();
1792   // expression stack is undefined here
1793   // rax,: exception




1669 }
1670 
1671 // How much stack a method activation needs in words.
1672 int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
1673 
1674   const int stub_code = 4;  // see generate_call_stub
1675   // Save space for one monitor to get into the interpreted method in case
1676   // the method is synchronized
1677   int monitor_size    = method->is_synchronized() ?
1678                                 1*frame::interpreter_frame_monitor_size() : 0;
1679 
1680   // total overhead size: entry_size + (saved rbp, thru expr stack bottom).
1681   // be sure to change this if you add/subtract anything to/from the overhead area
1682   const int overhead_size = -frame::interpreter_frame_initial_sp_offset;
1683 
1684   const int method_stack = (method->max_locals() + method->max_stack()) *
1685                            Interpreter::stackElementWords;
1686   return overhead_size + method_stack + stub_code;
1687 }
1688 





















































































1689 //------------------------------------------------------------------------------------------------------------------------
1690 // Exceptions
1691 
1692 void TemplateInterpreterGenerator::generate_throw_exception() {
1693   // Entry point in previous activation (i.e., if the caller was interpreted)
1694   Interpreter::_rethrow_exception_entry = __ pc();
1695   const Register thread = rcx;
1696 
1697   // Restore sp to interpreter_frame_last_sp even though we are going
1698   // to empty the expression stack for the exception processing.
1699   __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), NULL_WORD);
1700   // rax,: exception
1701   // rdx: return address/pc that threw exception
1702   __ restore_bcp();                              // rsi points to call/send
1703   __ restore_locals();
1704 
1705   // Entry point for exceptions thrown within interpreter code
1706   Interpreter::_throw_exception_entry = __ pc();
1707   // expression stack is undefined here
1708   // rax,: exception


src/cpu/x86/vm/templateInterpreter_x86_32.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File