Skip to content

Commit 95a805b

Browse files
committed
8299671: Speed up compiler/intrinsics/string/TestStringLatin1IndexOfChar.java
Backport-of: d2827ec8f77020241fee7d613fb7cf081b455eb9
1 parent a800231 commit 95a805b

File tree

1 file changed

+41
-8
lines changed

1 file changed

+41
-8
lines changed

test/hotspot/jtreg/compiler/intrinsics/string/TestStringLatin1IndexOfChar.java

+41-8
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,57 @@
3232
*
3333
* Run with varing levels of AVX and SSE support, also without the intrinsic at all
3434
*
35-
* @library /compiler/patches /test/lib
36-
* @run main/othervm -Xbatch -XX:Tier4InvocationThreshold=200 -XX:CompileThreshold=100 compiler.intrinsics.string.TestStringLatin1IndexOfChar
37-
* @run main/othervm -Xbatch -XX:Tier4InvocationThreshold=200 -XX:CompileThreshold=100 -XX:+UnlockDiagnosticVMOptions -XX:DisableIntrinsic=_indexOfL_char compiler.intrinsics.string.TestStringLatin1IndexOfChar
38-
* @run main/othervm -Xbatch -XX:Tier4InvocationThreshold=200 -XX:CompileThreshold=100 -XX:+IgnoreUnrecognizedVMOptions -XX:UseSSE=0 compiler.intrinsics.string.TestStringLatin1IndexOfChar
39-
* @run main/othervm -Xbatch -XX:Tier4InvocationThreshold=200 -XX:CompileThreshold=100 -XX:+IgnoreUnrecognizedVMOptions -XX:UseAVX=1 compiler.intrinsics.string.TestStringLatin1IndexOfChar
40-
* @run main/othervm -Xbatch -XX:Tier4InvocationThreshold=200 -XX:CompileThreshold=100 -XX:+IgnoreUnrecognizedVMOptions -XX:UseAVX=2 compiler.intrinsics.string.TestStringLatin1IndexOfChar
41-
* @run main/othervm -Xbatch -XX:Tier4InvocationThreshold=200 -XX:CompileThreshold=100 -XX:+IgnoreUnrecognizedVMOptions -XX:UseAVX=3 compiler.intrinsics.string.TestStringLatin1IndexOfChar
35+
* @requires vm.compiler2.enabled
36+
* @library /compiler/patches /test/lib /
37+
* @build jdk.test.whitebox.WhiteBox
38+
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
39+
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
40+
* -Xbatch compiler.intrinsics.string.TestStringLatin1IndexOfChar
41+
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
42+
* -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:DisableIntrinsic=_indexOfL_char compiler.intrinsics.string.TestStringLatin1IndexOfChar
43+
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
44+
* -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:UseAVX=0 compiler.intrinsics.string.TestStringLatin1IndexOfChar
45+
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
46+
* -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:UseAVX=1 compiler.intrinsics.string.TestStringLatin1IndexOfChar
47+
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
48+
* -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:UseAVX=2 compiler.intrinsics.string.TestStringLatin1IndexOfChar
49+
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
50+
* -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:UseAVX=3 compiler.intrinsics.string.TestStringLatin1IndexOfChar
4251
*/
4352

4453
package compiler.intrinsics.string;
4554

4655
import jdk.test.lib.Asserts;
56+
import jdk.test.whitebox.WhiteBox;
57+
import java.lang.reflect.Method;
58+
import compiler.whitebox.CompilerWhiteBoxTest;
4759

4860
public class TestStringLatin1IndexOfChar{
61+
private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
4962
private final static int MAX_LENGTH = 2048;//future proof for AVX-512 instructions
5063

5164
public static void main(String[] args) throws Exception {
52-
for (int i = 0; i < 1_000; ++i) {//repeat such that we enter into C2 code...
65+
Method methodFindOneItem = TestStringLatin1IndexOfChar.class.getDeclaredMethod("findOneItem");
66+
Method methodWithOffsetTest = TestStringLatin1IndexOfChar.class.getDeclaredMethod("withOffsetTest");
67+
Method methodTestEmpty = TestStringLatin1IndexOfChar.class.getDeclaredMethod("testEmpty");
68+
Asserts.assertNotNull(methodFindOneItem);
69+
Asserts.assertNotNull(methodWithOffsetTest);
70+
Asserts.assertNotNull(methodTestEmpty);
71+
72+
// Warmup - profiling must inline the methods
73+
for (int i = 0; i < 10; ++i) {
74+
findOneItem();
75+
withOffsetTest();
76+
testEmpty();
77+
}
78+
79+
// Compile
80+
WHITE_BOX.enqueueMethodForCompilation(methodFindOneItem, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION);
81+
WHITE_BOX.enqueueMethodForCompilation(methodWithOffsetTest, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION);
82+
WHITE_BOX.enqueueMethodForCompilation(methodTestEmpty, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION);
83+
84+
// Run compiled method
85+
for (int i = 0; i < 10; ++i) {
5386
findOneItem();
5487
withOffsetTest();
5588
testEmpty();

0 commit comments

Comments
 (0)