Mercurial > hg > truffle
comparison src/share/vm/opto/library_call.cpp @ 18041:52b4284cb496
Merge with jdk8u20-b26
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 15 Oct 2014 16:02:50 +0200 |
parents | 4ca6dc0799b6 00c8a1255912 |
children | 7848fc12602b |
comparison
equal
deleted
inserted
replaced
17606:45d7b2c7029d | 18041:52b4284cb496 |
---|---|
201 Node* round_double_node(Node* n); | 201 Node* round_double_node(Node* n); |
202 bool runtime_math(const TypeFunc* call_type, address funcAddr, const char* funcName); | 202 bool runtime_math(const TypeFunc* call_type, address funcAddr, const char* funcName); |
203 bool inline_math_native(vmIntrinsics::ID id); | 203 bool inline_math_native(vmIntrinsics::ID id); |
204 bool inline_trig(vmIntrinsics::ID id); | 204 bool inline_trig(vmIntrinsics::ID id); |
205 bool inline_math(vmIntrinsics::ID id); | 205 bool inline_math(vmIntrinsics::ID id); |
206 void inline_math_mathExact(Node* math); | 206 template <typename OverflowOp> |
207 bool inline_math_overflow(Node* arg1, Node* arg2); | |
208 void inline_math_mathExact(Node* math, Node* test); | |
207 bool inline_math_addExactI(bool is_increment); | 209 bool inline_math_addExactI(bool is_increment); |
208 bool inline_math_addExactL(bool is_increment); | 210 bool inline_math_addExactL(bool is_increment); |
209 bool inline_math_multiplyExactI(); | 211 bool inline_math_multiplyExactI(); |
210 bool inline_math_multiplyExactL(); | 212 bool inline_math_multiplyExactL(); |
211 bool inline_math_negateExactI(); | 213 bool inline_math_negateExactI(); |
212 bool inline_math_negateExactL(); | 214 bool inline_math_negateExactL(); |
213 bool inline_math_subtractExactI(bool is_decrement); | 215 bool inline_math_subtractExactI(bool is_decrement); |
214 bool inline_math_subtractExactL(bool is_decrement); | 216 bool inline_math_subtractExactL(bool is_decrement); |
215 bool inline_exp(); | 217 bool inline_exp(); |
216 bool inline_pow(); | 218 bool inline_pow(); |
217 void finish_pow_exp(Node* result, Node* x, Node* y, const TypeFunc* call_type, address funcAddr, const char* funcName); | 219 Node* finish_pow_exp(Node* result, Node* x, Node* y, const TypeFunc* call_type, address funcAddr, const char* funcName); |
218 bool inline_min_max(vmIntrinsics::ID id); | 220 bool inline_min_max(vmIntrinsics::ID id); |
219 Node* generate_min_max(vmIntrinsics::ID id, Node* x, Node* y); | 221 Node* generate_min_max(vmIntrinsics::ID id, Node* x, Node* y); |
220 // This returns Type::AnyPtr, RawPtr, or OopPtr. | 222 // This returns Type::AnyPtr, RawPtr, or OopPtr. |
221 int classify_unsafe_addr(Node* &base, Node* &offset); | 223 int classify_unsafe_addr(Node* &base, Node* &offset); |
222 Node* make_unsafe_address(Node* base, Node* offset); | 224 Node* make_unsafe_address(Node* base, Node* offset); |
302 bool inline_reference_get(); | 304 bool inline_reference_get(); |
303 bool inline_aescrypt_Block(vmIntrinsics::ID id); | 305 bool inline_aescrypt_Block(vmIntrinsics::ID id); |
304 bool inline_cipherBlockChaining_AESCrypt(vmIntrinsics::ID id); | 306 bool inline_cipherBlockChaining_AESCrypt(vmIntrinsics::ID id); |
305 Node* inline_cipherBlockChaining_AESCrypt_predicate(bool decrypting); | 307 Node* inline_cipherBlockChaining_AESCrypt_predicate(bool decrypting); |
306 Node* get_key_start_from_aescrypt_object(Node* aescrypt_object); | 308 Node* get_key_start_from_aescrypt_object(Node* aescrypt_object); |
309 Node* get_original_key_start_from_aescrypt_object(Node* aescrypt_object); | |
307 bool inline_encodeISOArray(); | 310 bool inline_encodeISOArray(); |
308 bool inline_updateCRC32(); | 311 bool inline_updateCRC32(); |
309 bool inline_updateBytesCRC32(); | 312 bool inline_updateBytesCRC32(); |
310 bool inline_updateByteBufferCRC32(); | 313 bool inline_updateByteBufferCRC32(); |
311 }; | 314 }; |
514 if (!UseCRC32Intrinsics) return NULL; | 517 if (!UseCRC32Intrinsics) return NULL; |
515 break; | 518 break; |
516 | 519 |
517 case vmIntrinsics::_incrementExactI: | 520 case vmIntrinsics::_incrementExactI: |
518 case vmIntrinsics::_addExactI: | 521 case vmIntrinsics::_addExactI: |
519 if (!Matcher::match_rule_supported(Op_AddExactI) || !UseMathExactIntrinsics) return NULL; | 522 if (!Matcher::match_rule_supported(Op_OverflowAddI) || !UseMathExactIntrinsics) return NULL; |
520 break; | 523 break; |
521 case vmIntrinsics::_incrementExactL: | 524 case vmIntrinsics::_incrementExactL: |
522 case vmIntrinsics::_addExactL: | 525 case vmIntrinsics::_addExactL: |
523 if (!Matcher::match_rule_supported(Op_AddExactL) || !UseMathExactIntrinsics) return NULL; | 526 if (!Matcher::match_rule_supported(Op_OverflowAddL) || !UseMathExactIntrinsics) return NULL; |
524 break; | 527 break; |
525 case vmIntrinsics::_decrementExactI: | 528 case vmIntrinsics::_decrementExactI: |
526 case vmIntrinsics::_subtractExactI: | 529 case vmIntrinsics::_subtractExactI: |
527 if (!Matcher::match_rule_supported(Op_SubExactI) || !UseMathExactIntrinsics) return NULL; | 530 if (!Matcher::match_rule_supported(Op_OverflowSubI) || !UseMathExactIntrinsics) return NULL; |
528 break; | 531 break; |
529 case vmIntrinsics::_decrementExactL: | 532 case vmIntrinsics::_decrementExactL: |
530 case vmIntrinsics::_subtractExactL: | 533 case vmIntrinsics::_subtractExactL: |
531 if (!Matcher::match_rule_supported(Op_SubExactL) || !UseMathExactIntrinsics) return NULL; | 534 if (!Matcher::match_rule_supported(Op_OverflowSubL) || !UseMathExactIntrinsics) return NULL; |
532 break; | 535 break; |
533 case vmIntrinsics::_negateExactI: | 536 case vmIntrinsics::_negateExactI: |
534 if (!Matcher::match_rule_supported(Op_NegExactI) || !UseMathExactIntrinsics) return NULL; | 537 if (!Matcher::match_rule_supported(Op_OverflowSubI) || !UseMathExactIntrinsics) return NULL; |
535 break; | 538 break; |
536 case vmIntrinsics::_negateExactL: | 539 case vmIntrinsics::_negateExactL: |
537 if (!Matcher::match_rule_supported(Op_NegExactL) || !UseMathExactIntrinsics) return NULL; | 540 if (!Matcher::match_rule_supported(Op_OverflowSubL) || !UseMathExactIntrinsics) return NULL; |
538 break; | 541 break; |
539 case vmIntrinsics::_multiplyExactI: | 542 case vmIntrinsics::_multiplyExactI: |
540 if (!Matcher::match_rule_supported(Op_MulExactI) || !UseMathExactIntrinsics) return NULL; | 543 if (!Matcher::match_rule_supported(Op_OverflowMulI) || !UseMathExactIntrinsics) return NULL; |
541 break; | 544 break; |
542 case vmIntrinsics::_multiplyExactL: | 545 case vmIntrinsics::_multiplyExactL: |
543 if (!Matcher::match_rule_supported(Op_MulExactL) || !UseMathExactIntrinsics) return NULL; | 546 if (!Matcher::match_rule_supported(Op_OverflowMulL) || !UseMathExactIntrinsics) return NULL; |
544 break; | 547 break; |
545 | 548 |
546 default: | 549 default: |
547 assert(id <= vmIntrinsics::LAST_COMPILER_INLINE, "caller responsibility"); | 550 assert(id <= vmIntrinsics::LAST_COMPILER_INLINE, "caller responsibility"); |
548 assert(id != vmIntrinsics::_Object_init && id != vmIntrinsics::_invoke, "enum out of order?"); | 551 assert(id != vmIntrinsics::_Object_init && id != vmIntrinsics::_invoke, "enum out of order?"); |
1055 Node* LibraryCallKit::generate_current_thread(Node* &tls_output) { | 1058 Node* LibraryCallKit::generate_current_thread(Node* &tls_output) { |
1056 ciKlass* thread_klass = env()->Thread_klass(); | 1059 ciKlass* thread_klass = env()->Thread_klass(); |
1057 const Type* thread_type = TypeOopPtr::make_from_klass(thread_klass)->cast_to_ptr_type(TypePtr::NotNull); | 1060 const Type* thread_type = TypeOopPtr::make_from_klass(thread_klass)->cast_to_ptr_type(TypePtr::NotNull); |
1058 Node* thread = _gvn.transform(new (C) ThreadLocalNode()); | 1061 Node* thread = _gvn.transform(new (C) ThreadLocalNode()); |
1059 Node* p = basic_plus_adr(top()/*!oop*/, thread, in_bytes(JavaThread::threadObj_offset())); | 1062 Node* p = basic_plus_adr(top()/*!oop*/, thread, in_bytes(JavaThread::threadObj_offset())); |
1060 Node* threadObj = make_load(NULL, p, thread_type, T_OBJECT); | 1063 Node* threadObj = make_load(NULL, p, thread_type, T_OBJECT, MemNode::unordered); |
1061 tls_output = thread; | 1064 tls_output = thread; |
1062 return threadObj; | 1065 return threadObj; |
1063 } | 1066 } |
1064 | 1067 |
1065 | 1068 |
1673 } | 1676 } |
1674 set_result(n); | 1677 set_result(n); |
1675 return true; | 1678 return true; |
1676 } | 1679 } |
1677 | 1680 |
1678 void LibraryCallKit::finish_pow_exp(Node* result, Node* x, Node* y, const TypeFunc* call_type, address funcAddr, const char* funcName) { | 1681 Node* LibraryCallKit::finish_pow_exp(Node* result, Node* x, Node* y, const TypeFunc* call_type, address funcAddr, const char* funcName) { |
1679 //------------------- | 1682 //------------------- |
1680 //result=(result.isNaN())? funcAddr():result; | 1683 //result=(result.isNaN())? funcAddr():result; |
1681 // Check: If isNaN() by checking result!=result? then either trap | 1684 // Check: If isNaN() by checking result!=result? then either trap |
1682 // or go to runtime | 1685 // or go to runtime |
1683 Node* cmpisnan = _gvn.transform(new (C) CmpDNode(result, result)); | 1686 Node* cmpisnan = _gvn.transform(new (C) CmpDNode(result, result)); |
1689 // The pow or exp intrinsic returned a NaN, which requires a call | 1692 // The pow or exp intrinsic returned a NaN, which requires a call |
1690 // to the runtime. Recompile with the runtime call. | 1693 // to the runtime. Recompile with the runtime call. |
1691 uncommon_trap(Deoptimization::Reason_intrinsic, | 1694 uncommon_trap(Deoptimization::Reason_intrinsic, |
1692 Deoptimization::Action_make_not_entrant); | 1695 Deoptimization::Action_make_not_entrant); |
1693 } | 1696 } |
1694 set_result(result); | 1697 return result; |
1695 } else { | 1698 } else { |
1696 // If this inlining ever returned NaN in the past, we compile a call | 1699 // If this inlining ever returned NaN in the past, we compile a call |
1697 // to the runtime to properly handle corner cases | 1700 // to the runtime to properly handle corner cases |
1698 | 1701 |
1699 IfNode* iff = create_and_xform_if(control(), bolisnum, PROB_STATIC_FREQUENT, COUNT_UNKNOWN); | 1702 IfNode* iff = create_and_xform_if(control(), bolisnum, PROB_STATIC_FREQUENT, COUNT_UNKNOWN); |
1719 assert(value_top == top(), "second value must be top"); | 1722 assert(value_top == top(), "second value must be top"); |
1720 #endif | 1723 #endif |
1721 | 1724 |
1722 result_region->init_req(2, control()); | 1725 result_region->init_req(2, control()); |
1723 result_val->init_req(2, value); | 1726 result_val->init_req(2, value); |
1724 set_result(result_region, result_val); | 1727 set_control(_gvn.transform(result_region)); |
1728 return _gvn.transform(result_val); | |
1725 } else { | 1729 } else { |
1726 set_result(result); | 1730 return result; |
1727 } | 1731 } |
1728 } | 1732 } |
1729 } | 1733 } |
1730 | 1734 |
1731 //------------------------------inline_exp------------------------------------- | 1735 //------------------------------inline_exp------------------------------------- |
1733 // really odd corner cases (+/- Infinity). Just uncommon-trap them. | 1737 // really odd corner cases (+/- Infinity). Just uncommon-trap them. |
1734 bool LibraryCallKit::inline_exp() { | 1738 bool LibraryCallKit::inline_exp() { |
1735 Node* arg = round_double_node(argument(0)); | 1739 Node* arg = round_double_node(argument(0)); |
1736 Node* n = _gvn.transform(new (C) ExpDNode(C, control(), arg)); | 1740 Node* n = _gvn.transform(new (C) ExpDNode(C, control(), arg)); |
1737 | 1741 |
1738 finish_pow_exp(n, arg, NULL, OptoRuntime::Math_D_D_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::dexp), "EXP"); | 1742 n = finish_pow_exp(n, arg, NULL, OptoRuntime::Math_D_D_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::dexp), "EXP"); |
1743 set_result(n); | |
1739 | 1744 |
1740 C->set_has_split_ifs(true); // Has chance for split-if optimization | 1745 C->set_has_split_ifs(true); // Has chance for split-if optimization |
1741 return true; | 1746 return true; |
1742 } | 1747 } |
1743 | 1748 |
1744 //------------------------------inline_pow------------------------------------- | 1749 //------------------------------inline_pow------------------------------------- |
1745 // Inline power instructions, if possible. | 1750 // Inline power instructions, if possible. |
1746 bool LibraryCallKit::inline_pow() { | 1751 bool LibraryCallKit::inline_pow() { |
1747 // Pseudocode for pow | 1752 // Pseudocode for pow |
1748 // if (x <= 0.0) { | 1753 // if (y == 2) { |
1749 // long longy = (long)y; | 1754 // return x * x; |
1750 // if ((double)longy == y) { // if y is long | 1755 // } else { |
1751 // if (y + 1 == y) longy = 0; // huge number: even | 1756 // if (x <= 0.0) { |
1752 // result = ((1&longy) == 0)?-DPow(abs(x), y):DPow(abs(x), y); | 1757 // long longy = (long)y; |
1758 // if ((double)longy == y) { // if y is long | |
1759 // if (y + 1 == y) longy = 0; // huge number: even | |
1760 // result = ((1&longy) == 0)?-DPow(abs(x), y):DPow(abs(x), y); | |
1761 // } else { | |
1762 // result = NaN; | |
1763 // } | |
1753 // } else { | 1764 // } else { |
1754 // result = NaN; | 1765 // result = DPow(x,y); |
1755 // } | 1766 // } |
1756 // } else { | 1767 // if (result != result)? { |
1757 // result = DPow(x,y); | 1768 // result = uncommon_trap() or runtime_call(); |
1769 // } | |
1770 // return result; | |
1758 // } | 1771 // } |
1759 // if (result != result)? { | |
1760 // result = uncommon_trap() or runtime_call(); | |
1761 // } | |
1762 // return result; | |
1763 | 1772 |
1764 Node* x = round_double_node(argument(0)); | 1773 Node* x = round_double_node(argument(0)); |
1765 Node* y = round_double_node(argument(2)); | 1774 Node* y = round_double_node(argument(2)); |
1766 | 1775 |
1767 Node* result = NULL; | 1776 Node* result = NULL; |
1777 | |
1778 Node* const_two_node = makecon(TypeD::make(2.0)); | |
1779 Node* cmp_node = _gvn.transform(new (C) CmpDNode(y, const_two_node)); | |
1780 Node* bool_node = _gvn.transform(new (C) BoolNode(cmp_node, BoolTest::eq)); | |
1781 IfNode* if_node = create_and_xform_if(control(), bool_node, PROB_STATIC_INFREQUENT, COUNT_UNKNOWN); | |
1782 Node* if_true = _gvn.transform(new (C) IfTrueNode(if_node)); | |
1783 Node* if_false = _gvn.transform(new (C) IfFalseNode(if_node)); | |
1784 | |
1785 RegionNode* region_node = new (C) RegionNode(3); | |
1786 region_node->init_req(1, if_true); | |
1787 | |
1788 Node* phi_node = new (C) PhiNode(region_node, Type::DOUBLE); | |
1789 // special case for x^y where y == 2, we can convert it to x * x | |
1790 phi_node->init_req(1, _gvn.transform(new (C) MulDNode(x, x))); | |
1791 | |
1792 // set control to if_false since we will now process the false branch | |
1793 set_control(if_false); | |
1768 | 1794 |
1769 if (!too_many_traps(Deoptimization::Reason_intrinsic)) { | 1795 if (!too_many_traps(Deoptimization::Reason_intrinsic)) { |
1770 // Short form: skip the fancy tests and just check for NaN result. | 1796 // Short form: skip the fancy tests and just check for NaN result. |
1771 result = _gvn.transform(new (C) PowDNode(C, control(), x, y)); | 1797 result = _gvn.transform(new (C) PowDNode(C, control(), x, y)); |
1772 } else { | 1798 } else { |
1887 set_control(_gvn.transform(r)); | 1913 set_control(_gvn.transform(r)); |
1888 record_for_igvn(r); | 1914 record_for_igvn(r); |
1889 result = _gvn.transform(phi); | 1915 result = _gvn.transform(phi); |
1890 } | 1916 } |
1891 | 1917 |
1892 finish_pow_exp(result, x, y, OptoRuntime::Math_DD_D_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::dpow), "POW"); | 1918 result = finish_pow_exp(result, x, y, OptoRuntime::Math_DD_D_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::dpow), "POW"); |
1919 | |
1920 // control from finish_pow_exp is now input to the region node | |
1921 region_node->set_req(2, control()); | |
1922 // the result from finish_pow_exp is now input to the phi node | |
1923 phi_node->init_req(2, result); | |
1924 set_control(_gvn.transform(region_node)); | |
1925 record_for_igvn(region_node); | |
1926 set_result(_gvn.transform(phi_node)); | |
1893 | 1927 |
1894 C->set_has_split_ifs(true); // Has chance for split-if optimization | 1928 C->set_has_split_ifs(true); // Has chance for split-if optimization |
1895 return true; | 1929 return true; |
1896 } | 1930 } |
1897 | 1931 |
1934 runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dlog), "LOG"); | 1968 runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dlog), "LOG"); |
1935 case vmIntrinsics::_dlog10: return Matcher::has_match_rule(Op_Log10D) ? inline_math(id) : | 1969 case vmIntrinsics::_dlog10: return Matcher::has_match_rule(Op_Log10D) ? inline_math(id) : |
1936 runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dlog10), "LOG10"); | 1970 runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dlog10), "LOG10"); |
1937 | 1971 |
1938 // These intrinsics are supported on all hardware | 1972 // These intrinsics are supported on all hardware |
1939 case vmIntrinsics::_dsqrt: return Matcher::has_match_rule(Op_SqrtD) ? inline_math(id) : false; | 1973 case vmIntrinsics::_dsqrt: return Matcher::match_rule_supported(Op_SqrtD) ? inline_math(id) : false; |
1940 case vmIntrinsics::_dabs: return Matcher::has_match_rule(Op_AbsD) ? inline_math(id) : false; | 1974 case vmIntrinsics::_dabs: return Matcher::has_match_rule(Op_AbsD) ? inline_math(id) : false; |
1941 | 1975 |
1942 case vmIntrinsics::_dexp: return Matcher::has_match_rule(Op_ExpD) ? inline_exp() : | 1976 case vmIntrinsics::_dexp: return Matcher::has_match_rule(Op_ExpD) ? inline_exp() : |
1943 runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dexp), "EXP"); | 1977 runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dexp), "EXP"); |
1944 case vmIntrinsics::_dpow: return Matcher::has_match_rule(Op_PowD) ? inline_pow() : | 1978 case vmIntrinsics::_dpow: return Matcher::has_match_rule(Op_PowD) ? inline_pow() : |
1967 bool LibraryCallKit::inline_min_max(vmIntrinsics::ID id) { | 2001 bool LibraryCallKit::inline_min_max(vmIntrinsics::ID id) { |
1968 set_result(generate_min_max(id, argument(0), argument(1))); | 2002 set_result(generate_min_max(id, argument(0), argument(1))); |
1969 return true; | 2003 return true; |
1970 } | 2004 } |
1971 | 2005 |
1972 void LibraryCallKit::inline_math_mathExact(Node* math) { | 2006 void LibraryCallKit::inline_math_mathExact(Node* math, Node *test) { |
1973 // If we didn't get the expected opcode it means we have optimized | 2007 Node* bol = _gvn.transform( new (C) BoolNode(test, BoolTest::overflow) ); |
1974 // the node to something else and don't need the exception edge. | |
1975 if (!math->is_MathExact()) { | |
1976 set_result(math); | |
1977 return; | |
1978 } | |
1979 | |
1980 Node* result = _gvn.transform( new(C) ProjNode(math, MathExactNode::result_proj_node)); | |
1981 Node* flags = _gvn.transform( new(C) FlagsProjNode(math, MathExactNode::flags_proj_node)); | |
1982 | |
1983 Node* bol = _gvn.transform( new (C) BoolNode(flags, BoolTest::overflow) ); | |
1984 IfNode* check = create_and_map_if(control(), bol, PROB_UNLIKELY_MAG(3), COUNT_UNKNOWN); | 2008 IfNode* check = create_and_map_if(control(), bol, PROB_UNLIKELY_MAG(3), COUNT_UNKNOWN); |
1985 Node* fast_path = _gvn.transform( new (C) IfFalseNode(check)); | 2009 Node* fast_path = _gvn.transform( new (C) IfFalseNode(check)); |
1986 Node* slow_path = _gvn.transform( new (C) IfTrueNode(check) ); | 2010 Node* slow_path = _gvn.transform( new (C) IfTrueNode(check) ); |
1987 | 2011 |
1988 { | 2012 { |
1996 uncommon_trap(Deoptimization::Reason_intrinsic, | 2020 uncommon_trap(Deoptimization::Reason_intrinsic, |
1997 Deoptimization::Action_none); | 2021 Deoptimization::Action_none); |
1998 } | 2022 } |
1999 | 2023 |
2000 set_control(fast_path); | 2024 set_control(fast_path); |
2001 set_result(result); | 2025 set_result(math); |
2026 } | |
2027 | |
2028 template <typename OverflowOp> | |
2029 bool LibraryCallKit::inline_math_overflow(Node* arg1, Node* arg2) { | |
2030 typedef typename OverflowOp::MathOp MathOp; | |
2031 | |
2032 MathOp* mathOp = new(C) MathOp(arg1, arg2); | |
2033 Node* operation = _gvn.transform( mathOp ); | |
2034 Node* ofcheck = _gvn.transform( new(C) OverflowOp(arg1, arg2) ); | |
2035 inline_math_mathExact(operation, ofcheck); | |
2036 return true; | |
2002 } | 2037 } |
2003 | 2038 |
2004 bool LibraryCallKit::inline_math_addExactI(bool is_increment) { | 2039 bool LibraryCallKit::inline_math_addExactI(bool is_increment) { |
2005 Node* arg1 = argument(0); | 2040 return inline_math_overflow<OverflowAddINode>(argument(0), is_increment ? intcon(1) : argument(1)); |
2006 Node* arg2 = NULL; | |
2007 | |
2008 if (is_increment) { | |
2009 arg2 = intcon(1); | |
2010 } else { | |
2011 arg2 = argument(1); | |
2012 } | |
2013 | |
2014 Node* add = _gvn.transform( new(C) AddExactINode(NULL, arg1, arg2) ); | |
2015 inline_math_mathExact(add); | |
2016 return true; | |
2017 } | 2041 } |
2018 | 2042 |
2019 bool LibraryCallKit::inline_math_addExactL(bool is_increment) { | 2043 bool LibraryCallKit::inline_math_addExactL(bool is_increment) { |
2020 Node* arg1 = argument(0); // type long | 2044 return inline_math_overflow<OverflowAddLNode>(argument(0), is_increment ? longcon(1) : argument(2)); |
2021 // argument(1) == TOP | |
2022 Node* arg2 = NULL; | |
2023 | |
2024 if (is_increment) { | |
2025 arg2 = longcon(1); | |
2026 } else { | |
2027 arg2 = argument(2); // type long | |
2028 // argument(3) == TOP | |
2029 } | |
2030 | |
2031 Node* add = _gvn.transform(new(C) AddExactLNode(NULL, arg1, arg2)); | |
2032 inline_math_mathExact(add); | |
2033 return true; | |
2034 } | 2045 } |
2035 | 2046 |
2036 bool LibraryCallKit::inline_math_subtractExactI(bool is_decrement) { | 2047 bool LibraryCallKit::inline_math_subtractExactI(bool is_decrement) { |
2037 Node* arg1 = argument(0); | 2048 return inline_math_overflow<OverflowSubINode>(argument(0), is_decrement ? intcon(1) : argument(1)); |
2038 Node* arg2 = NULL; | |
2039 | |
2040 if (is_decrement) { | |
2041 arg2 = intcon(1); | |
2042 } else { | |
2043 arg2 = argument(1); | |
2044 } | |
2045 | |
2046 Node* sub = _gvn.transform(new(C) SubExactINode(NULL, arg1, arg2)); | |
2047 inline_math_mathExact(sub); | |
2048 return true; | |
2049 } | 2049 } |
2050 | 2050 |
2051 bool LibraryCallKit::inline_math_subtractExactL(bool is_decrement) { | 2051 bool LibraryCallKit::inline_math_subtractExactL(bool is_decrement) { |
2052 Node* arg1 = argument(0); // type long | 2052 return inline_math_overflow<OverflowSubLNode>(argument(0), is_decrement ? longcon(1) : argument(2)); |
2053 // argument(1) == TOP | |
2054 Node* arg2 = NULL; | |
2055 | |
2056 if (is_decrement) { | |
2057 arg2 = longcon(1); | |
2058 } else { | |
2059 arg2 = argument(2); // type long | |
2060 // argument(3) == TOP | |
2061 } | |
2062 | |
2063 Node* sub = _gvn.transform(new(C) SubExactLNode(NULL, arg1, arg2)); | |
2064 inline_math_mathExact(sub); | |
2065 return true; | |
2066 } | 2053 } |
2067 | 2054 |
2068 bool LibraryCallKit::inline_math_negateExactI() { | 2055 bool LibraryCallKit::inline_math_negateExactI() { |
2069 Node* arg1 = argument(0); | 2056 return inline_math_overflow<OverflowSubINode>(intcon(0), argument(0)); |
2070 | |
2071 Node* neg = _gvn.transform(new(C) NegExactINode(NULL, arg1)); | |
2072 inline_math_mathExact(neg); | |
2073 return true; | |
2074 } | 2057 } |
2075 | 2058 |
2076 bool LibraryCallKit::inline_math_negateExactL() { | 2059 bool LibraryCallKit::inline_math_negateExactL() { |
2077 Node* arg1 = argument(0); | 2060 return inline_math_overflow<OverflowSubLNode>(longcon(0), argument(0)); |
2078 // argument(1) == TOP | |
2079 | |
2080 Node* neg = _gvn.transform(new(C) NegExactLNode(NULL, arg1)); | |
2081 inline_math_mathExact(neg); | |
2082 return true; | |
2083 } | 2061 } |
2084 | 2062 |
2085 bool LibraryCallKit::inline_math_multiplyExactI() { | 2063 bool LibraryCallKit::inline_math_multiplyExactI() { |
2086 Node* arg1 = argument(0); | 2064 return inline_math_overflow<OverflowMulINode>(argument(0), argument(1)); |
2087 Node* arg2 = argument(1); | |
2088 | |
2089 Node* mul = _gvn.transform(new(C) MulExactINode(NULL, arg1, arg2)); | |
2090 inline_math_mathExact(mul); | |
2091 return true; | |
2092 } | 2065 } |
2093 | 2066 |
2094 bool LibraryCallKit::inline_math_multiplyExactL() { | 2067 bool LibraryCallKit::inline_math_multiplyExactL() { |
2095 Node* arg1 = argument(0); | 2068 return inline_math_overflow<OverflowMulLNode>(argument(0), argument(2)); |
2096 // argument(1) == TOP | |
2097 Node* arg2 = argument(2); | |
2098 // argument(3) == TOP | |
2099 | |
2100 Node* mul = _gvn.transform(new(C) MulExactLNode(NULL, arg1, arg2)); | |
2101 inline_math_mathExact(mul); | |
2102 return true; | |
2103 } | 2069 } |
2104 | 2070 |
2105 Node* | 2071 Node* |
2106 LibraryCallKit::generate_min_max(vmIntrinsics::ID id, Node* x0, Node* y0) { | 2072 LibraryCallKit::generate_min_max(vmIntrinsics::ID id, Node* x0, Node* y0) { |
2107 // These are the candidate return value: | 2073 // These are the candidate return value: |
2625 // volatile membars (for stores; compare Parse::do_put_xxx), which | 2591 // volatile membars (for stores; compare Parse::do_put_xxx), which |
2626 // we cannot do effectively here because we probably only have a | 2592 // we cannot do effectively here because we probably only have a |
2627 // rough approximation of type. | 2593 // rough approximation of type. |
2628 need_mem_bar = true; | 2594 need_mem_bar = true; |
2629 // For Stores, place a memory ordering barrier now. | 2595 // For Stores, place a memory ordering barrier now. |
2630 if (is_store) | 2596 if (is_store) { |
2631 insert_mem_bar(Op_MemBarRelease); | 2597 insert_mem_bar(Op_MemBarRelease); |
2598 } else { | |
2599 if (support_IRIW_for_not_multiple_copy_atomic_cpu) { | |
2600 insert_mem_bar(Op_MemBarVolatile); | |
2601 } | |
2602 } | |
2632 } | 2603 } |
2633 | 2604 |
2634 // Memory barrier to prevent normal and 'unsafe' accesses from | 2605 // Memory barrier to prevent normal and 'unsafe' accesses from |
2635 // bypassing each other. Happens after null checks, so the | 2606 // bypassing each other. Happens after null checks, so the |
2636 // exception paths do not take memory state from the memory barrier, | 2607 // exception paths do not take memory state from the memory barrier, |
2638 // of safe & unsafe memory. Otherwise fails in a CTW of rt.jar | 2609 // of safe & unsafe memory. Otherwise fails in a CTW of rt.jar |
2639 // around 5701, class sun/reflect/UnsafeBooleanFieldAccessorImpl. | 2610 // around 5701, class sun/reflect/UnsafeBooleanFieldAccessorImpl. |
2640 if (need_mem_bar) insert_mem_bar(Op_MemBarCPUOrder); | 2611 if (need_mem_bar) insert_mem_bar(Op_MemBarCPUOrder); |
2641 | 2612 |
2642 if (!is_store) { | 2613 if (!is_store) { |
2643 Node* p = make_load(control(), adr, value_type, type, adr_type, is_volatile); | 2614 Node* p = make_load(control(), adr, value_type, type, adr_type, MemNode::unordered, is_volatile); |
2644 // load value | 2615 // load value |
2645 switch (type) { | 2616 switch (type) { |
2646 case T_BOOLEAN: | 2617 case T_BOOLEAN: |
2647 case T_CHAR: | 2618 case T_CHAR: |
2648 case T_BYTE: | 2619 case T_BYTE: |
2658 } | 2629 } |
2659 break; | 2630 break; |
2660 case T_ADDRESS: | 2631 case T_ADDRESS: |
2661 // Cast to an int type. | 2632 // Cast to an int type. |
2662 p = _gvn.transform(new (C) CastP2XNode(NULL, p)); | 2633 p = _gvn.transform(new (C) CastP2XNode(NULL, p)); |
2663 p = ConvX2L(p); | 2634 p = ConvX2UL(p); |
2664 break; | 2635 break; |
2665 default: | 2636 default: |
2666 fatal(err_msg_res("unexpected type %d: %s", type, type2name(type))); | 2637 fatal(err_msg_res("unexpected type %d: %s", type, type2name(type))); |
2667 break; | 2638 break; |
2668 } | 2639 } |
2682 val = ConvL2X(val); | 2653 val = ConvL2X(val); |
2683 val = _gvn.transform(new (C) CastX2PNode(val)); | 2654 val = _gvn.transform(new (C) CastX2PNode(val)); |
2684 break; | 2655 break; |
2685 } | 2656 } |
2686 | 2657 |
2658 MemNode::MemOrd mo = is_volatile ? MemNode::release : MemNode::unordered; | |
2687 if (type != T_OBJECT ) { | 2659 if (type != T_OBJECT ) { |
2688 (void) store_to_memory(control(), adr, val, type, adr_type, is_volatile); | 2660 (void) store_to_memory(control(), adr, val, type, adr_type, mo, is_volatile); |
2689 } else { | 2661 } else { |
2690 // Possibly an oop being stored to Java heap or native memory | 2662 // Possibly an oop being stored to Java heap or native memory |
2691 if (!TypePtr::NULL_PTR->higher_equal(_gvn.type(heap_base_oop))) { | 2663 if (!TypePtr::NULL_PTR->higher_equal(_gvn.type(heap_base_oop))) { |
2692 // oop to Java heap. | 2664 // oop to Java heap. |
2693 (void) store_oop_to_unknown(control(), heap_base_oop, adr, adr_type, val, type); | 2665 (void) store_oop_to_unknown(control(), heap_base_oop, adr, adr_type, val, type, mo); |
2694 } else { | 2666 } else { |
2695 // We can't tell at compile time if we are storing in the Java heap or outside | 2667 // We can't tell at compile time if we are storing in the Java heap or outside |
2696 // of it. So we need to emit code to conditionally do the proper type of | 2668 // of it. So we need to emit code to conditionally do the proper type of |
2697 // store. | 2669 // store. |
2698 | 2670 |
2700 #define __ ideal. | 2672 #define __ ideal. |
2701 // QQQ who knows what probability is here?? | 2673 // QQQ who knows what probability is here?? |
2702 __ if_then(heap_base_oop, BoolTest::ne, null(), PROB_UNLIKELY(0.999)); { | 2674 __ if_then(heap_base_oop, BoolTest::ne, null(), PROB_UNLIKELY(0.999)); { |
2703 // Sync IdealKit and graphKit. | 2675 // Sync IdealKit and graphKit. |
2704 sync_kit(ideal); | 2676 sync_kit(ideal); |
2705 Node* st = store_oop_to_unknown(control(), heap_base_oop, adr, adr_type, val, type); | 2677 Node* st = store_oop_to_unknown(control(), heap_base_oop, adr, adr_type, val, type, mo); |
2706 // Update IdealKit memory. | 2678 // Update IdealKit memory. |
2707 __ sync_kit(this); | 2679 __ sync_kit(this); |
2708 } __ else_(); { | 2680 } __ else_(); { |
2709 __ store(__ ctrl(), adr, val, type, alias_type->index(), is_volatile); | 2681 __ store(__ ctrl(), adr, val, type, alias_type->index(), mo, is_volatile); |
2710 } __ end_if(); | 2682 } __ end_if(); |
2711 // Final sync IdealKit and GraphKit. | 2683 // Final sync IdealKit and GraphKit. |
2712 final_sync(ideal); | 2684 final_sync(ideal); |
2713 #undef __ | 2685 #undef __ |
2714 } | 2686 } |
2715 } | 2687 } |
2716 } | 2688 } |
2717 | 2689 |
2718 if (is_volatile) { | 2690 if (is_volatile) { |
2719 if (!is_store) | 2691 if (!is_store) { |
2720 insert_mem_bar(Op_MemBarAcquire); | 2692 insert_mem_bar(Op_MemBarAcquire); |
2721 else | 2693 } else { |
2722 insert_mem_bar(Op_MemBarVolatile); | 2694 if (!support_IRIW_for_not_multiple_copy_atomic_cpu) { |
2695 insert_mem_bar(Op_MemBarVolatile); | |
2696 } | |
2697 } | |
2723 } | 2698 } |
2724 | 2699 |
2725 if (need_mem_bar) insert_mem_bar(Op_MemBarCPUOrder); | 2700 if (need_mem_bar) insert_mem_bar(Op_MemBarCPUOrder); |
2726 | 2701 |
2727 return true; | 2702 return true; |
2977 #ifdef _LP64 | 2952 #ifdef _LP64 |
2978 if (adr->bottom_type()->is_ptr_to_narrowoop()) { | 2953 if (adr->bottom_type()->is_ptr_to_narrowoop()) { |
2979 Node *newval_enc = _gvn.transform(new (C) EncodePNode(newval, newval->bottom_type()->make_narrowoop())); | 2954 Node *newval_enc = _gvn.transform(new (C) EncodePNode(newval, newval->bottom_type()->make_narrowoop())); |
2980 if (kind == LS_xchg) { | 2955 if (kind == LS_xchg) { |
2981 load_store = _gvn.transform(new (C) GetAndSetNNode(control(), mem, adr, | 2956 load_store = _gvn.transform(new (C) GetAndSetNNode(control(), mem, adr, |
2982 newval_enc, adr_type, value_type->make_narrowoop())); | 2957 newval_enc, adr_type, value_type->make_narrowoop())); |
2983 } else { | 2958 } else { |
2984 assert(kind == LS_cmpxchg, "wrong LoadStore operation"); | 2959 assert(kind == LS_cmpxchg, "wrong LoadStore operation"); |
2985 Node *oldval_enc = _gvn.transform(new (C) EncodePNode(oldval, oldval->bottom_type()->make_narrowoop())); | 2960 Node *oldval_enc = _gvn.transform(new (C) EncodePNode(oldval, oldval->bottom_type()->make_narrowoop())); |
2986 load_store = _gvn.transform(new (C) CompareAndSwapNNode(control(), mem, adr, | 2961 load_store = _gvn.transform(new (C) CompareAndSwapNNode(control(), mem, adr, |
2987 newval_enc, oldval_enc)); | 2962 newval_enc, oldval_enc)); |
2988 } | 2963 } |
2989 } else | 2964 } else |
2990 #endif | 2965 #endif |
2991 { | 2966 { |
2992 if (kind == LS_xchg) { | 2967 if (kind == LS_xchg) { |
3088 insert_mem_bar(Op_MemBarCPUOrder); | 3063 insert_mem_bar(Op_MemBarCPUOrder); |
3089 // Ensure that the store is atomic for longs: | 3064 // Ensure that the store is atomic for longs: |
3090 const bool require_atomic_access = true; | 3065 const bool require_atomic_access = true; |
3091 Node* store; | 3066 Node* store; |
3092 if (type == T_OBJECT) // reference stores need a store barrier. | 3067 if (type == T_OBJECT) // reference stores need a store barrier. |
3093 store = store_oop_to_unknown(control(), base, adr, adr_type, val, type); | 3068 store = store_oop_to_unknown(control(), base, adr, adr_type, val, type, MemNode::release); |
3094 else { | 3069 else { |
3095 store = store_to_memory(control(), adr, val, type, adr_type, require_atomic_access); | 3070 store = store_to_memory(control(), adr, val, type, adr_type, MemNode::release, require_atomic_access); |
3096 } | 3071 } |
3097 insert_mem_bar(Op_MemBarCPUOrder); | 3072 insert_mem_bar(Op_MemBarCPUOrder); |
3098 return true; | 3073 return true; |
3099 } | 3074 } |
3100 | 3075 |
3102 // Regardless of form, don't allow previous ld/st to move down, | 3077 // Regardless of form, don't allow previous ld/st to move down, |
3103 // then issue acquire, release, or volatile mem_bar. | 3078 // then issue acquire, release, or volatile mem_bar. |
3104 insert_mem_bar(Op_MemBarCPUOrder); | 3079 insert_mem_bar(Op_MemBarCPUOrder); |
3105 switch(id) { | 3080 switch(id) { |
3106 case vmIntrinsics::_loadFence: | 3081 case vmIntrinsics::_loadFence: |
3107 insert_mem_bar(Op_MemBarAcquire); | 3082 insert_mem_bar(Op_LoadFence); |
3108 return true; | 3083 return true; |
3109 case vmIntrinsics::_storeFence: | 3084 case vmIntrinsics::_storeFence: |
3110 insert_mem_bar(Op_MemBarRelease); | 3085 insert_mem_bar(Op_StoreFence); |
3111 return true; | 3086 return true; |
3112 case vmIntrinsics::_fullFence: | 3087 case vmIntrinsics::_fullFence: |
3113 insert_mem_bar(Op_MemBarVolatile); | 3088 insert_mem_bar(Op_MemBarVolatile); |
3114 return true; | 3089 return true; |
3115 default: | 3090 default: |
3150 // Serializable.class or Object[].class. The runtime will handle it. | 3125 // Serializable.class or Object[].class. The runtime will handle it. |
3151 // But we must make an explicit check for initialization. | 3126 // But we must make an explicit check for initialization. |
3152 Node* insp = basic_plus_adr(kls, in_bytes(InstanceKlass::init_state_offset())); | 3127 Node* insp = basic_plus_adr(kls, in_bytes(InstanceKlass::init_state_offset())); |
3153 // Use T_BOOLEAN for InstanceKlass::_init_state so the compiler | 3128 // Use T_BOOLEAN for InstanceKlass::_init_state so the compiler |
3154 // can generate code to load it as unsigned byte. | 3129 // can generate code to load it as unsigned byte. |
3155 Node* inst = make_load(NULL, insp, TypeInt::UBYTE, T_BOOLEAN); | 3130 Node* inst = make_load(NULL, insp, TypeInt::UBYTE, T_BOOLEAN, MemNode::unordered); |
3156 Node* bits = intcon(InstanceKlass::fully_initialized); | 3131 Node* bits = intcon(InstanceKlass::fully_initialized); |
3157 test = _gvn.transform(new (C) SubINode(inst, bits)); | 3132 test = _gvn.transform(new (C) SubINode(inst, bits)); |
3158 // The 'test' is non-zero if we need to take a slow path. | 3133 // The 'test' is non-zero if we need to take a slow path. |
3159 } | 3134 } |
3160 | 3135 |
3174 Node* cls = null_check(argument(1), T_OBJECT); | 3149 Node* cls = null_check(argument(1), T_OBJECT); |
3175 Node* kls = load_klass_from_mirror(cls, false, NULL, 0); | 3150 Node* kls = load_klass_from_mirror(cls, false, NULL, 0); |
3176 kls = null_check(kls, T_OBJECT); | 3151 kls = null_check(kls, T_OBJECT); |
3177 ByteSize offset = TRACE_ID_OFFSET; | 3152 ByteSize offset = TRACE_ID_OFFSET; |
3178 Node* insp = basic_plus_adr(kls, in_bytes(offset)); | 3153 Node* insp = basic_plus_adr(kls, in_bytes(offset)); |
3179 Node* tvalue = make_load(NULL, insp, TypeLong::LONG, T_LONG); | 3154 Node* tvalue = make_load(NULL, insp, TypeLong::LONG, T_LONG, MemNode::unordered); |
3180 Node* bits = longcon(~0x03l); // ignore bit 0 & 1 | 3155 Node* bits = longcon(~0x03l); // ignore bit 0 & 1 |
3181 Node* andl = _gvn.transform(new (C) AndLNode(tvalue, bits)); | 3156 Node* andl = _gvn.transform(new (C) AndLNode(tvalue, bits)); |
3182 Node* clsused = longcon(0x01l); // set the class bit | 3157 Node* clsused = longcon(0x01l); // set the class bit |
3183 Node* orl = _gvn.transform(new (C) OrLNode(tvalue, clsused)); | 3158 Node* orl = _gvn.transform(new (C) OrLNode(tvalue, clsused)); |
3184 | 3159 |
3185 const TypePtr *adr_type = _gvn.type(insp)->isa_ptr(); | 3160 const TypePtr *adr_type = _gvn.type(insp)->isa_ptr(); |
3186 store_to_memory(control(), insp, orl, T_LONG, adr_type); | 3161 store_to_memory(control(), insp, orl, T_LONG, adr_type, MemNode::unordered); |
3187 set_result(andl); | 3162 set_result(andl); |
3188 return true; | 3163 return true; |
3189 } | 3164 } |
3190 | 3165 |
3191 bool LibraryCallKit::inline_native_threadID() { | 3166 bool LibraryCallKit::inline_native_threadID() { |
3192 Node* tls_ptr = NULL; | 3167 Node* tls_ptr = NULL; |
3193 Node* cur_thr = generate_current_thread(tls_ptr); | 3168 Node* cur_thr = generate_current_thread(tls_ptr); |
3194 Node* p = basic_plus_adr(top()/*!oop*/, tls_ptr, in_bytes(JavaThread::osthread_offset())); | 3169 Node* p = basic_plus_adr(top()/*!oop*/, tls_ptr, in_bytes(JavaThread::osthread_offset())); |
3195 Node* osthread = make_load(NULL, p, TypeRawPtr::NOTNULL, T_ADDRESS); | 3170 Node* osthread = make_load(NULL, p, TypeRawPtr::NOTNULL, T_ADDRESS, MemNode::unordered); |
3196 p = basic_plus_adr(top()/*!oop*/, osthread, in_bytes(OSThread::thread_id_offset())); | 3171 p = basic_plus_adr(top()/*!oop*/, osthread, in_bytes(OSThread::thread_id_offset())); |
3197 | 3172 |
3198 Node* threadid = NULL; | 3173 Node* threadid = NULL; |
3199 size_t thread_id_size = OSThread::thread_id_size(); | 3174 size_t thread_id_size = OSThread::thread_id_size(); |
3200 if (thread_id_size == (size_t) BytesPerLong) { | 3175 if (thread_id_size == (size_t) BytesPerLong) { |
3201 threadid = ConvL2I(make_load(control(), p, TypeLong::LONG, T_LONG)); | 3176 threadid = ConvL2I(make_load(control(), p, TypeLong::LONG, T_LONG, MemNode::unordered)); |
3202 } else if (thread_id_size == (size_t) BytesPerInt) { | 3177 } else if (thread_id_size == (size_t) BytesPerInt) { |
3203 threadid = make_load(control(), p, TypeInt::INT, T_INT); | 3178 threadid = make_load(control(), p, TypeInt::INT, T_INT, MemNode::unordered); |
3204 } else { | 3179 } else { |
3205 ShouldNotReachHere(); | 3180 ShouldNotReachHere(); |
3206 } | 3181 } |
3207 set_result(threadid); | 3182 set_result(threadid); |
3208 return true; | 3183 return true; |
3234 | 3209 |
3235 //------------------------inline_native_isInterrupted------------------ | 3210 //------------------------inline_native_isInterrupted------------------ |
3236 // private native boolean java.lang.Thread.isInterrupted(boolean ClearInterrupted); | 3211 // private native boolean java.lang.Thread.isInterrupted(boolean ClearInterrupted); |
3237 bool LibraryCallKit::inline_native_isInterrupted() { | 3212 bool LibraryCallKit::inline_native_isInterrupted() { |
3238 // Add a fast path to t.isInterrupted(clear_int): | 3213 // Add a fast path to t.isInterrupted(clear_int): |
3239 // (t == Thread.current() && (!TLS._osthread._interrupted || !clear_int)) | 3214 // (t == Thread.current() && |
3215 // (!TLS._osthread._interrupted || WINDOWS_ONLY(false) NOT_WINDOWS(!clear_int))) | |
3240 // ? TLS._osthread._interrupted : /*slow path:*/ t.isInterrupted(clear_int) | 3216 // ? TLS._osthread._interrupted : /*slow path:*/ t.isInterrupted(clear_int) |
3241 // So, in the common case that the interrupt bit is false, | 3217 // So, in the common case that the interrupt bit is false, |
3242 // we avoid making a call into the VM. Even if the interrupt bit | 3218 // we avoid making a call into the VM. Even if the interrupt bit |
3243 // is true, if the clear_int argument is false, we avoid the VM call. | 3219 // is true, if the clear_int argument is false, we avoid the VM call. |
3244 // However, if the receiver is not currentThread, we must call the VM, | 3220 // However, if the receiver is not currentThread, we must call the VM, |
3273 | 3249 |
3274 generate_slow_guard(bol_thr, slow_region); | 3250 generate_slow_guard(bol_thr, slow_region); |
3275 | 3251 |
3276 // (b) Interrupt bit on TLS must be false. | 3252 // (b) Interrupt bit on TLS must be false. |
3277 Node* p = basic_plus_adr(top()/*!oop*/, tls_ptr, in_bytes(JavaThread::osthread_offset())); | 3253 Node* p = basic_plus_adr(top()/*!oop*/, tls_ptr, in_bytes(JavaThread::osthread_offset())); |
3278 Node* osthread = make_load(NULL, p, TypeRawPtr::NOTNULL, T_ADDRESS); | 3254 Node* osthread = make_load(NULL, p, TypeRawPtr::NOTNULL, T_ADDRESS, MemNode::unordered); |
3279 p = basic_plus_adr(top()/*!oop*/, osthread, in_bytes(OSThread::interrupted_offset())); | 3255 p = basic_plus_adr(top()/*!oop*/, osthread, in_bytes(OSThread::interrupted_offset())); |
3280 | 3256 |
3281 // Set the control input on the field _interrupted read to prevent it floating up. | 3257 // Set the control input on the field _interrupted read to prevent it floating up. |
3282 Node* int_bit = make_load(control(), p, TypeInt::BOOL, T_INT); | 3258 Node* int_bit = make_load(control(), p, TypeInt::BOOL, T_INT, MemNode::unordered); |
3283 Node* cmp_bit = _gvn.transform(new (C) CmpINode(int_bit, intcon(0))); | 3259 Node* cmp_bit = _gvn.transform(new (C) CmpINode(int_bit, intcon(0))); |
3284 Node* bol_bit = _gvn.transform(new (C) BoolNode(cmp_bit, BoolTest::ne)); | 3260 Node* bol_bit = _gvn.transform(new (C) BoolNode(cmp_bit, BoolTest::ne)); |
3285 | 3261 |
3286 IfNode* iff_bit = create_and_map_if(control(), bol_bit, PROB_UNLIKELY_MAG(3), COUNT_UNKNOWN); | 3262 IfNode* iff_bit = create_and_map_if(control(), bol_bit, PROB_UNLIKELY_MAG(3), COUNT_UNKNOWN); |
3287 | 3263 |
3291 result_val->init_req(no_int_result_path, intcon(0)); | 3267 result_val->init_req(no_int_result_path, intcon(0)); |
3292 | 3268 |
3293 // drop through to next case | 3269 // drop through to next case |
3294 set_control( _gvn.transform(new (C) IfTrueNode(iff_bit))); | 3270 set_control( _gvn.transform(new (C) IfTrueNode(iff_bit))); |
3295 | 3271 |
3272 #ifndef TARGET_OS_FAMILY_windows | |
3296 // (c) Or, if interrupt bit is set and clear_int is false, use 2nd fast path. | 3273 // (c) Or, if interrupt bit is set and clear_int is false, use 2nd fast path. |
3297 Node* clr_arg = argument(1); | 3274 Node* clr_arg = argument(1); |
3298 Node* cmp_arg = _gvn.transform(new (C) CmpINode(clr_arg, intcon(0))); | 3275 Node* cmp_arg = _gvn.transform(new (C) CmpINode(clr_arg, intcon(0))); |
3299 Node* bol_arg = _gvn.transform(new (C) BoolNode(cmp_arg, BoolTest::ne)); | 3276 Node* bol_arg = _gvn.transform(new (C) BoolNode(cmp_arg, BoolTest::ne)); |
3300 IfNode* iff_arg = create_and_map_if(control(), bol_arg, PROB_FAIR, COUNT_UNKNOWN); | 3277 IfNode* iff_arg = create_and_map_if(control(), bol_arg, PROB_FAIR, COUNT_UNKNOWN); |
3304 result_rgn->init_req(no_clear_result_path, false_arg); | 3281 result_rgn->init_req(no_clear_result_path, false_arg); |
3305 result_val->init_req(no_clear_result_path, intcon(1)); | 3282 result_val->init_req(no_clear_result_path, intcon(1)); |
3306 | 3283 |
3307 // drop through to next case | 3284 // drop through to next case |
3308 set_control( _gvn.transform(new (C) IfTrueNode(iff_arg))); | 3285 set_control( _gvn.transform(new (C) IfTrueNode(iff_arg))); |
3286 #else | |
3287 // To return true on Windows you must read the _interrupted field | |
3288 // and check the the event state i.e. take the slow path. | |
3289 #endif // TARGET_OS_FAMILY_windows | |
3309 | 3290 |
3310 // (d) Otherwise, go to the slow path. | 3291 // (d) Otherwise, go to the slow path. |
3311 slow_region->add_req(control()); | 3292 slow_region->add_req(control()); |
3312 set_control( _gvn.transform(slow_region)); | 3293 set_control( _gvn.transform(slow_region)); |
3313 | 3294 |
3345 | 3326 |
3346 //---------------------------load_mirror_from_klass---------------------------- | 3327 //---------------------------load_mirror_from_klass---------------------------- |
3347 // Given a klass oop, load its java mirror (a java.lang.Class oop). | 3328 // Given a klass oop, load its java mirror (a java.lang.Class oop). |
3348 Node* LibraryCallKit::load_mirror_from_klass(Node* klass) { | 3329 Node* LibraryCallKit::load_mirror_from_klass(Node* klass) { |
3349 Node* p = basic_plus_adr(klass, in_bytes(Klass::java_mirror_offset())); | 3330 Node* p = basic_plus_adr(klass, in_bytes(Klass::java_mirror_offset())); |
3350 return make_load(NULL, p, TypeInstPtr::MIRROR, T_OBJECT); | 3331 return make_load(NULL, p, TypeInstPtr::MIRROR, T_OBJECT, MemNode::unordered); |
3351 } | 3332 } |
3352 | 3333 |
3353 //-----------------------load_klass_from_mirror_common------------------------- | 3334 //-----------------------load_klass_from_mirror_common------------------------- |
3354 // Given a java mirror (a java.lang.Class oop), load its corresponding klass oop. | 3335 // Given a java mirror (a java.lang.Class oop), load its corresponding klass oop. |
3355 // Test the klass oop for null (signifying a primitive Class like Integer.TYPE), | 3336 // Test the klass oop for null (signifying a primitive Class like Integer.TYPE), |
3382 // Fall through if (mods & mask) == bits, take the guard otherwise. | 3363 // Fall through if (mods & mask) == bits, take the guard otherwise. |
3383 Node* LibraryCallKit::generate_access_flags_guard(Node* kls, int modifier_mask, int modifier_bits, RegionNode* region) { | 3364 Node* LibraryCallKit::generate_access_flags_guard(Node* kls, int modifier_mask, int modifier_bits, RegionNode* region) { |
3384 // Branch around if the given klass has the given modifier bit set. | 3365 // Branch around if the given klass has the given modifier bit set. |
3385 // Like generate_guard, adds a new path onto the region. | 3366 // Like generate_guard, adds a new path onto the region. |
3386 Node* modp = basic_plus_adr(kls, in_bytes(Klass::access_flags_offset())); | 3367 Node* modp = basic_plus_adr(kls, in_bytes(Klass::access_flags_offset())); |
3387 Node* mods = make_load(NULL, modp, TypeInt::INT, T_INT); | 3368 Node* mods = make_load(NULL, modp, TypeInt::INT, T_INT, MemNode::unordered); |
3388 Node* mask = intcon(modifier_mask); | 3369 Node* mask = intcon(modifier_mask); |
3389 Node* bits = intcon(modifier_bits); | 3370 Node* bits = intcon(modifier_bits); |
3390 Node* mbit = _gvn.transform(new (C) AndINode(mods, mask)); | 3371 Node* mbit = _gvn.transform(new (C) AndINode(mods, mask)); |
3391 Node* cmp = _gvn.transform(new (C) CmpINode(mbit, bits)); | 3372 Node* cmp = _gvn.transform(new (C) CmpINode(mbit, bits)); |
3392 Node* bol = _gvn.transform(new (C) BoolNode(cmp, BoolTest::ne)); | 3373 Node* bol = _gvn.transform(new (C) BoolNode(cmp, BoolTest::ne)); |
3499 query_value = gen_instanceof(obj, kls, safe_for_replace); | 3480 query_value = gen_instanceof(obj, kls, safe_for_replace); |
3500 break; | 3481 break; |
3501 | 3482 |
3502 case vmIntrinsics::_getModifiers: | 3483 case vmIntrinsics::_getModifiers: |
3503 p = basic_plus_adr(kls, in_bytes(Klass::modifier_flags_offset())); | 3484 p = basic_plus_adr(kls, in_bytes(Klass::modifier_flags_offset())); |
3504 query_value = make_load(NULL, p, TypeInt::INT, T_INT); | 3485 query_value = make_load(NULL, p, TypeInt::INT, T_INT, MemNode::unordered); |
3505 break; | 3486 break; |
3506 | 3487 |
3507 case vmIntrinsics::_isInterface: | 3488 case vmIntrinsics::_isInterface: |
3508 // (To verify this code sequence, check the asserts in JVM_IsInterface.) | 3489 // (To verify this code sequence, check the asserts in JVM_IsInterface.) |
3509 if (generate_interface_guard(kls, region) != NULL) | 3490 if (generate_interface_guard(kls, region) != NULL) |
3557 case vmIntrinsics::_getComponentType: | 3538 case vmIntrinsics::_getComponentType: |
3558 if (generate_array_guard(kls, region) != NULL) { | 3539 if (generate_array_guard(kls, region) != NULL) { |
3559 // Be sure to pin the oop load to the guard edge just created: | 3540 // Be sure to pin the oop load to the guard edge just created: |
3560 Node* is_array_ctrl = region->in(region->req()-1); | 3541 Node* is_array_ctrl = region->in(region->req()-1); |
3561 Node* cma = basic_plus_adr(kls, in_bytes(ArrayKlass::component_mirror_offset())); | 3542 Node* cma = basic_plus_adr(kls, in_bytes(ArrayKlass::component_mirror_offset())); |
3562 Node* cmo = make_load(is_array_ctrl, cma, TypeInstPtr::MIRROR, T_OBJECT); | 3543 Node* cmo = make_load(is_array_ctrl, cma, TypeInstPtr::MIRROR, T_OBJECT, MemNode::unordered); |
3563 phi->add_req(cmo); | 3544 phi->add_req(cmo); |
3564 } | 3545 } |
3565 query_value = null(); // non-array case is null | 3546 query_value = null(); // non-array case is null |
3566 break; | 3547 break; |
3567 | 3548 |
3568 case vmIntrinsics::_getClassAccessFlags: | 3549 case vmIntrinsics::_getClassAccessFlags: |
3569 p = basic_plus_adr(kls, in_bytes(Klass::access_flags_offset())); | 3550 p = basic_plus_adr(kls, in_bytes(Klass::access_flags_offset())); |
3570 query_value = make_load(NULL, p, TypeInt::INT, T_INT); | 3551 query_value = make_load(NULL, p, TypeInt::INT, T_INT, MemNode::unordered); |
3571 break; | 3552 break; |
3572 | 3553 |
3573 default: | 3554 default: |
3574 fatal_unexpected_iid(id); | 3555 fatal_unexpected_iid(id); |
3575 break; | 3556 break; |
3931 // Get the Method* out of the appropriate vtable entry. | 3912 // Get the Method* out of the appropriate vtable entry. |
3932 int entry_offset = (InstanceKlass::vtable_start_offset() + | 3913 int entry_offset = (InstanceKlass::vtable_start_offset() + |
3933 vtable_index*vtableEntry::size()) * wordSize + | 3914 vtable_index*vtableEntry::size()) * wordSize + |
3934 vtableEntry::method_offset_in_bytes(); | 3915 vtableEntry::method_offset_in_bytes(); |
3935 Node* entry_addr = basic_plus_adr(obj_klass, entry_offset); | 3916 Node* entry_addr = basic_plus_adr(obj_klass, entry_offset); |
3936 Node* target_call = make_load(NULL, entry_addr, TypePtr::NOTNULL, T_ADDRESS); | 3917 Node* target_call = make_load(NULL, entry_addr, TypePtr::NOTNULL, T_ADDRESS, MemNode::unordered); |
3937 | 3918 |
3938 // Compare the target method with the expected method (e.g., Object.hashCode). | 3919 // Compare the target method with the expected method (e.g., Object.hashCode). |
3939 const TypePtr* native_call_addr = TypeMetadataPtr::make(method); | 3920 const TypePtr* native_call_addr = TypeMetadataPtr::make(method); |
3940 | 3921 |
3941 Node* native_call = makecon(native_call_addr); | 3922 Node* native_call = makecon(native_call_addr); |
3995 set_edges_for_java_call(slow_call); | 3976 set_edges_for_java_call(slow_call); |
3996 return slow_call; | 3977 return slow_call; |
3997 } | 3978 } |
3998 | 3979 |
3999 | 3980 |
4000 //------------------------------inline_native_hashcode-------------------- | 3981 /** |
4001 // Build special case code for calls to hashCode on an object. | 3982 * Build special case code for calls to hashCode on an object. This call may |
3983 * be virtual (invokevirtual) or bound (invokespecial). For each case we generate | |
3984 * slightly different code. | |
3985 */ | |
4002 bool LibraryCallKit::inline_native_hashcode(bool is_virtual, bool is_static) { | 3986 bool LibraryCallKit::inline_native_hashcode(bool is_virtual, bool is_static) { |
4003 assert(is_static == callee()->is_static(), "correct intrinsic selection"); | 3987 assert(is_static == callee()->is_static(), "correct intrinsic selection"); |
4004 assert(!(is_virtual && is_static), "either virtual, special, or static"); | 3988 assert(!(is_virtual && is_static), "either virtual, special, or static"); |
4005 | 3989 |
4006 enum { _slow_path = 1, _fast_path, _null_path, PATH_LIMIT }; | 3990 enum { _slow_path = 1, _fast_path, _null_path, PATH_LIMIT }; |
4007 | 3991 |
4008 RegionNode* result_reg = new(C) RegionNode(PATH_LIMIT); | 3992 RegionNode* result_reg = new(C) RegionNode(PATH_LIMIT); |
4009 PhiNode* result_val = new(C) PhiNode(result_reg, | 3993 PhiNode* result_val = new(C) PhiNode(result_reg, TypeInt::INT); |
4010 TypeInt::INT); | |
4011 PhiNode* result_io = new(C) PhiNode(result_reg, Type::ABIO); | 3994 PhiNode* result_io = new(C) PhiNode(result_reg, Type::ABIO); |
4012 PhiNode* result_mem = new(C) PhiNode(result_reg, Type::MEMORY, | 3995 PhiNode* result_mem = new(C) PhiNode(result_reg, Type::MEMORY, TypePtr::BOTTOM); |
4013 TypePtr::BOTTOM); | |
4014 Node* obj = NULL; | 3996 Node* obj = NULL; |
4015 if (!is_static) { | 3997 if (!is_static) { |
4016 // Check for hashing null object | 3998 // Check for hashing null object |
4017 obj = null_check_receiver(); | 3999 obj = null_check_receiver(); |
4018 if (stopped()) return true; // unconditionally null | 4000 if (stopped()) return true; // unconditionally null |
4034 if (!stopped()) | 4016 if (!stopped()) |
4035 set_result(result_val->in(_null_path)); | 4017 set_result(result_val->in(_null_path)); |
4036 return true; | 4018 return true; |
4037 } | 4019 } |
4038 | 4020 |
4039 // After null check, get the object's klass. | |
4040 Node* obj_klass = load_object_klass(obj); | |
4041 | |
4042 // This call may be virtual (invokevirtual) or bound (invokespecial). | |
4043 // For each case we generate slightly different code. | |
4044 | |
4045 // We only go to the fast case code if we pass a number of guards. The | 4021 // We only go to the fast case code if we pass a number of guards. The |
4046 // paths which do not pass are accumulated in the slow_region. | 4022 // paths which do not pass are accumulated in the slow_region. |
4047 RegionNode* slow_region = new (C) RegionNode(1); | 4023 RegionNode* slow_region = new (C) RegionNode(1); |
4048 record_for_igvn(slow_region); | 4024 record_for_igvn(slow_region); |
4049 | 4025 |
4052 // If the target method which we are calling happens to be the native | 4028 // If the target method which we are calling happens to be the native |
4053 // Object hashCode() method, we pass the guard. We do not need this | 4029 // Object hashCode() method, we pass the guard. We do not need this |
4054 // guard for non-virtual calls -- the caller is known to be the native | 4030 // guard for non-virtual calls -- the caller is known to be the native |
4055 // Object hashCode(). | 4031 // Object hashCode(). |
4056 if (is_virtual) { | 4032 if (is_virtual) { |
4033 // After null check, get the object's klass. | |
4034 Node* obj_klass = load_object_klass(obj); | |
4057 generate_virtual_guard(obj_klass, slow_region); | 4035 generate_virtual_guard(obj_klass, slow_region); |
4058 } | 4036 } |
4059 | 4037 |
4060 // Get the header out of the object, use LoadMarkNode when available | 4038 // Get the header out of the object, use LoadMarkNode when available |
4061 Node* header_addr = basic_plus_adr(obj, oopDesc::mark_offset_in_bytes()); | 4039 Node* header_addr = basic_plus_adr(obj, oopDesc::mark_offset_in_bytes()); |
4062 Node* header = make_load(control(), header_addr, TypeX_X, TypeX_X->basic_type()); | 4040 // The control of the load must be NULL. Otherwise, the load can move before |
4041 // the null check after castPP removal. | |
4042 Node* no_ctrl = NULL; | |
4043 Node* header = make_load(no_ctrl, header_addr, TypeX_X, TypeX_X->basic_type(), MemNode::unordered); | |
4063 | 4044 |
4064 // Test the header to see if it is unlocked. | 4045 // Test the header to see if it is unlocked. |
4065 Node *lock_mask = _gvn.MakeConX(markOopDesc::biased_lock_mask_in_place); | 4046 Node* lock_mask = _gvn.MakeConX(markOopDesc::biased_lock_mask_in_place); |
4066 Node *lmasked_header = _gvn.transform(new (C) AndXNode(header, lock_mask)); | 4047 Node* lmasked_header = _gvn.transform(new (C) AndXNode(header, lock_mask)); |
4067 Node *unlocked_val = _gvn.MakeConX(markOopDesc::unlocked_value); | 4048 Node* unlocked_val = _gvn.MakeConX(markOopDesc::unlocked_value); |
4068 Node *chk_unlocked = _gvn.transform(new (C) CmpXNode( lmasked_header, unlocked_val)); | 4049 Node* chk_unlocked = _gvn.transform(new (C) CmpXNode( lmasked_header, unlocked_val)); |
4069 Node *test_unlocked = _gvn.transform(new (C) BoolNode( chk_unlocked, BoolTest::ne)); | 4050 Node* test_unlocked = _gvn.transform(new (C) BoolNode( chk_unlocked, BoolTest::ne)); |
4070 | 4051 |
4071 generate_slow_guard(test_unlocked, slow_region); | 4052 generate_slow_guard(test_unlocked, slow_region); |
4072 | 4053 |
4073 // Get the hash value and check to see that it has been properly assigned. | 4054 // Get the hash value and check to see that it has been properly assigned. |
4074 // We depend on hash_mask being at most 32 bits and avoid the use of | 4055 // We depend on hash_mask being at most 32 bits and avoid the use of |
4075 // hash_mask_in_place because it could be larger than 32 bits in a 64-bit | 4056 // hash_mask_in_place because it could be larger than 32 bits in a 64-bit |
4076 // vm: see markOop.hpp. | 4057 // vm: see markOop.hpp. |
4077 Node *hash_mask = _gvn.intcon(markOopDesc::hash_mask); | 4058 Node* hash_mask = _gvn.intcon(markOopDesc::hash_mask); |
4078 Node *hash_shift = _gvn.intcon(markOopDesc::hash_shift); | 4059 Node* hash_shift = _gvn.intcon(markOopDesc::hash_shift); |
4079 Node *hshifted_header= _gvn.transform(new (C) URShiftXNode(header, hash_shift)); | 4060 Node* hshifted_header= _gvn.transform(new (C) URShiftXNode(header, hash_shift)); |
4080 // This hack lets the hash bits live anywhere in the mark object now, as long | 4061 // This hack lets the hash bits live anywhere in the mark object now, as long |
4081 // as the shift drops the relevant bits into the low 32 bits. Note that | 4062 // as the shift drops the relevant bits into the low 32 bits. Note that |
4082 // Java spec says that HashCode is an int so there's no point in capturing | 4063 // Java spec says that HashCode is an int so there's no point in capturing |
4083 // an 'X'-sized hashcode (32 in 32-bit build or 64 in 64-bit build). | 4064 // an 'X'-sized hashcode (32 in 32-bit build or 64 in 64-bit build). |
4084 hshifted_header = ConvX2I(hshifted_header); | 4065 hshifted_header = ConvX2I(hshifted_header); |
4085 Node *hash_val = _gvn.transform(new (C) AndINode(hshifted_header, hash_mask)); | 4066 Node* hash_val = _gvn.transform(new (C) AndINode(hshifted_header, hash_mask)); |
4086 | 4067 |
4087 Node *no_hash_val = _gvn.intcon(markOopDesc::no_hash); | 4068 Node* no_hash_val = _gvn.intcon(markOopDesc::no_hash); |
4088 Node *chk_assigned = _gvn.transform(new (C) CmpINode( hash_val, no_hash_val)); | 4069 Node* chk_assigned = _gvn.transform(new (C) CmpINode( hash_val, no_hash_val)); |
4089 Node *test_assigned = _gvn.transform(new (C) BoolNode( chk_assigned, BoolTest::eq)); | 4070 Node* test_assigned = _gvn.transform(new (C) BoolNode( chk_assigned, BoolTest::eq)); |
4090 | 4071 |
4091 generate_slow_guard(test_assigned, slow_region); | 4072 generate_slow_guard(test_assigned, slow_region); |
4092 | 4073 |
4093 Node* init_mem = reset_memory(); | 4074 Node* init_mem = reset_memory(); |
4094 // fill in the rest of the null path: | 4075 // fill in the rest of the null path: |
4593 | 4574 |
4594 if (!stopped()) { | 4575 if (!stopped()) { |
4595 // It's an instance, and it passed the slow-path tests. | 4576 // It's an instance, and it passed the slow-path tests. |
4596 PreserveJVMState pjvms(this); | 4577 PreserveJVMState pjvms(this); |
4597 Node* obj_size = NULL; | 4578 Node* obj_size = NULL; |
4598 Node* alloc_obj = new_instance(obj_klass, NULL, &obj_size); | 4579 // Need to deoptimize on exception from allocation since Object.clone intrinsic |
4580 // is reexecuted if deoptimization occurs and there could be problems when merging | |
4581 // exception state between multiple Object.clone versions (reexecute=true vs reexecute=false). | |
4582 Node* alloc_obj = new_instance(obj_klass, NULL, &obj_size, /*deoptimize_on_exception=*/true); | |
4599 | 4583 |
4600 copy_to_clone(obj, alloc_obj, obj_size, false, !use_ReduceInitialCardMarks()); | 4584 copy_to_clone(obj, alloc_obj, obj_size, false, !use_ReduceInitialCardMarks()); |
4601 | 4585 |
4602 // Present the results of the slow call. | 4586 // Present the results of the slow call. |
4603 result_reg->init_req(_instance_path, control()); | 4587 result_reg->init_req(_instance_path, control()); |
5478 start = _gvn.transform(new(C) AndXNode(start, MakeConX(~to_clear))); | 5462 start = _gvn.transform(new(C) AndXNode(start, MakeConX(~to_clear))); |
5479 if (bump_bit != 0) { | 5463 if (bump_bit != 0) { |
5480 // Store a zero to the immediately preceding jint: | 5464 // Store a zero to the immediately preceding jint: |
5481 Node* x1 = _gvn.transform(new(C) AddXNode(start, MakeConX(-bump_bit))); | 5465 Node* x1 = _gvn.transform(new(C) AddXNode(start, MakeConX(-bump_bit))); |
5482 Node* p1 = basic_plus_adr(dest, x1); | 5466 Node* p1 = basic_plus_adr(dest, x1); |
5483 mem = StoreNode::make(_gvn, control(), mem, p1, adr_type, intcon(0), T_INT); | 5467 mem = StoreNode::make(_gvn, control(), mem, p1, adr_type, intcon(0), T_INT, MemNode::unordered); |
5484 mem = _gvn.transform(mem); | 5468 mem = _gvn.transform(mem); |
5485 } | 5469 } |
5486 } | 5470 } |
5487 Node* end = dest_size; // pre-rounded | 5471 Node* end = dest_size; // pre-rounded |
5488 mem = ClearArrayNode::clear_memory(control(), mem, dest, | 5472 mem = ClearArrayNode::clear_memory(control(), mem, dest, |
5528 // This is a common case, since abase can be odd mod 8. | 5512 // This is a common case, since abase can be odd mod 8. |
5529 if (((src_off | dest_off) & (BytesPerLong-1)) == BytesPerInt && | 5513 if (((src_off | dest_off) & (BytesPerLong-1)) == BytesPerInt && |
5530 ((src_off ^ dest_off) & (BytesPerLong-1)) == 0) { | 5514 ((src_off ^ dest_off) & (BytesPerLong-1)) == 0) { |
5531 Node* sptr = basic_plus_adr(src, src_off); | 5515 Node* sptr = basic_plus_adr(src, src_off); |
5532 Node* dptr = basic_plus_adr(dest, dest_off); | 5516 Node* dptr = basic_plus_adr(dest, dest_off); |
5533 Node* sval = make_load(control(), sptr, TypeInt::INT, T_INT, adr_type); | 5517 Node* sval = make_load(control(), sptr, TypeInt::INT, T_INT, adr_type, MemNode::unordered); |
5534 store_to_memory(control(), dptr, sval, T_INT, adr_type); | 5518 store_to_memory(control(), dptr, sval, T_INT, adr_type, MemNode::unordered); |
5535 src_off += BytesPerInt; | 5519 src_off += BytesPerInt; |
5536 dest_off += BytesPerInt; | 5520 dest_off += BytesPerInt; |
5537 } else { | 5521 } else { |
5538 return false; | 5522 return false; |
5539 } | 5523 } |
5594 // for the target array. This is an optimistic check. It will | 5578 // for the target array. This is an optimistic check. It will |
5595 // look in each non-null element's class, at the desired klass's | 5579 // look in each non-null element's class, at the desired klass's |
5596 // super_check_offset, for the desired klass. | 5580 // super_check_offset, for the desired klass. |
5597 int sco_offset = in_bytes(Klass::super_check_offset_offset()); | 5581 int sco_offset = in_bytes(Klass::super_check_offset_offset()); |
5598 Node* p3 = basic_plus_adr(dest_elem_klass, sco_offset); | 5582 Node* p3 = basic_plus_adr(dest_elem_klass, sco_offset); |
5599 Node* n3 = new(C) LoadINode(NULL, memory(p3), p3, _gvn.type(p3)->is_ptr()); | 5583 Node* n3 = new(C) LoadINode(NULL, memory(p3), p3, _gvn.type(p3)->is_ptr(), TypeInt::INT, MemNode::unordered); |
5600 Node* check_offset = ConvI2X(_gvn.transform(n3)); | 5584 Node* check_offset = ConvI2X(_gvn.transform(n3)); |
5601 Node* check_value = dest_elem_klass; | 5585 Node* check_value = dest_elem_klass; |
5602 | 5586 |
5603 Node* src_start = array_element_address(src, src_offset, T_OBJECT); | 5587 Node* src_start = array_element_address(src, src_offset, T_OBJECT); |
5604 Node* dest_start = array_element_address(dest, dest_offset, T_OBJECT); | 5588 Node* dest_start = array_element_address(dest, dest_offset, T_OBJECT); |
5735 result = _gvn.transform(new (C) AndINode(result, intcon(0xFF))); | 5719 result = _gvn.transform(new (C) AndINode(result, intcon(0xFF))); |
5736 | 5720 |
5737 Node* base = makecon(TypeRawPtr::make(StubRoutines::crc_table_addr())); | 5721 Node* base = makecon(TypeRawPtr::make(StubRoutines::crc_table_addr())); |
5738 Node* offset = _gvn.transform(new (C) LShiftINode(result, intcon(0x2))); | 5722 Node* offset = _gvn.transform(new (C) LShiftINode(result, intcon(0x2))); |
5739 Node* adr = basic_plus_adr(top(), base, ConvI2X(offset)); | 5723 Node* adr = basic_plus_adr(top(), base, ConvI2X(offset)); |
5740 result = make_load(control(), adr, TypeInt::INT, T_INT); | 5724 result = make_load(control(), adr, TypeInt::INT, T_INT, MemNode::unordered); |
5741 | 5725 |
5742 crc = _gvn.transform(new (C) URShiftINode(crc, intcon(8))); | 5726 crc = _gvn.transform(new (C) URShiftINode(crc, intcon(8))); |
5743 result = _gvn.transform(new (C) XorINode(crc, result)); | 5727 result = _gvn.transform(new (C) XorINode(crc, result)); |
5744 result = _gvn.transform(new (C) XorINode(result, M1)); | 5728 result = _gvn.transform(new (C) XorINode(result, M1)); |
5745 set_result(result); | 5729 set_result(result); |
5836 | 5820 |
5837 ciInstanceKlass* klass = env()->Object_klass(); | 5821 ciInstanceKlass* klass = env()->Object_klass(); |
5838 const TypeOopPtr* object_type = TypeOopPtr::make_from_klass(klass); | 5822 const TypeOopPtr* object_type = TypeOopPtr::make_from_klass(klass); |
5839 | 5823 |
5840 Node* no_ctrl = NULL; | 5824 Node* no_ctrl = NULL; |
5841 Node* result = make_load(no_ctrl, adr, object_type, T_OBJECT); | 5825 Node* result = make_load(no_ctrl, adr, object_type, T_OBJECT, MemNode::unordered); |
5842 | 5826 |
5843 // Use the pre-barrier to record the value in the referent field | 5827 // Use the pre-barrier to record the value in the referent field |
5844 pre_barrier(false /* do_load */, | 5828 pre_barrier(false /* do_load */, |
5845 control(), | 5829 control(), |
5846 NULL /* obj */, NULL /* adr */, max_juint /* alias_idx */, NULL /* val */, NULL /* val_type */, | 5830 NULL /* obj */, NULL /* adr */, max_juint /* alias_idx */, NULL /* val */, NULL /* val_type */, |
5883 | 5867 |
5884 // Build the resultant type of the load | 5868 // Build the resultant type of the load |
5885 const Type *type = TypeOopPtr::make_from_klass(field_klass->as_klass()); | 5869 const Type *type = TypeOopPtr::make_from_klass(field_klass->as_klass()); |
5886 | 5870 |
5887 // Build the load. | 5871 // Build the load. |
5888 Node* loadedField = make_load(NULL, adr, type, bt, adr_type, is_vol); | 5872 Node* loadedField = make_load(NULL, adr, type, bt, adr_type, MemNode::unordered, is_vol); |
5889 return loadedField; | 5873 return loadedField; |
5890 } | 5874 } |
5891 | 5875 |
5892 | 5876 |
5893 //------------------------------inline_aescrypt_Block----------------------- | 5877 //------------------------------inline_aescrypt_Block----------------------- |
5934 // now need to get the start of its expanded key array | 5918 // now need to get the start of its expanded key array |
5935 // this requires a newer class file that has this array as littleEndian ints, otherwise we revert to java | 5919 // this requires a newer class file that has this array as littleEndian ints, otherwise we revert to java |
5936 Node* k_start = get_key_start_from_aescrypt_object(aescrypt_object); | 5920 Node* k_start = get_key_start_from_aescrypt_object(aescrypt_object); |
5937 if (k_start == NULL) return false; | 5921 if (k_start == NULL) return false; |
5938 | 5922 |
5939 // Call the stub. | 5923 if (Matcher::pass_original_key_for_aes()) { |
5940 make_runtime_call(RC_LEAF|RC_NO_FP, OptoRuntime::aescrypt_block_Type(), | 5924 // on SPARC we need to pass the original key since key expansion needs to happen in intrinsics due to |
5941 stubAddr, stubName, TypePtr::BOTTOM, | 5925 // compatibility issues between Java key expansion and SPARC crypto instructions |
5942 src_start, dest_start, k_start); | 5926 Node* original_k_start = get_original_key_start_from_aescrypt_object(aescrypt_object); |
5927 if (original_k_start == NULL) return false; | |
5928 | |
5929 // Call the stub. | |
5930 make_runtime_call(RC_LEAF|RC_NO_FP, OptoRuntime::aescrypt_block_Type(), | |
5931 stubAddr, stubName, TypePtr::BOTTOM, | |
5932 src_start, dest_start, k_start, original_k_start); | |
5933 } else { | |
5934 // Call the stub. | |
5935 make_runtime_call(RC_LEAF|RC_NO_FP, OptoRuntime::aescrypt_block_Type(), | |
5936 stubAddr, stubName, TypePtr::BOTTOM, | |
5937 src_start, dest_start, k_start); | |
5938 } | |
5943 | 5939 |
5944 return true; | 5940 return true; |
5945 } | 5941 } |
5946 | 5942 |
5947 //------------------------------inline_cipherBlockChaining_AESCrypt----------------------- | 5943 //------------------------------inline_cipherBlockChaining_AESCrypt----------------------- |
6015 // similarly, get the start address of the r vector | 6011 // similarly, get the start address of the r vector |
6016 Node* objRvec = load_field_from_object(cipherBlockChaining_object, "r", "[B", /*is_exact*/ false); | 6012 Node* objRvec = load_field_from_object(cipherBlockChaining_object, "r", "[B", /*is_exact*/ false); |
6017 if (objRvec == NULL) return false; | 6013 if (objRvec == NULL) return false; |
6018 Node* r_start = array_element_address(objRvec, intcon(0), T_BYTE); | 6014 Node* r_start = array_element_address(objRvec, intcon(0), T_BYTE); |
6019 | 6015 |
6020 // Call the stub, passing src_start, dest_start, k_start, r_start and src_len | 6016 Node* cbcCrypt; |
6021 make_runtime_call(RC_LEAF|RC_NO_FP, | 6017 if (Matcher::pass_original_key_for_aes()) { |
6022 OptoRuntime::cipherBlockChaining_aescrypt_Type(), | 6018 // on SPARC we need to pass the original key since key expansion needs to happen in intrinsics due to |
6023 stubAddr, stubName, TypePtr::BOTTOM, | 6019 // compatibility issues between Java key expansion and SPARC crypto instructions |
6024 src_start, dest_start, k_start, r_start, len); | 6020 Node* original_k_start = get_original_key_start_from_aescrypt_object(aescrypt_object); |
6025 | 6021 if (original_k_start == NULL) return false; |
6026 // return is void so no result needs to be pushed | 6022 |
6027 | 6023 // Call the stub, passing src_start, dest_start, k_start, r_start, src_len and original_k_start |
6024 cbcCrypt = make_runtime_call(RC_LEAF|RC_NO_FP, | |
6025 OptoRuntime::cipherBlockChaining_aescrypt_Type(), | |
6026 stubAddr, stubName, TypePtr::BOTTOM, | |
6027 src_start, dest_start, k_start, r_start, len, original_k_start); | |
6028 } else { | |
6029 // Call the stub, passing src_start, dest_start, k_start, r_start and src_len | |
6030 cbcCrypt = make_runtime_call(RC_LEAF|RC_NO_FP, | |
6031 OptoRuntime::cipherBlockChaining_aescrypt_Type(), | |
6032 stubAddr, stubName, TypePtr::BOTTOM, | |
6033 src_start, dest_start, k_start, r_start, len); | |
6034 } | |
6035 | |
6036 // return cipher length (int) | |
6037 Node* retvalue = _gvn.transform(new (C) ProjNode(cbcCrypt, TypeFunc::Parms)); | |
6038 set_result(retvalue); | |
6028 return true; | 6039 return true; |
6029 } | 6040 } |
6030 | 6041 |
6031 //------------------------------get_key_start_from_aescrypt_object----------------------- | 6042 //------------------------------get_key_start_from_aescrypt_object----------------------- |
6032 Node * LibraryCallKit::get_key_start_from_aescrypt_object(Node *aescrypt_object) { | 6043 Node * LibraryCallKit::get_key_start_from_aescrypt_object(Node *aescrypt_object) { |
6035 if (objAESCryptKey == NULL) return (Node *) NULL; | 6046 if (objAESCryptKey == NULL) return (Node *) NULL; |
6036 | 6047 |
6037 // now have the array, need to get the start address of the K array | 6048 // now have the array, need to get the start address of the K array |
6038 Node* k_start = array_element_address(objAESCryptKey, intcon(0), T_INT); | 6049 Node* k_start = array_element_address(objAESCryptKey, intcon(0), T_INT); |
6039 return k_start; | 6050 return k_start; |
6051 } | |
6052 | |
6053 //------------------------------get_original_key_start_from_aescrypt_object----------------------- | |
6054 Node * LibraryCallKit::get_original_key_start_from_aescrypt_object(Node *aescrypt_object) { | |
6055 Node* objAESCryptKey = load_field_from_object(aescrypt_object, "lastKey", "[B", /*is_exact*/ false); | |
6056 assert (objAESCryptKey != NULL, "wrong version of com.sun.crypto.provider.AESCrypt"); | |
6057 if (objAESCryptKey == NULL) return (Node *) NULL; | |
6058 | |
6059 // now have the array, need to get the start address of the lastKey array | |
6060 Node* original_k_start = array_element_address(objAESCryptKey, intcon(0), T_BYTE); | |
6061 return original_k_start; | |
6040 } | 6062 } |
6041 | 6063 |
6042 //----------------------------inline_cipherBlockChaining_AESCrypt_predicate---------------------------- | 6064 //----------------------------inline_cipherBlockChaining_AESCrypt_predicate---------------------------- |
6043 // Return node representing slow path of predicate check. | 6065 // Return node representing slow path of predicate check. |
6044 // the pseudo code we want to emulate with this predicate is: | 6066 // the pseudo code we want to emulate with this predicate is: |