author | cjplummer |
Thu, 29 Oct 2015 12:04:04 -0700 | |
changeset 33730 | 30e064828045 |
parent 30604 | b8d532cb6420 |
child 36851 | 03e2f4d0a421 |
permissions | -rw-r--r-- |
24011
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
1 |
/* |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28190
diff
changeset
|
2 |
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
24011
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
4 |
* |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
8 |
* |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
13 |
* accompanied this code). |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
14 |
* |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
18 |
* |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
21 |
* questions. |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
22 |
*/ |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
23 |
|
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
24 |
/* |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
25 |
* @test CorrectnessTest |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
26 |
* @bug 8038418 |
33730
30e064828045
8140189: [TESTBUG] Get rid of "@library /../../test/lib" in jtreg tests
cjplummer
parents:
30604
diff
changeset
|
27 |
* @library /testlibrary /test/lib |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28190
diff
changeset
|
28 |
* @modules java.base/sun.misc |
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28190
diff
changeset
|
29 |
* java.management |
27925 | 30 |
* @ignore 8066173 |
24011
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
31 |
* @compile execution/TypeConflict.java execution/TypeProfile.java |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
32 |
* execution/MethodHandleDelegate.java |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
33 |
* @build CorrectnessTest |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
34 |
* @build OffTest |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
35 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox |
25958
8dc85547d6d6
8011397: JTREG needs to copy additional WhiteBox class file to JTwork/scratch/sun/hotspot
mgerdin
parents:
24011
diff
changeset
|
36 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
24011
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
37 |
* @run main/timeout=1200 OffTest |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
38 |
*/ |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
39 |
|
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
29678
diff
changeset
|
40 |
import jdk.test.lib.OutputAnalyzer; |
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
29678
diff
changeset
|
41 |
import jdk.test.lib.ProcessTools; |
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
29678
diff
changeset
|
42 |
import jdk.test.lib.Utils; |
27453
9aeb9b97bef6
8044186: Introduce a reproducible random generator
iignatyev
parents:
25958
diff
changeset
|
43 |
import java.util.Random; |
24011
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
44 |
import scenarios.ProfilingType; |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
45 |
|
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
46 |
public class OffTest { |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
47 |
private static final String[] OPTIONS = { |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
48 |
"-Xbootclasspath/a:.", |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
49 |
"-XX:+IgnoreUnrecognizedVMOptions", |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
50 |
"-XX:+UnlockExperimentalVMOptions", |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
51 |
"-XX:+UnlockDiagnosticVMOptions", |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
52 |
"-XX:+WhiteBoxAPI", |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
53 |
"-XX:CompileCommand=exclude,execution/*::methodNotToCompile", |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
54 |
"-XX:CompileCommand=dontinline,scenarios/Scenario::collectReturnType", |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
55 |
"", // -XX:TypeProfileLevel=? |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
56 |
"", // -XX:?UseTypeSpeculation |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
57 |
CorrectnessTest.class.getName(), |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
58 |
"", // ProfilingType.name() |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
59 |
}; |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
60 |
|
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
61 |
private static final String TYPE_PROFILE_LEVEL = "TypeProfileLevel"; |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
62 |
private static final String USE_TYPE_SPECULATION = "UseTypeSpeculation"; |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
63 |
private static final int TYPE_PROFILE_LEVEL_LENGTH = 3; |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
64 |
private static final int TYPE_PROFILE_LEVEL_BOUND = 3; |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
65 |
private static final int DEFAULT_COUNT = 10; |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
66 |
private static final int PROFILING_TYPE_INDEX = OPTIONS.length - 1; |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
67 |
private static final int TYPE_PROFILE_INDEX = OPTIONS.length - 4; |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
68 |
private static final int USE_TYPE_SPECULATION_INDEX = OPTIONS.length - 3; |
27453
9aeb9b97bef6
8044186: Introduce a reproducible random generator
iignatyev
parents:
25958
diff
changeset
|
69 |
private static final Random RNG = Utils.getRandomInstance(); |
24011
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
70 |
|
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
71 |
public static void main(String[] args) throws Exception { |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
72 |
int count = DEFAULT_COUNT; |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
73 |
if (args.length > 0) { |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
74 |
count = Integer.parseInt(args[0]) ; |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
75 |
} |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
76 |
for (int i = 0; i < count; ++i) { |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
77 |
runTest(); |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
78 |
} |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
79 |
} |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
80 |
|
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
81 |
private static void runTest() throws Exception { |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
82 |
String useTypeSpeculation = "-XX:" + (RNG.nextBoolean() ? "+" : "-") + USE_TYPE_SPECULATION; |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
83 |
String typeProfileLevel = "-XX:" + TYPE_PROFILE_LEVEL + "=" + randomTypeProfileLevel(); |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
84 |
ProfilingType type = randomProfileType(); |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
85 |
OPTIONS[TYPE_PROFILE_INDEX] = typeProfileLevel; |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
86 |
OPTIONS[USE_TYPE_SPECULATION_INDEX] = useTypeSpeculation; |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
87 |
OPTIONS[PROFILING_TYPE_INDEX] = type.name(); |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
88 |
ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(/* addTestVmOptions= */ true, OPTIONS); |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
89 |
OutputAnalyzer outputAnalyzer = new OutputAnalyzer(processBuilder.start()); |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
90 |
outputAnalyzer.shouldHaveExitValue(0); |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
91 |
} |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
92 |
|
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
93 |
private static ProfilingType randomProfileType() { |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
94 |
ProfilingType[] value = ProfilingType.values(); |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
95 |
return value[RNG.nextInt(value.length)]; |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
96 |
} |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
97 |
|
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
98 |
private static String randomTypeProfileLevel() { |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
99 |
StringBuilder stringBuilder = new StringBuilder(); |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
100 |
for (int i = 0; i < TYPE_PROFILE_LEVEL_LENGTH; ++i) { |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
101 |
stringBuilder.append(RNG.nextInt(TYPE_PROFILE_LEVEL_BOUND)); |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
102 |
} |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
103 |
return stringBuilder.toString(); |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
104 |
} |
c2dc59a495eb
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
105 |
} |