author | coleenp |
Thu, 23 Jul 2015 15:17:58 -0400 | |
changeset 31981 | 9caa094a485f |
parent 31615 | e48d94b97b6c |
child 33069 | d8eed614f298 |
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" |
|
27 |
#include "memory/allocation.inline.hpp" |
|
28 |
#include "memory/oopFactory.hpp" |
|
29 |
#include "memory/resourceArea.hpp" |
|
30 |
#include "oops/klass.hpp" |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13202
diff
changeset
|
31 |
#include "oops/method.hpp" |
7397 | 32 |
#include "oops/oop.inline.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 |
|
13195 | 38 |
class MethodMatcher : public CHeapObj<mtCompiler> { |
1 | 39 |
public: |
40 |
enum Mode { |
|
41 |
Exact, |
|
42 |
Prefix = 1, |
|
43 |
Suffix = 2, |
|
44 |
Substring = Prefix | Suffix, |
|
45 |
Any, |
|
46 |
Unknown = -1 |
|
47 |
}; |
|
48 |
||
49 |
protected: |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
50 |
Symbol* _class_name; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
51 |
Symbol* _method_name; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
52 |
Symbol* _signature; |
1 | 53 |
Mode _class_mode; |
54 |
Mode _method_mode; |
|
55 |
MethodMatcher* _next; |
|
56 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
57 |
static bool match(Symbol* candidate, Symbol* match, Mode match_mode); |
1 | 58 |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
59 |
Symbol* class_name() const { return _class_name; } |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
60 |
Symbol* method_name() const { return _method_name; } |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
61 |
Symbol* signature() const { return _signature; } |
1 | 62 |
|
63 |
public: |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
64 |
MethodMatcher(Symbol* class_name, Mode class_mode, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
65 |
Symbol* method_name, Mode method_mode, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
66 |
Symbol* signature, MethodMatcher* next); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
67 |
MethodMatcher(Symbol* class_name, Symbol* method_name, MethodMatcher* next); |
1 | 68 |
|
69 |
// utility method |
|
70 |
MethodMatcher* find(methodHandle method) { |
|
14391
df0a1573d5bd
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
14147
diff
changeset
|
71 |
Symbol* class_name = method->method_holder()->name(); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
72 |
Symbol* method_name = method->name(); |
1 | 73 |
for (MethodMatcher* current = this; current != NULL; current = current->_next) { |
74 |
if (match(class_name, current->class_name(), current->_class_mode) && |
|
75 |
match(method_name, current->method_name(), current->_method_mode) && |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
76 |
(current->signature() == NULL || current->signature() == method->signature())) { |
1 | 77 |
return current; |
78 |
} |
|
79 |
} |
|
80 |
return NULL; |
|
81 |
} |
|
82 |
||
83 |
bool match(methodHandle method) { |
|
84 |
return find(method) != NULL; |
|
85 |
} |
|
86 |
||
87 |
MethodMatcher* next() const { return _next; } |
|
88 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
89 |
static void print_symbol(Symbol* h, Mode mode) { |
1 | 90 |
ResourceMark rm; |
91 |
||
92 |
if (mode == Suffix || mode == Substring || mode == Any) { |
|
93 |
tty->print("*"); |
|
94 |
} |
|
95 |
if (mode != Any) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
96 |
h->print_symbol_on(tty); |
1 | 97 |
} |
98 |
if (mode == Prefix || mode == Substring) { |
|
99 |
tty->print("*"); |
|
100 |
} |
|
101 |
} |
|
102 |
||
103 |
void print_base() { |
|
104 |
print_symbol(class_name(), _class_mode); |
|
105 |
tty->print("."); |
|
106 |
print_symbol(method_name(), _method_mode); |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
107 |
if (signature() != NULL) { |
1 | 108 |
signature()->print_symbol_on(tty); |
109 |
} |
|
110 |
} |
|
111 |
||
112 |
virtual void print() { |
|
113 |
print_base(); |
|
114 |
tty->cr(); |
|
115 |
} |
|
116 |
}; |
|
117 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
118 |
MethodMatcher::MethodMatcher(Symbol* class_name, Symbol* method_name, MethodMatcher* next) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
119 |
_class_name = class_name; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
120 |
_method_name = method_name; |
1 | 121 |
_next = next; |
122 |
_class_mode = MethodMatcher::Exact; |
|
123 |
_method_mode = MethodMatcher::Exact; |
|
124 |
_signature = NULL; |
|
125 |
} |
|
126 |
||
127 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
128 |
MethodMatcher::MethodMatcher(Symbol* class_name, Mode class_mode, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
129 |
Symbol* method_name, Mode method_mode, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
130 |
Symbol* signature, MethodMatcher* next): |
1 | 131 |
_class_mode(class_mode) |
132 |
, _method_mode(method_mode) |
|
133 |
, _next(next) |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
134 |
, _class_name(class_name) |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
135 |
, _method_name(method_name) |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
136 |
, _signature(signature) { |
1 | 137 |
} |
138 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
139 |
bool MethodMatcher::match(Symbol* candidate, Symbol* match, Mode match_mode) { |
1 | 140 |
if (match_mode == Any) { |
141 |
return true; |
|
142 |
} |
|
143 |
||
144 |
if (match_mode == Exact) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
145 |
return candidate == match; |
1 | 146 |
} |
147 |
||
148 |
ResourceMark rm; |
|
149 |
const char * candidate_string = candidate->as_C_string(); |
|
150 |
const char * match_string = match->as_C_string(); |
|
151 |
||
152 |
switch (match_mode) { |
|
153 |
case Prefix: |
|
154 |
return strstr(candidate_string, match_string) == candidate_string; |
|
155 |
||
156 |
case Suffix: { |
|
157 |
size_t clen = strlen(candidate_string); |
|
158 |
size_t mlen = strlen(match_string); |
|
159 |
return clen >= mlen && strcmp(candidate_string + clen - mlen, match_string) == 0; |
|
160 |
} |
|
161 |
||
162 |
case Substring: |
|
163 |
return strstr(candidate_string, match_string) != NULL; |
|
164 |
||
165 |
default: |
|
166 |
return false; |
|
167 |
} |
|
168 |
} |
|
169 |
||
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
170 |
enum OptionType { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
171 |
IntxType, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
172 |
UintxType, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
173 |
BoolType, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
174 |
CcstrType, |
27143
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
175 |
DoubleType, |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
176 |
UnknownType |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
177 |
}; |
1 | 178 |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
179 |
/* Methods to map real type names to OptionType */ |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
180 |
template<typename T> |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
181 |
static OptionType get_type_for() { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
182 |
return UnknownType; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
183 |
}; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
184 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
185 |
template<> OptionType get_type_for<intx>() { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
186 |
return IntxType; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
187 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
188 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
189 |
template<> OptionType get_type_for<uintx>() { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
190 |
return UintxType; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
191 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
192 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
193 |
template<> OptionType get_type_for<bool>() { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
194 |
return BoolType; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
195 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
196 |
|
26433 | 197 |
template<> OptionType get_type_for<ccstr>() { |
198 |
return CcstrType; |
|
199 |
} |
|
200 |
||
27143
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
201 |
template<> OptionType get_type_for<double>() { |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
202 |
return DoubleType; |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
203 |
} |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
204 |
|
26433 | 205 |
template<typename T> |
206 |
static const T copy_value(const T value) { |
|
207 |
return value; |
|
208 |
} |
|
209 |
||
210 |
template<> const ccstr copy_value<ccstr>(const ccstr value) { |
|
211 |
return (const ccstr)os::strdup_check_oom(value); |
|
212 |
} |
|
213 |
||
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
214 |
template <typename T> |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
215 |
class TypedMethodOptionMatcher : public MethodMatcher { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
216 |
const char* _option; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
217 |
OptionType _type; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
218 |
const T _value; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
219 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
220 |
public: |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
221 |
TypedMethodOptionMatcher(Symbol* class_name, Mode class_mode, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
222 |
Symbol* method_name, Mode method_mode, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
223 |
Symbol* signature, const char* opt, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
224 |
const T value, MethodMatcher* next) : |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
225 |
MethodMatcher(class_name, class_mode, method_name, method_mode, signature, next), |
26433 | 226 |
_type(get_type_for<T>()), _value(copy_value<T>(value)) { |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
227 |
_option = os::strdup_check_oom(opt); |
25949 | 228 |
} |
229 |
||
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
230 |
~TypedMethodOptionMatcher() { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
231 |
os::free((void*)_option); |
1 | 232 |
} |
233 |
||
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
234 |
TypedMethodOptionMatcher* match(methodHandle method, const char* opt) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
235 |
TypedMethodOptionMatcher* current = this; |
1 | 236 |
while (current != NULL) { |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
237 |
current = (TypedMethodOptionMatcher*)current->find(method); |
1 | 238 |
if (current == NULL) { |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
239 |
return NULL; |
1 | 240 |
} |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
241 |
if (strcmp(current->_option, opt) == 0) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
242 |
return current; |
1 | 243 |
} |
244 |
current = current->next(); |
|
245 |
} |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
246 |
return NULL; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
247 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
248 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
249 |
TypedMethodOptionMatcher* next() { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
250 |
return (TypedMethodOptionMatcher*)_next; |
1 | 251 |
} |
252 |
||
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
253 |
OptionType get_type(void) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
254 |
return _type; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
255 |
}; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
256 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
257 |
T value() { return _value; } |
1 | 258 |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
259 |
void print() { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
260 |
ttyLocker ttyl; |
1 | 261 |
print_base(); |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
262 |
tty->print(" %s", _option); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
263 |
tty->print(" <unknown option type>"); |
1 | 264 |
tty->cr(); |
265 |
} |
|
266 |
}; |
|
267 |
||
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
268 |
template<> |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
269 |
void TypedMethodOptionMatcher<intx>::print() { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
270 |
ttyLocker ttyl; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
271 |
print_base(); |
26433 | 272 |
tty->print(" intx %s", _option); |
273 |
tty->print(" = " INTX_FORMAT, _value); |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
274 |
tty->cr(); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
275 |
}; |
1 | 276 |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
277 |
template<> |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
278 |
void TypedMethodOptionMatcher<uintx>::print() { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
279 |
ttyLocker ttyl; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
280 |
print_base(); |
26433 | 281 |
tty->print(" uintx %s", _option); |
282 |
tty->print(" = " UINTX_FORMAT, _value); |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
283 |
tty->cr(); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
284 |
}; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
285 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
286 |
template<> |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
287 |
void TypedMethodOptionMatcher<bool>::print() { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
288 |
ttyLocker ttyl; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
289 |
print_base(); |
26433 | 290 |
tty->print(" bool %s", _option); |
291 |
tty->print(" = %s", _value ? "true" : "false"); |
|
292 |
tty->cr(); |
|
293 |
}; |
|
294 |
||
295 |
template<> |
|
296 |
void TypedMethodOptionMatcher<ccstr>::print() { |
|
297 |
ttyLocker ttyl; |
|
298 |
print_base(); |
|
299 |
tty->print(" const char* %s", _option); |
|
300 |
tty->print(" = '%s'", _value); |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
301 |
tty->cr(); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
302 |
}; |
1 | 303 |
|
27143
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
304 |
template<> |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
305 |
void TypedMethodOptionMatcher<double>::print() { |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
306 |
ttyLocker ttyl; |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
307 |
print_base(); |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
308 |
tty->print(" double %s", _option); |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
309 |
tty->print(" = %f", _value); |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
310 |
tty->cr(); |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
311 |
}; |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
312 |
|
1 | 313 |
// this must parallel the command_names below |
314 |
enum OracleCommand { |
|
315 |
UnknownCommand = -1, |
|
316 |
OracleFirstCommand = 0, |
|
317 |
BreakCommand = OracleFirstCommand, |
|
318 |
PrintCommand, |
|
319 |
ExcludeCommand, |
|
320 |
InlineCommand, |
|
321 |
DontInlineCommand, |
|
322 |
CompileOnlyCommand, |
|
323 |
LogCommand, |
|
324 |
OptionCommand, |
|
325 |
QuietCommand, |
|
326 |
HelpCommand, |
|
327 |
OracleCommandCount |
|
328 |
}; |
|
329 |
||
330 |
// this must parallel the enum OracleCommand |
|
331 |
static const char * command_names[] = { |
|
332 |
"break", |
|
333 |
"print", |
|
334 |
"exclude", |
|
335 |
"inline", |
|
336 |
"dontinline", |
|
337 |
"compileonly", |
|
338 |
"log", |
|
339 |
"option", |
|
340 |
"quiet", |
|
341 |
"help" |
|
342 |
}; |
|
343 |
||
344 |
class MethodMatcher; |
|
345 |
static MethodMatcher* lists[OracleCommandCount] = { 0, }; |
|
346 |
||
347 |
||
348 |
static bool check_predicate(OracleCommand command, methodHandle method) { |
|
349 |
return ((lists[command] != NULL) && |
|
350 |
!method.is_null() && |
|
351 |
lists[command]->match(method)); |
|
352 |
} |
|
353 |
||
354 |
||
355 |
static MethodMatcher* add_predicate(OracleCommand command, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
356 |
Symbol* class_name, MethodMatcher::Mode c_mode, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
357 |
Symbol* method_name, MethodMatcher::Mode m_mode, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
358 |
Symbol* signature) { |
1 | 359 |
assert(command != OptionCommand, "must use add_option_string"); |
360 |
if (command == LogCommand && !LogCompilation && lists[LogCommand] == NULL) |
|
361 |
tty->print_cr("Warning: +LogCompilation must be enabled in order for individual methods to be logged."); |
|
362 |
lists[command] = new MethodMatcher(class_name, c_mode, method_name, m_mode, signature, lists[command]); |
|
363 |
return lists[command]; |
|
364 |
} |
|
365 |
||
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
366 |
template<typename T> |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
367 |
static MethodMatcher* add_option_string(Symbol* class_name, MethodMatcher::Mode c_mode, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
368 |
Symbol* method_name, MethodMatcher::Mode m_mode, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
369 |
Symbol* signature, |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
370 |
const char* option, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
371 |
T value) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
372 |
lists[OptionCommand] = new TypedMethodOptionMatcher<T>(class_name, c_mode, method_name, m_mode, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
373 |
signature, option, value, lists[OptionCommand]); |
1 | 374 |
return lists[OptionCommand]; |
375 |
} |
|
376 |
||
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
377 |
template<typename T> |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
378 |
static bool get_option_value(methodHandle method, const char* option, T& value) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
379 |
TypedMethodOptionMatcher<T>* m; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
380 |
if (lists[OptionCommand] != NULL |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
381 |
&& (m = ((TypedMethodOptionMatcher<T>*)lists[OptionCommand])->match(method, option)) != NULL |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
382 |
&& m->get_type() == get_type_for<T>()) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
383 |
value = m->value(); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
384 |
return true; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
385 |
} else { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
386 |
return false; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
387 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
388 |
} |
1 | 389 |
|
390 |
bool CompilerOracle::has_option_string(methodHandle method, const char* option) { |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
391 |
bool value = false; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
392 |
get_option_value(method, option, value); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
393 |
return value; |
1 | 394 |
} |
395 |
||
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
396 |
template<typename T> |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
397 |
bool CompilerOracle::has_option_value(methodHandle method, const char* option, T& value) { |
26441
fb92944bb02d
8057129: Fix AIX build after the Extend CompileCommand=option change 8055286
simonis
parents:
26433
diff
changeset
|
398 |
return ::get_option_value(method, option, value); |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
399 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
400 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
401 |
// Explicit instantiation for all OptionTypes supported. |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
402 |
template bool CompilerOracle::has_option_value<intx>(methodHandle method, const char* option, intx& value); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
403 |
template bool CompilerOracle::has_option_value<uintx>(methodHandle method, const char* option, uintx& value); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
404 |
template bool CompilerOracle::has_option_value<bool>(methodHandle method, const char* option, bool& value); |
26433 | 405 |
template bool CompilerOracle::has_option_value<ccstr>(methodHandle method, const char* option, ccstr& value); |
27143
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
406 |
template bool CompilerOracle::has_option_value<double>(methodHandle method, const char* option, double& value); |
1 | 407 |
|
408 |
bool CompilerOracle::should_exclude(methodHandle method, bool& quietly) { |
|
409 |
quietly = true; |
|
410 |
if (lists[ExcludeCommand] != NULL) { |
|
411 |
if (lists[ExcludeCommand]->match(method)) { |
|
412 |
quietly = _quiet; |
|
413 |
return true; |
|
414 |
} |
|
415 |
} |
|
416 |
||
417 |
if (lists[CompileOnlyCommand] != NULL) { |
|
418 |
return !lists[CompileOnlyCommand]->match(method); |
|
419 |
} |
|
420 |
return false; |
|
421 |
} |
|
422 |
||
423 |
||
424 |
bool CompilerOracle::should_inline(methodHandle method) { |
|
425 |
return (check_predicate(InlineCommand, method)); |
|
426 |
} |
|
427 |
||
428 |
||
429 |
bool CompilerOracle::should_not_inline(methodHandle method) { |
|
430 |
return (check_predicate(DontInlineCommand, method)); |
|
431 |
} |
|
432 |
||
433 |
||
434 |
bool CompilerOracle::should_print(methodHandle method) { |
|
435 |
return (check_predicate(PrintCommand, method)); |
|
436 |
} |
|
437 |
||
24658
e41df2fc6e87
8042727: nsk/jdb/unwatch/unwatch001 crash in InstanceKlass::methods_do(void (*)(Method*))
coleenp
parents:
24424
diff
changeset
|
438 |
bool CompilerOracle::should_print_methods() { |
e41df2fc6e87
8042727: nsk/jdb/unwatch/unwatch001 crash in InstanceKlass::methods_do(void (*)(Method*))
coleenp
parents:
24424
diff
changeset
|
439 |
return lists[PrintCommand] != NULL; |
e41df2fc6e87
8042727: nsk/jdb/unwatch/unwatch001 crash in InstanceKlass::methods_do(void (*)(Method*))
coleenp
parents:
24424
diff
changeset
|
440 |
} |
1 | 441 |
|
442 |
bool CompilerOracle::should_log(methodHandle method) { |
|
443 |
if (!LogCompilation) return false; |
|
444 |
if (lists[LogCommand] == NULL) return true; // by default, log all |
|
445 |
return (check_predicate(LogCommand, method)); |
|
446 |
} |
|
447 |
||
448 |
||
449 |
bool CompilerOracle::should_break_at(methodHandle method) { |
|
450 |
return check_predicate(BreakCommand, method); |
|
451 |
} |
|
452 |
||
453 |
||
454 |
static OracleCommand parse_command_name(const char * line, int* bytes_read) { |
|
455 |
assert(ARRAY_SIZE(command_names) == OracleCommandCount, |
|
456 |
"command_names size mismatch"); |
|
457 |
||
458 |
*bytes_read = 0; |
|
7701
766eb9258574
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
7397
diff
changeset
|
459 |
char command[33]; |
1 | 460 |
int result = sscanf(line, "%32[a-z]%n", command, bytes_read); |
461 |
for (uint i = 0; i < ARRAY_SIZE(command_names); i++) { |
|
462 |
if (strcmp(command, command_names[i]) == 0) { |
|
463 |
return (OracleCommand)i; |
|
464 |
} |
|
465 |
} |
|
466 |
return UnknownCommand; |
|
467 |
} |
|
468 |
||
469 |
static void usage() { |
|
28496
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
470 |
tty->cr(); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
471 |
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
|
472 |
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
|
473 |
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
|
474 |
tty->print_cr("option provides the following commands:"); |
1 | 475 |
tty->cr(); |
28496
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
476 |
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
|
477 |
tty->print_cr(" print,<pattern> - print assembly"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
478 |
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
|
479 |
tty->print_cr(" inline,<pattern> - always inline"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
480 |
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
|
481 |
tty->print_cr(" compileonly,<pattern> - compile only"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
482 |
tty->print_cr(" log,<pattern> - log compilation"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
483 |
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
|
484 |
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
|
485 |
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
|
486 |
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
|
487 |
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
|
488 |
tty->print_cr(" help - print this text"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
489 |
tty->cr(); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
490 |
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
|
491 |
tty->print_cr(" package/Class.method()"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
492 |
tty->cr(); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
493 |
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
|
494 |
tty->print_cr(" package.Class::method()"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
495 |
tty->cr(); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
496 |
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
|
497 |
tty->print_cr(" package/Class.method ()"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
498 |
tty->cr(); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
499 |
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
|
500 |
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
|
501 |
tty->print_cr(" *ackage/Clas*.*etho*()"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
502 |
tty->cr(); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
503 |
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
|
504 |
tty->print_cr(" -XX:CompileCommand=exclude,java/*.* -XX:CompileCommand=log,java*.*"); |
1 | 505 |
tty->cr(); |
28496
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
506 |
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
|
507 |
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
|
508 |
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
|
509 |
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
|
510 |
tty->print_cr(" exclude java/*.*"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
511 |
tty->print_cr(" option java/*.* ReplayInline"); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
512 |
tty->cr(); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
513 |
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
|
514 |
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
|
515 |
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
|
516 |
tty->cr(); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
517 |
}; |
1 | 518 |
|
28496
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
519 |
// The JVM specification defines the allowed characters. |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
520 |
// Tokens that are disallowed by the JVM specification can have |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
521 |
// a meaning to the parser so we need to include them here. |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
522 |
// The parser does not enforce all rules of the JVMS - a successful parse |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
523 |
// does not mean that it is an allowed name. Illegal names will |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
524 |
// be ignored since they never can match a class or method. |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
525 |
// |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
526 |
// '\0' and 0xf0-0xff are disallowed in constant string values |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
527 |
// 0x20 ' ', 0x09 '\t' and, 0x2c ',' are used in the matching |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
528 |
// 0x5b '[' and 0x5d ']' can not be used because of the matcher |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
529 |
// 0x28 '(' and 0x29 ')' are used for the signature |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
530 |
// 0x2e '.' is always replaced before the matching |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
531 |
// 0x2f '/' is only used in the class name as package separator |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
532 |
|
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
533 |
#define RANGEBASE "\x1\x2\x3\x4\x5\x6\x7\x8\xa\xb\xc\xd\xe\xf" \ |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
534 |
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" \ |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
535 |
"\x21\x22\x23\x24\x25\x26\x27\x2a\x2b\x2c\x2d" \ |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
536 |
"\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f" \ |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
537 |
"\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f" \ |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
538 |
"\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5c\x5e\x5f" \ |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
539 |
"\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f" \ |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
540 |
"\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f" \ |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
541 |
"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" \ |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
542 |
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" \ |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
543 |
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" \ |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
544 |
"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" \ |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
545 |
"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" \ |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
546 |
"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" \ |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
547 |
"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef" |
1 | 548 |
|
549 |
#define RANGE0 "[*" RANGEBASE "]" |
|
550 |
#define RANGESLASH "[*" RANGEBASE "/]" |
|
551 |
||
552 |
static MethodMatcher::Mode check_mode(char name[], const char*& error_msg) { |
|
553 |
int match = MethodMatcher::Exact; |
|
4584
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
554 |
while (name[0] == '*') { |
1 | 555 |
match |= MethodMatcher::Suffix; |
28720
76473974643b
8069389: CompilerOracle prefix wildcarding is broken for long strings
neliasso
parents:
28496
diff
changeset
|
556 |
// Copy remaining string plus NUL to the beginning |
76473974643b
8069389: CompilerOracle prefix wildcarding is broken for long strings
neliasso
parents:
28496
diff
changeset
|
557 |
memmove(name, name + 1, strlen(name + 1) + 1); |
1 | 558 |
} |
559 |
||
4584
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
560 |
if (strcmp(name, "*") == 0) return MethodMatcher::Any; |
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
561 |
|
1 | 562 |
size_t len = strlen(name); |
4584
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
563 |
while (len > 0 && name[len - 1] == '*') { |
1 | 564 |
match |= MethodMatcher::Prefix; |
4584
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
565 |
name[--len] = '\0'; |
1 | 566 |
} |
567 |
||
568 |
if (strstr(name, "*") != NULL) { |
|
569 |
error_msg = " Embedded * not allowed"; |
|
570 |
return MethodMatcher::Unknown; |
|
571 |
} |
|
572 |
return (MethodMatcher::Mode)match; |
|
573 |
} |
|
574 |
||
575 |
static bool scan_line(const char * line, |
|
576 |
char class_name[], MethodMatcher::Mode* c_mode, |
|
577 |
char method_name[], MethodMatcher::Mode* m_mode, |
|
578 |
int* bytes_read, const char*& error_msg) { |
|
579 |
*bytes_read = 0; |
|
580 |
error_msg = NULL; |
|
31615 | 581 |
if (2 == sscanf(line, "%*[ \t]%255" RANGESLASH "%*[ ]" "%255" RANGE0 "%n", class_name, method_name, bytes_read)) { |
23185 | 582 |
*c_mode = check_mode(class_name, error_msg); |
583 |
*m_mode = check_mode(method_name, error_msg); |
|
584 |
return *c_mode != MethodMatcher::Unknown && *m_mode != MethodMatcher::Unknown; |
|
1 | 585 |
} |
586 |
return false; |
|
587 |
} |
|
588 |
||
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
589 |
// 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
|
590 |
// On failure, error_msg contains description for the first error. |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
591 |
// For future extensions: set error_msg on first error. |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
592 |
static MethodMatcher* scan_flag_and_value(const char* type, const char* line, int& total_bytes_read, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
593 |
Symbol* c_name, MethodMatcher::Mode c_match, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
594 |
Symbol* m_name, MethodMatcher::Mode m_match, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
595 |
Symbol* signature, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
596 |
char* errorbuf, const int buf_size) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
597 |
total_bytes_read = 0; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
598 |
int bytes_read = 0; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
599 |
char flag[256]; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
600 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
601 |
// Read flag name. |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
602 |
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
|
603 |
line += bytes_read; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
604 |
total_bytes_read += bytes_read; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
605 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
606 |
// Read value. |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
607 |
if (strcmp(type, "intx") == 0) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
608 |
intx value; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
609 |
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
|
610 |
total_bytes_read += bytes_read; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
611 |
return add_option_string(c_name, c_match, m_name, m_match, signature, flag, value); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
612 |
} else { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
613 |
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
|
614 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
615 |
} else if (strcmp(type, "uintx") == 0) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
616 |
uintx value; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
617 |
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
|
618 |
total_bytes_read += bytes_read; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
619 |
return add_option_string(c_name, c_match, m_name, m_match, signature, flag, value); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
620 |
} else { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
621 |
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
|
622 |
} |
26433 | 623 |
} else if (strcmp(type, "ccstr") == 0) { |
624 |
ResourceMark rm; |
|
625 |
char* value = NEW_RESOURCE_ARRAY(char, strlen(line) + 1); |
|
626 |
if (sscanf(line, "%*[ \t]%255[_a-zA-Z0-9]%n", value, &bytes_read) == 1) { |
|
627 |
total_bytes_read += bytes_read; |
|
628 |
return add_option_string(c_name, c_match, m_name, m_match, signature, flag, (ccstr)value); |
|
629 |
} else { |
|
630 |
jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s", flag, type); |
|
631 |
} |
|
632 |
} else if (strcmp(type, "ccstrlist") == 0) { |
|
633 |
// Accumulates several strings into one. The internal type is ccstr. |
|
634 |
ResourceMark rm; |
|
635 |
char* value = NEW_RESOURCE_ARRAY(char, strlen(line) + 1); |
|
636 |
char* next_value = value; |
|
637 |
if (sscanf(line, "%*[ \t]%255[_a-zA-Z0-9]%n", next_value, &bytes_read) == 1) { |
|
638 |
total_bytes_read += bytes_read; |
|
639 |
line += bytes_read; |
|
640 |
next_value += bytes_read; |
|
641 |
char* end_value = next_value-1; |
|
642 |
while (sscanf(line, "%*[ \t]%255[_a-zA-Z0-9]%n", next_value, &bytes_read) == 1) { |
|
643 |
total_bytes_read += bytes_read; |
|
644 |
line += bytes_read; |
|
645 |
*end_value = ' '; // override '\0' |
|
646 |
next_value += bytes_read; |
|
647 |
end_value = next_value-1; |
|
648 |
} |
|
649 |
return add_option_string(c_name, c_match, m_name, m_match, signature, flag, (ccstr)value); |
|
650 |
} else { |
|
651 |
jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s", flag, type); |
|
652 |
} |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
653 |
} else if (strcmp(type, "bool") == 0) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
654 |
char value[256]; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
655 |
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
|
656 |
if (strcmp(value, "true") == 0) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
657 |
total_bytes_read += bytes_read; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
658 |
return add_option_string(c_name, c_match, m_name, m_match, signature, flag, true); |
26433 | 659 |
} else if (strcmp(value, "false") == 0) { |
660 |
total_bytes_read += bytes_read; |
|
661 |
return add_option_string(c_name, c_match, m_name, m_match, signature, flag, false); |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
662 |
} else { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
663 |
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
|
664 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
665 |
} else { |
31615 | 666 |
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
|
667 |
} |
27143
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
668 |
} else if (strcmp(type, "double") == 0) { |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
669 |
char buffer[2][256]; |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
670 |
// Decimal separator '.' has been replaced with ' ' or '/' earlier, |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
671 |
// so read integer and fraction part of double value separately. |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
672 |
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
|
673 |
char value[512] = ""; |
30281 | 674 |
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
|
675 |
total_bytes_read += bytes_read; |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
676 |
return add_option_string(c_name, c_match, m_name, m_match, signature, flag, atof(value)); |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
677 |
} else { |
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
678 |
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
|
679 |
} |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
680 |
} else { |
31615 | 681 |
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
|
682 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
683 |
} else { |
31615 | 684 |
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
|
685 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
686 |
return NULL; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
687 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
688 |
|
28721
b9655115bf4e
8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents:
28720
diff
changeset
|
689 |
int skip_whitespace(char* line) { |
b9655115bf4e
8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents:
28720
diff
changeset
|
690 |
// Skip any leading spaces |
b9655115bf4e
8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents:
28720
diff
changeset
|
691 |
int whitespace_read = 0; |
b9655115bf4e
8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents:
28720
diff
changeset
|
692 |
sscanf(line, "%*[ \t]%n", &whitespace_read); |
b9655115bf4e
8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents:
28720
diff
changeset
|
693 |
return whitespace_read; |
b9655115bf4e
8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents:
28720
diff
changeset
|
694 |
} |
b9655115bf4e
8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents:
28720
diff
changeset
|
695 |
|
1 | 696 |
void CompilerOracle::parse_from_line(char* line) { |
697 |
if (line[0] == '\0') return; |
|
698 |
if (line[0] == '#') return; |
|
699 |
||
700 |
bool have_colon = (strstr(line, "::") != NULL); |
|
701 |
for (char* lp = line; *lp != '\0'; lp++) { |
|
702 |
// Allow '.' to separate the class name from the method name. |
|
703 |
// This is the preferred spelling of methods: |
|
704 |
// exclude java/lang/String.indexOf(I)I |
|
705 |
// Allow ',' for spaces (eases command line quoting). |
|
706 |
// exclude,java/lang/String.indexOf |
|
707 |
// For backward compatibility, allow space as separator also. |
|
708 |
// exclude java/lang/String indexOf |
|
709 |
// exclude,java/lang/String,indexOf |
|
710 |
// For easy cut-and-paste of method names, allow VM output format |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13202
diff
changeset
|
711 |
// as produced by Method::print_short_name: |
1 | 712 |
// exclude java.lang.String::indexOf |
713 |
// For simple implementation convenience here, convert them all to space. |
|
714 |
if (have_colon) { |
|
715 |
if (*lp == '.') *lp = '/'; // dots build the package prefix |
|
716 |
if (*lp == ':') *lp = ' '; |
|
717 |
} |
|
718 |
if (*lp == ',' || *lp == '.') *lp = ' '; |
|
719 |
} |
|
720 |
||
721 |
char* original_line = line; |
|
722 |
int bytes_read; |
|
723 |
OracleCommand command = parse_command_name(line, &bytes_read); |
|
724 |
line += bytes_read; |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
725 |
ResourceMark rm; |
1 | 726 |
|
7701
766eb9258574
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
7397
diff
changeset
|
727 |
if (command == UnknownCommand) { |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
728 |
ttyLocker ttyl; |
28496
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
729 |
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
|
730 |
tty->print_cr(" \"%s\"", original_line); |
28496
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
731 |
CompilerOracle::print_tip(); |
7701
766eb9258574
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
7397
diff
changeset
|
732 |
return; |
766eb9258574
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
7397
diff
changeset
|
733 |
} |
766eb9258574
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
7397
diff
changeset
|
734 |
|
1 | 735 |
if (command == QuietCommand) { |
736 |
_quiet = true; |
|
737 |
return; |
|
738 |
} |
|
739 |
||
740 |
if (command == HelpCommand) { |
|
741 |
usage(); |
|
742 |
return; |
|
743 |
} |
|
744 |
||
745 |
MethodMatcher::Mode c_match = MethodMatcher::Exact; |
|
746 |
MethodMatcher::Mode m_match = MethodMatcher::Exact; |
|
747 |
char class_name[256]; |
|
748 |
char method_name[256]; |
|
749 |
char sig[1024]; |
|
750 |
char errorbuf[1024]; |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
751 |
const char* error_msg = NULL; // description of first error that appears |
1 | 752 |
MethodMatcher* match = NULL; |
753 |
||
754 |
if (scan_line(line, class_name, &c_match, method_name, &m_match, &bytes_read, error_msg)) { |
|
755 |
EXCEPTION_MARK; |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
756 |
Symbol* c_name = SymbolTable::new_symbol(class_name, CHECK); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
757 |
Symbol* m_name = SymbolTable::new_symbol(method_name, CHECK); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
758 |
Symbol* signature = NULL; |
1 | 759 |
|
760 |
line += bytes_read; |
|
28496
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
761 |
|
1 | 762 |
// there might be a signature following the method. |
763 |
// signatures always begin with ( so match that by hand |
|
28721
b9655115bf4e
8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents:
28720
diff
changeset
|
764 |
line += skip_whitespace(line); |
28496
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
765 |
if (1 == sscanf(line, "(%254[[);/" RANGEBASE "]%n", sig + 1, &bytes_read)) { |
1 | 766 |
sig[0] = '('; |
767 |
line += bytes_read; |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
768 |
signature = SymbolTable::new_symbol(sig, CHECK); |
1 | 769 |
} |
770 |
||
771 |
if (command == OptionCommand) { |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
772 |
// Look for trailing options. |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
773 |
// |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
774 |
// Two types of trailing options are |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
775 |
// supported: |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
776 |
// |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
777 |
// (1) CompileCommand=option,Klass::method,flag |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
778 |
// (2) CompileCommand=option,Klass::method,type,flag,value |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
779 |
// |
27143
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
780 |
// Type (1) is used to enable a boolean flag for a method. |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
781 |
// |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
782 |
// Type (2) is used to support options with a value. Values can have the |
27143
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
783 |
// the following types: intx, uintx, bool, ccstr, ccstrlist, and double. |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
784 |
// |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
785 |
// For future extensions: extend scan_flag_and_value() |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
786 |
char option[256]; // stores flag for Type (1) and type of Type (2) |
28721
b9655115bf4e
8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents:
28720
diff
changeset
|
787 |
|
b9655115bf4e
8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents:
28720
diff
changeset
|
788 |
line += skip_whitespace(line); |
b9655115bf4e
8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents:
28720
diff
changeset
|
789 |
while (sscanf(line, "%255[a-zA-Z0-9]%n", option, &bytes_read) == 1) { |
1 | 790 |
if (match != NULL && !_quiet) { |
791 |
// Print out the last match added |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
792 |
ttyLocker ttyl; |
28496
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
793 |
tty->print("CompileCommand: %s ", command_names[command]); |
1 | 794 |
match->print(); |
795 |
} |
|
796 |
line += bytes_read; |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
797 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
798 |
if (strcmp(option, "intx") == 0 |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
799 |
|| strcmp(option, "uintx") == 0 |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
800 |
|| strcmp(option, "bool") == 0 |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
801 |
|| strcmp(option, "ccstr") == 0 |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
802 |
|| strcmp(option, "ccstrlist") == 0 |
27143
feee4a6106bc
8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents:
26441
diff
changeset
|
803 |
|| strcmp(option, "double") == 0 |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
804 |
) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
805 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
806 |
// Type (2) option: parse flag name and value. |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
807 |
match = scan_flag_and_value(option, line, bytes_read, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
808 |
c_name, c_match, m_name, m_match, signature, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
809 |
errorbuf, sizeof(errorbuf)); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
810 |
if (match == NULL) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
811 |
error_msg = errorbuf; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
812 |
break; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
813 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
814 |
line += bytes_read; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
815 |
} else { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
816 |
// Type (1) option |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
817 |
match = add_option_string(c_name, c_match, m_name, m_match, signature, option, true); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
818 |
} |
28721
b9655115bf4e
8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents:
28720
diff
changeset
|
819 |
line += skip_whitespace(line); |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
820 |
} // while( |
1 | 821 |
} else { |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
822 |
match = add_predicate(command, c_name, c_match, m_name, m_match, signature); |
1 | 823 |
} |
824 |
} |
|
825 |
||
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
826 |
ttyLocker ttyl; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
827 |
if (error_msg != NULL) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
828 |
// an error has happened |
28496
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
829 |
tty->print_cr("CompileCommand: An error occured during parsing"); |
1 | 830 |
tty->print_cr(" \"%s\"", original_line); |
831 |
if (error_msg != NULL) { |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23185
diff
changeset
|
832 |
tty->print_cr("%s", error_msg); |
1 | 833 |
} |
28496
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
834 |
CompilerOracle::print_tip(); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
835 |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
836 |
} else { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
837 |
// check for remaining characters |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
838 |
bytes_read = 0; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
839 |
sscanf(line, "%*[ \t]%n", &bytes_read); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
840 |
if (line[bytes_read] != '\0') { |
28496
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
841 |
tty->print_cr("CompileCommand: Bad pattern"); |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
842 |
tty->print_cr(" \"%s\"", original_line); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
843 |
tty->print_cr(" Unrecognized text %s after command ", line); |
28496
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
844 |
CompilerOracle::print_tip(); |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
845 |
} else if (match != NULL && !_quiet) { |
28496
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
846 |
tty->print("CompileCommand: %s ", command_names[command]); |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
847 |
match->print(); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
848 |
} |
1 | 849 |
} |
850 |
} |
|
851 |
||
28496
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
852 |
void CompilerOracle::print_tip() { |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
853 |
tty->cr(); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
854 |
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
|
855 |
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
|
856 |
tty->cr(); |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
857 |
} |
f9753412d4f5
8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents:
27143
diff
changeset
|
858 |
|
13194
603ef19adcb8
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
12981
diff
changeset
|
859 |
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
|
860 |
|
1 | 861 |
static const char* cc_file() { |
12981
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
862 |
#ifdef ASSERT |
1 | 863 |
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
|
864 |
return default_cc_file; |
12981
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
865 |
#endif |
1 | 866 |
return CompileCommandFile; |
867 |
} |
|
12981
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
868 |
|
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
869 |
bool CompilerOracle::has_command_file() { |
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
870 |
return cc_file() != NULL; |
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
871 |
} |
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
872 |
|
1 | 873 |
bool CompilerOracle::_quiet = false; |
874 |
||
875 |
void CompilerOracle::parse_from_file() { |
|
12981
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
876 |
assert(has_command_file(), "command file must be specified"); |
1 | 877 |
FILE* stream = fopen(cc_file(), "rt"); |
878 |
if (stream == NULL) return; |
|
879 |
||
880 |
char token[1024]; |
|
881 |
int pos = 0; |
|
882 |
int c = getc(stream); |
|
14139 | 883 |
while(c != EOF && pos < (int)(sizeof(token)-1)) { |
1 | 884 |
if (c == '\n') { |
885 |
token[pos++] = '\0'; |
|
886 |
parse_from_line(token); |
|
887 |
pos = 0; |
|
888 |
} else { |
|
889 |
token[pos++] = c; |
|
890 |
} |
|
891 |
c = getc(stream); |
|
892 |
} |
|
893 |
token[pos++] = '\0'; |
|
894 |
parse_from_line(token); |
|
895 |
||
896 |
fclose(stream); |
|
897 |
} |
|
898 |
||
899 |
void CompilerOracle::parse_from_string(const char* str, void (*parse_line)(char*)) { |
|
900 |
char token[1024]; |
|
901 |
int pos = 0; |
|
902 |
const char* sp = str; |
|
903 |
int c = *sp++; |
|
14139 | 904 |
while (c != '\0' && pos < (int)(sizeof(token)-1)) { |
1 | 905 |
if (c == '\n') { |
906 |
token[pos++] = '\0'; |
|
907 |
parse_line(token); |
|
908 |
pos = 0; |
|
909 |
} else { |
|
910 |
token[pos++] = c; |
|
911 |
} |
|
912 |
c = *sp++; |
|
913 |
} |
|
914 |
token[pos++] = '\0'; |
|
915 |
parse_line(token); |
|
916 |
} |
|
917 |
||
918 |
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
|
919 |
assert(has_command_file(), "command file must be specified"); |
1 | 920 |
fileStream stream(fopen(cc_file(), "at")); |
921 |
stream.print("# "); |
|
922 |
for (int index = 0; message[index] != '\0'; index++) { |
|
923 |
stream.put(message[index]); |
|
924 |
if (message[index] == '\n') stream.print("# "); |
|
925 |
} |
|
926 |
stream.cr(); |
|
927 |
} |
|
928 |
||
929 |
void CompilerOracle::append_exclude_to_file(methodHandle method) { |
|
12981
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
930 |
assert(has_command_file(), "command file must be specified"); |
1 | 931 |
fileStream stream(fopen(cc_file(), "at")); |
932 |
stream.print("exclude "); |
|
14391
df0a1573d5bd
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
14147
diff
changeset
|
933 |
method->method_holder()->name()->print_symbol_on(&stream); |
1 | 934 |
stream.print("."); |
935 |
method->name()->print_symbol_on(&stream); |
|
936 |
method->signature()->print_symbol_on(&stream); |
|
937 |
stream.cr(); |
|
938 |
stream.cr(); |
|
939 |
} |
|
940 |
||
941 |
||
942 |
void compilerOracle_init() { |
|
943 |
CompilerOracle::parse_from_string(CompileCommand, CompilerOracle::parse_from_line); |
|
944 |
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
|
945 |
if (CompilerOracle::has_command_file()) { |
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
946 |
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
|
947 |
} else { |
603ef19adcb8
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
12981
diff
changeset
|
948 |
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
|
949 |
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
|
950 |
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
|
951 |
"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
|
952 |
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
|
953 |
} |
12981
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
954 |
} |
4584
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
955 |
if (lists[PrintCommand] != NULL) { |
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
956 |
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
|
957 |
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
|
958 |
} else if (FLAG_IS_DEFAULT(DebugNonSafepoints)) { |
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
959 |
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
|
960 |
DebugNonSafepoints = true; |
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
961 |
} |
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
962 |
} |
1 | 963 |
} |
964 |
||
965 |
||
966 |
void CompilerOracle::parse_compile_only(char * line) { |
|
967 |
int i; |
|
968 |
char name[1024]; |
|
969 |
const char* className = NULL; |
|
970 |
const char* methodName = NULL; |
|
971 |
||
972 |
bool have_colon = (strstr(line, "::") != NULL); |
|
973 |
char method_sep = have_colon ? ':' : '.'; |
|
974 |
||
975 |
if (Verbose) { |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23185
diff
changeset
|
976 |
tty->print_cr("%s", line); |
1 | 977 |
} |
978 |
||
979 |
ResourceMark rm; |
|
980 |
while (*line != '\0') { |
|
981 |
MethodMatcher::Mode c_match = MethodMatcher::Exact; |
|
982 |
MethodMatcher::Mode m_match = MethodMatcher::Exact; |
|
983 |
||
984 |
for (i = 0; |
|
985 |
i < 1024 && *line != '\0' && *line != method_sep && *line != ',' && !isspace(*line); |
|
986 |
line++, i++) { |
|
987 |
name[i] = *line; |
|
988 |
if (name[i] == '.') name[i] = '/'; // package prefix uses '/' |
|
989 |
} |
|
990 |
||
991 |
if (i > 0) { |
|
992 |
char* newName = NEW_RESOURCE_ARRAY( char, i + 1); |
|
993 |
if (newName == NULL) |
|
994 |
return; |
|
995 |
strncpy(newName, name, i); |
|
996 |
newName[i] = '\0'; |
|
997 |
||
998 |
if (className == NULL) { |
|
999 |
className = newName; |
|
1000 |
c_match = MethodMatcher::Prefix; |
|
1001 |
} else { |
|
1002 |
methodName = newName; |
|
1003 |
} |
|
1004 |
} |
|
1005 |
||
1006 |
if (*line == method_sep) { |
|
1007 |
if (className == NULL) { |
|
1008 |
className = ""; |
|
1009 |
c_match = MethodMatcher::Any; |
|
1010 |
} else { |
|
1011 |
// foo/bar.blah is an exact match on foo/bar, bar.blah is a suffix match on bar |
|
1012 |
if (strchr(className, '/') != NULL) { |
|
1013 |
c_match = MethodMatcher::Exact; |
|
1014 |
} else { |
|
1015 |
c_match = MethodMatcher::Suffix; |
|
1016 |
} |
|
1017 |
} |
|
1018 |
} else { |
|
1019 |
// got foo or foo/bar |
|
1020 |
if (className == NULL) { |
|
1021 |
ShouldNotReachHere(); |
|
1022 |
} else { |
|
1023 |
// got foo or foo/bar |
|
1024 |
if (strchr(className, '/') != NULL) { |
|
1025 |
c_match = MethodMatcher::Prefix; |
|
1026 |
} else if (className[0] == '\0') { |
|
1027 |
c_match = MethodMatcher::Any; |
|
1028 |
} else { |
|
1029 |
c_match = MethodMatcher::Substring; |
|
1030 |
} |
|
1031 |
} |
|
1032 |
} |
|
1033 |
||
1034 |
// each directive is terminated by , or NUL or . followed by NUL |
|
1035 |
if (*line == ',' || *line == '\0' || (line[0] == '.' && line[1] == '\0')) { |
|
1036 |
if (methodName == NULL) { |
|
1037 |
methodName = ""; |
|
1038 |
if (*line != method_sep) { |
|
1039 |
m_match = MethodMatcher::Any; |
|
1040 |
} |
|
1041 |
} |
|
1042 |
||
1043 |
EXCEPTION_MARK; |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
1044 |
Symbol* c_name = SymbolTable::new_symbol(className, CHECK); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
1045 |
Symbol* m_name = SymbolTable::new_symbol(methodName, CHECK); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
1046 |
Symbol* signature = NULL; |
1 | 1047 |
|
1048 |
add_predicate(CompileOnlyCommand, c_name, c_match, m_name, m_match, signature); |
|
1049 |
if (PrintVMOptions) { |
|
1050 |
tty->print("CompileOnly: compileonly "); |
|
1051 |
lists[CompileOnlyCommand]->print(); |
|
1052 |
} |
|
1053 |
||
1054 |
className = NULL; |
|
1055 |
methodName = NULL; |
|
1056 |
} |
|
1057 |
||
1058 |
line = *line == '\0' ? line : line + 1; |
|
1059 |
} |
|
1060 |
} |