hotspot/test/compiler/types/correctness/OffTest.java
author thartmann
Fri, 12 Dec 2014 09:37:38 +0100
changeset 28190 5a6b07edeb21
parent 27925 84a23e5ef17c
child 29678 dd2f3932c21e
permissions -rw-r--r--
8066433: Move Whitebox test library to top level repository Summary: Moved Whitebox test library to top level repository. Reviewed-by: iignatyev, sla, mr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24011
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
     1
/*
c2dc59a495eb 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.
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
28190
5a6b07edeb21 8066433: Move Whitebox test library to top level repository
thartmann
parents: 27925
diff changeset
    27
 * @library /testlibrary /../../test/lib
27925
84a23e5ef17c 8066713: ignore compiler/types/correctness
iignatyev
parents: 27453
diff changeset
    28
 * @ignore 8066173
24011
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    29
 * @compile execution/TypeConflict.java execution/TypeProfile.java
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    30
 *          execution/MethodHandleDelegate.java
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    31
 * @build CorrectnessTest
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    32
 * @build OffTest
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    33
 * @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
    34
 *                              sun.hotspot.WhiteBox$WhiteBoxPermission
24011
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    35
 * @run main/timeout=1200 OffTest
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    36
 */
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    37
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    38
import com.oracle.java.testlibrary.OutputAnalyzer;
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    39
import com.oracle.java.testlibrary.ProcessTools;
27453
9aeb9b97bef6 8044186: Introduce a reproducible random generator
iignatyev
parents: 25958
diff changeset
    40
import com.oracle.java.testlibrary.Utils;
9aeb9b97bef6 8044186: Introduce a reproducible random generator
iignatyev
parents: 25958
diff changeset
    41
import java.util.Random;
24011
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    42
import scenarios.ProfilingType;
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    43
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    44
public class OffTest {
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    45
    private static final String[] OPTIONS = {
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    46
            "-Xbootclasspath/a:.",
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    47
            "-XX:+IgnoreUnrecognizedVMOptions",
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    48
            "-XX:+UnlockExperimentalVMOptions",
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    49
            "-XX:+UnlockDiagnosticVMOptions",
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    50
            "-XX:+WhiteBoxAPI",
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    51
            "-XX:CompileCommand=exclude,execution/*::methodNotToCompile",
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    52
            "-XX:CompileCommand=dontinline,scenarios/Scenario::collectReturnType",
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    53
            "", // -XX:TypeProfileLevel=?
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    54
            "", // -XX:?UseTypeSpeculation
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    55
            CorrectnessTest.class.getName(),
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    56
            "", // ProfilingType.name()
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    57
    };
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    58
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    59
    private static final String TYPE_PROFILE_LEVEL = "TypeProfileLevel";
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    60
    private static final String USE_TYPE_SPECULATION = "UseTypeSpeculation";
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    61
    private static final int TYPE_PROFILE_LEVEL_LENGTH = 3;
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    62
    private static final int TYPE_PROFILE_LEVEL_BOUND = 3;
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    63
    private static final int DEFAULT_COUNT = 10;
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    64
    private static final int PROFILING_TYPE_INDEX = OPTIONS.length - 1;
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    65
    private static final int TYPE_PROFILE_INDEX = OPTIONS.length - 4;
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    66
    private static final int USE_TYPE_SPECULATION_INDEX = OPTIONS.length - 3;
27453
9aeb9b97bef6 8044186: Introduce a reproducible random generator
iignatyev
parents: 25958
diff changeset
    67
    private static final Random RNG = Utils.getRandomInstance();
24011
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    68
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    69
    public static void main(String[] args) throws Exception {
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    70
        int count = DEFAULT_COUNT;
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    71
        if (args.length > 0) {
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    72
            count = Integer.parseInt(args[0]) ;
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    73
        }
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    74
        for (int i = 0; i < count; ++i) {
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    75
            runTest();
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    76
        }
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    77
    }
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
    private static void runTest() throws Exception {
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    80
        String useTypeSpeculation = "-XX:" + (RNG.nextBoolean() ? "+" : "-") +  USE_TYPE_SPECULATION;
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    81
        String typeProfileLevel = "-XX:" + TYPE_PROFILE_LEVEL + "=" + randomTypeProfileLevel();
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    82
        ProfilingType type = randomProfileType();
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    83
        OPTIONS[TYPE_PROFILE_INDEX] = typeProfileLevel;
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    84
        OPTIONS[USE_TYPE_SPECULATION_INDEX] = useTypeSpeculation;
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    85
        OPTIONS[PROFILING_TYPE_INDEX] = type.name();
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    86
        ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(/* addTestVmOptions= */ true, OPTIONS);
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    87
        OutputAnalyzer outputAnalyzer = new OutputAnalyzer(processBuilder.start());
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    88
        outputAnalyzer.shouldHaveExitValue(0);
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    89
    }
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    90
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    91
    private static ProfilingType randomProfileType() {
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    92
        ProfilingType[] value = ProfilingType.values();
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    93
        return value[RNG.nextInt(value.length)];
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    94
    }
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    95
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    96
    private static String randomTypeProfileLevel() {
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    97
        StringBuilder stringBuilder = new StringBuilder();
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    98
        for (int i = 0; i < TYPE_PROFILE_LEVEL_LENGTH; ++i) {
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
    99
            stringBuilder.append(RNG.nextInt(TYPE_PROFILE_LEVEL_BOUND));
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
   100
        }
c2dc59a495eb 8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff changeset
   101
        return stringBuilder.toString();
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
}