author | dpochepk |
Wed, 20 Jul 2016 19:35:08 +0300 | |
changeset 40079 | 40d48ddc12bc |
parent 35138 | de9e69473956 |
child 46560 | 388aa8d67c80 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
31615 | 2 |
* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4584
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4584
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4584
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "compiler/compilerOracle.hpp" |
|
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
27 |
#include "compiler/methodMatcher.hpp" |
7397 | 28 |
#include "memory/allocation.inline.hpp" |
29 |
#include "memory/oopFactory.hpp" |
|
30 |
#include "memory/resourceArea.hpp" |
|
31 |
#include "oops/klass.hpp" |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13202
diff
changeset
|
32 |
#include "oops/method.hpp" |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
33 |
#include "oops/symbol.hpp" |
7397 | 34 |
#include "runtime/handles.inline.hpp" |
35 |
#include "runtime/jniHandles.hpp" |
|
25949 | 36 |
#include "runtime/os.hpp" |
1 | 37 |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
38 |
enum OptionType { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
39 |
IntxType, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
40 |
UintxType, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
41 |
BoolType, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
42 |
CcstrType, |
27143
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
43 |
DoubleType, |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
44 |
UnknownType |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
45 |
}; |
1 | 46 |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
47 |
/* Methods to map real type names to OptionType */ |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
48 |
template<typename T> |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
49 |
static OptionType get_type_for() { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
50 |
return UnknownType; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
51 |
}; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
52 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
53 |
template<> OptionType get_type_for<intx>() { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
54 |
return IntxType; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
55 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
56 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
57 |
template<> OptionType get_type_for<uintx>() { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
58 |
return UintxType; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
59 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
60 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
61 |
template<> OptionType get_type_for<bool>() { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
62 |
return BoolType; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
63 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
64 |
|
26433 | 65 |
template<> OptionType get_type_for<ccstr>() { |
66 |
return CcstrType; |
|
67 |
} |
|
68 |
||
27143
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
69 |
template<> OptionType get_type_for<double>() { |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
70 |
return DoubleType; |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
71 |
} |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
72 |
|
1 | 73 |
// this must parallel the command_names below |
74 |
enum OracleCommand { |
|
75 |
UnknownCommand = -1, |
|
76 |
OracleFirstCommand = 0, |
|
77 |
BreakCommand = OracleFirstCommand, |
|
78 |
PrintCommand, |
|
79 |
ExcludeCommand, |
|
80 |
InlineCommand, |
|
81 |
DontInlineCommand, |
|
82 |
CompileOnlyCommand, |
|
83 |
LogCommand, |
|
84 |
OptionCommand, |
|
85 |
QuietCommand, |
|
86 |
HelpCommand, |
|
87 |
OracleCommandCount |
|
88 |
}; |
|
89 |
||
90 |
// this must parallel the enum OracleCommand |
|
91 |
static const char * command_names[] = { |
|
92 |
"break", |
|
93 |
"print", |
|
94 |
"exclude", |
|
95 |
"inline", |
|
96 |
"dontinline", |
|
97 |
"compileonly", |
|
98 |
"log", |
|
99 |
"option", |
|
100 |
"quiet", |
|
101 |
"help" |
|
102 |
}; |
|
103 |
||
104 |
class MethodMatcher; |
|
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
105 |
class TypedMethodOptionMatcher; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
106 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
107 |
static BasicMatcher* lists[OracleCommandCount] = { 0, }; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
108 |
static TypedMethodOptionMatcher* option_list = NULL; |
33451
0712796e4039
8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
33069
diff
changeset
|
109 |
static bool any_set = false; |
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
110 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
111 |
class TypedMethodOptionMatcher : public MethodMatcher { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
112 |
private: |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
113 |
TypedMethodOptionMatcher* _next; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
114 |
const char* _option; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
115 |
OptionType _type; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
116 |
public: |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
117 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
118 |
union { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
119 |
bool bool_value; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
120 |
intx intx_value; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
121 |
uintx uintx_value; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
122 |
double double_value; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
123 |
ccstr ccstr_value; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
124 |
} _u; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
125 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
126 |
TypedMethodOptionMatcher() : MethodMatcher(), |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
127 |
_next(NULL), |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
128 |
_type(UnknownType) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
129 |
_option = NULL; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
130 |
memset(&_u, 0, sizeof(_u)); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
131 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
132 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
133 |
static TypedMethodOptionMatcher* parse_method_pattern(char*& line, const char*& error_msg); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
134 |
TypedMethodOptionMatcher* match(methodHandle method, const char* opt, OptionType type); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
135 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
136 |
void init(const char* opt, OptionType type, TypedMethodOptionMatcher* next) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
137 |
_next = next; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
138 |
_type = type; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
139 |
_option = os::strdup_check_oom(opt); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
140 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
141 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
142 |
void set_next(TypedMethodOptionMatcher* next) {_next = next; } |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
143 |
TypedMethodOptionMatcher* next() { return _next; } |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
144 |
OptionType type() { return _type; } |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
145 |
template<typename T> T value(); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
146 |
template<typename T> void set_value(T value); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
147 |
void print(); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
148 |
void print_all(); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
149 |
TypedMethodOptionMatcher* clone(); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
150 |
~TypedMethodOptionMatcher(); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
151 |
}; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
152 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
153 |
// A few templated accessors instead of a full template class. |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
154 |
template<> intx TypedMethodOptionMatcher::value<intx>() { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
155 |
return _u.intx_value; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
156 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
157 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
158 |
template<> uintx TypedMethodOptionMatcher::value<uintx>() { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
159 |
return _u.uintx_value; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
160 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
161 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
162 |
template<> bool TypedMethodOptionMatcher::value<bool>() { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
163 |
return _u.bool_value; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
164 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
165 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
166 |
template<> double TypedMethodOptionMatcher::value<double>() { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
167 |
return _u.double_value; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
168 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
169 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
170 |
template<> ccstr TypedMethodOptionMatcher::value<ccstr>() { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
171 |
return _u.ccstr_value; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
172 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
173 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
174 |
template<> void TypedMethodOptionMatcher::set_value(intx value) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
175 |
_u.intx_value = value; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
176 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
177 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
178 |
template<> void TypedMethodOptionMatcher::set_value(uintx value) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
179 |
_u.uintx_value = value; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
180 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
181 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
182 |
template<> void TypedMethodOptionMatcher::set_value(double value) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
183 |
_u.double_value = value; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
184 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
185 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
186 |
template<> void TypedMethodOptionMatcher::set_value(bool value) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
187 |
_u.bool_value = value; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
188 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
189 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
190 |
template<> void TypedMethodOptionMatcher::set_value(ccstr value) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
191 |
_u.ccstr_value = (const ccstr)os::strdup_check_oom(value); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
192 |
} |
1 | 193 |
|
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
194 |
void TypedMethodOptionMatcher::print() { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
195 |
ttyLocker ttyl; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
196 |
print_base(tty); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
197 |
switch (_type) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
198 |
case IntxType: |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
199 |
tty->print_cr(" intx %s = " INTX_FORMAT, _option, value<intx>()); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
200 |
break; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
201 |
case UintxType: |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
202 |
tty->print_cr(" uintx %s = " UINTX_FORMAT, _option, value<uintx>()); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
203 |
break; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
204 |
case BoolType: |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
205 |
tty->print_cr(" bool %s = %s", _option, value<bool>() ? "true" : "false"); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
206 |
break; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
207 |
case DoubleType: |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
208 |
tty->print_cr(" double %s = %f", _option, value<double>()); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
209 |
break; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
210 |
case CcstrType: |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
211 |
tty->print_cr(" const char* %s = '%s'", _option, value<ccstr>()); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
212 |
break; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
213 |
default: |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
214 |
ShouldNotReachHere(); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
215 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
216 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
217 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
218 |
void TypedMethodOptionMatcher::print_all() { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
219 |
print(); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
220 |
if (_next != NULL) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
221 |
tty->print(" "); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
222 |
_next->print_all(); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
223 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
224 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
225 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
226 |
TypedMethodOptionMatcher* TypedMethodOptionMatcher::clone() { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
227 |
TypedMethodOptionMatcher* m = new TypedMethodOptionMatcher(); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
228 |
m->_class_mode = _class_mode; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
229 |
m->_class_name = _class_name; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
230 |
m->_method_mode = _method_mode; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
231 |
m->_method_name = _method_name; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
232 |
m->_signature = _signature; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
233 |
// Need to ref count the symbols |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
234 |
if (_class_name != NULL) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
235 |
_class_name->increment_refcount(); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
236 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
237 |
if (_method_name != NULL) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
238 |
_method_name->increment_refcount(); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
239 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
240 |
if (_signature != NULL) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
241 |
_signature->increment_refcount(); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
242 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
243 |
return m; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
244 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
245 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
246 |
TypedMethodOptionMatcher::~TypedMethodOptionMatcher() { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
247 |
if (_option != NULL) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
248 |
os::free((void*)_option); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
249 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
250 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
251 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
252 |
TypedMethodOptionMatcher* TypedMethodOptionMatcher::parse_method_pattern(char*& line, const char*& error_msg) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
253 |
assert(error_msg == NULL, "Dont call here with error_msg already set"); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
254 |
TypedMethodOptionMatcher* tom = new TypedMethodOptionMatcher(); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
255 |
MethodMatcher::parse_method_pattern(line, error_msg, tom); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
256 |
if (error_msg != NULL) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
257 |
delete tom; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
258 |
return NULL; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
259 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
260 |
return tom; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
261 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
262 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
263 |
TypedMethodOptionMatcher* TypedMethodOptionMatcher::match(methodHandle method, const char* opt, OptionType type) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
264 |
TypedMethodOptionMatcher* current = this; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
265 |
while (current != NULL) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
266 |
// Fastest compare first. |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
267 |
if (current->type() == type) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
268 |
if (strcmp(current->_option, opt) == 0) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
269 |
if (current->matches(method)) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
270 |
return current; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
271 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
272 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
273 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
274 |
current = current->next(); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
275 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
276 |
return NULL; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
277 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
278 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
279 |
template<typename T> |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
280 |
static void add_option_string(TypedMethodOptionMatcher* matcher, |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
281 |
const char* option, |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
282 |
T value) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
283 |
assert(matcher != option_list, "No circular lists please"); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
284 |
matcher->init(option, get_type_for<T>(), option_list); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
285 |
matcher->set_value<T>(value); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
286 |
option_list = matcher; |
33451
0712796e4039
8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
33069
diff
changeset
|
287 |
any_set = true; |
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
288 |
return; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
289 |
} |
1 | 290 |
|
291 |
static bool check_predicate(OracleCommand command, methodHandle method) { |
|
292 |
return ((lists[command] != NULL) && |
|
293 |
!method.is_null() && |
|
294 |
lists[command]->match(method)); |
|
295 |
} |
|
296 |
||
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
297 |
static void add_predicate(OracleCommand command, BasicMatcher* bm) { |
1 | 298 |
assert(command != OptionCommand, "must use add_option_string"); |
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
299 |
if (command == LogCommand && !LogCompilation && lists[LogCommand] == NULL) { |
1 | 300 |
tty->print_cr("Warning: +LogCompilation must be enabled in order for individual methods to be logged."); |
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
301 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
302 |
bm->set_next(lists[command]); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
303 |
lists[command] = bm; |
33451
0712796e4039
8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
33069
diff
changeset
|
304 |
if ((command != DontInlineCommand) && (command != InlineCommand)) { |
0712796e4039
8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
33069
diff
changeset
|
305 |
any_set = true; |
0712796e4039
8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
33069
diff
changeset
|
306 |
} |
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
307 |
return; |
1 | 308 |
} |
309 |
||
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
310 |
template<typename T> |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33069
diff
changeset
|
311 |
bool CompilerOracle::has_option_value(const methodHandle& method, const char* option, T& value) { |
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
312 |
if (option_list != NULL) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
313 |
TypedMethodOptionMatcher* m = option_list->match(method, option, get_type_for<T>()); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
314 |
if (m != NULL) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
315 |
value = m->value<T>(); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
316 |
return true; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
317 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
318 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
319 |
return false; |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
320 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
321 |
|
33451
0712796e4039
8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
33069
diff
changeset
|
322 |
bool CompilerOracle::has_any_option() { |
0712796e4039
8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
33069
diff
changeset
|
323 |
return any_set; |
0712796e4039
8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
33069
diff
changeset
|
324 |
} |
0712796e4039
8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
33069
diff
changeset
|
325 |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
326 |
// Explicit instantiation for all OptionTypes supported. |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33069
diff
changeset
|
327 |
template bool CompilerOracle::has_option_value<intx>(const methodHandle& method, const char* option, intx& value); |
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33069
diff
changeset
|
328 |
template bool CompilerOracle::has_option_value<uintx>(const methodHandle& method, const char* option, uintx& value); |
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33069
diff
changeset
|
329 |
template bool CompilerOracle::has_option_value<bool>(const methodHandle& method, const char* option, bool& value); |
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33069
diff
changeset
|
330 |
template bool CompilerOracle::has_option_value<ccstr>(const methodHandle& method, const char* option, ccstr& value); |
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33069
diff
changeset
|
331 |
template bool CompilerOracle::has_option_value<double>(const methodHandle& method, const char* option, double& value); |
1 | 332 |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33069
diff
changeset
|
333 |
bool CompilerOracle::has_option_string(const methodHandle& method, const char* option) { |
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
334 |
bool value = false; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
335 |
has_option_value(method, option, value); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
336 |
return value; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
337 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
338 |
|
33626 | 339 |
bool CompilerOracle::should_exclude(const methodHandle& method) { |
33451
0712796e4039
8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
33069
diff
changeset
|
340 |
if (check_predicate(ExcludeCommand, method)) { |
0712796e4039
8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
33069
diff
changeset
|
341 |
return true; |
1 | 342 |
} |
343 |
if (lists[CompileOnlyCommand] != NULL) { |
|
344 |
return !lists[CompileOnlyCommand]->match(method); |
|
345 |
} |
|
346 |
return false; |
|
347 |
} |
|
348 |
||
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33069
diff
changeset
|
349 |
bool CompilerOracle::should_inline(const methodHandle& method) { |
1 | 350 |
return (check_predicate(InlineCommand, method)); |
351 |
} |
|
352 |
||
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33069
diff
changeset
|
353 |
bool CompilerOracle::should_not_inline(const methodHandle& method) { |
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
354 |
return check_predicate(DontInlineCommand, method) || check_predicate(ExcludeCommand, method); |
1 | 355 |
} |
356 |
||
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33069
diff
changeset
|
357 |
bool CompilerOracle::should_print(const methodHandle& method) { |
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
358 |
return check_predicate(PrintCommand, method); |
1 | 359 |
} |
360 |
||
24658
e41df2fc6e87
8042727: nsk/jdb/unwatch/unwatch001 crash in InstanceKlass::methods_do(void (*)(Method*))
coleenp
parents:
24424
diff
changeset
|
361 |
bool CompilerOracle::should_print_methods() { |
e41df2fc6e87
8042727: nsk/jdb/unwatch/unwatch001 crash in InstanceKlass::methods_do(void (*)(Method*))
coleenp
parents:
24424
diff
changeset
|
362 |
return lists[PrintCommand] != NULL; |
e41df2fc6e87
8042727: nsk/jdb/unwatch/unwatch001 crash in InstanceKlass::methods_do(void (*)(Method*))
coleenp
parents:
24424
diff
changeset
|
363 |
} |
1 | 364 |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33069
diff
changeset
|
365 |
bool CompilerOracle::should_log(const methodHandle& method) { |
1 | 366 |
if (!LogCompilation) return false; |
367 |
if (lists[LogCommand] == NULL) return true; // by default, log all |
|
368 |
return (check_predicate(LogCommand, method)); |
|
369 |
} |
|
370 |
||
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33069
diff
changeset
|
371 |
bool CompilerOracle::should_break_at(const methodHandle& method) { |
1 | 372 |
return check_predicate(BreakCommand, method); |
373 |
} |
|
374 |
||
375 |
static OracleCommand parse_command_name(const char * line, int* bytes_read) { |
|
376 |
assert(ARRAY_SIZE(command_names) == OracleCommandCount, |
|
377 |
"command_names size mismatch"); |
|
378 |
||
379 |
*bytes_read = 0; |
|
7701
766eb9258574
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
7397
diff
changeset
|
380 |
char command[33]; |
1 | 381 |
int result = sscanf(line, "%32[a-z]%n", command, bytes_read); |
382 |
for (uint i = 0; i < ARRAY_SIZE(command_names); i++) { |
|
383 |
if (strcmp(command, command_names[i]) == 0) { |
|
384 |
return (OracleCommand)i; |
|
385 |
} |
|
386 |
} |
|
387 |
return UnknownCommand; |
|
388 |
} |
|
389 |
||
390 |
static void usage() { |
|
28496
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
391 |
tty->cr(); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
392 |
tty->print_cr("The CompileCommand option enables the user of the JVM to control specific"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
393 |
tty->print_cr("behavior of the dynamic compilers. Many commands require a pattern that defines"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
394 |
tty->print_cr("the set of methods the command shall be applied to. The CompileCommand"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
395 |
tty->print_cr("option provides the following commands:"); |
1 | 396 |
tty->cr(); |
28496
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
397 |
tty->print_cr(" break,<pattern> - debug breakpoint in compiler and in generated code"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
398 |
tty->print_cr(" print,<pattern> - print assembly"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
399 |
tty->print_cr(" exclude,<pattern> - don't compile or inline"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
400 |
tty->print_cr(" inline,<pattern> - always inline"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
401 |
tty->print_cr(" dontinline,<pattern> - don't inline"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
402 |
tty->print_cr(" compileonly,<pattern> - compile only"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
403 |
tty->print_cr(" log,<pattern> - log compilation"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
404 |
tty->print_cr(" option,<pattern>,<option type>,<option name>,<value>"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
405 |
tty->print_cr(" - set value of custom option"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
406 |
tty->print_cr(" option,<pattern>,<bool option name>"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
407 |
tty->print_cr(" - shorthand for setting boolean flag"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
408 |
tty->print_cr(" quiet - silence the compile command output"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
409 |
tty->print_cr(" help - print this text"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
410 |
tty->cr(); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
411 |
tty->print_cr("The preferred format for the method matching pattern is:"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
412 |
tty->print_cr(" package/Class.method()"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
413 |
tty->cr(); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
414 |
tty->print_cr("For backward compatibility this form is also allowed:"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
415 |
tty->print_cr(" package.Class::method()"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
416 |
tty->cr(); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
417 |
tty->print_cr("The signature can be separated by an optional whitespace or comma:"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
418 |
tty->print_cr(" package/Class.method ()"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
419 |
tty->cr(); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
420 |
tty->print_cr("The class and method identifier can be used together with leading or"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
421 |
tty->print_cr("trailing *'s for a small amount of wildcarding:"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
422 |
tty->print_cr(" *ackage/Clas*.*etho*()"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
423 |
tty->cr(); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
424 |
tty->print_cr("It is possible to use more than one CompileCommand on the command line:"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
425 |
tty->print_cr(" -XX:CompileCommand=exclude,java/*.* -XX:CompileCommand=log,java*.*"); |
1 | 426 |
tty->cr(); |
28496
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
427 |
tty->print_cr("The CompileCommands can be loaded from a file with the flag"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
428 |
tty->print_cr("-XX:CompileCommandFile=<file> or be added to the file '.hotspot_compiler'"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
429 |
tty->print_cr("Use the same format in the file as the argument to the CompileCommand flag."); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
430 |
tty->print_cr("Add one command on each line."); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
431 |
tty->print_cr(" exclude java/*.*"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
432 |
tty->print_cr(" option java/*.* ReplayInline"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
433 |
tty->cr(); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
434 |
tty->print_cr("The following commands have conflicting behavior: 'exclude', 'inline', 'dontinline',"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
435 |
tty->print_cr("and 'compileonly'. There is no priority of commands. Applying (a subset of) these"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
436 |
tty->print_cr("commands to the same method results in undefined behavior."); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
437 |
tty->cr(); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
438 |
}; |
1 | 439 |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
440 |
// Scan next flag and value in line, return MethodMatcher object on success, NULL on failure. |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
441 |
// On failure, error_msg contains description for the first error. |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
442 |
// For future extensions: set error_msg on first error. |
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
443 |
static void scan_flag_and_value(const char* type, const char* line, int& total_bytes_read, |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
444 |
TypedMethodOptionMatcher* matcher, |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
445 |
char* errorbuf, const int buf_size) { |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
446 |
total_bytes_read = 0; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
447 |
int bytes_read = 0; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
448 |
char flag[256]; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
449 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
450 |
// Read flag name. |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
451 |
if (sscanf(line, "%*[ \t]%255[a-zA-Z0-9]%n", flag, &bytes_read) == 1) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
452 |
line += bytes_read; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
453 |
total_bytes_read += bytes_read; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
454 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
455 |
// Read value. |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
456 |
if (strcmp(type, "intx") == 0) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
457 |
intx value; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
458 |
if (sscanf(line, "%*[ \t]" INTX_FORMAT "%n", &value, &bytes_read) == 1) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
459 |
total_bytes_read += bytes_read; |
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
460 |
add_option_string(matcher, flag, value); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
461 |
return; |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
462 |
} else { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
463 |
jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s ", flag, type); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
464 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
465 |
} else if (strcmp(type, "uintx") == 0) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
466 |
uintx value; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
467 |
if (sscanf(line, "%*[ \t]" UINTX_FORMAT "%n", &value, &bytes_read) == 1) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
468 |
total_bytes_read += bytes_read; |
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
469 |
add_option_string(matcher, flag, value); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
470 |
return; |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
471 |
} else { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
472 |
jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s", flag, type); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
473 |
} |
26433 | 474 |
} else if (strcmp(type, "ccstr") == 0) { |
475 |
ResourceMark rm; |
|
476 |
char* value = NEW_RESOURCE_ARRAY(char, strlen(line) + 1); |
|
477 |
if (sscanf(line, "%*[ \t]%255[_a-zA-Z0-9]%n", value, &bytes_read) == 1) { |
|
478 |
total_bytes_read += bytes_read; |
|
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
479 |
add_option_string(matcher, flag, (ccstr)value); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
480 |
return; |
26433 | 481 |
} else { |
482 |
jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s", flag, type); |
|
483 |
} |
|
484 |
} else if (strcmp(type, "ccstrlist") == 0) { |
|
485 |
// Accumulates several strings into one. The internal type is ccstr. |
|
486 |
ResourceMark rm; |
|
487 |
char* value = NEW_RESOURCE_ARRAY(char, strlen(line) + 1); |
|
488 |
char* next_value = value; |
|
489 |
if (sscanf(line, "%*[ \t]%255[_a-zA-Z0-9]%n", next_value, &bytes_read) == 1) { |
|
490 |
total_bytes_read += bytes_read; |
|
491 |
line += bytes_read; |
|
492 |
next_value += bytes_read; |
|
493 |
char* end_value = next_value-1; |
|
494 |
while (sscanf(line, "%*[ \t]%255[_a-zA-Z0-9]%n", next_value, &bytes_read) == 1) { |
|
495 |
total_bytes_read += bytes_read; |
|
496 |
line += bytes_read; |
|
497 |
*end_value = ' '; // override '\0' |
|
498 |
next_value += bytes_read; |
|
499 |
end_value = next_value-1; |
|
500 |
} |
|
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
501 |
add_option_string(matcher, flag, (ccstr)value); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
502 |
return; |
26433 | 503 |
} else { |
504 |
jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s", flag, type); |
|
505 |
} |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
506 |
} else if (strcmp(type, "bool") == 0) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
507 |
char value[256]; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
508 |
if (sscanf(line, "%*[ \t]%255[a-zA-Z]%n", value, &bytes_read) == 1) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
509 |
if (strcmp(value, "true") == 0) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
510 |
total_bytes_read += bytes_read; |
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
511 |
add_option_string(matcher, flag, true); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
512 |
return; |
26433 | 513 |
} else if (strcmp(value, "false") == 0) { |
514 |
total_bytes_read += bytes_read; |
|
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
515 |
add_option_string(matcher, flag, false); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
516 |
return; |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
517 |
} else { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
518 |
jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s", flag, type); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
519 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
520 |
} else { |
31615 | 521 |
jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s", flag, type); |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
522 |
} |
27143
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
523 |
} else if (strcmp(type, "double") == 0) { |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
524 |
char buffer[2][256]; |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
525 |
// Decimal separator '.' has been replaced with ' ' or '/' earlier, |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
526 |
// so read integer and fraction part of double value separately. |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
527 |
if (sscanf(line, "%*[ \t]%255[0-9]%*[ /\t]%255[0-9]%n", buffer[0], buffer[1], &bytes_read) == 2) { |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
528 |
char value[512] = ""; |
30281 | 529 |
jio_snprintf(value, sizeof(value), "%s.%s", buffer[0], buffer[1]); |
27143
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
530 |
total_bytes_read += bytes_read; |
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
531 |
add_option_string(matcher, flag, atof(value)); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
532 |
return; |
27143
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
533 |
} else { |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
534 |
jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s", flag, type); |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
535 |
} |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
536 |
} else { |
31615 | 537 |
jio_snprintf(errorbuf, buf_size, " Type %s not supported ", type); |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
538 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
539 |
} else { |
31615 | 540 |
jio_snprintf(errorbuf, buf_size, " Flag name for type %s should be alphanumeric ", type); |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
541 |
} |
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
542 |
return; |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
543 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
544 |
|
28721
b9655115bf4e
8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents:
28720
diff
changeset
|
545 |
int skip_whitespace(char* line) { |
b9655115bf4e
8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents:
28720
diff
changeset
|
546 |
// Skip any leading spaces |
b9655115bf4e
8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents:
28720
diff
changeset
|
547 |
int whitespace_read = 0; |
b9655115bf4e
8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents:
28720
diff
changeset
|
548 |
sscanf(line, "%*[ \t]%n", &whitespace_read); |
b9655115bf4e
8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents:
28720
diff
changeset
|
549 |
return whitespace_read; |
b9655115bf4e
8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents:
28720
diff
changeset
|
550 |
} |
b9655115bf4e
8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents:
28720
diff
changeset
|
551 |
|
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
552 |
void CompilerOracle::print_parse_error(const char*& error_msg, char* original_line) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
553 |
assert(error_msg != NULL, "Must have error_message"); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
554 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
555 |
ttyLocker ttyl; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
556 |
tty->print_cr("CompileCommand: An error occurred during parsing"); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
557 |
tty->print_cr("Line: %s", original_line); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
558 |
tty->print_cr("Error: %s", error_msg); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
559 |
CompilerOracle::print_tip(); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
560 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
561 |
|
1 | 562 |
void CompilerOracle::parse_from_line(char* line) { |
563 |
if (line[0] == '\0') return; |
|
564 |
if (line[0] == '#') return; |
|
565 |
||
566 |
char* original_line = line; |
|
567 |
int bytes_read; |
|
568 |
OracleCommand command = parse_command_name(line, &bytes_read); |
|
569 |
line += bytes_read; |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
570 |
ResourceMark rm; |
1 | 571 |
|
7701
766eb9258574
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
7397
diff
changeset
|
572 |
if (command == UnknownCommand) { |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
573 |
ttyLocker ttyl; |
28496
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
574 |
tty->print_cr("CompileCommand: unrecognized command"); |
7701
766eb9258574
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
7397
diff
changeset
|
575 |
tty->print_cr(" \"%s\"", original_line); |
28496
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
576 |
CompilerOracle::print_tip(); |
7701
766eb9258574
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
7397
diff
changeset
|
577 |
return; |
766eb9258574
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
7397
diff
changeset
|
578 |
} |
766eb9258574
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
7397
diff
changeset
|
579 |
|
1 | 580 |
if (command == QuietCommand) { |
581 |
_quiet = true; |
|
582 |
return; |
|
583 |
} |
|
584 |
||
585 |
if (command == HelpCommand) { |
|
586 |
usage(); |
|
587 |
return; |
|
588 |
} |
|
589 |
||
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
590 |
const char* error_msg = NULL; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
591 |
if (command == OptionCommand) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
592 |
// Look for trailing options. |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
593 |
// |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
594 |
// Two types of trailing options are |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
595 |
// supported: |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
596 |
// |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
597 |
// (1) CompileCommand=option,Klass::method,flag |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
598 |
// (2) CompileCommand=option,Klass::method,type,flag,value |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
599 |
// |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
600 |
// Type (1) is used to enable a boolean flag for a method. |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
601 |
// |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
602 |
// Type (2) is used to support options with a value. Values can have the |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
603 |
// the following types: intx, uintx, bool, ccstr, ccstrlist, and double. |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
604 |
// |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
605 |
// For future extensions: extend scan_flag_and_value() |
1 | 606 |
|
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
607 |
char option[256]; // stores flag for Type (1) and type of Type (2) |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
608 |
line++; // skip the ',' |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
609 |
TypedMethodOptionMatcher* archetype = TypedMethodOptionMatcher::parse_method_pattern(line, error_msg); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
610 |
if (archetype == NULL) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
611 |
assert(error_msg != NULL, "Must have error_message"); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
612 |
print_parse_error(error_msg, original_line); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
613 |
return; |
1 | 614 |
} |
615 |
||
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
616 |
line += skip_whitespace(line); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
617 |
|
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
618 |
// This is unnecessarily complex. Should retire multi-option lines and skip while loop |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
619 |
while (sscanf(line, "%255[a-zA-Z0-9]%n", option, &bytes_read) == 1) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
620 |
line += bytes_read; |
28721
b9655115bf4e
8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents:
28720
diff
changeset
|
621 |
|
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
622 |
// typed_matcher is used as a blueprint for each option, deleted at the end |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
623 |
TypedMethodOptionMatcher* typed_matcher = archetype->clone(); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
624 |
if (strcmp(option, "intx") == 0 |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
625 |
|| strcmp(option, "uintx") == 0 |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
626 |
|| strcmp(option, "bool") == 0 |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
627 |
|| strcmp(option, "ccstr") == 0 |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
628 |
|| strcmp(option, "ccstrlist") == 0 |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
629 |
|| strcmp(option, "double") == 0 |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
630 |
) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
631 |
char errorbuf[1024] = {0}; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
632 |
// Type (2) option: parse flag name and value. |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
633 |
scan_flag_and_value(option, line, bytes_read, typed_matcher, errorbuf, sizeof(errorbuf)); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
634 |
if (*errorbuf != '\0') { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
635 |
error_msg = errorbuf; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
636 |
print_parse_error(error_msg, original_line); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
637 |
return; |
1 | 638 |
} |
639 |
line += bytes_read; |
|
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
640 |
} else { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
641 |
// Type (1) option |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
642 |
add_option_string(typed_matcher, option, true); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
643 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
644 |
if (typed_matcher != NULL && !_quiet) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
645 |
// Print out the last match added |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
646 |
assert(error_msg == NULL, "No error here"); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
647 |
ttyLocker ttyl; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
648 |
tty->print("CompileCommand: %s ", command_names[command]); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
649 |
typed_matcher->print(); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
650 |
} |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
651 |
line += skip_whitespace(line); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
652 |
} // while( |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
653 |
delete archetype; |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
654 |
} else { // not an OptionCommand) |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
655 |
assert(error_msg == NULL, "Don't call here with error_msg already set"); |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
656 |
|
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
657 |
BasicMatcher* matcher = BasicMatcher::parse_method_pattern(line, error_msg); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
658 |
if (error_msg != NULL) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
659 |
assert(matcher == NULL, "consistency"); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
660 |
print_parse_error(error_msg, original_line); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
661 |
return; |
1 | 662 |
} |
663 |
||
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
664 |
add_predicate(command, matcher); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
665 |
if (!_quiet) { |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
666 |
ttyLocker ttyl; |
28496
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
667 |
tty->print("CompileCommand: %s ", command_names[command]); |
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
668 |
matcher->print(tty); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
669 |
tty->cr(); |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
670 |
} |
1 | 671 |
} |
672 |
} |
|
673 |
||
28496
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
674 |
void CompilerOracle::print_tip() { |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
675 |
tty->cr(); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
676 |
tty->print_cr("Usage: '-XX:CompileCommand=command,\"package/Class.method()\"'"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
677 |
tty->print_cr("Use: '-XX:CompileCommand=help' for more information."); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
678 |
tty->cr(); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
679 |
} |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
680 |
|
13194
603ef19adcb8
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
12981
diff
changeset
|
681 |
static const char* default_cc_file = ".hotspot_compiler"; |
603ef19adcb8
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
12981
diff
changeset
|
682 |
|
1 | 683 |
static const char* cc_file() { |
12981
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
684 |
#ifdef ASSERT |
1 | 685 |
if (CompileCommandFile == NULL) |
13194
603ef19adcb8
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
12981
diff
changeset
|
686 |
return default_cc_file; |
12981
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
687 |
#endif |
1 | 688 |
return CompileCommandFile; |
689 |
} |
|
12981
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
690 |
|
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
691 |
bool CompilerOracle::has_command_file() { |
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
692 |
return cc_file() != NULL; |
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
693 |
} |
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
694 |
|
1 | 695 |
bool CompilerOracle::_quiet = false; |
696 |
||
697 |
void CompilerOracle::parse_from_file() { |
|
12981
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
698 |
assert(has_command_file(), "command file must be specified"); |
1 | 699 |
FILE* stream = fopen(cc_file(), "rt"); |
700 |
if (stream == NULL) return; |
|
701 |
||
702 |
char token[1024]; |
|
703 |
int pos = 0; |
|
704 |
int c = getc(stream); |
|
14139 | 705 |
while(c != EOF && pos < (int)(sizeof(token)-1)) { |
1 | 706 |
if (c == '\n') { |
707 |
token[pos++] = '\0'; |
|
708 |
parse_from_line(token); |
|
709 |
pos = 0; |
|
710 |
} else { |
|
711 |
token[pos++] = c; |
|
712 |
} |
|
713 |
c = getc(stream); |
|
714 |
} |
|
715 |
token[pos++] = '\0'; |
|
716 |
parse_from_line(token); |
|
717 |
||
718 |
fclose(stream); |
|
719 |
} |
|
720 |
||
721 |
void CompilerOracle::parse_from_string(const char* str, void (*parse_line)(char*)) { |
|
722 |
char token[1024]; |
|
723 |
int pos = 0; |
|
724 |
const char* sp = str; |
|
725 |
int c = *sp++; |
|
14139 | 726 |
while (c != '\0' && pos < (int)(sizeof(token)-1)) { |
1 | 727 |
if (c == '\n') { |
728 |
token[pos++] = '\0'; |
|
729 |
parse_line(token); |
|
730 |
pos = 0; |
|
731 |
} else { |
|
732 |
token[pos++] = c; |
|
733 |
} |
|
734 |
c = *sp++; |
|
735 |
} |
|
736 |
token[pos++] = '\0'; |
|
737 |
parse_line(token); |
|
738 |
} |
|
739 |
||
740 |
void CompilerOracle::append_comment_to_file(const char* message) { |
|
12981
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
741 |
assert(has_command_file(), "command file must be specified"); |
1 | 742 |
fileStream stream(fopen(cc_file(), "at")); |
743 |
stream.print("# "); |
|
744 |
for (int index = 0; message[index] != '\0'; index++) { |
|
745 |
stream.put(message[index]); |
|
746 |
if (message[index] == '\n') stream.print("# "); |
|
747 |
} |
|
748 |
stream.cr(); |
|
749 |
} |
|
750 |
||
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33069
diff
changeset
|
751 |
void CompilerOracle::append_exclude_to_file(const methodHandle& method) { |
12981
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
752 |
assert(has_command_file(), "command file must be specified"); |
1 | 753 |
fileStream stream(fopen(cc_file(), "at")); |
754 |
stream.print("exclude "); |
|
14391
df0a1573d5bd
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
14147
diff
changeset
|
755 |
method->method_holder()->name()->print_symbol_on(&stream); |
1 | 756 |
stream.print("."); |
757 |
method->name()->print_symbol_on(&stream); |
|
758 |
method->signature()->print_symbol_on(&stream); |
|
759 |
stream.cr(); |
|
760 |
stream.cr(); |
|
761 |
} |
|
762 |
||
763 |
||
764 |
void compilerOracle_init() { |
|
765 |
CompilerOracle::parse_from_string(CompileCommand, CompilerOracle::parse_from_line); |
|
766 |
CompilerOracle::parse_from_string(CompileOnly, CompilerOracle::parse_compile_only); |
|
12981
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
767 |
if (CompilerOracle::has_command_file()) { |
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
768 |
CompilerOracle::parse_from_file(); |
13194
603ef19adcb8
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
12981
diff
changeset
|
769 |
} else { |
603ef19adcb8
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
12981
diff
changeset
|
770 |
struct stat buf; |
603ef19adcb8
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
12981
diff
changeset
|
771 |
if (os::stat(default_cc_file, &buf) == 0) { |
603ef19adcb8
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
12981
diff
changeset
|
772 |
warning("%s file is present but has been ignored. " |
603ef19adcb8
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
12981
diff
changeset
|
773 |
"Run with -XX:CompileCommandFile=%s to load the file.", |
603ef19adcb8
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
12981
diff
changeset
|
774 |
default_cc_file, default_cc_file); |
603ef19adcb8
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
12981
diff
changeset
|
775 |
} |
12981
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
776 |
} |
4584
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
777 |
if (lists[PrintCommand] != NULL) { |
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
778 |
if (PrintAssembly) { |
13194
603ef19adcb8
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
12981
diff
changeset
|
779 |
warning("CompileCommand and/or %s file contains 'print' commands, but PrintAssembly is also enabled", default_cc_file); |
4584
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
780 |
} else if (FLAG_IS_DEFAULT(DebugNonSafepoints)) { |
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
781 |
warning("printing of assembly code is enabled; turning on DebugNonSafepoints to gain additional output"); |
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
782 |
DebugNonSafepoints = true; |
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
783 |
} |
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
784 |
} |
1 | 785 |
} |
786 |
||
787 |
||
788 |
void CompilerOracle::parse_compile_only(char * line) { |
|
789 |
int i; |
|
790 |
char name[1024]; |
|
791 |
const char* className = NULL; |
|
792 |
const char* methodName = NULL; |
|
793 |
||
794 |
bool have_colon = (strstr(line, "::") != NULL); |
|
795 |
char method_sep = have_colon ? ':' : '.'; |
|
796 |
||
797 |
if (Verbose) { |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23185
diff
changeset
|
798 |
tty->print_cr("%s", line); |
1 | 799 |
} |
800 |
||
801 |
ResourceMark rm; |
|
802 |
while (*line != '\0') { |
|
803 |
MethodMatcher::Mode c_match = MethodMatcher::Exact; |
|
804 |
MethodMatcher::Mode m_match = MethodMatcher::Exact; |
|
805 |
||
806 |
for (i = 0; |
|
807 |
i < 1024 && *line != '\0' && *line != method_sep && *line != ',' && !isspace(*line); |
|
808 |
line++, i++) { |
|
809 |
name[i] = *line; |
|
810 |
if (name[i] == '.') name[i] = '/'; // package prefix uses '/' |
|
811 |
} |
|
812 |
||
813 |
if (i > 0) { |
|
814 |
char* newName = NEW_RESOURCE_ARRAY( char, i + 1); |
|
815 |
if (newName == NULL) |
|
816 |
return; |
|
817 |
strncpy(newName, name, i); |
|
818 |
newName[i] = '\0'; |
|
819 |
||
820 |
if (className == NULL) { |
|
821 |
className = newName; |
|
822 |
} else { |
|
823 |
methodName = newName; |
|
824 |
} |
|
825 |
} |
|
826 |
||
827 |
if (*line == method_sep) { |
|
828 |
if (className == NULL) { |
|
829 |
className = ""; |
|
830 |
c_match = MethodMatcher::Any; |
|
831 |
} |
|
832 |
} else { |
|
833 |
// got foo or foo/bar |
|
834 |
if (className == NULL) { |
|
835 |
ShouldNotReachHere(); |
|
836 |
} else { |
|
40079
40d48ddc12bc
8071652: -XX:CompileOnly does not behave as documented
dpochepk
parents:
35138
diff
changeset
|
837 |
// missing class name handled as "Any" class match |
40d48ddc12bc
8071652: -XX:CompileOnly does not behave as documented
dpochepk
parents:
35138
diff
changeset
|
838 |
if (className[0] == '\0') { |
1 | 839 |
c_match = MethodMatcher::Any; |
840 |
} |
|
841 |
} |
|
842 |
} |
|
843 |
||
844 |
// each directive is terminated by , or NUL or . followed by NUL |
|
845 |
if (*line == ',' || *line == '\0' || (line[0] == '.' && line[1] == '\0')) { |
|
846 |
if (methodName == NULL) { |
|
847 |
methodName = ""; |
|
848 |
if (*line != method_sep) { |
|
849 |
m_match = MethodMatcher::Any; |
|
850 |
} |
|
851 |
} |
|
852 |
||
853 |
EXCEPTION_MARK; |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
854 |
Symbol* c_name = SymbolTable::new_symbol(className, CHECK); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
855 |
Symbol* m_name = SymbolTable::new_symbol(methodName, CHECK); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
856 |
Symbol* signature = NULL; |
1 | 857 |
|
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
858 |
BasicMatcher* bm = new BasicMatcher(); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
859 |
bm->init(c_name, c_match, m_name, m_match, signature); |
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
860 |
add_predicate(CompileOnlyCommand, bm); |
1 | 861 |
if (PrintVMOptions) { |
862 |
tty->print("CompileOnly: compileonly "); |
|
33069
d8eed614f298
8135068: Extract method matchers from CompilerOracle
neliasso
parents:
31615
diff
changeset
|
863 |
lists[CompileOnlyCommand]->print_all(tty); |
1 | 864 |
} |
865 |
||
866 |
className = NULL; |
|
867 |
methodName = NULL; |
|
868 |
} |
|
869 |
||
870 |
line = *line == '\0' ? line : line + 1; |
|
871 |
} |
|
872 |
} |