Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/compilercontrol/share/MultiCommand.java
41155 views
1
/*
2
* Copyright (c) 2015, 2020, 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
package compiler.compilercontrol.share;
25
26
import compiler.compilercontrol.share.method.MethodDescriptor;
27
import compiler.compilercontrol.share.scenario.Command;
28
import compiler.compilercontrol.share.scenario.CommandGenerator;
29
import compiler.compilercontrol.share.scenario.CompileCommand;
30
import compiler.compilercontrol.share.scenario.Scenario;
31
import jdk.test.lib.Utils;
32
33
import java.lang.reflect.Executable;
34
import java.util.ArrayList;
35
import java.util.List;
36
37
import static compiler.compilercontrol.share.IntrinsicCommand.VALID_INTRINSIC_SAMPLES;
38
import static compiler.compilercontrol.share.IntrinsicCommand.INVALID_INTRINSIC_SAMPLES;
39
40
public class MultiCommand extends AbstractTestBase {
41
private final List<CompileCommand> testCases;
42
43
public MultiCommand(List<CompileCommand> testCases) {
44
this.testCases = testCases;
45
}
46
47
/**
48
* Generates a test containing multiple random commands
49
*
50
* @param validOnly shows that all commands should be valid
51
* @return test instance to run
52
*/
53
public static AbstractTestBase generateRandomTest(boolean validOnly) {
54
CommandGenerator cmdGen = new CommandGenerator();
55
List<Command> commands = cmdGen.generateCommands();
56
List<CompileCommand> testCases = new ArrayList<>();
57
58
for (Command cmd : commands) {
59
String argument = null;
60
61
if (validOnly && cmd == Command.NONEXISTENT) {
62
// replace with a valid command
63
cmd = Command.EXCLUDE;
64
}
65
if (cmd == Command.INTRINSIC) {
66
if (validOnly) {
67
argument = Utils.getRandomElement(VALID_INTRINSIC_SAMPLES);
68
} else {
69
argument = Utils.getRandomElement(INVALID_INTRINSIC_SAMPLES);
70
}
71
}
72
73
Executable exec = Utils.getRandomElement(METHODS).first;
74
MethodDescriptor md;
75
if (validOnly) {
76
md = AbstractTestBase.getValidMethodDescriptor(exec);
77
} else {
78
md = AbstractTestBase.METHOD_GEN.generateRandomDescriptor(exec);
79
}
80
CompileCommand cc;
81
if (cmd == Command.INTRINSIC) {
82
cc = cmdGen.generateCompileCommand(cmd, md, null, argument);
83
} else {
84
cc = cmdGen.generateCompileCommand(cmd, md, null);
85
}
86
testCases.add(cc);
87
}
88
return new MultiCommand(testCases);
89
}
90
91
@Override
92
public void test() {
93
Scenario.Builder builder = Scenario.getBuilder();
94
builder.addFlag("-Xmixed");
95
builder.addFlag("-XX:+UnlockDiagnosticVMOptions");
96
builder.addFlag("-XX:CompilerDirectivesLimit=101");
97
for (CompileCommand cc : testCases) {
98
builder.add(cc);
99
}
100
Scenario scenario = builder.build();
101
scenario.execute();
102
}
103
}
104
105