Wed, 17 Mar 2010 10:47:03 -0700
6935535: String.indexOf() returns incorrect result on x86 with SSE4.2
Summary: Added missing counter decrement when substring search restarted.
Reviewed-by: twisti
src/cpu/x86/vm/assembler_x86.cpp | file | annotate | diff | comparison | revisions | |
test/compiler/6935535/Test.java | file | annotate | diff | comparison | revisions |
1.1 --- a/src/cpu/x86/vm/assembler_x86.cpp Wed Mar 17 10:22:41 2010 +0100 1.2 +++ b/src/cpu/x86/vm/assembler_x86.cpp Wed Mar 17 10:47:03 2010 -0700 1.3 @@ -8460,6 +8460,7 @@ 1.4 subptr(str1, result); // Restore counter 1.5 shrl(str1, 1); 1.6 addl(cnt1, str1); 1.7 + decrementl(cnt1); 1.8 lea(str1, Address(result, 2)); // Reload string 1.9 1.10 // Load substr
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/compiler/6935535/Test.java Wed Mar 17 10:47:03 2010 -0700 2.3 @@ -0,0 +1,48 @@ 2.4 +/* 2.5 + * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved. 2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.7 + * 2.8 + * This code is free software; you can redistribute it and/or modify it 2.9 + * under the terms of the GNU General Public License version 2 only, as 2.10 + * published by the Free Software Foundation. 2.11 + * 2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.15 + * version 2 for more details (a copy is included in the LICENSE file that 2.16 + * accompanied this code). 2.17 + * 2.18 + * You should have received a copy of the GNU General Public License version 2.19 + * 2 along with this work; if not, write to the Free Software Foundation, 2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.21 + * 2.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 2.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 2.24 + * have any questions. 2.25 + */ 2.26 + 2.27 +/** 2.28 + * @test 2.29 + * @bug 6935535 2.30 + * @summary String.indexOf() returns incorrect result on x86 with SSE4.2 2.31 + * 2.32 + * @run main/othervm -Xcomp Test 2.33 + */ 2.34 + 2.35 +public class Test { 2.36 + 2.37 + static int IndexOfTest(String str) { 2.38 + return str.indexOf("1111111111111xx1x"); 2.39 + } 2.40 + 2.41 + public static void main(String args[]) { 2.42 + String str = "1111111111111xx1111111111111xx1x"; 2.43 + str = str.substring(0, 31); 2.44 + int idx = IndexOfTest(str); 2.45 + System.out.println("IndexOf(" + "1111111111111xx1x" + ") = " + idx + " in " + str); 2.46 + if (idx != -1) { 2.47 + System.exit(97); 2.48 + } 2.49 + } 2.50 +} 2.51 +