< prev index next >

src/cpu/sparc/vm/interp_masm_sparc.cpp

Print this page




1633 
1634     // If no method data exists, go to profile_continue.
1635     test_method_data_pointer(profile_continue);
1636 
1637 
1638     Label skip_receiver_profile;
1639     if (receiver_can_be_null) {
1640       Label not_null;
1641       br_notnull_short(receiver, Assembler::pt, not_null);
1642       // We are making a call.  Increment the count for null receiver.
1643       increment_mdp_data_at(in_bytes(CounterData::count_offset()), scratch);
1644       ba_short(skip_receiver_profile);
1645       bind(not_null);
1646     }
1647 
1648     // Record the receiver type.
1649     record_klass_in_profile(receiver, scratch, true);
1650     bind(skip_receiver_profile);
1651 
1652     // The method data pointer needs to be updated to reflect the new target.


1653     update_mdp_by_constant(in_bytes(VirtualCallData::virtual_call_data_size()));
1654     bind (profile_continue);




1655   }
1656 }
1657 
1658 void InterpreterMacroAssembler::record_klass_in_profile_helper(
1659                                         Register receiver, Register scratch,
1660                                         int start_row, Label& done, bool is_virtual_call) {



















1661   if (TypeProfileWidth == 0) {
1662     if (is_virtual_call) {
1663       increment_mdp_data_at(in_bytes(CounterData::count_offset()), scratch);
1664     }
1665     return;








1666   }





1667 
1668   int last_row = VirtualCallData::row_limit() - 1;









1669   assert(start_row <= last_row, "must be work left to do");
1670   // Test this row for both the receiver and for null.
1671   // Take any of three different outcomes:
1672   //   1. found receiver => increment count and goto done
1673   //   2. found null => keep looking for case 1, maybe allocate this cell
1674   //   3. found something else => keep looking for cases 1 and 2
1675   // Case 3 is handled by a recursive call.
1676   for (int row = start_row; row <= last_row; row++) {
1677     Label next_test;
1678     bool test_for_null_also = (row == start_row);
1679 
1680     // See if the receiver is receiver[n].
1681     int recvr_offset = in_bytes(VirtualCallData::receiver_offset(row));
1682     test_mdp_data_at(recvr_offset, receiver, next_test, scratch);
1683     // delayed()->tst(scratch);
1684 
1685     // The receiver is receiver[n].  Increment count[n].
1686     int count_offset = in_bytes(VirtualCallData::receiver_count_offset(row));
1687     increment_mdp_data_at(count_offset, scratch);
1688     ba_short(done);
1689     bind(next_test);
1690 
1691     if (test_for_null_also) {
1692       Label found_null;
1693       // Failed the equality check on receiver[n]...  Test for null.
1694       if (start_row == last_row) {
1695         // The only thing left to do is handle the null case.
1696         if (is_virtual_call) {
1697           brx(Assembler::zero, false, Assembler::pn, found_null);
1698           delayed()->nop();
1699           // Receiver did not match any saved receiver and there is no empty row for it.
1700           // Increment total counter to indicate polymorphic case.
1701           increment_mdp_data_at(in_bytes(CounterData::count_offset()), scratch);
1702           ba_short(done);
1703           bind(found_null);
1704         } else {
1705           brx(Assembler::notZero, false, Assembler::pt, done);
1706           delayed()->nop();
1707         }
1708         break;
1709       }
1710       // Since null is rare, make it be the branch-taken case.
1711       brx(Assembler::zero, false, Assembler::pn, found_null);
1712       delayed()->nop();
1713 
1714       // Put all the "Case 3" tests here.
1715       record_klass_in_profile_helper(receiver, scratch, start_row + 1, done, is_virtual_call);

1716 
1717       // Found a null.  Keep searching for a matching receiver,
1718       // but remember that this is an empty (unused) slot.
1719       bind(found_null);
1720     }
1721   }
1722 
1723   // In the fall-through case, we found no matching receiver, but we
1724   // observed the receiver[start_row] is NULL.
1725 
1726   // Fill in the receiver field and increment the count.
1727   int recvr_offset = in_bytes(VirtualCallData::receiver_offset(start_row));
1728   set_mdp_data_at(recvr_offset, receiver);
1729   int count_offset = in_bytes(VirtualCallData::receiver_count_offset(start_row));
1730   mov(DataLayout::counter_increment, scratch);
1731   set_mdp_data_at(count_offset, scratch);
1732   if (start_row > 0) {
1733     ba_short(done);
1734   }
1735 }
1736 
1737 void InterpreterMacroAssembler::record_klass_in_profile(Register receiver,
1738                                                         Register scratch, bool is_virtual_call) {
1739   assert(ProfileInterpreter, "must be profiling");
1740   Label done;
1741 
1742   record_klass_in_profile_helper(receiver, scratch, 0, done, is_virtual_call);
1743 
1744   bind (done);
1745 }
1746 
1747 
1748 // Count a ret in the bytecodes.
1749 
1750 void InterpreterMacroAssembler::profile_ret(TosState state,
1751                                             Register return_bci,
1752                                             Register scratch) {
1753   if (ProfileInterpreter) {
1754     Label profile_continue;
1755     uint row;
1756 
1757     // If no method data exists, go to profile_continue.
1758     test_method_data_pointer(profile_continue);
1759 
1760     // Update the total ret count.
1761     increment_mdp_data_at(in_bytes(CounterData::count_offset()), scratch);
1762 


1778 
1779     update_mdp_for_ret(state, return_bci);
1780 
1781     bind (profile_continue);
1782   }
1783 }
1784 
1785 // Profile an unexpected null in the bytecodes.
1786 void InterpreterMacroAssembler::profile_null_seen(Register scratch) {
1787   if (ProfileInterpreter) {
1788     Label profile_continue;
1789 
1790     // If no method data exists, go to profile_continue.
1791     test_method_data_pointer(profile_continue);
1792 
1793     set_mdp_flag_at(BitData::null_seen_byte_constant(), scratch);
1794 
1795     // The method data pointer needs to be updated.
1796     int mdp_delta = in_bytes(BitData::bit_data_size());
1797     if (TypeProfileCasts) {
1798       mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size());
1799     }
1800     update_mdp_by_constant(mdp_delta);
1801 
1802     bind (profile_continue);
1803   }
1804 }
1805 
1806 void InterpreterMacroAssembler::profile_typecheck(Register klass,
1807                                                   Register scratch) {
1808   if (ProfileInterpreter) {
1809     Label profile_continue;
1810 
1811     // If no method data exists, go to profile_continue.
1812     test_method_data_pointer(profile_continue);
1813 
1814     int mdp_delta = in_bytes(BitData::bit_data_size());
1815     if (TypeProfileCasts) {
1816       mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size());
1817 
1818       // Record the object type.
1819       record_klass_in_profile(klass, scratch, false);
1820     }
1821 
1822     // The method data pointer needs to be updated.
1823     update_mdp_by_constant(mdp_delta);
1824 
1825     bind (profile_continue);
1826   }
1827 }
1828 
1829 void InterpreterMacroAssembler::profile_typecheck_failed(Register scratch) {
1830   if (ProfileInterpreter && TypeProfileCasts) {
1831     Label profile_continue;
1832 
1833     // If no method data exists, go to profile_continue.
1834     test_method_data_pointer(profile_continue);
1835 
1836     int count_offset = in_bytes(CounterData::count_offset());
1837     // Back up the address, since we have already bumped the mdp.
1838     count_offset -= in_bytes(VirtualCallData::virtual_call_data_size());
1839 
1840     // *Decrement* the counter.  We expect to see zero or small negatives.
1841     increment_mdp_data_at(count_offset, scratch, true);
1842 
1843     bind (profile_continue);
1844   }
1845 }
1846 
1847 // Count the default case of a switch construct.
1848 
1849 void InterpreterMacroAssembler::profile_switch_default(Register scratch) {
1850   if (ProfileInterpreter) {
1851     Label profile_continue;
1852 
1853     // If no method data exists, go to profile_continue.
1854     test_method_data_pointer(profile_continue);
1855 
1856     // Update the default case count
1857     increment_mdp_data_at(in_bytes(MultiBranchData::default_count_offset()),
1858                           scratch);




1633 
1634     // If no method data exists, go to profile_continue.
1635     test_method_data_pointer(profile_continue);
1636 
1637 
1638     Label skip_receiver_profile;
1639     if (receiver_can_be_null) {
1640       Label not_null;
1641       br_notnull_short(receiver, Assembler::pt, not_null);
1642       // We are making a call.  Increment the count for null receiver.
1643       increment_mdp_data_at(in_bytes(CounterData::count_offset()), scratch);
1644       ba_short(skip_receiver_profile);
1645       bind(not_null);
1646     }
1647 
1648     // Record the receiver type.
1649     record_klass_in_profile(receiver, scratch, true);
1650     bind(skip_receiver_profile);
1651 
1652     // The method data pointer needs to be updated to reflect the new target.
1653 #if INCLUDE_JVMCI
1654     if (MethodProfileWidth == 0) {
1655       update_mdp_by_constant(in_bytes(VirtualCallData::virtual_call_data_size()));
1656     }
1657 #else
1658     update_mdp_by_constant(in_bytes(VirtualCallData::virtual_call_data_size()));
1659 #endif
1660     bind(profile_continue);
1661   }
1662 }
1663 
1664 #if INCLUDE_JVMCI
1665 void InterpreterMacroAssembler::profile_called_method(Register method, Register scratch) {
1666   assert_different_registers(method, scratch);
1667   if (ProfileInterpreter && MethodProfileWidth > 0) {
1668     Label profile_continue;
1669 
1670     // If no method data exists, go to profile_continue.
1671     test_method_data_pointer(profile_continue);
1672 
1673     Label done;
1674     record_item_in_profile_helper(method, scratch, 0, done, MethodProfileWidth,
1675       &VirtualCallData::method_offset, &VirtualCallData::method_count_offset, in_bytes(VirtualCallData::nonprofiled_receiver_count_offset()));
1676     bind(done);
1677 
1678     update_mdp_by_constant(in_bytes(VirtualCallData::virtual_call_data_size()));
1679     bind(profile_continue);
1680   }
1681 }
1682 #endif // INCLUDE_JVMCI
1683 
1684 void InterpreterMacroAssembler::record_klass_in_profile_helper(Register receiver, Register scratch,
1685                                                                Label& done, bool is_virtual_call) {
1686   if (TypeProfileWidth == 0) {
1687     if (is_virtual_call) {
1688       increment_mdp_data_at(in_bytes(CounterData::count_offset()), scratch);
1689     }
1690 #if INCLUDE_JVMCI
1691     else if (EnableJVMCI) {
1692       increment_mdp_data_at(in_bytes(ReceiverTypeData::nonprofiled_receiver_count_offset()), scratch);
1693     }
1694 #endif
1695   } else {
1696     int non_profiled_offset = -1;
1697     if (is_virtual_call) {
1698       non_profiled_offset = in_bytes(CounterData::count_offset());
1699     }
1700 #if INCLUDE_JVMCI
1701     else if (EnableJVMCI) {
1702       non_profiled_offset = in_bytes(ReceiverTypeData::nonprofiled_receiver_count_offset());
1703     }
1704 #endif
1705 
1706     record_item_in_profile_helper(receiver, scratch, 0, done, TypeProfileWidth,
1707       &VirtualCallData::receiver_offset, &VirtualCallData::receiver_count_offset, non_profiled_offset);
1708   }
1709 }
1710 
1711 void InterpreterMacroAssembler::record_item_in_profile_helper(Register item,
1712                                           Register scratch, int start_row, Label& done, int total_rows,
1713                                           OffsetFunction item_offset_fn, OffsetFunction item_count_offset_fn,
1714                                           int non_profiled_offset) {
1715   int last_row = total_rows - 1;
1716   assert(start_row <= last_row, "must be work left to do");
1717   // Test this row for both the item and for null.
1718   // Take any of three different outcomes:
1719   //   1. found item => increment count and goto done
1720   //   2. found null => keep looking for case 1, maybe allocate this cell
1721   //   3. found something else => keep looking for cases 1 and 2
1722   // Case 3 is handled by a recursive call.
1723   for (int row = start_row; row <= last_row; row++) {
1724     Label next_test;
1725     bool test_for_null_also = (row == start_row);
1726 
1727     // See if the item is item[n].
1728     int item_offset = in_bytes(item_offset_fn(row));
1729     test_mdp_data_at(item_offset, item, next_test, scratch);
1730     // delayed()->tst(scratch);
1731 
1732     // The receiver is item[n].  Increment count[n].
1733     int count_offset = in_bytes(item_count_offset_fn(row));
1734     increment_mdp_data_at(count_offset, scratch);
1735     ba_short(done);
1736     bind(next_test);
1737 
1738     if (test_for_null_also) {
1739       Label found_null;
1740       // Failed the equality check on item[n]...  Test for null.
1741       if (start_row == last_row) {
1742         // The only thing left to do is handle the null case.
1743         if (non_profiled_offset >= 0) {
1744           brx(Assembler::zero, false, Assembler::pn, found_null);
1745           delayed()->nop();
1746           // Item did not match any saved item and there is no empty row for it.
1747           // Increment total counter to indicate polymorphic case.
1748           increment_mdp_data_at(non_profiled_offset, scratch);
1749           ba_short(done);
1750           bind(found_null);
1751         } else {
1752           brx(Assembler::notZero, false, Assembler::pt, done);
1753           delayed()->nop();
1754         }
1755         break;
1756       }
1757       // Since null is rare, make it be the branch-taken case.
1758       brx(Assembler::zero, false, Assembler::pn, found_null);
1759       delayed()->nop();
1760 
1761       // Put all the "Case 3" tests here.
1762       record_item_in_profile_helper(item, scratch, start_row + 1, done, total_rows,
1763         item_offset_fn, item_count_offset_fn, non_profiled_offset);
1764 
1765       // Found a null.  Keep searching for a matching item,
1766       // but remember that this is an empty (unused) slot.
1767       bind(found_null);
1768     }
1769   }
1770 
1771   // In the fall-through case, we found no matching item, but we
1772   // observed the item[start_row] is NULL.
1773 
1774   // Fill in the item field and increment the count.
1775   int item_offset = in_bytes(item_offset_fn(start_row));
1776   set_mdp_data_at(item_offset, item);
1777   int count_offset = in_bytes(item_count_offset_fn(start_row));
1778   mov(DataLayout::counter_increment, scratch);
1779   set_mdp_data_at(count_offset, scratch);
1780   if (start_row > 0) {
1781     ba_short(done);
1782   }
1783 }
1784 
1785 void InterpreterMacroAssembler::record_klass_in_profile(Register receiver,
1786                                                         Register scratch, bool is_virtual_call) {
1787   assert(ProfileInterpreter, "must be profiling");
1788   Label done;
1789 
1790   record_klass_in_profile_helper(receiver, scratch, done, is_virtual_call);
1791 
1792   bind (done);
1793 }
1794 
1795 
1796 // Count a ret in the bytecodes.
1797 
1798 void InterpreterMacroAssembler::profile_ret(TosState state,
1799                                             Register return_bci,
1800                                             Register scratch) {
1801   if (ProfileInterpreter) {
1802     Label profile_continue;
1803     uint row;
1804 
1805     // If no method data exists, go to profile_continue.
1806     test_method_data_pointer(profile_continue);
1807 
1808     // Update the total ret count.
1809     increment_mdp_data_at(in_bytes(CounterData::count_offset()), scratch);
1810 


1826 
1827     update_mdp_for_ret(state, return_bci);
1828 
1829     bind (profile_continue);
1830   }
1831 }
1832 
1833 // Profile an unexpected null in the bytecodes.
1834 void InterpreterMacroAssembler::profile_null_seen(Register scratch) {
1835   if (ProfileInterpreter) {
1836     Label profile_continue;
1837 
1838     // If no method data exists, go to profile_continue.
1839     test_method_data_pointer(profile_continue);
1840 
1841     set_mdp_flag_at(BitData::null_seen_byte_constant(), scratch);
1842 
1843     // The method data pointer needs to be updated.
1844     int mdp_delta = in_bytes(BitData::bit_data_size());
1845     if (TypeProfileCasts) {
1846       mdp_delta = in_bytes(ReceiverTypeData::receiver_type_data_size());
1847     }
1848     update_mdp_by_constant(mdp_delta);
1849 
1850     bind (profile_continue);
1851   }
1852 }
1853 
1854 void InterpreterMacroAssembler::profile_typecheck(Register klass,
1855                                                   Register scratch) {
1856   if (ProfileInterpreter) {
1857     Label profile_continue;
1858 
1859     // If no method data exists, go to profile_continue.
1860     test_method_data_pointer(profile_continue);
1861 
1862     int mdp_delta = in_bytes(BitData::bit_data_size());
1863     if (TypeProfileCasts) {
1864       mdp_delta = in_bytes(ReceiverTypeData::receiver_type_data_size());
1865 
1866       // Record the object type.
1867       record_klass_in_profile(klass, scratch, false);
1868     }
1869 
1870     // The method data pointer needs to be updated.
1871     update_mdp_by_constant(mdp_delta);
1872 
1873     bind (profile_continue);
1874   }
1875 }
1876 
1877 void InterpreterMacroAssembler::profile_typecheck_failed(Register scratch) {
1878   if (ProfileInterpreter && TypeProfileCasts) {
1879     Label profile_continue;
1880 
1881     // If no method data exists, go to profile_continue.
1882     test_method_data_pointer(profile_continue);
1883 
1884     int count_offset = in_bytes(CounterData::count_offset());
1885     // Back up the address, since we have already bumped the mdp.
1886     count_offset -= in_bytes(ReceiverTypeData::receiver_type_data_size());
1887 
1888     // *Decrement* the counter.  We expect to see zero or small negatives.
1889     increment_mdp_data_at(count_offset, scratch, true);
1890 
1891     bind (profile_continue);
1892   }
1893 }
1894 
1895 // Count the default case of a switch construct.
1896 
1897 void InterpreterMacroAssembler::profile_switch_default(Register scratch) {
1898   if (ProfileInterpreter) {
1899     Label profile_continue;
1900 
1901     // If no method data exists, go to profile_continue.
1902     test_method_data_pointer(profile_continue);
1903 
1904     // Update the default case count
1905     increment_mdp_data_at(in_bytes(MultiBranchData::default_count_offset()),
1906                           scratch);


< prev index next >