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