Mercurial > hg > graal-compiler
comparison src/cpu/sparc/vm/templateInterpreter_sparc.cpp @ 17980:0bf37f737702
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: twisti, kvn
author | roland |
---|---|
date | Tue, 01 Apr 2014 09:36:49 +0200 |
parents | 2100bf712e2a |
children | 52b4284cb496 |
comparison
equal
deleted
inserted
replaced
17978:ad51f24671c2 | 17980:0bf37f737702 |
---|---|
1562 // Save space for one monitor to get into the interpreted method in case | 1562 // Save space for one monitor to get into the interpreted method in case |
1563 // the method is synchronized | 1563 // the method is synchronized |
1564 int monitor_size = method->is_synchronized() ? | 1564 int monitor_size = method->is_synchronized() ? |
1565 1*frame::interpreter_frame_monitor_size() : 0; | 1565 1*frame::interpreter_frame_monitor_size() : 0; |
1566 return size_activation_helper(method->max_locals(), method->max_stack(), | 1566 return size_activation_helper(method->max_locals(), method->max_stack(), |
1567 monitor_size) + call_stub_size; | 1567 monitor_size) + call_stub_size; |
1568 } | 1568 } |
1569 | 1569 |
1570 int AbstractInterpreter::layout_activation(Method* method, | 1570 int AbstractInterpreter::size_activation(int max_stack, |
1571 int tempcount, | 1571 int temps, |
1572 int popframe_extra_args, | 1572 int extra_args, |
1573 int moncount, | 1573 int monitors, |
1574 int caller_actual_parameters, | 1574 int callee_params, |
1575 int callee_param_count, | 1575 int callee_locals, |
1576 int callee_local_count, | 1576 bool is_top_frame) { |
1577 frame* caller, | |
1578 frame* interpreter_frame, | |
1579 bool is_top_frame, | |
1580 bool is_bottom_frame) { | |
1581 // Note: This calculation must exactly parallel the frame setup | 1577 // Note: This calculation must exactly parallel the frame setup |
1582 // in InterpreterGenerator::generate_fixed_frame. | 1578 // in InterpreterGenerator::generate_fixed_frame. |
1583 // If f!=NULL, set up the following variables: | 1579 |
1584 // - Lmethod | 1580 int monitor_size = monitors * frame::interpreter_frame_monitor_size(); |
1585 // - Llocals | |
1586 // - Lmonitors (to the indicated number of monitors) | |
1587 // - Lesp (to the indicated number of temps) | |
1588 // The frame f (if not NULL) on entry is a description of the caller of the frame | |
1589 // we are about to layout. We are guaranteed that we will be able to fill in a | |
1590 // new interpreter frame as its callee (i.e. the stack space is allocated and | |
1591 // the amount was determined by an earlier call to this method with f == NULL). | |
1592 // On return f (if not NULL) while describe the interpreter frame we just layed out. | |
1593 | |
1594 int monitor_size = moncount * frame::interpreter_frame_monitor_size(); | |
1595 int rounded_vm_local_words = round_to(frame::interpreter_frame_vm_local_words,WordsPerLong); | |
1596 | 1581 |
1597 assert(monitor_size == round_to(monitor_size, WordsPerLong), "must align"); | 1582 assert(monitor_size == round_to(monitor_size, WordsPerLong), "must align"); |
1583 | |
1598 // | 1584 // |
1599 // Note: if you look closely this appears to be doing something much different | 1585 // Note: if you look closely this appears to be doing something much different |
1600 // than generate_fixed_frame. What is happening is this. On sparc we have to do | 1586 // than generate_fixed_frame. What is happening is this. On sparc we have to do |
1601 // this dance with interpreter_sp_adjustment because the window save area would | 1587 // this dance with interpreter_sp_adjustment because the window save area would |
1602 // appear just below the bottom (tos) of the caller's java expression stack. Because | 1588 // appear just below the bottom (tos) of the caller's java expression stack. Because |
1617 // this code aware of what the interactions are when that initial caller fram was an osr or | 1603 // this code aware of what the interactions are when that initial caller fram was an osr or |
1618 // other adapter frame. deoptimization is complicated enough and hard enough to debug that | 1604 // other adapter frame. deoptimization is complicated enough and hard enough to debug that |
1619 // there is no sense in messing working code. | 1605 // there is no sense in messing working code. |
1620 // | 1606 // |
1621 | 1607 |
1622 int rounded_cls = round_to((callee_local_count - callee_param_count), WordsPerLong); | 1608 int rounded_cls = round_to((callee_locals - callee_params), WordsPerLong); |
1623 assert(rounded_cls == round_to(rounded_cls, WordsPerLong), "must align"); | 1609 assert(rounded_cls == round_to(rounded_cls, WordsPerLong), "must align"); |
1624 | 1610 |
1625 int raw_frame_size = size_activation_helper(rounded_cls, method->max_stack(), | 1611 int raw_frame_size = size_activation_helper(rounded_cls, max_stack, monitor_size); |
1626 monitor_size); | 1612 |
1627 | 1613 return raw_frame_size; |
1628 if (interpreter_frame != NULL) { | 1614 } |
1629 // The skeleton frame must already look like an interpreter frame | 1615 |
1630 // even if not fully filled out. | 1616 void AbstractInterpreter::layout_activation(Method* method, |
1631 assert(interpreter_frame->is_interpreted_frame(), "Must be interpreted frame"); | 1617 int tempcount, |
1632 | 1618 int popframe_extra_args, |
1633 intptr_t* fp = interpreter_frame->fp(); | 1619 int moncount, |
1634 | 1620 int caller_actual_parameters, |
1635 JavaThread* thread = JavaThread::current(); | 1621 int callee_param_count, |
1636 RegisterMap map(thread, false); | 1622 int callee_local_count, |
1637 // More verification that skeleton frame is properly walkable | 1623 frame* caller, |
1638 assert(fp == caller->sp(), "fp must match"); | 1624 frame* interpreter_frame, |
1639 | 1625 bool is_top_frame, |
1640 intptr_t* montop = fp - rounded_vm_local_words; | 1626 bool is_bottom_frame) { |
1641 | 1627 // Set up the following variables: |
1642 // preallocate monitors (cf. __ add_monitor_to_stack) | 1628 // - Lmethod |
1643 intptr_t* monitors = montop - monitor_size; | 1629 // - Llocals |
1644 | 1630 // - Lmonitors (to the indicated number of monitors) |
1645 // preallocate stack space | 1631 // - Lesp (to the indicated number of temps) |
1646 intptr_t* esp = monitors - 1 - | 1632 // The frame caller on entry is a description of the caller of the |
1647 (tempcount * Interpreter::stackElementWords) - | 1633 // frame we are about to layout. We are guaranteed that we will be |
1648 popframe_extra_args; | 1634 // able to fill in a new interpreter frame as its callee (i.e. the |
1649 | 1635 // stack space is allocated and the amount was determined by an |
1650 int local_words = method->max_locals() * Interpreter::stackElementWords; | 1636 // earlier call to the size_activation() method). On return caller |
1651 NEEDS_CLEANUP; | 1637 // while describe the interpreter frame we just layed out. |
1652 intptr_t* locals; | 1638 |
1653 if (caller->is_interpreted_frame()) { | 1639 // The skeleton frame must already look like an interpreter frame |
1654 // Can force the locals area to end up properly overlapping the top of the expression stack. | 1640 // even if not fully filled out. |
1655 intptr_t* Lesp_ptr = caller->interpreter_frame_tos_address() - 1; | 1641 assert(interpreter_frame->is_interpreted_frame(), "Must be interpreted frame"); |
1656 // Note that this computation means we replace size_of_parameters() values from the caller | 1642 |
1657 // interpreter frame's expression stack with our argument locals | 1643 int rounded_vm_local_words = round_to(frame::interpreter_frame_vm_local_words,WordsPerLong); |
1658 int parm_words = caller_actual_parameters * Interpreter::stackElementWords; | 1644 int monitor_size = moncount * frame::interpreter_frame_monitor_size(); |
1659 locals = Lesp_ptr + parm_words; | 1645 assert(monitor_size == round_to(monitor_size, WordsPerLong), "must align"); |
1660 int delta = local_words - parm_words; | 1646 |
1661 int computed_sp_adjustment = (delta > 0) ? round_to(delta, WordsPerLong) : 0; | 1647 intptr_t* fp = interpreter_frame->fp(); |
1662 *interpreter_frame->register_addr(I5_savedSP) = (intptr_t) (fp + computed_sp_adjustment) - STACK_BIAS; | 1648 |
1663 if (!is_bottom_frame) { | 1649 JavaThread* thread = JavaThread::current(); |
1664 // Llast_SP is set below for the current frame to SP (with the | 1650 RegisterMap map(thread, false); |
1665 // extra space for the callee's locals). Here we adjust | 1651 // More verification that skeleton frame is properly walkable |
1666 // Llast_SP for the caller's frame, removing the extra space | 1652 assert(fp == caller->sp(), "fp must match"); |
1667 // for the current method's locals. | 1653 |
1668 *caller->register_addr(Llast_SP) = *interpreter_frame->register_addr(I5_savedSP); | 1654 intptr_t* montop = fp - rounded_vm_local_words; |
1669 } else { | 1655 |
1670 assert(*caller->register_addr(Llast_SP) >= *interpreter_frame->register_addr(I5_savedSP), "strange Llast_SP"); | 1656 // preallocate monitors (cf. __ add_monitor_to_stack) |
1671 } | 1657 intptr_t* monitors = montop - monitor_size; |
1658 | |
1659 // preallocate stack space | |
1660 intptr_t* esp = monitors - 1 - | |
1661 (tempcount * Interpreter::stackElementWords) - | |
1662 popframe_extra_args; | |
1663 | |
1664 int local_words = method->max_locals() * Interpreter::stackElementWords; | |
1665 NEEDS_CLEANUP; | |
1666 intptr_t* locals; | |
1667 if (caller->is_interpreted_frame()) { | |
1668 // Can force the locals area to end up properly overlapping the top of the expression stack. | |
1669 intptr_t* Lesp_ptr = caller->interpreter_frame_tos_address() - 1; | |
1670 // Note that this computation means we replace size_of_parameters() values from the caller | |
1671 // interpreter frame's expression stack with our argument locals | |
1672 int parm_words = caller_actual_parameters * Interpreter::stackElementWords; | |
1673 locals = Lesp_ptr + parm_words; | |
1674 int delta = local_words - parm_words; | |
1675 int computed_sp_adjustment = (delta > 0) ? round_to(delta, WordsPerLong) : 0; | |
1676 *interpreter_frame->register_addr(I5_savedSP) = (intptr_t) (fp + computed_sp_adjustment) - STACK_BIAS; | |
1677 if (!is_bottom_frame) { | |
1678 // Llast_SP is set below for the current frame to SP (with the | |
1679 // extra space for the callee's locals). Here we adjust | |
1680 // Llast_SP for the caller's frame, removing the extra space | |
1681 // for the current method's locals. | |
1682 *caller->register_addr(Llast_SP) = *interpreter_frame->register_addr(I5_savedSP); | |
1672 } else { | 1683 } else { |
1673 assert(caller->is_compiled_frame() || caller->is_entry_frame(), "only possible cases"); | 1684 assert(*caller->register_addr(Llast_SP) >= *interpreter_frame->register_addr(I5_savedSP), "strange Llast_SP"); |
1674 // Don't have Lesp available; lay out locals block in the caller | 1685 } |
1675 // adjacent to the register window save area. | 1686 } else { |
1676 // | 1687 assert(caller->is_compiled_frame() || caller->is_entry_frame(), "only possible cases"); |
1677 // Compiled frames do not allocate a varargs area which is why this if | 1688 // Don't have Lesp available; lay out locals block in the caller |
1678 // statement is needed. | 1689 // adjacent to the register window save area. |
1679 // | 1690 // |
1680 if (caller->is_compiled_frame()) { | 1691 // Compiled frames do not allocate a varargs area which is why this if |
1681 locals = fp + frame::register_save_words + local_words - 1; | 1692 // statement is needed. |
1682 } else { | 1693 // |
1683 locals = fp + frame::memory_parameter_word_sp_offset + local_words - 1; | 1694 if (caller->is_compiled_frame()) { |
1684 } | 1695 locals = fp + frame::register_save_words + local_words - 1; |
1685 if (!caller->is_entry_frame()) { | 1696 } else { |
1686 // Caller wants his own SP back | 1697 locals = fp + frame::memory_parameter_word_sp_offset + local_words - 1; |
1687 int caller_frame_size = caller->cb()->frame_size(); | 1698 } |
1688 *interpreter_frame->register_addr(I5_savedSP) = (intptr_t)(caller->fp() - caller_frame_size) - STACK_BIAS; | 1699 if (!caller->is_entry_frame()) { |
1700 // Caller wants his own SP back | |
1701 int caller_frame_size = caller->cb()->frame_size(); | |
1702 *interpreter_frame->register_addr(I5_savedSP) = (intptr_t)(caller->fp() - caller_frame_size) - STACK_BIAS; | |
1703 } | |
1704 } | |
1705 if (TraceDeoptimization) { | |
1706 if (caller->is_entry_frame()) { | |
1707 // make sure I5_savedSP and the entry frames notion of saved SP | |
1708 // agree. This assertion duplicate a check in entry frame code | |
1709 // but catches the failure earlier. | |
1710 assert(*caller->register_addr(Lscratch) == *interpreter_frame->register_addr(I5_savedSP), | |
1711 "would change callers SP"); | |
1712 } | |
1713 if (caller->is_entry_frame()) { | |
1714 tty->print("entry "); | |
1715 } | |
1716 if (caller->is_compiled_frame()) { | |
1717 tty->print("compiled "); | |
1718 if (caller->is_deoptimized_frame()) { | |
1719 tty->print("(deopt) "); | |
1689 } | 1720 } |
1690 } | 1721 } |
1691 if (TraceDeoptimization) { | 1722 if (caller->is_interpreted_frame()) { |
1692 if (caller->is_entry_frame()) { | 1723 tty->print("interpreted "); |
1693 // make sure I5_savedSP and the entry frames notion of saved SP | |
1694 // agree. This assertion duplicate a check in entry frame code | |
1695 // but catches the failure earlier. | |
1696 assert(*caller->register_addr(Lscratch) == *interpreter_frame->register_addr(I5_savedSP), | |
1697 "would change callers SP"); | |
1698 } | |
1699 if (caller->is_entry_frame()) { | |
1700 tty->print("entry "); | |
1701 } | |
1702 if (caller->is_compiled_frame()) { | |
1703 tty->print("compiled "); | |
1704 if (caller->is_deoptimized_frame()) { | |
1705 tty->print("(deopt) "); | |
1706 } | |
1707 } | |
1708 if (caller->is_interpreted_frame()) { | |
1709 tty->print("interpreted "); | |
1710 } | |
1711 tty->print_cr("caller fp=0x%x sp=0x%x", caller->fp(), caller->sp()); | |
1712 tty->print_cr("save area = 0x%x, 0x%x", caller->sp(), caller->sp() + 16); | |
1713 tty->print_cr("save area = 0x%x, 0x%x", caller->fp(), caller->fp() + 16); | |
1714 tty->print_cr("interpreter fp=0x%x sp=0x%x", interpreter_frame->fp(), interpreter_frame->sp()); | |
1715 tty->print_cr("save area = 0x%x, 0x%x", interpreter_frame->sp(), interpreter_frame->sp() + 16); | |
1716 tty->print_cr("save area = 0x%x, 0x%x", interpreter_frame->fp(), interpreter_frame->fp() + 16); | |
1717 tty->print_cr("Llocals = 0x%x", locals); | |
1718 tty->print_cr("Lesp = 0x%x", esp); | |
1719 tty->print_cr("Lmonitors = 0x%x", monitors); | |
1720 } | 1724 } |
1721 | 1725 tty->print_cr("caller fp=0x%x sp=0x%x", caller->fp(), caller->sp()); |
1722 if (method->max_locals() > 0) { | 1726 tty->print_cr("save area = 0x%x, 0x%x", caller->sp(), caller->sp() + 16); |
1723 assert(locals < caller->sp() || locals >= (caller->sp() + 16), "locals in save area"); | 1727 tty->print_cr("save area = 0x%x, 0x%x", caller->fp(), caller->fp() + 16); |
1724 assert(locals < caller->fp() || locals > (caller->fp() + 16), "locals in save area"); | 1728 tty->print_cr("interpreter fp=0x%x sp=0x%x", interpreter_frame->fp(), interpreter_frame->sp()); |
1725 assert(locals < interpreter_frame->sp() || locals > (interpreter_frame->sp() + 16), "locals in save area"); | 1729 tty->print_cr("save area = 0x%x, 0x%x", interpreter_frame->sp(), interpreter_frame->sp() + 16); |
1726 assert(locals < interpreter_frame->fp() || locals >= (interpreter_frame->fp() + 16), "locals in save area"); | 1730 tty->print_cr("save area = 0x%x, 0x%x", interpreter_frame->fp(), interpreter_frame->fp() + 16); |
1727 } | 1731 tty->print_cr("Llocals = 0x%x", locals); |
1732 tty->print_cr("Lesp = 0x%x", esp); | |
1733 tty->print_cr("Lmonitors = 0x%x", monitors); | |
1734 } | |
1735 | |
1736 if (method->max_locals() > 0) { | |
1737 assert(locals < caller->sp() || locals >= (caller->sp() + 16), "locals in save area"); | |
1738 assert(locals < caller->fp() || locals > (caller->fp() + 16), "locals in save area"); | |
1739 assert(locals < interpreter_frame->sp() || locals > (interpreter_frame->sp() + 16), "locals in save area"); | |
1740 assert(locals < interpreter_frame->fp() || locals >= (interpreter_frame->fp() + 16), "locals in save area"); | |
1741 } | |
1728 #ifdef _LP64 | 1742 #ifdef _LP64 |
1729 assert(*interpreter_frame->register_addr(I5_savedSP) & 1, "must be odd"); | 1743 assert(*interpreter_frame->register_addr(I5_savedSP) & 1, "must be odd"); |
1730 #endif | 1744 #endif |
1731 | 1745 |
1732 *interpreter_frame->register_addr(Lmethod) = (intptr_t) method; | 1746 *interpreter_frame->register_addr(Lmethod) = (intptr_t) method; |
1733 *interpreter_frame->register_addr(Llocals) = (intptr_t) locals; | 1747 *interpreter_frame->register_addr(Llocals) = (intptr_t) locals; |
1734 *interpreter_frame->register_addr(Lmonitors) = (intptr_t) monitors; | 1748 *interpreter_frame->register_addr(Lmonitors) = (intptr_t) monitors; |
1735 *interpreter_frame->register_addr(Lesp) = (intptr_t) esp; | 1749 *interpreter_frame->register_addr(Lesp) = (intptr_t) esp; |
1736 // Llast_SP will be same as SP as there is no adapter space | 1750 // Llast_SP will be same as SP as there is no adapter space |
1737 *interpreter_frame->register_addr(Llast_SP) = (intptr_t) interpreter_frame->sp() - STACK_BIAS; | 1751 *interpreter_frame->register_addr(Llast_SP) = (intptr_t) interpreter_frame->sp() - STACK_BIAS; |
1738 *interpreter_frame->register_addr(LcpoolCache) = (intptr_t) method->constants()->cache(); | 1752 *interpreter_frame->register_addr(LcpoolCache) = (intptr_t) method->constants()->cache(); |
1739 #ifdef FAST_DISPATCH | 1753 #ifdef FAST_DISPATCH |
1740 *interpreter_frame->register_addr(IdispatchTables) = (intptr_t) Interpreter::dispatch_table(); | 1754 *interpreter_frame->register_addr(IdispatchTables) = (intptr_t) Interpreter::dispatch_table(); |
1741 #endif | 1755 #endif |
1742 | 1756 |
1743 | 1757 |
1744 #ifdef ASSERT | 1758 #ifdef ASSERT |
1745 BasicObjectLock* mp = (BasicObjectLock*)monitors; | 1759 BasicObjectLock* mp = (BasicObjectLock*)monitors; |
1746 | 1760 |
1747 assert(interpreter_frame->interpreter_frame_method() == method, "method matches"); | 1761 assert(interpreter_frame->interpreter_frame_method() == method, "method matches"); |
1748 assert(interpreter_frame->interpreter_frame_local_at(9) == (intptr_t *)((intptr_t)locals - (9 * Interpreter::stackElementSize)), "locals match"); | 1762 assert(interpreter_frame->interpreter_frame_local_at(9) == (intptr_t *)((intptr_t)locals - (9 * Interpreter::stackElementSize)), "locals match"); |
1749 assert(interpreter_frame->interpreter_frame_monitor_end() == mp, "monitor_end matches"); | 1763 assert(interpreter_frame->interpreter_frame_monitor_end() == mp, "monitor_end matches"); |
1750 assert(((intptr_t *)interpreter_frame->interpreter_frame_monitor_begin()) == ((intptr_t *)mp)+monitor_size, "monitor_begin matches"); | 1764 assert(((intptr_t *)interpreter_frame->interpreter_frame_monitor_begin()) == ((intptr_t *)mp)+monitor_size, "monitor_begin matches"); |
1751 assert(interpreter_frame->interpreter_frame_tos_address()-1 == esp, "esp matches"); | 1765 assert(interpreter_frame->interpreter_frame_tos_address()-1 == esp, "esp matches"); |
1752 | 1766 |
1753 // check bounds | 1767 // check bounds |
1754 intptr_t* lo = interpreter_frame->sp() + (frame::memory_parameter_word_sp_offset - 1); | 1768 intptr_t* lo = interpreter_frame->sp() + (frame::memory_parameter_word_sp_offset - 1); |
1755 intptr_t* hi = interpreter_frame->fp() - rounded_vm_local_words; | 1769 intptr_t* hi = interpreter_frame->fp() - rounded_vm_local_words; |
1756 assert(lo < monitors && montop <= hi, "monitors in bounds"); | 1770 assert(lo < monitors && montop <= hi, "monitors in bounds"); |
1757 assert(lo <= esp && esp < monitors, "esp in bounds"); | 1771 assert(lo <= esp && esp < monitors, "esp in bounds"); |
1758 #endif // ASSERT | 1772 #endif // ASSERT |
1759 } | |
1760 | |
1761 return raw_frame_size; | |
1762 } | 1773 } |
1763 | 1774 |
1764 //---------------------------------------------------------------------------------------------------- | 1775 //---------------------------------------------------------------------------------------------------- |
1765 // Exceptions | 1776 // Exceptions |
1766 void TemplateInterpreterGenerator::generate_throw_exception() { | 1777 void TemplateInterpreterGenerator::generate_throw_exception() { |