Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/compilercontrol/share/scenario/CompileCommand.java
41161 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.scenario;
25
26
import compiler.compilercontrol.share.method.MethodDescriptor;
27
28
/**
29
* Compile Command description interface
30
*/
31
public class CompileCommand {
32
public final Command command;
33
public final MethodDescriptor methodDescriptor;
34
public final Scenario.Compiler compiler;
35
public final Scenario.Type type;
36
public final String argument;
37
38
public CompileCommand(Command command,
39
MethodDescriptor methodDescriptor,
40
Scenario.Compiler compiler,
41
Scenario.Type type) {
42
this.command = command;
43
this.methodDescriptor = methodDescriptor;
44
this.compiler = compiler;
45
this.type = type;
46
this.argument = null;
47
}
48
49
public CompileCommand(Command command,
50
MethodDescriptor methodDescriptor,
51
Scenario.Compiler compiler,
52
Scenario.Type type,
53
String argument) {
54
this.command = command;
55
this.methodDescriptor = methodDescriptor;
56
this.compiler = compiler;
57
this.type = type;
58
this.argument = argument;
59
}
60
61
62
/**
63
* Shows that this compile command is valid
64
*
65
* @return true if this is a valid command
66
*/
67
public boolean isValid() {
68
if (command == Command.NONEXISTENT) {
69
return false;
70
}
71
// -XX:CompileCommand(File) ignores invalid items
72
// Invalid intrinsic ids in CompilerDirectivesFile will force hotspot to exit with non-zero value.
73
if (command == Command.INTRINSIC && type == Scenario.Type.DIRECTIVE) {
74
if (argument != null) {
75
String[] ids = argument.split(",");
76
for (String id : ids) {
77
char ch = id.charAt(0);
78
79
// Not a strict check.
80
// a valid ControlIntrinsic argument is separated by ",", each one starts with '+' or '-'.
81
// intrinsicId starts with '_'
82
if ((ch != '+' && ch != '-') || id.charAt(1) != '_') {
83
return false;
84
}
85
}
86
}
87
}
88
89
return methodDescriptor.isValid();
90
}
91
92
/**
93
* Formats the command according to the following pattern:
94
* {@code <command_name> Type: <type> Compiler: <compiler> MethodDescriptor: <method_descriptor> IsValid: <true/false>}
95
* Sample output:
96
* COMPILEONLY Type: OPTION Compiler: C1 MethodDescriptor: *Klass.method* IsValid: true
97
*/
98
protected String formatFields() {
99
return command.name() +
100
" Type: " + type +
101
" Compiler: " + compiler +
102
" MethodDescriptor: " + (methodDescriptor == null ? "null" : methodDescriptor.getString()) +
103
" IsValid: " + isValid();
104
}
105
106
/**
107
* Returns formatted string representation in the form
108
* {@code "(CompileCommand Field1: <field1> Field2: <field2> ...)}
109
* The fields are formatted by {@link #formatFields()}.
110
*/
111
public String toString() {
112
return "(CompileCommand " + formatFields() + ")";
113
}
114
}
115
116