Mercurial > hg > truffle
annotate test/compiler/types/correctness/OffTest.java @ 21237:cc6e6c3e0eb7
MoveResolver: minor refactoring.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Thu, 30 Apr 2015 10:59:58 +0200 |
parents | 534fbe3d90f0 |
children |
rev | line source |
---|---|
17881
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
1 /* |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
534fbe3d90f0
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. |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
4 * |
534fbe3d90f0
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 |
534fbe3d90f0
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 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
8 * |
534fbe3d90f0
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 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
534fbe3d90f0
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 |
534fbe3d90f0
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 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
13 * accompanied this code). |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
14 * |
534fbe3d90f0
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 |
534fbe3d90f0
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, |
534fbe3d90f0
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. |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
18 * |
534fbe3d90f0
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 |
534fbe3d90f0
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 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
21 * questions. |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
22 */ |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
23 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
24 /* |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
25 * @test CorrectnessTest |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
26 * @bug 8038418 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
27 * @library /testlibrary /testlibrary/whitebox |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
28 * @compile execution/TypeConflict.java execution/TypeProfile.java |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
29 * execution/MethodHandleDelegate.java |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
30 * @build CorrectnessTest |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
31 * @build OffTest |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
32 * @run main ClassFileInstaller sun.hotspot.WhiteBox |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
33 * @run main/timeout=1200 OffTest |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
34 */ |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
35 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
36 import com.oracle.java.testlibrary.OutputAnalyzer; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
37 import com.oracle.java.testlibrary.ProcessTools; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
38 import scenarios.ProfilingType; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
39 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
40 import java.util.Random; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
41 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
42 public class OffTest { |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
43 private static final String[] OPTIONS = { |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
44 "-Xbootclasspath/a:.", |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
45 "-XX:+IgnoreUnrecognizedVMOptions", |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
46 "-XX:+UnlockExperimentalVMOptions", |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
47 "-XX:+UnlockDiagnosticVMOptions", |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
48 "-XX:+WhiteBoxAPI", |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
49 "-XX:CompileCommand=exclude,execution/*::methodNotToCompile", |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
50 "-XX:CompileCommand=dontinline,scenarios/Scenario::collectReturnType", |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
51 "", // -XX:TypeProfileLevel=? |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
52 "", // -XX:?UseTypeSpeculation |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
53 CorrectnessTest.class.getName(), |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
54 "", // ProfilingType.name() |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
55 }; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
56 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
57 private static final String TYPE_PROFILE_LEVEL = "TypeProfileLevel"; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
58 private static final String USE_TYPE_SPECULATION = "UseTypeSpeculation"; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
59 private static final int TYPE_PROFILE_LEVEL_LENGTH = 3; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
60 private static final int TYPE_PROFILE_LEVEL_BOUND = 3; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
61 private static final int DEFAULT_COUNT = 10; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
62 private static final int PROFILING_TYPE_INDEX = OPTIONS.length - 1; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
63 private static final int TYPE_PROFILE_INDEX = OPTIONS.length - 4; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
64 private static final int USE_TYPE_SPECULATION_INDEX = OPTIONS.length - 3; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
65 private static final Random RNG; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
66 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
67 static { |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
68 String str = System.getProperty("seed"); |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
69 long seed = str != null ? Long.parseLong(str) : new Random().nextLong(); |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
70 RNG = new Random(seed); |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
71 System.out.printf("-Dseed=%d%n", seed); |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
72 } |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
73 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
74 public static void main(String[] args) throws Exception { |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
75 int count = DEFAULT_COUNT; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
76 if (args.length > 0) { |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
77 count = Integer.parseInt(args[0]) ; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
78 } |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
79 for (int i = 0; i < count; ++i) { |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
80 runTest(); |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
81 } |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
82 } |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
83 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
84 private static void runTest() throws Exception { |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
85 String useTypeSpeculation = "-XX:" + (RNG.nextBoolean() ? "+" : "-") + USE_TYPE_SPECULATION; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
86 String typeProfileLevel = "-XX:" + TYPE_PROFILE_LEVEL + "=" + randomTypeProfileLevel(); |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
87 ProfilingType type = randomProfileType(); |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
88 OPTIONS[TYPE_PROFILE_INDEX] = typeProfileLevel; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
89 OPTIONS[USE_TYPE_SPECULATION_INDEX] = useTypeSpeculation; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
90 OPTIONS[PROFILING_TYPE_INDEX] = type.name(); |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
91 ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(/* addTestVmOptions= */ true, OPTIONS); |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
92 OutputAnalyzer outputAnalyzer = new OutputAnalyzer(processBuilder.start()); |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
93 outputAnalyzer.shouldHaveExitValue(0); |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
94 } |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
95 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
96 private static ProfilingType randomProfileType() { |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
97 ProfilingType[] value = ProfilingType.values(); |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
98 return value[RNG.nextInt(value.length)]; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
99 } |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
100 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
101 private static String randomTypeProfileLevel() { |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
102 StringBuilder stringBuilder = new StringBuilder(); |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
103 for (int i = 0; i < TYPE_PROFILE_LEVEL_LENGTH; ++i) { |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
104 stringBuilder.append(RNG.nextInt(TYPE_PROFILE_LEVEL_BOUND)); |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
105 } |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
106 return stringBuilder.toString(); |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
107 } |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
108 } |