186 bool is_virtual = false, bool is_static = false);
187 CallJavaNode* generate_method_call_static(vmIntrinsics::ID method_id) {
188 return generate_method_call(method_id, false, true);
189 }
190 CallJavaNode* generate_method_call_virtual(vmIntrinsics::ID method_id) {
191 return generate_method_call(method_id, true, false);
192 }
193 Node * load_field_from_object(Node * fromObj, const char * fieldName, const char * fieldTypeString, bool is_exact, bool is_static);
194
195 Node* make_string_method_node(int opcode, Node* str1_start, Node* cnt1, Node* str2_start, Node* cnt2);
196 Node* make_string_method_node(int opcode, Node* str1, Node* str2);
197 bool inline_string_compareTo();
198 bool inline_string_indexOf();
199 Node* string_indexOf(Node* string_object, ciTypeArray* target_array, jint offset, jint cache_i, jint md2_i);
200 bool inline_string_equals();
201 Node* round_double_node(Node* n);
202 bool runtime_math(const TypeFunc* call_type, address funcAddr, const char* funcName);
203 bool inline_math_native(vmIntrinsics::ID id);
204 bool inline_trig(vmIntrinsics::ID id);
205 bool inline_math(vmIntrinsics::ID id);
206 void inline_math_mathExact(Node* math);
207 bool inline_math_addExactI(bool is_increment);
208 bool inline_math_addExactL(bool is_increment);
209 bool inline_math_multiplyExactI();
210 bool inline_math_multiplyExactL();
211 bool inline_math_negateExactI();
212 bool inline_math_negateExactL();
213 bool inline_math_subtractExactI(bool is_decrement);
214 bool inline_math_subtractExactL(bool is_decrement);
215 bool inline_exp();
216 bool inline_pow();
217 void 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);
219 Node* generate_min_max(vmIntrinsics::ID id, Node* x, Node* y);
220 // This returns Type::AnyPtr, RawPtr, or OopPtr.
221 int classify_unsafe_addr(Node* &base, Node* &offset);
222 Node* make_unsafe_address(Node* base, Node* offset);
223 // Helper for inline_unsafe_access.
224 // Generates the guards that check whether the result of
225 // Unsafe.getObject should be recorded in an SATB log buffer.
226 void insert_pre_barrier(Node* base_oop, Node* offset, Node* pre_val, bool need_mem_bar);
500 case vmIntrinsics::_aescrypt_encryptBlock:
501 case vmIntrinsics::_aescrypt_decryptBlock:
502 if (!UseAESIntrinsics) return NULL;
503 break;
504
505 case vmIntrinsics::_cipherBlockChaining_encryptAESCrypt:
506 case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt:
507 if (!UseAESIntrinsics) return NULL;
508 // these two require the predicated logic
509 is_predicted = true;
510 break;
511
512 case vmIntrinsics::_updateCRC32:
513 case vmIntrinsics::_updateBytesCRC32:
514 case vmIntrinsics::_updateByteBufferCRC32:
515 if (!UseCRC32Intrinsics) return NULL;
516 break;
517
518 case vmIntrinsics::_incrementExactI:
519 case vmIntrinsics::_addExactI:
520 if (!Matcher::match_rule_supported(Op_AddExactI) || !UseMathExactIntrinsics) return NULL;
521 break;
522 case vmIntrinsics::_incrementExactL:
523 case vmIntrinsics::_addExactL:
524 if (!Matcher::match_rule_supported(Op_AddExactL) || !UseMathExactIntrinsics) return NULL;
525 break;
526 case vmIntrinsics::_decrementExactI:
527 case vmIntrinsics::_subtractExactI:
528 if (!Matcher::match_rule_supported(Op_SubExactI) || !UseMathExactIntrinsics) return NULL;
529 break;
530 case vmIntrinsics::_decrementExactL:
531 case vmIntrinsics::_subtractExactL:
532 if (!Matcher::match_rule_supported(Op_SubExactL) || !UseMathExactIntrinsics) return NULL;
533 break;
534 case vmIntrinsics::_negateExactI:
535 if (!Matcher::match_rule_supported(Op_NegExactI) || !UseMathExactIntrinsics) return NULL;
536 break;
537 case vmIntrinsics::_negateExactL:
538 if (!Matcher::match_rule_supported(Op_NegExactL) || !UseMathExactIntrinsics) return NULL;
539 break;
540 case vmIntrinsics::_multiplyExactI:
541 if (!Matcher::match_rule_supported(Op_MulExactI) || !UseMathExactIntrinsics) return NULL;
542 break;
543 case vmIntrinsics::_multiplyExactL:
544 if (!Matcher::match_rule_supported(Op_MulExactL) || !UseMathExactIntrinsics) return NULL;
545 break;
546
547 default:
548 assert(id <= vmIntrinsics::LAST_COMPILER_INLINE, "caller responsibility");
549 assert(id != vmIntrinsics::_Object_init && id != vmIntrinsics::_invoke, "enum out of order?");
550 break;
551 }
552
553 // -XX:-InlineClassNatives disables natives from the Class class.
554 // The flag applies to all reflective calls, notably Array.newArray
555 // (visible to Java programmers as Array.newInstance).
556 if (m->holder()->name() == ciSymbol::java_lang_Class() ||
557 m->holder()->name() == ciSymbol::java_lang_reflect_Array()) {
558 if (!InlineClassNatives) return NULL;
559 }
560
561 // -XX:-InlineThreadNatives disables natives from the Thread class.
562 if (m->holder()->name() == ciSymbol::java_lang_Thread()) {
563 if (!InlineThreadNatives) return NULL;
564 }
1953 default:
1954 fatal_unexpected_iid(id);
1955 return false;
1956 }
1957 }
1958
1959 static bool is_simple_name(Node* n) {
1960 return (n->req() == 1 // constant
1961 || (n->is_Type() && n->as_Type()->type()->singleton())
1962 || n->is_Proj() // parameter or return value
1963 || n->is_Phi() // local of some sort
1964 );
1965 }
1966
1967 //----------------------------inline_min_max-----------------------------------
1968 bool LibraryCallKit::inline_min_max(vmIntrinsics::ID id) {
1969 set_result(generate_min_max(id, argument(0), argument(1)));
1970 return true;
1971 }
1972
1973 void LibraryCallKit::inline_math_mathExact(Node* math) {
1974 // If we didn't get the expected opcode it means we have optimized
1975 // the node to something else and don't need the exception edge.
1976 if (!math->is_MathExact()) {
1977 set_result(math);
1978 return;
1979 }
1980
1981 Node* result = _gvn.transform( new(C) ProjNode(math, MathExactNode::result_proj_node));
1982 Node* flags = _gvn.transform( new(C) FlagsProjNode(math, MathExactNode::flags_proj_node));
1983
1984 Node* bol = _gvn.transform( new (C) BoolNode(flags, BoolTest::overflow) );
1985 IfNode* check = create_and_map_if(control(), bol, PROB_UNLIKELY_MAG(3), COUNT_UNKNOWN);
1986 Node* fast_path = _gvn.transform( new (C) IfFalseNode(check));
1987 Node* slow_path = _gvn.transform( new (C) IfTrueNode(check) );
1988
1989 {
1990 PreserveJVMState pjvms(this);
1991 PreserveReexecuteState preexecs(this);
1992 jvms()->set_should_reexecute(true);
1993
1994 set_control(slow_path);
1995 set_i_o(i_o());
1996
1997 uncommon_trap(Deoptimization::Reason_intrinsic,
1998 Deoptimization::Action_none);
1999 }
2000
2001 set_control(fast_path);
2002 set_result(result);
2003 }
2004
2005 bool LibraryCallKit::inline_math_addExactI(bool is_increment) {
2006 Node* arg1 = argument(0);
2007 Node* arg2 = NULL;
2008
2009 if (is_increment) {
2010 arg2 = intcon(1);
2011 } else {
2012 arg2 = argument(1);
2013 }
2014
2015 Node* add = _gvn.transform( new(C) AddExactINode(NULL, arg1, arg2) );
2016 inline_math_mathExact(add);
2017 return true;
2018 }
2019
2020 bool LibraryCallKit::inline_math_addExactL(bool is_increment) {
2021 Node* arg1 = argument(0); // type long
2022 // argument(1) == TOP
2023 Node* arg2 = NULL;
2024
2025 if (is_increment) {
2026 arg2 = longcon(1);
2027 } else {
2028 arg2 = argument(2); // type long
2029 // argument(3) == TOP
2030 }
2031
2032 Node* add = _gvn.transform(new(C) AddExactLNode(NULL, arg1, arg2));
2033 inline_math_mathExact(add);
2034 return true;
2035 }
2036
2037 bool LibraryCallKit::inline_math_subtractExactI(bool is_decrement) {
2038 Node* arg1 = argument(0);
2039 Node* arg2 = NULL;
2040
2041 if (is_decrement) {
2042 arg2 = intcon(1);
2043 } else {
2044 arg2 = argument(1);
2045 }
2046
2047 Node* sub = _gvn.transform(new(C) SubExactINode(NULL, arg1, arg2));
2048 inline_math_mathExact(sub);
2049 return true;
2050 }
2051
2052 bool LibraryCallKit::inline_math_subtractExactL(bool is_decrement) {
2053 Node* arg1 = argument(0); // type long
2054 // argument(1) == TOP
2055 Node* arg2 = NULL;
2056
2057 if (is_decrement) {
2058 arg2 = longcon(1);
2059 } else {
2060 arg2 = argument(2); // type long
2061 // argument(3) == TOP
2062 }
2063
2064 Node* sub = _gvn.transform(new(C) SubExactLNode(NULL, arg1, arg2));
2065 inline_math_mathExact(sub);
2066 return true;
2067 }
2068
2069 bool LibraryCallKit::inline_math_negateExactI() {
2070 Node* arg1 = argument(0);
2071
2072 Node* neg = _gvn.transform(new(C) NegExactINode(NULL, arg1));
2073 inline_math_mathExact(neg);
2074 return true;
2075 }
2076
2077 bool LibraryCallKit::inline_math_negateExactL() {
2078 Node* arg1 = argument(0);
2079 // argument(1) == TOP
2080
2081 Node* neg = _gvn.transform(new(C) NegExactLNode(NULL, arg1));
2082 inline_math_mathExact(neg);
2083 return true;
2084 }
2085
2086 bool LibraryCallKit::inline_math_multiplyExactI() {
2087 Node* arg1 = argument(0);
2088 Node* arg2 = argument(1);
2089
2090 Node* mul = _gvn.transform(new(C) MulExactINode(NULL, arg1, arg2));
2091 inline_math_mathExact(mul);
2092 return true;
2093 }
2094
2095 bool LibraryCallKit::inline_math_multiplyExactL() {
2096 Node* arg1 = argument(0);
2097 // argument(1) == TOP
2098 Node* arg2 = argument(2);
2099 // argument(3) == TOP
2100
2101 Node* mul = _gvn.transform(new(C) MulExactLNode(NULL, arg1, arg2));
2102 inline_math_mathExact(mul);
2103 return true;
2104 }
2105
2106 Node*
2107 LibraryCallKit::generate_min_max(vmIntrinsics::ID id, Node* x0, Node* y0) {
2108 // These are the candidate return value:
2109 Node* xvalue = x0;
2110 Node* yvalue = y0;
2111
2112 if (xvalue == yvalue) {
2113 return xvalue;
2114 }
2115
2116 bool want_max = (id == vmIntrinsics::_max);
2117
2118 const TypeInt* txvalue = _gvn.type(xvalue)->isa_int();
2119 const TypeInt* tyvalue = _gvn.type(yvalue)->isa_int();
2120 if (txvalue == NULL || tyvalue == NULL) return top();
2121 // This is not really necessary, but it is consistent with a
2122 // hypothetical MaxINode::Value method:
2123 int widen = MAX2(txvalue->_widen, tyvalue->_widen);
|
186 bool is_virtual = false, bool is_static = false);
187 CallJavaNode* generate_method_call_static(vmIntrinsics::ID method_id) {
188 return generate_method_call(method_id, false, true);
189 }
190 CallJavaNode* generate_method_call_virtual(vmIntrinsics::ID method_id) {
191 return generate_method_call(method_id, true, false);
192 }
193 Node * load_field_from_object(Node * fromObj, const char * fieldName, const char * fieldTypeString, bool is_exact, bool is_static);
194
195 Node* make_string_method_node(int opcode, Node* str1_start, Node* cnt1, Node* str2_start, Node* cnt2);
196 Node* make_string_method_node(int opcode, Node* str1, Node* str2);
197 bool inline_string_compareTo();
198 bool inline_string_indexOf();
199 Node* string_indexOf(Node* string_object, ciTypeArray* target_array, jint offset, jint cache_i, jint md2_i);
200 bool inline_string_equals();
201 Node* round_double_node(Node* n);
202 bool runtime_math(const TypeFunc* call_type, address funcAddr, const char* funcName);
203 bool inline_math_native(vmIntrinsics::ID id);
204 bool inline_trig(vmIntrinsics::ID id);
205 bool inline_math(vmIntrinsics::ID id);
206 template <typename OverflowOp>
207 bool inline_math_overflow(Node* arg1, Node* arg2);
208 void inline_math_mathExact(Node* math, Node* test);
209 bool inline_math_addExactI(bool is_increment);
210 bool inline_math_addExactL(bool is_increment);
211 bool inline_math_multiplyExactI();
212 bool inline_math_multiplyExactL();
213 bool inline_math_negateExactI();
214 bool inline_math_negateExactL();
215 bool inline_math_subtractExactI(bool is_decrement);
216 bool inline_math_subtractExactL(bool is_decrement);
217 bool inline_exp();
218 bool inline_pow();
219 void finish_pow_exp(Node* result, Node* x, Node* y, const TypeFunc* call_type, address funcAddr, const char* funcName);
220 bool inline_min_max(vmIntrinsics::ID id);
221 Node* generate_min_max(vmIntrinsics::ID id, Node* x, Node* y);
222 // This returns Type::AnyPtr, RawPtr, or OopPtr.
223 int classify_unsafe_addr(Node* &base, Node* &offset);
224 Node* make_unsafe_address(Node* base, Node* offset);
225 // Helper for inline_unsafe_access.
226 // Generates the guards that check whether the result of
227 // Unsafe.getObject should be recorded in an SATB log buffer.
228 void insert_pre_barrier(Node* base_oop, Node* offset, Node* pre_val, bool need_mem_bar);
502 case vmIntrinsics::_aescrypt_encryptBlock:
503 case vmIntrinsics::_aescrypt_decryptBlock:
504 if (!UseAESIntrinsics) return NULL;
505 break;
506
507 case vmIntrinsics::_cipherBlockChaining_encryptAESCrypt:
508 case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt:
509 if (!UseAESIntrinsics) return NULL;
510 // these two require the predicated logic
511 is_predicted = true;
512 break;
513
514 case vmIntrinsics::_updateCRC32:
515 case vmIntrinsics::_updateBytesCRC32:
516 case vmIntrinsics::_updateByteBufferCRC32:
517 if (!UseCRC32Intrinsics) return NULL;
518 break;
519
520 case vmIntrinsics::_incrementExactI:
521 case vmIntrinsics::_addExactI:
522 if (!Matcher::match_rule_supported(Op_OverflowAddI) || !UseMathExactIntrinsics) return NULL;
523 break;
524 case vmIntrinsics::_incrementExactL:
525 case vmIntrinsics::_addExactL:
526 if (!Matcher::match_rule_supported(Op_OverflowAddL) || !UseMathExactIntrinsics) return NULL;
527 break;
528 case vmIntrinsics::_decrementExactI:
529 case vmIntrinsics::_subtractExactI:
530 if (!Matcher::match_rule_supported(Op_OverflowSubI) || !UseMathExactIntrinsics) return NULL;
531 break;
532 case vmIntrinsics::_decrementExactL:
533 case vmIntrinsics::_subtractExactL:
534 if (!Matcher::match_rule_supported(Op_OverflowSubL) || !UseMathExactIntrinsics) return NULL;
535 break;
536 case vmIntrinsics::_negateExactI:
537 if (!Matcher::match_rule_supported(Op_OverflowSubI) || !UseMathExactIntrinsics) return NULL;
538 break;
539 case vmIntrinsics::_negateExactL:
540 if (!Matcher::match_rule_supported(Op_OverflowSubL) || !UseMathExactIntrinsics) return NULL;
541 break;
542 case vmIntrinsics::_multiplyExactI:
543 if (!Matcher::match_rule_supported(Op_OverflowMulI) || !UseMathExactIntrinsics) return NULL;
544 break;
545 case vmIntrinsics::_multiplyExactL:
546 if (!Matcher::match_rule_supported(Op_OverflowMulL) || !UseMathExactIntrinsics) return NULL;
547 break;
548
549 default:
550 assert(id <= vmIntrinsics::LAST_COMPILER_INLINE, "caller responsibility");
551 assert(id != vmIntrinsics::_Object_init && id != vmIntrinsics::_invoke, "enum out of order?");
552 break;
553 }
554
555 // -XX:-InlineClassNatives disables natives from the Class class.
556 // The flag applies to all reflective calls, notably Array.newArray
557 // (visible to Java programmers as Array.newInstance).
558 if (m->holder()->name() == ciSymbol::java_lang_Class() ||
559 m->holder()->name() == ciSymbol::java_lang_reflect_Array()) {
560 if (!InlineClassNatives) return NULL;
561 }
562
563 // -XX:-InlineThreadNatives disables natives from the Thread class.
564 if (m->holder()->name() == ciSymbol::java_lang_Thread()) {
565 if (!InlineThreadNatives) return NULL;
566 }
1955 default:
1956 fatal_unexpected_iid(id);
1957 return false;
1958 }
1959 }
1960
1961 static bool is_simple_name(Node* n) {
1962 return (n->req() == 1 // constant
1963 || (n->is_Type() && n->as_Type()->type()->singleton())
1964 || n->is_Proj() // parameter or return value
1965 || n->is_Phi() // local of some sort
1966 );
1967 }
1968
1969 //----------------------------inline_min_max-----------------------------------
1970 bool LibraryCallKit::inline_min_max(vmIntrinsics::ID id) {
1971 set_result(generate_min_max(id, argument(0), argument(1)));
1972 return true;
1973 }
1974
1975 void LibraryCallKit::inline_math_mathExact(Node* math, Node *test) {
1976 Node* bol = _gvn.transform( new (C) BoolNode(test, BoolTest::overflow) );
1977 IfNode* check = create_and_map_if(control(), bol, PROB_UNLIKELY_MAG(3), COUNT_UNKNOWN);
1978 Node* fast_path = _gvn.transform( new (C) IfFalseNode(check));
1979 Node* slow_path = _gvn.transform( new (C) IfTrueNode(check) );
1980
1981 {
1982 PreserveJVMState pjvms(this);
1983 PreserveReexecuteState preexecs(this);
1984 jvms()->set_should_reexecute(true);
1985
1986 set_control(slow_path);
1987 set_i_o(i_o());
1988
1989 uncommon_trap(Deoptimization::Reason_intrinsic,
1990 Deoptimization::Action_none);
1991 }
1992
1993 set_control(fast_path);
1994 set_result(math);
1995 }
1996
1997 template <typename OverflowOp>
1998 bool LibraryCallKit::inline_math_overflow(Node* arg1, Node* arg2) {
1999 typedef typename OverflowOp::MathOp MathOp;
2000
2001 MathOp* mathOp = new(C) MathOp(arg1, arg2);
2002 Node* operation = _gvn.transform( mathOp );
2003 Node* ofcheck = _gvn.transform( new(C) OverflowOp(arg1, arg2) );
2004 inline_math_mathExact(operation, ofcheck);
2005 return true;
2006 }
2007
2008 bool LibraryCallKit::inline_math_addExactI(bool is_increment) {
2009 return inline_math_overflow<OverflowAddINode>(argument(0), is_increment ? intcon(1) : argument(1));
2010 }
2011
2012 bool LibraryCallKit::inline_math_addExactL(bool is_increment) {
2013 return inline_math_overflow<OverflowAddLNode>(argument(0), is_increment ? longcon(1) : argument(2));
2014 }
2015
2016 bool LibraryCallKit::inline_math_subtractExactI(bool is_decrement) {
2017 return inline_math_overflow<OverflowSubINode>(argument(0), is_decrement ? intcon(1) : argument(1));
2018 }
2019
2020 bool LibraryCallKit::inline_math_subtractExactL(bool is_decrement) {
2021 return inline_math_overflow<OverflowSubLNode>(argument(0), is_decrement ? longcon(1) : argument(2));
2022 }
2023
2024 bool LibraryCallKit::inline_math_negateExactI() {
2025 return inline_math_overflow<OverflowSubINode>(intcon(0), argument(0));
2026 }
2027
2028 bool LibraryCallKit::inline_math_negateExactL() {
2029 return inline_math_overflow<OverflowSubLNode>(longcon(0), argument(0));
2030 }
2031
2032 bool LibraryCallKit::inline_math_multiplyExactI() {
2033 return inline_math_overflow<OverflowMulINode>(argument(0), argument(1));
2034 }
2035
2036 bool LibraryCallKit::inline_math_multiplyExactL() {
2037 return inline_math_overflow<OverflowMulLNode>(argument(0), argument(2));
2038 }
2039
2040 Node*
2041 LibraryCallKit::generate_min_max(vmIntrinsics::ID id, Node* x0, Node* y0) {
2042 // These are the candidate return value:
2043 Node* xvalue = x0;
2044 Node* yvalue = y0;
2045
2046 if (xvalue == yvalue) {
2047 return xvalue;
2048 }
2049
2050 bool want_max = (id == vmIntrinsics::_max);
2051
2052 const TypeInt* txvalue = _gvn.type(xvalue)->isa_int();
2053 const TypeInt* tyvalue = _gvn.type(yvalue)->isa_int();
2054 if (txvalue == NULL || tyvalue == NULL) return top();
2055 // This is not really necessary, but it is consistent with a
2056 // hypothetical MaxINode::Value method:
2057 int widen = MAX2(txvalue->_widen, tyvalue->_widen);
|