comparison test/compiler/types/correctness/OffTest.java @ 18041:52b4284cb496

Merge with jdk8u20-b26
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 15 Oct 2014 16:02:50 +0200
parents 534fbe3d90f0
children
comparison
equal deleted inserted replaced
17606:45d7b2c7029d 18041:52b4284cb496
1 /*
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test CorrectnessTest
26 * @bug 8038418
27 * @library /testlibrary /testlibrary/whitebox
28 * @compile execution/TypeConflict.java execution/TypeProfile.java
29 * execution/MethodHandleDelegate.java
30 * @build CorrectnessTest
31 * @build OffTest
32 * @run main ClassFileInstaller sun.hotspot.WhiteBox
33 * @run main/timeout=1200 OffTest
34 */
35
36 import com.oracle.java.testlibrary.OutputAnalyzer;
37 import com.oracle.java.testlibrary.ProcessTools;
38 import scenarios.ProfilingType;
39
40 import java.util.Random;
41
42 public class OffTest {
43 private static final String[] OPTIONS = {
44 "-Xbootclasspath/a:.",
45 "-XX:+IgnoreUnrecognizedVMOptions",
46 "-XX:+UnlockExperimentalVMOptions",
47 "-XX:+UnlockDiagnosticVMOptions",
48 "-XX:+WhiteBoxAPI",
49 "-XX:CompileCommand=exclude,execution/*::methodNotToCompile",
50 "-XX:CompileCommand=dontinline,scenarios/Scenario::collectReturnType",
51 "", // -XX:TypeProfileLevel=?
52 "", // -XX:?UseTypeSpeculation
53 CorrectnessTest.class.getName(),
54 "", // ProfilingType.name()
55 };
56
57 private static final String TYPE_PROFILE_LEVEL = "TypeProfileLevel";
58 private static final String USE_TYPE_SPECULATION = "UseTypeSpeculation";
59 private static final int TYPE_PROFILE_LEVEL_LENGTH = 3;
60 private static final int TYPE_PROFILE_LEVEL_BOUND = 3;
61 private static final int DEFAULT_COUNT = 10;
62 private static final int PROFILING_TYPE_INDEX = OPTIONS.length - 1;
63 private static final int TYPE_PROFILE_INDEX = OPTIONS.length - 4;
64 private static final int USE_TYPE_SPECULATION_INDEX = OPTIONS.length - 3;
65 private static final Random RNG;
66
67 static {
68 String str = System.getProperty("seed");
69 long seed = str != null ? Long.parseLong(str) : new Random().nextLong();
70 RNG = new Random(seed);
71 System.out.printf("-Dseed=%d%n", seed);
72 }
73
74 public static void main(String[] args) throws Exception {
75 int count = DEFAULT_COUNT;
76 if (args.length > 0) {
77 count = Integer.parseInt(args[0]) ;
78 }
79 for (int i = 0; i < count; ++i) {
80 runTest();
81 }
82 }
83
84 private static void runTest() throws Exception {
85 String useTypeSpeculation = "-XX:" + (RNG.nextBoolean() ? "+" : "-") + USE_TYPE_SPECULATION;
86 String typeProfileLevel = "-XX:" + TYPE_PROFILE_LEVEL + "=" + randomTypeProfileLevel();
87 ProfilingType type = randomProfileType();
88 OPTIONS[TYPE_PROFILE_INDEX] = typeProfileLevel;
89 OPTIONS[USE_TYPE_SPECULATION_INDEX] = useTypeSpeculation;
90 OPTIONS[PROFILING_TYPE_INDEX] = type.name();
91 ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(/* addTestVmOptions= */ true, OPTIONS);
92 OutputAnalyzer outputAnalyzer = new OutputAnalyzer(processBuilder.start());
93 outputAnalyzer.shouldHaveExitValue(0);
94 }
95
96 private static ProfilingType randomProfileType() {
97 ProfilingType[] value = ProfilingType.values();
98 return value[RNG.nextInt(value.length)];
99 }
100
101 private static String randomTypeProfileLevel() {
102 StringBuilder stringBuilder = new StringBuilder();
103 for (int i = 0; i < TYPE_PROFILE_LEVEL_LENGTH; ++i) {
104 stringBuilder.append(RNG.nextInt(TYPE_PROFILE_LEVEL_BOUND));
105 }
106 return stringBuilder.toString();
107 }
108 }