comparison src/cpu/sparc/vm/interp_masm_sparc.cpp @ 10458:63e44cdabb91

fixed SPARC interpreter
author twisti
date Thu, 20 Jun 2013 10:56:34 -0700
parents 603ca7e51354
children 6b0fd0964b87
comparison
equal deleted inserted replaced
10457:fb95519008d6 10458:63e44cdabb91
1644 // Record the receiver type. 1644 // Record the receiver type.
1645 record_klass_in_profile(receiver, scratch, true); 1645 record_klass_in_profile(receiver, scratch, true);
1646 bind(skip_receiver_profile); 1646 bind(skip_receiver_profile);
1647 1647
1648 // The method data pointer needs to be updated to reflect the new target. 1648 // The method data pointer needs to be updated to reflect the new target.
1649 #ifdef GRAAL
1650 if (MethodProfileWidth == 0) {
1651 update_mdp_by_constant(in_bytes(VirtualCallData::virtual_call_data_size()));
1652 }
1653 #else
1649 update_mdp_by_constant(in_bytes(VirtualCallData::virtual_call_data_size())); 1654 update_mdp_by_constant(in_bytes(VirtualCallData::virtual_call_data_size()));
1650 bind (profile_continue); 1655 #endif
1651 } 1656 bind(profile_continue);
1652 } 1657 }
1653 1658 }
1654 void InterpreterMacroAssembler::record_klass_in_profile_helper( 1659
1655 Register receiver, Register scratch, 1660 #ifdef GRAAL
1656 int start_row, Label& done, bool is_virtual_call) { 1661 void InterpreterMacroAssembler::profile_called_method(Register method, Register scratch) {
1662 assert_different_registers(method, scratch);
1663 if (ProfileInterpreter && MethodProfileWidth > 0) {
1664 Label profile_continue;
1665
1666 // If no method data exists, go to profile_continue.
1667 test_method_data_pointer(profile_continue);
1668
1669 Label done;
1670 record_item_in_profile_helper(method, scratch, 0, done, MethodProfileWidth,
1671 &VirtualCallData::method_offset, &VirtualCallData::method_count_offset, in_bytes(VirtualCallData::nonprofiled_receiver_count_offset()));
1672 bind(done);
1673
1674 update_mdp_by_constant(in_bytes(VirtualCallData::virtual_call_data_size()));
1675 bind(profile_continue);
1676 }
1677 }
1678 #endif
1679
1680 void InterpreterMacroAssembler::record_klass_in_profile_helper(Register receiver, Register scratch,
1681 Label& done, bool is_virtual_call) {
1657 if (TypeProfileWidth == 0) { 1682 if (TypeProfileWidth == 0) {
1658 if (is_virtual_call) { 1683 if (is_virtual_call) {
1659 increment_mdp_data_at(in_bytes(CounterData::count_offset()), scratch); 1684 increment_mdp_data_at(in_bytes(CounterData::count_offset()), scratch);
1660 } 1685 }
1661 return; 1686 #ifdef GRAAL
1662 } 1687 else {
1663 1688 increment_mdp_data_at(in_bytes(ReceiverTypeData::nonprofiled_receiver_count_offset()), scratch);
1664 int last_row = VirtualCallData::row_limit() - 1; 1689 }
1690 #endif
1691 } else {
1692 bool use_non_profiled_counter = !is_virtual_call || IS_GRAAL_DEFINED;
1693 int non_profiled_offset = -1;
1694 if (use_non_profiled_counter) {
1695 non_profiled_offset = in_bytes(CounterData::count_offset());
1696 #ifdef GRAAL
1697 if (!is_virtual_call) {
1698 non_profiled_offset = in_bytes(ReceiverTypeData::nonprofiled_receiver_count_offset());
1699 }
1700 #endif
1701 assert(non_profiled_offset >= 0, "must be");
1702 }
1703
1704 record_item_in_profile_helper(receiver, scratch, 0, done, TypeProfileWidth,
1705 &VirtualCallData::receiver_offset, &VirtualCallData::receiver_count_offset, non_profiled_offset);
1706 }
1707 }
1708
1709 void InterpreterMacroAssembler::record_item_in_profile_helper(Register item,
1710 Register scratch, int start_row, Label& done, int total_rows,
1711 OffsetFunction item_offset_fn, OffsetFunction item_count_offset_fn,
1712 int non_profiled_offset) {
1713 int last_row = total_rows - 1;
1665 assert(start_row <= last_row, "must be work left to do"); 1714 assert(start_row <= last_row, "must be work left to do");
1666 // Test this row for both the receiver and for null. 1715 // Test this row for both the item and for null.
1667 // Take any of three different outcomes: 1716 // Take any of three different outcomes:
1668 // 1. found receiver => increment count and goto done 1717 // 1. found item => increment count and goto done
1669 // 2. found null => keep looking for case 1, maybe allocate this cell 1718 // 2. found null => keep looking for case 1, maybe allocate this cell
1670 // 3. found something else => keep looking for cases 1 and 2 1719 // 3. found something else => keep looking for cases 1 and 2
1671 // Case 3 is handled by a recursive call. 1720 // Case 3 is handled by a recursive call.
1672 for (int row = start_row; row <= last_row; row++) { 1721 for (int row = start_row; row <= last_row; row++) {
1673 Label next_test; 1722 Label next_test;
1674 bool test_for_null_also = (row == start_row); 1723 bool test_for_null_also = (row == start_row);
1675 1724
1676 // See if the receiver is receiver[n]. 1725 // See if the item is item[n].
1677 int recvr_offset = in_bytes(VirtualCallData::receiver_offset(row)); 1726 int item_offset = in_bytes(item_offset_fn(row));
1678 test_mdp_data_at(recvr_offset, receiver, next_test, scratch); 1727 test_mdp_data_at(item_offset, item, next_test, scratch);
1679 // delayed()->tst(scratch); 1728 // delayed()->tst(scratch);
1680 1729
1681 // The receiver is receiver[n]. Increment count[n]. 1730 // The receiver is item[n]. Increment count[n].
1682 int count_offset = in_bytes(VirtualCallData::receiver_count_offset(row)); 1731 int count_offset = in_bytes(item_count_offset_fn(row));
1683 increment_mdp_data_at(count_offset, scratch); 1732 increment_mdp_data_at(count_offset, scratch);
1684 ba_short(done); 1733 ba_short(done);
1685 bind(next_test); 1734 bind(next_test);
1686 1735
1687 if (test_for_null_also) { 1736 if (test_for_null_also) {
1688 Label found_null; 1737 Label found_null;
1689 // Failed the equality check on receiver[n]... Test for null. 1738 // Failed the equality check on item[n]... Test for null.
1690 if (start_row == last_row) { 1739 if (start_row == last_row) {
1691 // The only thing left to do is handle the null case. 1740 // The only thing left to do is handle the null case.
1692 if (is_virtual_call) { 1741 if (non_profiled_offset >= 0) {
1693 brx(Assembler::zero, false, Assembler::pn, found_null); 1742 brx(Assembler::zero, false, Assembler::pn, found_null);
1694 delayed()->nop(); 1743 delayed()->nop();
1695 // Receiver did not match any saved receiver and there is no empty row for it. 1744 // Item did not match any saved item and there is no empty row for it.
1696 // Increment total counter to indicate polymorphic case. 1745 // Increment total counter to indicate polymorphic case.
1697 increment_mdp_data_at(in_bytes(CounterData::count_offset()), scratch); 1746 increment_mdp_data_at(non_profiled_offset, scratch);
1698 ba_short(done); 1747 ba_short(done);
1699 bind(found_null); 1748 bind(found_null);
1700 } else { 1749 } else {
1701 brx(Assembler::notZero, false, Assembler::pt, done); 1750 brx(Assembler::notZero, false, Assembler::pt, done);
1702 delayed()->nop(); 1751 delayed()->nop();
1706 // Since null is rare, make it be the branch-taken case. 1755 // Since null is rare, make it be the branch-taken case.
1707 brx(Assembler::zero, false, Assembler::pn, found_null); 1756 brx(Assembler::zero, false, Assembler::pn, found_null);
1708 delayed()->nop(); 1757 delayed()->nop();
1709 1758
1710 // Put all the "Case 3" tests here. 1759 // Put all the "Case 3" tests here.
1711 record_klass_in_profile_helper(receiver, scratch, start_row + 1, done, is_virtual_call); 1760 record_item_in_profile_helper(item, scratch, start_row + 1, done, total_rows,
1712 1761 item_offset_fn, item_count_offset_fn, non_profiled_offset);
1713 // Found a null. Keep searching for a matching receiver, 1762
1763 // Found a null. Keep searching for a matching item,
1714 // but remember that this is an empty (unused) slot. 1764 // but remember that this is an empty (unused) slot.
1715 bind(found_null); 1765 bind(found_null);
1716 } 1766 }
1717 } 1767 }
1718 1768
1719 // In the fall-through case, we found no matching receiver, but we 1769 // In the fall-through case, we found no matching item, but we
1720 // observed the receiver[start_row] is NULL. 1770 // observed the item[start_row] is NULL.
1721 1771
1722 // Fill in the receiver field and increment the count. 1772 // Fill in the item field and increment the count.
1723 int recvr_offset = in_bytes(VirtualCallData::receiver_offset(start_row)); 1773 int item_offset = in_bytes(item_offset_fn(start_row));
1724 set_mdp_data_at(recvr_offset, receiver); 1774 set_mdp_data_at(item_offset, item);
1725 int count_offset = in_bytes(VirtualCallData::receiver_count_offset(start_row)); 1775 int count_offset = in_bytes(item_count_offset_fn(start_row));
1726 mov(DataLayout::counter_increment, scratch); 1776 mov(DataLayout::counter_increment, scratch);
1727 set_mdp_data_at(count_offset, scratch); 1777 set_mdp_data_at(count_offset, scratch);
1728 if (start_row > 0) { 1778 if (start_row > 0) {
1729 ba_short(done); 1779 ba_short(done);
1730 } 1780 }
1733 void InterpreterMacroAssembler::record_klass_in_profile(Register receiver, 1783 void InterpreterMacroAssembler::record_klass_in_profile(Register receiver,
1734 Register scratch, bool is_virtual_call) { 1784 Register scratch, bool is_virtual_call) {
1735 assert(ProfileInterpreter, "must be profiling"); 1785 assert(ProfileInterpreter, "must be profiling");
1736 Label done; 1786 Label done;
1737 1787
1738 record_klass_in_profile_helper(receiver, scratch, 0, done, is_virtual_call); 1788 record_klass_in_profile_helper(receiver, scratch, done, is_virtual_call);
1739 1789
1740 bind (done); 1790 bind (done);
1741 } 1791 }
1742 1792
1743 1793
1789 set_mdp_flag_at(BitData::null_seen_byte_constant(), scratch); 1839 set_mdp_flag_at(BitData::null_seen_byte_constant(), scratch);
1790 1840
1791 // The method data pointer needs to be updated. 1841 // The method data pointer needs to be updated.
1792 int mdp_delta = in_bytes(BitData::bit_data_size()); 1842 int mdp_delta = in_bytes(BitData::bit_data_size());
1793 if (TypeProfileCasts) { 1843 if (TypeProfileCasts) {
1794 mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size()); 1844 mdp_delta = in_bytes(ReceiverTypeData::receiver_type_data_size());
1795 } 1845 }
1796 update_mdp_by_constant(mdp_delta); 1846 update_mdp_by_constant(mdp_delta);
1797 1847
1798 bind (profile_continue); 1848 bind (profile_continue);
1799 } 1849 }
1807 // If no method data exists, go to profile_continue. 1857 // If no method data exists, go to profile_continue.
1808 test_method_data_pointer(profile_continue); 1858 test_method_data_pointer(profile_continue);
1809 1859
1810 int mdp_delta = in_bytes(BitData::bit_data_size()); 1860 int mdp_delta = in_bytes(BitData::bit_data_size());
1811 if (TypeProfileCasts) { 1861 if (TypeProfileCasts) {
1812 mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size()); 1862 mdp_delta = in_bytes(ReceiverTypeData::receiver_type_data_size());
1813 1863
1814 // Record the object type. 1864 // Record the object type.
1815 record_klass_in_profile(klass, scratch, false); 1865 record_klass_in_profile(klass, scratch, false);
1816 } 1866 }
1817 1867
1829 // If no method data exists, go to profile_continue. 1879 // If no method data exists, go to profile_continue.
1830 test_method_data_pointer(profile_continue); 1880 test_method_data_pointer(profile_continue);
1831 1881
1832 int count_offset = in_bytes(CounterData::count_offset()); 1882 int count_offset = in_bytes(CounterData::count_offset());
1833 // Back up the address, since we have already bumped the mdp. 1883 // Back up the address, since we have already bumped the mdp.
1834 count_offset -= in_bytes(VirtualCallData::virtual_call_data_size()); 1884 count_offset -= in_bytes(ReceiverTypeData::receiver_type_data_size());
1835 1885
1836 // *Decrement* the counter. We expect to see zero or small negatives. 1886 // *Decrement* the counter. We expect to see zero or small negatives.
1837 increment_mdp_data_at(count_offset, scratch, true); 1887 increment_mdp_data_at(count_offset, scratch, true);
1838 1888
1839 bind (profile_continue); 1889 bind (profile_continue);