Skip to content

Commit b760469

Browse files
author
duke
committed
Backport 1d889b9
1 parent f4ddafc commit b760469

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/hotspot/cpu/x86/c2_stubGenerator_x86_64_string.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024, 2025, Intel Corporation. All rights reserved.
2+
* Copyright (c) 2024, 2026, Intel Corporation. All rights reserved.
33
*
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -1330,10 +1330,12 @@ static void big_case_loop_helper(bool sizeKnown, int size, Label &noMatch, Label
13301330
// Clarification: The BYTE_K compare above compares haystack[(n-32):(n-1)]. We need to
13311331
// compare haystack[(k-1):(k-1+31)]. Subtracting either index gives shift value of
13321332
// (k + 31 - n): x = (k-1+31)-(n-1) = k-1+31-n+1 = k+31-n.
1333+
// When isU is set, similarly, shift is from haystack[(n-32):(n-1)] to [(k-2):(k-2+31)]
1334+
13331335
if (sizeKnown) {
1334-
__ movl(temp2, 31 + size);
1336+
__ movl(temp2, (isU ? 30 : 31) + size);
13351337
} else {
1336-
__ movl(temp2, 31);
1338+
__ movl(temp2, isU ? 30 : 31);
13371339
__ addl(temp2, needleLen);
13381340
}
13391341
__ subl(temp2, hsLength);

test/jdk/java/lang/String/IndexOf.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024, Intel Corporation. All rights reserved.
2+
* Copyright (c) 2024, 2026, Intel Corporation. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -37,6 +37,15 @@
3737
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -Xcomp -XX:-TieredCompilation -XX:UseAVX=2 -XX:+UnlockDiagnosticVMOptions -XX:+EnableX86ECoreOpts IndexOf
3838
*/
3939

40+
/*
41+
* @test
42+
* @bug 8360271
43+
* @summary test String indexOf() intrinsic
44+
* @requires vm.cpu.features ~= ".*avx2.*"
45+
* @requires vm.compiler2.enabled
46+
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -Xcomp -XX:-TieredCompilation -XX:UseAVX=2 -XX:+UnlockDiagnosticVMOptions -XX:+EnableX86ECoreOpts -XX:-CompactStrings IndexOf
47+
*/
48+
4049
public class IndexOf {
4150
final int scope = 32*2+16+8;
4251
final char a, aa, b, c, d;
@@ -56,11 +65,11 @@ enum Encoding {LL, UU, UL; }
5665
d = 'd';
5766
break;
5867
case UU:
59-
a = '\u0061';
68+
a = '\u1061';
6069
aa = a;
61-
b = '\u0062';
70+
b = '\u1062';
6271
c = '\u1063';
63-
d = '\u0064';
72+
d = '\u1064';
6473
break;
6574
default: //case UL:
6675
a = 'a';
@@ -73,7 +82,7 @@ enum Encoding {LL, UU, UL; }
7382
}
7483

7584
// needle =~ /ab*d/
76-
// badNeedle =~ /ab*db*d/
85+
// badNeedle =~ /ab*cb*d/
7786
interface Append {void append(int pos, char cc);}
7887
String newNeedle(int size, int badPosition) {
7988
if (size<2) {throw new RuntimeException("Fix testcase "+size);}

0 commit comments

Comments
 (0)