OpenJDK / jdk / jdk
changeset 57505:10ca494c141f
8229351: AArch64: the const STUB_THRESHOLD in macroAssembler_aarch64.cpp needs to be tuned
Summary: Optimize the stub thresholds of string_compare intrinsics
Reviewed-by: adinn, aph, avoitylov
author | qpzhang |
---|---|
date | Mon, 12 Aug 2019 16:22:24 +0800 |
parents | 68adcd2fbc6b |
children | 9b4336f9fa6d |
files | src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp test/hotspot/jtreg/compiler/intrinsics/string/TestStringCompareToDifferentLength.java test/hotspot/jtreg/compiler/intrinsics/string/TestStringCompareToSameLength.java |
diffstat | 4 files changed, 19 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp Thu Dec 19 08:36:40 2019 +0000 +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp Mon Aug 12 16:22:24 2019 +0800 @@ -4919,11 +4919,15 @@ DIFFERENCE, NEXT_WORD, SHORT_LOOP_TAIL, SHORT_LAST2, SHORT_LAST_INIT, SHORT_LOOP_START, TAIL_CHECK; - const u1 STUB_THRESHOLD = 64 + 8; bool isLL = ae == StrIntrinsicNode::LL; bool isLU = ae == StrIntrinsicNode::LU; bool isUL = ae == StrIntrinsicNode::UL; + // The stub threshold for LL strings is: 72 (64 + 8) chars + // UU: 36 chars, or 72 bytes (valid for the 64-byte large loop with prefetch) + // LU/UL: 24 chars, or 48 bytes (valid for the 16-character loop at least) + const u1 stub_threshold = isLL ? 72 : ((isLU || isUL) ? 24 : 36); + bool str1_isL = isLL || isLU; bool str2_isL = isLL || isUL; @@ -4964,7 +4968,7 @@ cmp(str1, str2); br(Assembler::EQ, DONE); ldr(tmp2, Address(str2)); - cmp(cnt2, STUB_THRESHOLD); + cmp(cnt2, stub_threshold); br(GE, STUB); subsw(cnt2, cnt2, minCharsInWord); br(EQ, TAIL_CHECK); @@ -4976,7 +4980,7 @@ cmp(str1, str2); br(Assembler::EQ, DONE); ldr(tmp2, Address(str2)); - cmp(cnt2, STUB_THRESHOLD); + cmp(cnt2, stub_threshold); br(GE, STUB); subw(cnt2, cnt2, 4); eor(vtmpZ, T16B, vtmpZ, vtmpZ); @@ -4992,7 +4996,7 @@ cmp(str1, str2); br(Assembler::EQ, DONE); ldrs(vtmp, Address(str2)); - cmp(cnt2, STUB_THRESHOLD); + cmp(cnt2, stub_threshold); br(GE, STUB); subw(cnt2, cnt2, 4); lea(str1, Address(str1, cnt2, Address::uxtw(str1_chr_shift)));
--- a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp Thu Dec 19 08:36:40 2019 +0000 +++ b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp Mon Aug 12 16:22:24 2019 +0800 @@ -4110,6 +4110,7 @@ __ bind(NO_PREFETCH); __ subs(cnt2, cnt2, 16); __ br(__ LT, TAIL); + __ align(OptoLoopAlignment); __ bind(SMALL_LOOP); // smaller loop __ subs(cnt2, cnt2, 16); compare_string_16_x_LU(tmpL, tmpU, DIFF1, DIFF2); @@ -4199,6 +4200,7 @@ // less than 16 bytes left? __ subs(cnt2, cnt2, isLL ? 16 : 8); __ br(__ LT, TAIL); + __ align(OptoLoopAlignment); __ bind(SMALL_LOOP); compare_string_16_bytes_same(DIFF, DIFF2); __ subs(cnt2, cnt2, isLL ? 16 : 8);
--- a/test/hotspot/jtreg/compiler/intrinsics/string/TestStringCompareToDifferentLength.java Thu Dec 19 08:36:40 2019 +0000 +++ b/test/hotspot/jtreg/compiler/intrinsics/string/TestStringCompareToDifferentLength.java Mon Aug 12 16:22:24 2019 +0800 @@ -32,12 +32,12 @@ * parameters: <string length>, <maximum string length delta> * Input parameters for this test are set according to Aarch64 * String::compareTo intrinsic implementation specifics. Aarch64 - * implementation has 1, 4, 8 -characters loops for length < 72 and + * implementation has 1, 4, 8 -bytes loops for length < 72 and * 16, 32, 64 -characters loops for length >= 72. Code is also affected * by SoftwarePrefetchHintDistance vm flag value. - * @run main/othervm -XX:SoftwarePrefetchHintDistance=192 compiler.intrinsics.string.TestStringCompareToDifferentLength 4 2 5 10 13 17 20 25 71 72 73 88 90 192 193 208 209 - * @run main/othervm -XX:SoftwarePrefetchHintDistance=16 compiler.intrinsics.string.TestStringCompareToDifferentLength 4 2 5 10 13 17 20 25 71 72 73 88 90 - * @run main/othervm -XX:SoftwarePrefetchHintDistance=-1 compiler.intrinsics.string.TestStringCompareToDifferentLength 4 2 5 10 13 17 20 25 71 72 73 88 90 + * @run main/othervm -XX:SoftwarePrefetchHintDistance=192 compiler.intrinsics.string.TestStringCompareToDifferentLength 4 2 5 10 13 17 20 23 24 25 71 72 73 88 90 192 193 208 209 + * @run main/othervm -XX:SoftwarePrefetchHintDistance=16 compiler.intrinsics.string.TestStringCompareToDifferentLength 4 2 5 10 13 17 20 23 24 25 71 72 73 88 90 + * @run main/othervm -XX:SoftwarePrefetchHintDistance=-1 compiler.intrinsics.string.TestStringCompareToDifferentLength 4 2 5 10 13 17 20 23 24 25 71 72 73 88 90 */ package compiler.intrinsics.string;
--- a/test/hotspot/jtreg/compiler/intrinsics/string/TestStringCompareToSameLength.java Thu Dec 19 08:36:40 2019 +0000 +++ b/test/hotspot/jtreg/compiler/intrinsics/string/TestStringCompareToSameLength.java Mon Aug 12 16:22:24 2019 +0800 @@ -32,16 +32,16 @@ * String size is specified via commandline. Various size values can * be specified during intrinsic development in order to test cases * specific for new or modified intrinsic implementation. Aarch64 - * implementation has 1, 4, 8 -characters loops for length < 72 and - * 16, 32, 64 -characters loops for string length >= 72. Code is also + * implementation has 1, 4, 8 -bytes loops for length < 72 and + * 16, 32, 64 -bytes loops for string length >= 72. Code is also * affected by SoftwarePrefetchHintDistance flag value. * Test class can also accept "-fullmode" parameter * with maxLength paramter after it. Then it will iterate through all * string length values up to maxLength parameter (inclusive). It takes * a lot of time but is useful for development. - * @run main/othervm -XX:SoftwarePrefetchHintDistance=192 compiler.intrinsics.string.TestStringCompareToSameLength 2 5 10 13 17 20 25 71 72 73 88 90 192 193 208 209 - * @run main/othervm -XX:SoftwarePrefetchHintDistance=16 compiler.intrinsics.string.TestStringCompareToSameLength 2 5 10 13 17 20 25 71 72 73 88 90 - * @run main/othervm -XX:SoftwarePrefetchHintDistance=-1 compiler.intrinsics.string.TestStringCompareToSameLength 2 5 10 13 17 20 25 71 72 73 88 90 + * @run main/othervm -XX:SoftwarePrefetchHintDistance=192 compiler.intrinsics.string.TestStringCompareToSameLength 2 5 10 13 17 20 25 35 36 37 71 72 73 88 90 192 193 208 209 + * @run main/othervm -XX:SoftwarePrefetchHintDistance=16 compiler.intrinsics.string.TestStringCompareToSameLength 2 5 10 13 17 20 25 35 36 37 71 72 73 88 90 + * @run main/othervm -XX:SoftwarePrefetchHintDistance=-1 compiler.intrinsics.string.TestStringCompareToSameLength 2 5 10 13 17 20 25 35 36 37 71 72 73 88 90 */ package compiler.intrinsics.string;