author | kvn |
Tue, 02 Sep 2014 10:26:48 -0700 | |
changeset 26433 | 27020fde2dbf |
parent 26430 | 7f20c536cd5b |
child 26441 | fb92944bb02d |
permissions | -rw-r--r-- |
1 | 1 |
/* |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23185
diff
changeset
|
2 |
* Copyright (c) 1998, 2014, 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 |
tty->print(" "); |
109 |
signature()->print_symbol_on(tty); |
|
110 |
} |
|
111 |
} |
|
112 |
||
113 |
virtual void print() { |
|
114 |
print_base(); |
|
115 |
tty->cr(); |
|
116 |
} |
|
117 |
}; |
|
118 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
119 |
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
|
120 |
_class_name = class_name; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
121 |
_method_name = method_name; |
1 | 122 |
_next = next; |
123 |
_class_mode = MethodMatcher::Exact; |
|
124 |
_method_mode = MethodMatcher::Exact; |
|
125 |
_signature = NULL; |
|
126 |
} |
|
127 |
||
128 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
129 |
MethodMatcher::MethodMatcher(Symbol* class_name, Mode class_mode, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
130 |
Symbol* method_name, Mode method_mode, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
131 |
Symbol* signature, MethodMatcher* next): |
1 | 132 |
_class_mode(class_mode) |
133 |
, _method_mode(method_mode) |
|
134 |
, _next(next) |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
135 |
, _class_name(class_name) |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
136 |
, _method_name(method_name) |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
137 |
, _signature(signature) { |
1 | 138 |
} |
139 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
140 |
bool MethodMatcher::match(Symbol* candidate, Symbol* match, Mode match_mode) { |
1 | 141 |
if (match_mode == Any) { |
142 |
return true; |
|
143 |
} |
|
144 |
||
145 |
if (match_mode == Exact) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
146 |
return candidate == match; |
1 | 147 |
} |
148 |
||
149 |
ResourceMark rm; |
|
150 |
const char * candidate_string = candidate->as_C_string(); |
|
151 |
const char * match_string = match->as_C_string(); |
|
152 |
||
153 |
switch (match_mode) { |
|
154 |
case Prefix: |
|
155 |
return strstr(candidate_string, match_string) == candidate_string; |
|
156 |
||
157 |
case Suffix: { |
|
158 |
size_t clen = strlen(candidate_string); |
|
159 |
size_t mlen = strlen(match_string); |
|
160 |
return clen >= mlen && strcmp(candidate_string + clen - mlen, match_string) == 0; |
|
161 |
} |
|
162 |
||
163 |
case Substring: |
|
164 |
return strstr(candidate_string, match_string) != NULL; |
|
165 |
||
166 |
default: |
|
167 |
return false; |
|
168 |
} |
|
169 |
} |
|
170 |
||
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
171 |
enum OptionType { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
172 |
IntxType, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
173 |
UintxType, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
174 |
BoolType, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
175 |
CcstrType, |
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 |
||
201 |
template<typename T> |
|
202 |
static const T copy_value(const T value) { |
|
203 |
return value; |
|
204 |
} |
|
205 |
||
206 |
template<> const ccstr copy_value<ccstr>(const ccstr value) { |
|
207 |
return (const ccstr)os::strdup_check_oom(value); |
|
208 |
} |
|
209 |
||
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
210 |
template <typename T> |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
211 |
class TypedMethodOptionMatcher : public MethodMatcher { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
212 |
const char* _option; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
213 |
OptionType _type; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
214 |
const T _value; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
215 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
216 |
public: |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
217 |
TypedMethodOptionMatcher(Symbol* class_name, Mode class_mode, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
218 |
Symbol* method_name, Mode method_mode, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
219 |
Symbol* signature, const char* opt, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
220 |
const T value, MethodMatcher* next) : |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
221 |
MethodMatcher(class_name, class_mode, method_name, method_mode, signature, next), |
26433 | 222 |
_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
|
223 |
_option = os::strdup_check_oom(opt); |
25949 | 224 |
} |
225 |
||
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
226 |
~TypedMethodOptionMatcher() { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
227 |
os::free((void*)_option); |
1 | 228 |
} |
229 |
||
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
230 |
TypedMethodOptionMatcher* match(methodHandle method, const char* opt) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
231 |
TypedMethodOptionMatcher* current = this; |
1 | 232 |
while (current != NULL) { |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
233 |
current = (TypedMethodOptionMatcher*)current->find(method); |
1 | 234 |
if (current == NULL) { |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
235 |
return NULL; |
1 | 236 |
} |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
237 |
if (strcmp(current->_option, opt) == 0) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
238 |
return current; |
1 | 239 |
} |
240 |
current = current->next(); |
|
241 |
} |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
242 |
return NULL; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
243 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
244 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
245 |
TypedMethodOptionMatcher* next() { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
246 |
return (TypedMethodOptionMatcher*)_next; |
1 | 247 |
} |
248 |
||
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
249 |
OptionType get_type(void) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
250 |
return _type; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
251 |
}; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
252 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
253 |
T value() { return _value; } |
1 | 254 |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
255 |
void print() { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
256 |
ttyLocker ttyl; |
1 | 257 |
print_base(); |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
258 |
tty->print(" %s", _option); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
259 |
tty->print(" <unknown option type>"); |
1 | 260 |
tty->cr(); |
261 |
} |
|
262 |
}; |
|
263 |
||
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
264 |
template<> |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
265 |
void TypedMethodOptionMatcher<intx>::print() { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
266 |
ttyLocker ttyl; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
267 |
print_base(); |
26433 | 268 |
tty->print(" intx %s", _option); |
269 |
tty->print(" = " INTX_FORMAT, _value); |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
270 |
tty->cr(); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
271 |
}; |
1 | 272 |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
273 |
template<> |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
274 |
void TypedMethodOptionMatcher<uintx>::print() { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
275 |
ttyLocker ttyl; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
276 |
print_base(); |
26433 | 277 |
tty->print(" uintx %s", _option); |
278 |
tty->print(" = " UINTX_FORMAT, _value); |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
279 |
tty->cr(); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
280 |
}; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
281 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
282 |
template<> |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
283 |
void TypedMethodOptionMatcher<bool>::print() { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
284 |
ttyLocker ttyl; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
285 |
print_base(); |
26433 | 286 |
tty->print(" bool %s", _option); |
287 |
tty->print(" = %s", _value ? "true" : "false"); |
|
288 |
tty->cr(); |
|
289 |
}; |
|
290 |
||
291 |
template<> |
|
292 |
void TypedMethodOptionMatcher<ccstr>::print() { |
|
293 |
ttyLocker ttyl; |
|
294 |
print_base(); |
|
295 |
tty->print(" const char* %s", _option); |
|
296 |
tty->print(" = '%s'", _value); |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
297 |
tty->cr(); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
298 |
}; |
1 | 299 |
|
300 |
// this must parallel the command_names below |
|
301 |
enum OracleCommand { |
|
302 |
UnknownCommand = -1, |
|
303 |
OracleFirstCommand = 0, |
|
304 |
BreakCommand = OracleFirstCommand, |
|
305 |
PrintCommand, |
|
306 |
ExcludeCommand, |
|
307 |
InlineCommand, |
|
308 |
DontInlineCommand, |
|
309 |
CompileOnlyCommand, |
|
310 |
LogCommand, |
|
311 |
OptionCommand, |
|
312 |
QuietCommand, |
|
313 |
HelpCommand, |
|
314 |
OracleCommandCount |
|
315 |
}; |
|
316 |
||
317 |
// this must parallel the enum OracleCommand |
|
318 |
static const char * command_names[] = { |
|
319 |
"break", |
|
320 |
"print", |
|
321 |
"exclude", |
|
322 |
"inline", |
|
323 |
"dontinline", |
|
324 |
"compileonly", |
|
325 |
"log", |
|
326 |
"option", |
|
327 |
"quiet", |
|
328 |
"help" |
|
329 |
}; |
|
330 |
||
331 |
class MethodMatcher; |
|
332 |
static MethodMatcher* lists[OracleCommandCount] = { 0, }; |
|
333 |
||
334 |
||
335 |
static bool check_predicate(OracleCommand command, methodHandle method) { |
|
336 |
return ((lists[command] != NULL) && |
|
337 |
!method.is_null() && |
|
338 |
lists[command]->match(method)); |
|
339 |
} |
|
340 |
||
341 |
||
342 |
static MethodMatcher* add_predicate(OracleCommand command, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
343 |
Symbol* class_name, MethodMatcher::Mode c_mode, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
344 |
Symbol* method_name, MethodMatcher::Mode m_mode, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
345 |
Symbol* signature) { |
1 | 346 |
assert(command != OptionCommand, "must use add_option_string"); |
347 |
if (command == LogCommand && !LogCompilation && lists[LogCommand] == NULL) |
|
348 |
tty->print_cr("Warning: +LogCompilation must be enabled in order for individual methods to be logged."); |
|
349 |
lists[command] = new MethodMatcher(class_name, c_mode, method_name, m_mode, signature, lists[command]); |
|
350 |
return lists[command]; |
|
351 |
} |
|
352 |
||
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
353 |
template<typename T> |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
354 |
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
|
355 |
Symbol* method_name, MethodMatcher::Mode m_mode, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
356 |
Symbol* signature, |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
357 |
const char* option, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
358 |
T value) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
359 |
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
|
360 |
signature, option, value, lists[OptionCommand]); |
1 | 361 |
return lists[OptionCommand]; |
362 |
} |
|
363 |
||
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
364 |
template<typename T> |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
365 |
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
|
366 |
TypedMethodOptionMatcher<T>* m; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
367 |
if (lists[OptionCommand] != NULL |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
368 |
&& (m = ((TypedMethodOptionMatcher<T>*)lists[OptionCommand])->match(method, option)) != NULL |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
369 |
&& m->get_type() == get_type_for<T>()) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
370 |
value = m->value(); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
371 |
return true; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
372 |
} else { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
373 |
return false; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
374 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
375 |
} |
1 | 376 |
|
377 |
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
|
378 |
bool value = false; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
379 |
get_option_value(method, option, value); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
380 |
return value; |
1 | 381 |
} |
382 |
||
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
383 |
template<typename T> |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
384 |
bool CompilerOracle::has_option_value(methodHandle method, const char* option, T& value) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
385 |
return get_option_value(method, option, value); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
386 |
} |
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 |
// Explicit instantiation for all OptionTypes supported. |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
389 |
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
|
390 |
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
|
391 |
template bool CompilerOracle::has_option_value<bool>(methodHandle method, const char* option, bool& value); |
26433 | 392 |
template bool CompilerOracle::has_option_value<ccstr>(methodHandle method, const char* option, ccstr& value); |
1 | 393 |
|
394 |
bool CompilerOracle::should_exclude(methodHandle method, bool& quietly) { |
|
395 |
quietly = true; |
|
396 |
if (lists[ExcludeCommand] != NULL) { |
|
397 |
if (lists[ExcludeCommand]->match(method)) { |
|
398 |
quietly = _quiet; |
|
399 |
return true; |
|
400 |
} |
|
401 |
} |
|
402 |
||
403 |
if (lists[CompileOnlyCommand] != NULL) { |
|
404 |
return !lists[CompileOnlyCommand]->match(method); |
|
405 |
} |
|
406 |
return false; |
|
407 |
} |
|
408 |
||
409 |
||
410 |
bool CompilerOracle::should_inline(methodHandle method) { |
|
411 |
return (check_predicate(InlineCommand, method)); |
|
412 |
} |
|
413 |
||
414 |
||
415 |
bool CompilerOracle::should_not_inline(methodHandle method) { |
|
416 |
return (check_predicate(DontInlineCommand, method)); |
|
417 |
} |
|
418 |
||
419 |
||
420 |
bool CompilerOracle::should_print(methodHandle method) { |
|
421 |
return (check_predicate(PrintCommand, method)); |
|
422 |
} |
|
423 |
||
24658
e41df2fc6e87
8042727: nsk/jdb/unwatch/unwatch001 crash in InstanceKlass::methods_do(void (*)(Method*))
coleenp
parents:
24424
diff
changeset
|
424 |
bool CompilerOracle::should_print_methods() { |
e41df2fc6e87
8042727: nsk/jdb/unwatch/unwatch001 crash in InstanceKlass::methods_do(void (*)(Method*))
coleenp
parents:
24424
diff
changeset
|
425 |
return lists[PrintCommand] != NULL; |
e41df2fc6e87
8042727: nsk/jdb/unwatch/unwatch001 crash in InstanceKlass::methods_do(void (*)(Method*))
coleenp
parents:
24424
diff
changeset
|
426 |
} |
1 | 427 |
|
428 |
bool CompilerOracle::should_log(methodHandle method) { |
|
429 |
if (!LogCompilation) return false; |
|
430 |
if (lists[LogCommand] == NULL) return true; // by default, log all |
|
431 |
return (check_predicate(LogCommand, method)); |
|
432 |
} |
|
433 |
||
434 |
||
435 |
bool CompilerOracle::should_break_at(methodHandle method) { |
|
436 |
return check_predicate(BreakCommand, method); |
|
437 |
} |
|
438 |
||
439 |
||
440 |
static OracleCommand parse_command_name(const char * line, int* bytes_read) { |
|
441 |
assert(ARRAY_SIZE(command_names) == OracleCommandCount, |
|
442 |
"command_names size mismatch"); |
|
443 |
||
444 |
*bytes_read = 0; |
|
7701
766eb9258574
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
7397
diff
changeset
|
445 |
char command[33]; |
1 | 446 |
int result = sscanf(line, "%32[a-z]%n", command, bytes_read); |
447 |
for (uint i = 0; i < ARRAY_SIZE(command_names); i++) { |
|
448 |
if (strcmp(command, command_names[i]) == 0) { |
|
449 |
return (OracleCommand)i; |
|
450 |
} |
|
451 |
} |
|
452 |
return UnknownCommand; |
|
453 |
} |
|
454 |
||
455 |
||
456 |
static void usage() { |
|
457 |
tty->print_cr(" CompileCommand and the CompilerOracle allows simple control over"); |
|
458 |
tty->print_cr(" what's allowed to be compiled. The standard supported directives"); |
|
459 |
tty->print_cr(" are exclude and compileonly. The exclude directive stops a method"); |
|
460 |
tty->print_cr(" from being compiled and compileonly excludes all methods except for"); |
|
461 |
tty->print_cr(" the ones mentioned by compileonly directives. The basic form of"); |
|
462 |
tty->print_cr(" all commands is a command name followed by the name of the method"); |
|
463 |
tty->print_cr(" in one of two forms: the standard class file format as in"); |
|
464 |
tty->print_cr(" class/name.methodName or the PrintCompilation format"); |
|
465 |
tty->print_cr(" class.name::methodName. The method name can optionally be followed"); |
|
466 |
tty->print_cr(" by a space then the signature of the method in the class file"); |
|
467 |
tty->print_cr(" format. Otherwise the directive applies to all methods with the"); |
|
468 |
tty->print_cr(" same name and class regardless of signature. Leading and trailing"); |
|
469 |
tty->print_cr(" *'s in the class and/or method name allows a small amount of"); |
|
470 |
tty->print_cr(" wildcarding. "); |
|
471 |
tty->cr(); |
|
472 |
tty->print_cr(" Examples:"); |
|
473 |
tty->cr(); |
|
474 |
tty->print_cr(" exclude java/lang/StringBuffer.append"); |
|
475 |
tty->print_cr(" compileonly java/lang/StringBuffer.toString ()Ljava/lang/String;"); |
|
476 |
tty->print_cr(" exclude java/lang/String*.*"); |
|
477 |
tty->print_cr(" exclude *.toString"); |
|
478 |
} |
|
479 |
||
480 |
||
481 |
// The characters allowed in a class or method name. All characters > 0x7f |
|
482 |
// are allowed in order to handle obfuscated class files (e.g. Volano) |
|
483 |
#define RANGEBASE "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$_<>" \ |
|
484 |
"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" \ |
|
485 |
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" \ |
|
486 |
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" \ |
|
487 |
"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" \ |
|
488 |
"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" \ |
|
489 |
"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" \ |
|
490 |
"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef" \ |
|
491 |
"\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff" |
|
492 |
||
493 |
#define RANGE0 "[*" RANGEBASE "]" |
|
494 |
#define RANGESLASH "[*" RANGEBASE "/]" |
|
495 |
||
496 |
static MethodMatcher::Mode check_mode(char name[], const char*& error_msg) { |
|
497 |
int match = MethodMatcher::Exact; |
|
4584
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
498 |
while (name[0] == '*') { |
1 | 499 |
match |= MethodMatcher::Suffix; |
500 |
strcpy(name, name + 1); |
|
501 |
} |
|
502 |
||
4584
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
503 |
if (strcmp(name, "*") == 0) return MethodMatcher::Any; |
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
504 |
|
1 | 505 |
size_t len = strlen(name); |
4584
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
506 |
while (len > 0 && name[len - 1] == '*') { |
1 | 507 |
match |= MethodMatcher::Prefix; |
4584
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
508 |
name[--len] = '\0'; |
1 | 509 |
} |
510 |
||
511 |
if (strstr(name, "*") != NULL) { |
|
512 |
error_msg = " Embedded * not allowed"; |
|
513 |
return MethodMatcher::Unknown; |
|
514 |
} |
|
515 |
return (MethodMatcher::Mode)match; |
|
516 |
} |
|
517 |
||
518 |
static bool scan_line(const char * line, |
|
519 |
char class_name[], MethodMatcher::Mode* c_mode, |
|
520 |
char method_name[], MethodMatcher::Mode* m_mode, |
|
521 |
int* bytes_read, const char*& error_msg) { |
|
522 |
*bytes_read = 0; |
|
523 |
error_msg = NULL; |
|
23185 | 524 |
if (2 == sscanf(line, "%*[ \t]%255" RANGESLASH "%*[ ]" "%255" RANGE0 "%n", class_name, method_name, bytes_read)) { |
525 |
*c_mode = check_mode(class_name, error_msg); |
|
526 |
*m_mode = check_mode(method_name, error_msg); |
|
527 |
return *c_mode != MethodMatcher::Unknown && *m_mode != MethodMatcher::Unknown; |
|
1 | 528 |
} |
529 |
return false; |
|
530 |
} |
|
531 |
||
532 |
||
533 |
||
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
534 |
// 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
|
535 |
// On failure, error_msg contains description for the first error. |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
536 |
// For future extensions: set error_msg on first error. |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
537 |
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
|
538 |
Symbol* c_name, MethodMatcher::Mode c_match, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
539 |
Symbol* m_name, MethodMatcher::Mode m_match, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
540 |
Symbol* signature, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
541 |
char* errorbuf, const int buf_size) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
542 |
total_bytes_read = 0; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
543 |
int bytes_read = 0; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
544 |
char flag[256]; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
545 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
546 |
// Read flag name. |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
547 |
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
|
548 |
line += bytes_read; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
549 |
total_bytes_read += bytes_read; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
550 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
551 |
// Read value. |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
552 |
if (strcmp(type, "intx") == 0) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
553 |
intx value; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
554 |
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
|
555 |
total_bytes_read += bytes_read; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
556 |
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
|
557 |
} else { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
558 |
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
|
559 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
560 |
} else if (strcmp(type, "uintx") == 0) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
561 |
uintx value; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
562 |
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
|
563 |
total_bytes_read += bytes_read; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
564 |
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
|
565 |
} else { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
566 |
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
|
567 |
} |
26433 | 568 |
} else if (strcmp(type, "ccstr") == 0) { |
569 |
ResourceMark rm; |
|
570 |
char* value = NEW_RESOURCE_ARRAY(char, strlen(line) + 1); |
|
571 |
if (sscanf(line, "%*[ \t]%255[_a-zA-Z0-9]%n", value, &bytes_read) == 1) { |
|
572 |
total_bytes_read += bytes_read; |
|
573 |
return add_option_string(c_name, c_match, m_name, m_match, signature, flag, (ccstr)value); |
|
574 |
} else { |
|
575 |
jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s", flag, type); |
|
576 |
} |
|
577 |
} else if (strcmp(type, "ccstrlist") == 0) { |
|
578 |
// Accumulates several strings into one. The internal type is ccstr. |
|
579 |
ResourceMark rm; |
|
580 |
char* value = NEW_RESOURCE_ARRAY(char, strlen(line) + 1); |
|
581 |
char* next_value = value; |
|
582 |
if (sscanf(line, "%*[ \t]%255[_a-zA-Z0-9]%n", next_value, &bytes_read) == 1) { |
|
583 |
total_bytes_read += bytes_read; |
|
584 |
line += bytes_read; |
|
585 |
next_value += bytes_read; |
|
586 |
char* end_value = next_value-1; |
|
587 |
while (sscanf(line, "%*[ \t]%255[_a-zA-Z0-9]%n", next_value, &bytes_read) == 1) { |
|
588 |
total_bytes_read += bytes_read; |
|
589 |
line += bytes_read; |
|
590 |
*end_value = ' '; // override '\0' |
|
591 |
next_value += bytes_read; |
|
592 |
end_value = next_value-1; |
|
593 |
} |
|
594 |
return add_option_string(c_name, c_match, m_name, m_match, signature, flag, (ccstr)value); |
|
595 |
} else { |
|
596 |
jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s", flag, type); |
|
597 |
} |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
598 |
} else if (strcmp(type, "bool") == 0) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
599 |
char value[256]; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
600 |
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
|
601 |
if (strcmp(value, "true") == 0) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
602 |
total_bytes_read += bytes_read; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
603 |
return add_option_string(c_name, c_match, m_name, m_match, signature, flag, true); |
26433 | 604 |
} else if (strcmp(value, "false") == 0) { |
605 |
total_bytes_read += bytes_read; |
|
606 |
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
|
607 |
} else { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
608 |
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
|
609 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
610 |
} else { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
611 |
jio_snprintf(errorbuf, sizeof(errorbuf), " 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
|
612 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
613 |
} else { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
614 |
jio_snprintf(errorbuf, sizeof(errorbuf), " Type %s not supported ", type); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
615 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
616 |
} else { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
617 |
jio_snprintf(errorbuf, sizeof(errorbuf), " Flag name for type %s should be alphanumeric ", type); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
618 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
619 |
return NULL; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
620 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
621 |
|
1 | 622 |
void CompilerOracle::parse_from_line(char* line) { |
623 |
if (line[0] == '\0') return; |
|
624 |
if (line[0] == '#') return; |
|
625 |
||
626 |
bool have_colon = (strstr(line, "::") != NULL); |
|
627 |
for (char* lp = line; *lp != '\0'; lp++) { |
|
628 |
// Allow '.' to separate the class name from the method name. |
|
629 |
// This is the preferred spelling of methods: |
|
630 |
// exclude java/lang/String.indexOf(I)I |
|
631 |
// Allow ',' for spaces (eases command line quoting). |
|
632 |
// exclude,java/lang/String.indexOf |
|
633 |
// For backward compatibility, allow space as separator also. |
|
634 |
// exclude java/lang/String indexOf |
|
635 |
// exclude,java/lang/String,indexOf |
|
636 |
// 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
|
637 |
// as produced by Method::print_short_name: |
1 | 638 |
// exclude java.lang.String::indexOf |
639 |
// For simple implementation convenience here, convert them all to space. |
|
640 |
if (have_colon) { |
|
641 |
if (*lp == '.') *lp = '/'; // dots build the package prefix |
|
642 |
if (*lp == ':') *lp = ' '; |
|
643 |
} |
|
644 |
if (*lp == ',' || *lp == '.') *lp = ' '; |
|
645 |
} |
|
646 |
||
647 |
char* original_line = line; |
|
648 |
int bytes_read; |
|
649 |
OracleCommand command = parse_command_name(line, &bytes_read); |
|
650 |
line += bytes_read; |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
651 |
ResourceMark rm; |
1 | 652 |
|
7701
766eb9258574
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
7397
diff
changeset
|
653 |
if (command == UnknownCommand) { |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
654 |
ttyLocker ttyl; |
7701
766eb9258574
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
7397
diff
changeset
|
655 |
tty->print_cr("CompilerOracle: unrecognized line"); |
766eb9258574
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
7397
diff
changeset
|
656 |
tty->print_cr(" \"%s\"", original_line); |
766eb9258574
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
7397
diff
changeset
|
657 |
return; |
766eb9258574
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
7397
diff
changeset
|
658 |
} |
766eb9258574
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
7397
diff
changeset
|
659 |
|
1 | 660 |
if (command == QuietCommand) { |
661 |
_quiet = true; |
|
662 |
return; |
|
663 |
} |
|
664 |
||
665 |
if (command == HelpCommand) { |
|
666 |
usage(); |
|
667 |
return; |
|
668 |
} |
|
669 |
||
670 |
MethodMatcher::Mode c_match = MethodMatcher::Exact; |
|
671 |
MethodMatcher::Mode m_match = MethodMatcher::Exact; |
|
672 |
char class_name[256]; |
|
673 |
char method_name[256]; |
|
674 |
char sig[1024]; |
|
675 |
char errorbuf[1024]; |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
676 |
const char* error_msg = NULL; // description of first error that appears |
1 | 677 |
MethodMatcher* match = NULL; |
678 |
||
679 |
if (scan_line(line, class_name, &c_match, method_name, &m_match, &bytes_read, error_msg)) { |
|
680 |
EXCEPTION_MARK; |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
681 |
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
|
682 |
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
|
683 |
Symbol* signature = NULL; |
1 | 684 |
|
685 |
line += bytes_read; |
|
686 |
// there might be a signature following the method. |
|
687 |
// signatures always begin with ( so match that by hand |
|
7701
766eb9258574
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
7397
diff
changeset
|
688 |
if (1 == sscanf(line, "%*[ \t](%254[[);/" RANGEBASE "]%n", sig + 1, &bytes_read)) { |
1 | 689 |
sig[0] = '('; |
690 |
line += bytes_read; |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
691 |
signature = SymbolTable::new_symbol(sig, CHECK); |
1 | 692 |
} |
693 |
||
694 |
if (command == OptionCommand) { |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
695 |
// Look for trailing options. |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
696 |
// |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
697 |
// Two types of trailing options are |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
698 |
// supported: |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
699 |
// |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
700 |
// (1) CompileCommand=option,Klass::method,flag |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
701 |
// (2) CompileCommand=option,Klass::method,type,flag,value |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
702 |
// |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
703 |
// Type (1) is used to support ciMethod::has_option("someflag") |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
704 |
// (i.e., to check if a flag "someflag" is enabled for a method). |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
705 |
// |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
706 |
// Type (2) is used to support options with a value. Values can have the |
26433 | 707 |
// the following types: intx, uintx, bool, ccstr, and ccstrlist. |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
708 |
// |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
709 |
// For future extensions: extend scan_flag_and_value() |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
710 |
char option[256]; // stores flag for Type (1) and type of Type (2) |
1 | 711 |
while (sscanf(line, "%*[ \t]%255[a-zA-Z0-9]%n", option, &bytes_read) == 1) { |
712 |
if (match != NULL && !_quiet) { |
|
713 |
// Print out the last match added |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
714 |
ttyLocker ttyl; |
1 | 715 |
tty->print("CompilerOracle: %s ", command_names[command]); |
716 |
match->print(); |
|
717 |
} |
|
718 |
line += bytes_read; |
|
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
719 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
720 |
if (strcmp(option, "intx") == 0 |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
721 |
|| strcmp(option, "uintx") == 0 |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
722 |
|| strcmp(option, "bool") == 0 |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
723 |
|| strcmp(option, "ccstr") == 0 |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
724 |
|| strcmp(option, "ccstrlist") == 0 |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
725 |
) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
726 |
|
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
727 |
// Type (2) option: parse flag name and value. |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
728 |
match = scan_flag_and_value(option, line, bytes_read, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
729 |
c_name, c_match, m_name, m_match, signature, |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
730 |
errorbuf, sizeof(errorbuf)); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
731 |
if (match == NULL) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
732 |
error_msg = errorbuf; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
733 |
break; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
734 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
735 |
line += bytes_read; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
736 |
} else { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
737 |
// Type (1) option |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
738 |
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
|
739 |
} |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
740 |
} // while( |
1 | 741 |
} else { |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
742 |
match = add_predicate(command, c_name, c_match, m_name, m_match, signature); |
1 | 743 |
} |
744 |
} |
|
745 |
||
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
746 |
ttyLocker ttyl; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
747 |
if (error_msg != NULL) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
748 |
// an error has happened |
1 | 749 |
tty->print_cr("CompilerOracle: unrecognized line"); |
750 |
tty->print_cr(" \"%s\"", original_line); |
|
751 |
if (error_msg != NULL) { |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23185
diff
changeset
|
752 |
tty->print_cr("%s", error_msg); |
1 | 753 |
} |
26430
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
754 |
} else { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
755 |
// check for remaining characters |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
756 |
bytes_read = 0; |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
757 |
sscanf(line, "%*[ \t]%n", &bytes_read); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
758 |
if (line[bytes_read] != '\0') { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
759 |
tty->print_cr("CompilerOracle: unrecognized line"); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
760 |
tty->print_cr(" \"%s\"", original_line); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
761 |
tty->print_cr(" Unrecognized text %s after command ", line); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
762 |
} else if (match != NULL && !_quiet) { |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
763 |
tty->print("CompilerOracle: %s ", command_names[command]); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
764 |
match->print(); |
7f20c536cd5b
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
25949
diff
changeset
|
765 |
} |
1 | 766 |
} |
767 |
} |
|
768 |
||
13194
603ef19adcb8
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
12981
diff
changeset
|
769 |
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
|
770 |
|
1 | 771 |
static const char* cc_file() { |
12981
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
772 |
#ifdef ASSERT |
1 | 773 |
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
|
774 |
return default_cc_file; |
12981
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
775 |
#endif |
1 | 776 |
return CompileCommandFile; |
777 |
} |
|
12981
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
778 |
|
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
779 |
bool CompilerOracle::has_command_file() { |
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
780 |
return cc_file() != NULL; |
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
781 |
} |
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
782 |
|
1 | 783 |
bool CompilerOracle::_quiet = false; |
784 |
||
785 |
void CompilerOracle::parse_from_file() { |
|
12981
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
786 |
assert(has_command_file(), "command file must be specified"); |
1 | 787 |
FILE* stream = fopen(cc_file(), "rt"); |
788 |
if (stream == NULL) return; |
|
789 |
||
790 |
char token[1024]; |
|
791 |
int pos = 0; |
|
792 |
int c = getc(stream); |
|
14139 | 793 |
while(c != EOF && pos < (int)(sizeof(token)-1)) { |
1 | 794 |
if (c == '\n') { |
795 |
token[pos++] = '\0'; |
|
796 |
parse_from_line(token); |
|
797 |
pos = 0; |
|
798 |
} else { |
|
799 |
token[pos++] = c; |
|
800 |
} |
|
801 |
c = getc(stream); |
|
802 |
} |
|
803 |
token[pos++] = '\0'; |
|
804 |
parse_from_line(token); |
|
805 |
||
806 |
fclose(stream); |
|
807 |
} |
|
808 |
||
809 |
void CompilerOracle::parse_from_string(const char* str, void (*parse_line)(char*)) { |
|
810 |
char token[1024]; |
|
811 |
int pos = 0; |
|
812 |
const char* sp = str; |
|
813 |
int c = *sp++; |
|
14139 | 814 |
while (c != '\0' && pos < (int)(sizeof(token)-1)) { |
1 | 815 |
if (c == '\n') { |
816 |
token[pos++] = '\0'; |
|
817 |
parse_line(token); |
|
818 |
pos = 0; |
|
819 |
} else { |
|
820 |
token[pos++] = c; |
|
821 |
} |
|
822 |
c = *sp++; |
|
823 |
} |
|
824 |
token[pos++] = '\0'; |
|
825 |
parse_line(token); |
|
826 |
} |
|
827 |
||
828 |
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
|
829 |
assert(has_command_file(), "command file must be specified"); |
1 | 830 |
fileStream stream(fopen(cc_file(), "at")); |
831 |
stream.print("# "); |
|
832 |
for (int index = 0; message[index] != '\0'; index++) { |
|
833 |
stream.put(message[index]); |
|
834 |
if (message[index] == '\n') stream.print("# "); |
|
835 |
} |
|
836 |
stream.cr(); |
|
837 |
} |
|
838 |
||
839 |
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
|
840 |
assert(has_command_file(), "command file must be specified"); |
1 | 841 |
fileStream stream(fopen(cc_file(), "at")); |
842 |
stream.print("exclude "); |
|
14391
df0a1573d5bd
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
14147
diff
changeset
|
843 |
method->method_holder()->name()->print_symbol_on(&stream); |
1 | 844 |
stream.print("."); |
845 |
method->name()->print_symbol_on(&stream); |
|
846 |
method->signature()->print_symbol_on(&stream); |
|
847 |
stream.cr(); |
|
848 |
stream.cr(); |
|
849 |
} |
|
850 |
||
851 |
||
852 |
void compilerOracle_init() { |
|
853 |
CompilerOracle::parse_from_string(CompileCommand, CompilerOracle::parse_from_line); |
|
854 |
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
|
855 |
if (CompilerOracle::has_command_file()) { |
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
856 |
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
|
857 |
} else { |
603ef19adcb8
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
12981
diff
changeset
|
858 |
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
|
859 |
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
|
860 |
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
|
861 |
"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
|
862 |
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
|
863 |
} |
12981
b557c10f5444
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
8921
diff
changeset
|
864 |
} |
4584
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
865 |
if (lists[PrintCommand] != NULL) { |
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
866 |
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
|
867 |
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
|
868 |
} else if (FLAG_IS_DEFAULT(DebugNonSafepoints)) { |
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
869 |
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
|
870 |
DebugNonSafepoints = true; |
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
871 |
} |
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1
diff
changeset
|
872 |
} |
1 | 873 |
} |
874 |
||
875 |
||
876 |
void CompilerOracle::parse_compile_only(char * line) { |
|
877 |
int i; |
|
878 |
char name[1024]; |
|
879 |
const char* className = NULL; |
|
880 |
const char* methodName = NULL; |
|
881 |
||
882 |
bool have_colon = (strstr(line, "::") != NULL); |
|
883 |
char method_sep = have_colon ? ':' : '.'; |
|
884 |
||
885 |
if (Verbose) { |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23185
diff
changeset
|
886 |
tty->print_cr("%s", line); |
1 | 887 |
} |
888 |
||
889 |
ResourceMark rm; |
|
890 |
while (*line != '\0') { |
|
891 |
MethodMatcher::Mode c_match = MethodMatcher::Exact; |
|
892 |
MethodMatcher::Mode m_match = MethodMatcher::Exact; |
|
893 |
||
894 |
for (i = 0; |
|
895 |
i < 1024 && *line != '\0' && *line != method_sep && *line != ',' && !isspace(*line); |
|
896 |
line++, i++) { |
|
897 |
name[i] = *line; |
|
898 |
if (name[i] == '.') name[i] = '/'; // package prefix uses '/' |
|
899 |
} |
|
900 |
||
901 |
if (i > 0) { |
|
902 |
char* newName = NEW_RESOURCE_ARRAY( char, i + 1); |
|
903 |
if (newName == NULL) |
|
904 |
return; |
|
905 |
strncpy(newName, name, i); |
|
906 |
newName[i] = '\0'; |
|
907 |
||
908 |
if (className == NULL) { |
|
909 |
className = newName; |
|
910 |
c_match = MethodMatcher::Prefix; |
|
911 |
} else { |
|
912 |
methodName = newName; |
|
913 |
} |
|
914 |
} |
|
915 |
||
916 |
if (*line == method_sep) { |
|
917 |
if (className == NULL) { |
|
918 |
className = ""; |
|
919 |
c_match = MethodMatcher::Any; |
|
920 |
} else { |
|
921 |
// foo/bar.blah is an exact match on foo/bar, bar.blah is a suffix match on bar |
|
922 |
if (strchr(className, '/') != NULL) { |
|
923 |
c_match = MethodMatcher::Exact; |
|
924 |
} else { |
|
925 |
c_match = MethodMatcher::Suffix; |
|
926 |
} |
|
927 |
} |
|
928 |
} else { |
|
929 |
// got foo or foo/bar |
|
930 |
if (className == NULL) { |
|
931 |
ShouldNotReachHere(); |
|
932 |
} else { |
|
933 |
// got foo or foo/bar |
|
934 |
if (strchr(className, '/') != NULL) { |
|
935 |
c_match = MethodMatcher::Prefix; |
|
936 |
} else if (className[0] == '\0') { |
|
937 |
c_match = MethodMatcher::Any; |
|
938 |
} else { |
|
939 |
c_match = MethodMatcher::Substring; |
|
940 |
} |
|
941 |
} |
|
942 |
} |
|
943 |
||
944 |
// each directive is terminated by , or NUL or . followed by NUL |
|
945 |
if (*line == ',' || *line == '\0' || (line[0] == '.' && line[1] == '\0')) { |
|
946 |
if (methodName == NULL) { |
|
947 |
methodName = ""; |
|
948 |
if (*line != method_sep) { |
|
949 |
m_match = MethodMatcher::Any; |
|
950 |
} |
|
951 |
} |
|
952 |
||
953 |
EXCEPTION_MARK; |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
954 |
Symbol* c_name = SymbolTable::new_symbol(className, CHECK); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
955 |
Symbol* m_name = SymbolTable::new_symbol(methodName, CHECK); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7701
diff
changeset
|
956 |
Symbol* signature = NULL; |
1 | 957 |
|
958 |
add_predicate(CompileOnlyCommand, c_name, c_match, m_name, m_match, signature); |
|
959 |
if (PrintVMOptions) { |
|
960 |
tty->print("CompileOnly: compileonly "); |
|
961 |
lists[CompileOnlyCommand]->print(); |
|
962 |
} |
|
963 |
||
964 |
className = NULL; |
|
965 |
methodName = NULL; |
|
966 |
} |
|
967 |
||
968 |
line = *line == '\0' ? line : line + 1; |
|
969 |
} |
|
970 |
} |