diff --git a/src/hotspot/share/opto/library_call.cpp b/src/hotspot/share/opto/library_call.cpp index c3f23da4044..bed19bced72 100644 --- a/src/hotspot/share/opto/library_call.cpp +++ b/src/hotspot/share/opto/library_call.cpp @@ -982,29 +982,47 @@ Node* LibraryCallKit::generate_current_thread(Node* &tls_output) { // str1 and str2 pointing to byte[] nodes containing Latin1 or UTF16 encoded // characters (depending on 'is_byte'). cnt1 and cnt2 are pointing to Int nodes // containing the lengths of str1 and str2. -Node* LibraryCallKit::make_string_method_node(int opcode, Node* str1_start, Node* cnt1, Node* str2_start, Node* cnt2, StrIntrinsicNode::ArgEnc ae) { #if HOTSPOT_TARGET_CLASSLIB == 8 +Node* LibraryCallKit::make_string_method_node(int opcode, Node* str1_start, Node* cnt1, Node* str2_start, Node* cnt2, StrIntrinsicNode::ArgEnc ae) { assert(!CompactStrings && ae == StrIntrinsicNode::UU, "classlib8 requires CHARS"); -#endif Node* result = NULL; switch (opcode) { case Op_StrIndexOf: -#if HOTSPOT_TARGET_CLASSLIB == 8 result = new StrIndexOfNode(control(), memory(TypeAryPtr::CHARS), str1_start, cnt1, str2_start, cnt2, ae); -#else - result = new StrIndexOfNode(control(), memory(TypeAryPtr::BYTES), - str1_start, cnt1, str2_start, cnt2, ae); -#endif break; case Op_StrComp: -#if HOTSPOT_TARGET_CLASSLIB == 8 result = new StrCompNode(control(), memory(TypeAryPtr::CHARS), str1_start, cnt1, str2_start, cnt2, ae); -#else + break; + case Op_StrEquals: + // We already know that cnt1 == cnt2 here (checked in 'inline_string_equals'). + // Use the constant length if there is one because optimized match rule may exist. + result = new StrEqualsNode(control(), memory(TypeAryPtr::CHARS), + str1_start, str2_start, cnt2->is_Con() ? cnt2 : cnt1, ae); + break; + default: + ShouldNotReachHere(); + return NULL; + } + + // All these intrinsics have checks. + C->set_has_split_ifs(true); // Has chance for split-if optimization + clear_upper_avx(); + + return _gvn.transform(result); +} +#else // HOTSPOT_TARGET_CLASSLIB +Node* LibraryCallKit::make_string_method_node(int opcode, Node* str1_start, Node* cnt1, Node* str2_start, Node* cnt2, StrIntrinsicNode::ArgEnc ae) { + Node* result = NULL; + switch (opcode) { + case Op_StrIndexOf: + result = new StrIndexOfNode(control(), memory(TypeAryPtr::BYTES), + str1_start, cnt1, str2_start, cnt2, ae); + break; + case Op_StrComp: result = new StrCompNode(control(), memory(TypeAryPtr::BYTES), str1_start, cnt1, str2_start, cnt2, ae); -#endif break; case Op_StrEquals: // We already know that cnt1 == cnt2 here (checked in 'inline_string_equals'). @@ -1023,6 +1041,7 @@ Node* LibraryCallKit::make_string_method_node(int opcode, Node* str1_start, Node return _gvn.transform(result); } +#endif // HOTSPOT_TARGET_CLASSLIB //------------------------------inline_string_compareTo------------------------ bool LibraryCallKit::inline_string_compareTo(StrIntrinsicNode::ArgEnc ae) { @@ -1069,6 +1088,15 @@ bool LibraryCallKit::inline_string_equals(StrIntrinsicNode::ArgEnc ae) { arg1 = must_be_not_null(arg1, true); arg2 = must_be_not_null(arg2, true); +#if HOTSPOT_TARGET_CLASSLIB == 8 + // Get start addr and length of first argument + Node* arg1_start = array_element_address(arg1, intcon(0), T_CHAR); + Node* arg1_cnt = load_array_length(arg1); + + // Get start addr and length of second argument + Node* arg2_start = array_element_address(arg2, intcon(0), T_CHAR); + Node* arg2_cnt = load_array_length(arg2); +#else // Get start addr and length of first argument Node* arg1_start = array_element_address(arg1, intcon(0), T_BYTE); Node* arg1_cnt = load_array_length(arg1); @@ -1076,6 +1104,7 @@ bool LibraryCallKit::inline_string_equals(StrIntrinsicNode::ArgEnc ae) { // Get start addr and length of second argument Node* arg2_start = array_element_address(arg2, intcon(0), T_BYTE); Node* arg2_cnt = load_array_length(arg2); +#endif // Check for arg1_cnt != arg2_cnt Node* cmp = _gvn.transform(new CmpINode(arg1_cnt, arg2_cnt)); @@ -1396,7 +1425,11 @@ bool LibraryCallKit::inline_string_indexOfChar(StrIntrinsicNode::ArgEnc ae) { RegionNode* region = new RegionNode(3); Node* phi = new PhiNode(region, TypeInt::INT); +#if HOTSPOT_TARGET_CLASSLIB == 8 + Node* result = new StrIndexOfCharNode(control(), memory(TypeAryPtr::CHARS), src_start, src_count, int_ch, ae); +#else Node* result = new StrIndexOfCharNode(control(), memory(TypeAryPtr::BYTES), src_start, src_count, int_ch, ae); +#endif C->set_has_split_ifs(true); // Has chance for split-if optimization _gvn.transform(result);