Mercurial > hg > truffle
comparison src/share/vm/opto/library_call.cpp @ 775:93c14e5562c4
6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
Summary: These methods can be instrinsified by using bit scan, bit test, and population count instructions.
Reviewed-by: kvn, never
author | twisti |
---|---|
date | Wed, 06 May 2009 00:27:52 -0700 |
parents | 9c6be3edf0dc |
children | aabd393cf1ee |
comparison
equal
deleted
inserted
replaced
755:36ee9b69616e | 775:93c14e5562c4 |
---|---|
220 Node* dest, Node* dest_offset, | 220 Node* dest, Node* dest_offset, |
221 Node* copy_length); | 221 Node* copy_length); |
222 bool inline_unsafe_CAS(BasicType type); | 222 bool inline_unsafe_CAS(BasicType type); |
223 bool inline_unsafe_ordered_store(BasicType type); | 223 bool inline_unsafe_ordered_store(BasicType type); |
224 bool inline_fp_conversions(vmIntrinsics::ID id); | 224 bool inline_fp_conversions(vmIntrinsics::ID id); |
225 bool inline_numberOfLeadingZeros(vmIntrinsics::ID id); | |
226 bool inline_numberOfTrailingZeros(vmIntrinsics::ID id); | |
225 bool inline_bitCount(vmIntrinsics::ID id); | 227 bool inline_bitCount(vmIntrinsics::ID id); |
226 bool inline_reverseBytes(vmIntrinsics::ID id); | 228 bool inline_reverseBytes(vmIntrinsics::ID id); |
227 }; | 229 }; |
228 | 230 |
229 | 231 |
627 case vmIntrinsics::_intBitsToFloat: | 629 case vmIntrinsics::_intBitsToFloat: |
628 case vmIntrinsics::_doubleToRawLongBits: | 630 case vmIntrinsics::_doubleToRawLongBits: |
629 case vmIntrinsics::_doubleToLongBits: | 631 case vmIntrinsics::_doubleToLongBits: |
630 case vmIntrinsics::_longBitsToDouble: | 632 case vmIntrinsics::_longBitsToDouble: |
631 return inline_fp_conversions(intrinsic_id()); | 633 return inline_fp_conversions(intrinsic_id()); |
634 | |
635 case vmIntrinsics::_numberOfLeadingZeros_i: | |
636 case vmIntrinsics::_numberOfLeadingZeros_l: | |
637 return inline_numberOfLeadingZeros(intrinsic_id()); | |
638 | |
639 case vmIntrinsics::_numberOfTrailingZeros_i: | |
640 case vmIntrinsics::_numberOfTrailingZeros_l: | |
641 return inline_numberOfTrailingZeros(intrinsic_id()); | |
632 | 642 |
633 case vmIntrinsics::_bitCount_i: | 643 case vmIntrinsics::_bitCount_i: |
634 case vmIntrinsics::_bitCount_l: | 644 case vmIntrinsics::_bitCount_l: |
635 return inline_bitCount(intrinsic_id()); | 645 return inline_bitCount(intrinsic_id()); |
636 | 646 |
1842 } else { | 1852 } else { |
1843 return basic_plus_adr(base, offset); | 1853 return basic_plus_adr(base, offset); |
1844 } | 1854 } |
1845 } | 1855 } |
1846 | 1856 |
1857 //-------------------inline_numberOfLeadingZeros_int/long----------------------- | |
1858 // inline int Integer.numberOfLeadingZeros(int) | |
1859 // inline int Long.numberOfLeadingZeros(long) | |
1860 bool LibraryCallKit::inline_numberOfLeadingZeros(vmIntrinsics::ID id) { | |
1861 assert(id == vmIntrinsics::_numberOfLeadingZeros_i || id == vmIntrinsics::_numberOfLeadingZeros_l, "not numberOfLeadingZeros"); | |
1862 if (id == vmIntrinsics::_numberOfLeadingZeros_i && !Matcher::match_rule_supported(Op_CountLeadingZerosI)) return false; | |
1863 if (id == vmIntrinsics::_numberOfLeadingZeros_l && !Matcher::match_rule_supported(Op_CountLeadingZerosL)) return false; | |
1864 _sp += arg_size(); // restore stack pointer | |
1865 switch (id) { | |
1866 case vmIntrinsics::_numberOfLeadingZeros_i: | |
1867 push(_gvn.transform(new (C, 2) CountLeadingZerosINode(pop()))); | |
1868 break; | |
1869 case vmIntrinsics::_numberOfLeadingZeros_l: | |
1870 push(_gvn.transform(new (C, 2) CountLeadingZerosLNode(pop_pair()))); | |
1871 break; | |
1872 default: | |
1873 ShouldNotReachHere(); | |
1874 } | |
1875 return true; | |
1876 } | |
1877 | |
1878 //-------------------inline_numberOfTrailingZeros_int/long---------------------- | |
1879 // inline int Integer.numberOfTrailingZeros(int) | |
1880 // inline int Long.numberOfTrailingZeros(long) | |
1881 bool LibraryCallKit::inline_numberOfTrailingZeros(vmIntrinsics::ID id) { | |
1882 assert(id == vmIntrinsics::_numberOfTrailingZeros_i || id == vmIntrinsics::_numberOfTrailingZeros_l, "not numberOfTrailingZeros"); | |
1883 if (id == vmIntrinsics::_numberOfTrailingZeros_i && !Matcher::match_rule_supported(Op_CountTrailingZerosI)) return false; | |
1884 if (id == vmIntrinsics::_numberOfTrailingZeros_l && !Matcher::match_rule_supported(Op_CountTrailingZerosL)) return false; | |
1885 _sp += arg_size(); // restore stack pointer | |
1886 switch (id) { | |
1887 case vmIntrinsics::_numberOfTrailingZeros_i: | |
1888 push(_gvn.transform(new (C, 2) CountTrailingZerosINode(pop()))); | |
1889 break; | |
1890 case vmIntrinsics::_numberOfTrailingZeros_l: | |
1891 push(_gvn.transform(new (C, 2) CountTrailingZerosLNode(pop_pair()))); | |
1892 break; | |
1893 default: | |
1894 ShouldNotReachHere(); | |
1895 } | |
1896 return true; | |
1897 } | |
1898 | |
1847 //----------------------------inline_bitCount_int/long----------------------- | 1899 //----------------------------inline_bitCount_int/long----------------------- |
1848 // inline int Integer.bitCount(int) | 1900 // inline int Integer.bitCount(int) |
1849 // inline int Long.bitCount(long) | 1901 // inline int Long.bitCount(long) |
1850 bool LibraryCallKit::inline_bitCount(vmIntrinsics::ID id) { | 1902 bool LibraryCallKit::inline_bitCount(vmIntrinsics::ID id) { |
1851 assert(id == vmIntrinsics::_bitCount_i || id == vmIntrinsics::_bitCount_l, "not bitCount"); | 1903 assert(id == vmIntrinsics::_bitCount_i || id == vmIntrinsics::_bitCount_l, "not bitCount"); |