United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6875866 Intrinsic for String.indexOf() is broken on x86 with SSE4.2
JDK-6875866 : Intrinsic for String.indexOf() is broken on x86 with SSE4.2

Details
Type:
Bug
Submit Date:
2009-08-26
Status:
Closed
Updated Date:
2012-08-20
Project Name:
JDK
Resolved Date:
2011-03-08
Component:
hotspot
OS:
solaris
Sub-Component:
compiler
CPU:
x86
Priority:
P2
Resolution:
Fixed
Affected Versions:
hs16
Fixed Versions:
hs16 (b09)

Related Reports
Backport:
Backport:
Backport:
Backport:
Relates:
Relates:

Sub Tasks

Description
Implementation of String.indexOf() intrinsic using SSE 4.2 instructions is incorrect.
The regression is introduced by 6761600 in HS15_b05 so jdk6u14p, jdk6u18 and JDK7 are affected.

% cat Test.java
public class Test {

  static int IndexOfTest(String str) {
    return str.indexOf("11111xx1x");
  }

  public static void main(String args[]) {
    String str = "11111xx11111xx1x";
    int idx = IndexOfTest(str);  
    System.out.println("IndexOf = " + idx);
  }
}

% /java/re/jdk/6u14/promoted/p/b03/binaries/solaris-amd64/bin/java -d64 -Xcomp Test
IndexOf = -1

% /java/re/jdk/6u18/promoted/latest/binaries/solaris-i586/bin/java -Xcomp Test
IndexOf = -1
i% /java/re/jdk/6u18/promoted/latest/binaries/solaris-amd64/bin/java -d64 -Xcomp Test
IndexOf = -1
% /java/re/jdk/6u18/promoted/latest/binaries/solaris-i586/bin/java  -XX:-UseSSE42Intrinsics -Xcomp Test
IndexOf = 7

                                    

Comments
EVALUATION

http://hg.openjdk.java.net/hsx/hsx16/baseline/rev/9f00229d78ce
                                     
2009-08-26
PUBLIC COMMENTS

Problem:
String.indexOf SSE4.2 code starts string rescanning from
a wrong place after failing to match a part of substring.

Solution:
Start from the next element after the previous match.
                                     
2009-08-26
EVALUATION

http://hg.openjdk.java.net/hsx/hsx16/master/rev/9f00229d78ce
                                     
2009-09-04
EVALUATION

http://hg.openjdk.java.net/jdk7/hotspot-comp/hotspot/rev/62001a362ce9
                                     
2009-09-15



Hardware and Software, Engineered to Work Together