hotspot/test/compiler/compilercontrol/share/MultiCommand.java
author vdeshpande
Fri, 26 Aug 2016 12:20:09 -0700
changeset 41362 e09e871860a7
parent 39427 c154eca6daa5
permissions -rw-r--r--
8154122: Intrinsify fused mac operations Summary: added FMA intrinsics on x86 Reviewed-by: kvn, aph, darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33452
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
     1
/*
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
     4
 *
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
     8
 *
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    13
 * accompanied this code).
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    14
 *
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    18
 *
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    21
 * questions.
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    22
 */
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    23
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    24
package compiler.compilercontrol.share;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    25
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    26
import compiler.compilercontrol.share.method.MethodDescriptor;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    27
import compiler.compilercontrol.share.scenario.Command;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    28
import compiler.compilercontrol.share.scenario.CommandGenerator;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    29
import compiler.compilercontrol.share.scenario.CompileCommand;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    30
import compiler.compilercontrol.share.scenario.Scenario;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    31
import jdk.test.lib.Utils;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    32
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    33
import java.lang.reflect.Executable;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    34
import java.util.ArrayList;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    35
import java.util.List;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    36
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    37
public class MultiCommand extends AbstractTestBase {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    38
    private final List<CompileCommand> testCases;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    39
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    40
    public MultiCommand(List<CompileCommand> testCases) {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    41
        this.testCases = testCases;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    42
    }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    43
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    44
    /**
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    45
     * Generates a test containing multiple random commands
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    46
     *
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    47
     * @param validOnly shows that all commands should be valid
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    48
     * @return test instance to run
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    49
     */
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    50
    public static AbstractTestBase generateRandomTest(boolean validOnly) {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    51
        CommandGenerator cmdGen = new CommandGenerator();
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    52
        List<Command> commands = cmdGen.generateCommands();
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    53
        List<CompileCommand> testCases = new ArrayList<>();
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    54
        for (Command cmd : commands) {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    55
            if (validOnly && cmd == Command.NONEXISTENT) {
36610
7b866d93cd34 8150955: RandomValidCommandsTest.java fails with UnsatisfiedLinkError: sun.hotspot.WhiteBox.registerNatives
ppunegov
parents: 33452
diff changeset
    56
                // replace with a valid command
7b866d93cd34 8150955: RandomValidCommandsTest.java fails with UnsatisfiedLinkError: sun.hotspot.WhiteBox.registerNatives
ppunegov
parents: 33452
diff changeset
    57
                cmd = Command.EXCLUDE;
33452
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    58
            }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    59
            Executable exec = Utils.getRandomElement(METHODS).first;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    60
            MethodDescriptor md;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    61
            if (validOnly) {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    62
                md = AbstractTestBase.getValidMethodDescriptor(exec);
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    63
            } else {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    64
                md = AbstractTestBase.METHOD_GEN.generateRandomDescriptor(exec);
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    65
            }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    66
            CompileCommand cc = cmdGen.generateCompileCommand(cmd, md, null);
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    67
            testCases.add(cc);
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    68
        }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    69
        return new MultiCommand(testCases);
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    70
    }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    71
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    72
    @Override
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    73
    public void test() {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    74
        Scenario.Builder builder = Scenario.getBuilder();
36796
c751f445f5d4 8150054: Make compilercontrol test ignore xcomp
neliasso
parents: 36610
diff changeset
    75
        builder.addFlag("-Xmixed");
39427
c154eca6daa5 8158754: compilercontrol tests: RandomCommandsTest.java and RandomValidCommandsTest.java - fail in PIT
iignatyev
parents: 38715
diff changeset
    76
        builder.addFlag("-XX:+UnlockDiagnosticVMOptions");
38715
f8a3a82dfaf0 8157717: MultiCommand breaks directives amount limit
neliasso
parents: 36796
diff changeset
    77
        builder.addFlag("-XX:CompilerDirectivesLimit=101");
33452
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    78
        for (CompileCommand cc : testCases) {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    79
            cc.print();
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    80
            builder.add(cc);
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    81
        }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    82
        Scenario scenario = builder.build();
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    83
        scenario.execute();
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    84
    }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    85
}