Mercurial > hg > truffle
annotate src/share/vm/compiler/compilerOracle.cpp @ 21187:f74b9f898cf2
NodeLIRBuilder: move creation of jump from moveToPhi() to visitEndNode().
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Mon, 20 Apr 2015 11:56:21 +0200 |
parents | 7848fc12602b |
children |
rev | line source |
---|---|
0 | 1 /* |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
14223
diff
changeset
|
2 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1155
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1155
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1155
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 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" | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6204
diff
changeset
|
31 #include "oops/method.hpp" |
1972 | 32 #include "oops/oop.inline.hpp" |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
33 #include "oops/symbol.hpp" |
1972 | 34 #include "runtime/handles.inline.hpp" |
35 #include "runtime/jniHandles.hpp" | |
0 | 36 |
6197 | 37 class MethodMatcher : public CHeapObj<mtCompiler> { |
0 | 38 public: |
39 enum Mode { | |
40 Exact, | |
41 Prefix = 1, | |
42 Suffix = 2, | |
43 Substring = Prefix | Suffix, | |
44 Any, | |
45 Unknown = -1 | |
46 }; | |
47 | |
48 protected: | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
49 Symbol* _class_name; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
50 Symbol* _method_name; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
51 Symbol* _signature; |
0 | 52 Mode _class_mode; |
53 Mode _method_mode; | |
54 MethodMatcher* _next; | |
55 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
56 static bool match(Symbol* candidate, Symbol* match, Mode match_mode); |
0 | 57 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
58 Symbol* class_name() const { return _class_name; } |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
59 Symbol* method_name() const { return _method_name; } |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
60 Symbol* signature() const { return _signature; } |
0 | 61 |
62 public: | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
63 MethodMatcher(Symbol* class_name, Mode class_mode, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
64 Symbol* method_name, Mode method_mode, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
65 Symbol* signature, MethodMatcher* next); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
66 MethodMatcher(Symbol* class_name, Symbol* method_name, MethodMatcher* next); |
0 | 67 |
68 // utility method | |
69 MethodMatcher* find(methodHandle method) { | |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6909
diff
changeset
|
70 Symbol* class_name = method->method_holder()->name(); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
71 Symbol* method_name = method->name(); |
0 | 72 for (MethodMatcher* current = this; current != NULL; current = current->_next) { |
73 if (match(class_name, current->class_name(), current->_class_mode) && | |
74 match(method_name, current->method_name(), current->_method_mode) && | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
75 (current->signature() == NULL || current->signature() == method->signature())) { |
0 | 76 return current; |
77 } | |
78 } | |
79 return NULL; | |
80 } | |
81 | |
82 bool match(methodHandle method) { | |
83 return find(method) != NULL; | |
84 } | |
85 | |
86 MethodMatcher* next() const { return _next; } | |
87 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
88 static void print_symbol(Symbol* h, Mode mode) { |
0 | 89 ResourceMark rm; |
90 | |
91 if (mode == Suffix || mode == Substring || mode == Any) { | |
92 tty->print("*"); | |
93 } | |
94 if (mode != Any) { | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
95 h->print_symbol_on(tty); |
0 | 96 } |
97 if (mode == Prefix || mode == Substring) { | |
98 tty->print("*"); | |
99 } | |
100 } | |
101 | |
102 void print_base() { | |
103 print_symbol(class_name(), _class_mode); | |
104 tty->print("."); | |
105 print_symbol(method_name(), _method_mode); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
106 if (signature() != NULL) { |
0 | 107 tty->print(" "); |
108 signature()->print_symbol_on(tty); | |
109 } | |
110 } | |
111 | |
112 virtual void print() { | |
113 print_base(); | |
114 tty->cr(); | |
115 } | |
116 }; | |
117 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
118 MethodMatcher::MethodMatcher(Symbol* class_name, Symbol* method_name, MethodMatcher* next) { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
119 _class_name = class_name; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
120 _method_name = method_name; |
0 | 121 _next = next; |
122 _class_mode = MethodMatcher::Exact; | |
123 _method_mode = MethodMatcher::Exact; | |
124 _signature = NULL; | |
125 } | |
126 | |
127 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
128 MethodMatcher::MethodMatcher(Symbol* class_name, Mode class_mode, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
129 Symbol* method_name, Mode method_mode, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
130 Symbol* signature, MethodMatcher* next): |
0 | 131 _class_mode(class_mode) |
132 , _method_mode(method_mode) | |
133 , _next(next) | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
134 , _class_name(class_name) |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
135 , _method_name(method_name) |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
136 , _signature(signature) { |
0 | 137 } |
138 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
139 bool MethodMatcher::match(Symbol* candidate, Symbol* match, Mode match_mode) { |
0 | 140 if (match_mode == Any) { |
141 return true; | |
142 } | |
143 | |
144 if (match_mode == Exact) { | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
145 return candidate == match; |
0 | 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 | |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
170 enum OptionType { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
171 IntxType, |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
172 UintxType, |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
173 BoolType, |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
174 CcstrType, |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
175 UnknownType |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
176 }; |
0 | 177 |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
178 /* Methods to map real type names to OptionType */ |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
179 template<typename T> |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
180 static OptionType get_type_for() { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
181 return UnknownType; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
182 }; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
183 |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
184 template<> OptionType get_type_for<intx>() { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
185 return IntxType; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
186 } |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
187 |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
188 template<> OptionType get_type_for<uintx>() { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
189 return UintxType; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
190 } |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
191 |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
192 template<> OptionType get_type_for<bool>() { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
193 return BoolType; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
194 } |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
195 |
20430 | 196 template<> OptionType get_type_for<ccstr>() { |
197 return CcstrType; | |
198 } | |
199 | |
200 template<typename T> | |
201 static const T copy_value(const T value) { | |
202 return value; | |
203 } | |
204 | |
205 template<> const ccstr copy_value<ccstr>(const ccstr value) { | |
206 return (const ccstr)strdup(value); | |
207 } | |
208 | |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
209 template <typename T> |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
210 class TypedMethodOptionMatcher : public MethodMatcher { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
211 const char* _option; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
212 OptionType _type; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
213 const T _value; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
214 |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
215 public: |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
216 TypedMethodOptionMatcher(Symbol* class_name, Mode class_mode, |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
217 Symbol* method_name, Mode method_mode, |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
218 Symbol* signature, const char* opt, |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
219 const T value, MethodMatcher* next) : |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
220 MethodMatcher(class_name, class_mode, method_name, method_mode, signature, next), |
20430 | 221 _type(get_type_for<T>()), _value(copy_value<T>(value)) { |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
222 _option = strdup(opt); |
0 | 223 } |
224 | |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
225 ~TypedMethodOptionMatcher() { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
226 free((void*)_option); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
227 } |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
228 |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
229 TypedMethodOptionMatcher* match(methodHandle method, const char* opt) { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
230 TypedMethodOptionMatcher* current = this; |
0 | 231 while (current != NULL) { |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
232 current = (TypedMethodOptionMatcher*)current->find(method); |
0 | 233 if (current == NULL) { |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
234 return NULL; |
0 | 235 } |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
236 if (strcmp(current->_option, opt) == 0) { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
237 return current; |
0 | 238 } |
239 current = current->next(); | |
240 } | |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
241 return NULL; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
242 } |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
243 |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
244 TypedMethodOptionMatcher* next() { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
245 return (TypedMethodOptionMatcher*)_next; |
0 | 246 } |
247 | |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
248 OptionType get_type(void) { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
249 return _type; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
250 }; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
251 |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
252 T value() { return _value; } |
0 | 253 |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
254 void print() { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
255 ttyLocker ttyl; |
0 | 256 print_base(); |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
257 tty->print(" %s", _option); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
258 tty->print(" <unknown option type>"); |
0 | 259 tty->cr(); |
260 } | |
261 }; | |
262 | |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
263 template<> |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
264 void TypedMethodOptionMatcher<intx>::print() { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
265 ttyLocker ttyl; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
266 print_base(); |
20430 | 267 tty->print(" intx %s", _option); |
268 tty->print(" = " INTX_FORMAT, _value); | |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
269 tty->cr(); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
270 }; |
0 | 271 |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
272 template<> |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
273 void TypedMethodOptionMatcher<uintx>::print() { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
274 ttyLocker ttyl; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
275 print_base(); |
20430 | 276 tty->print(" uintx %s", _option); |
277 tty->print(" = " UINTX_FORMAT, _value); | |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
278 tty->cr(); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
279 }; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
280 |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
281 template<> |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
282 void TypedMethodOptionMatcher<bool>::print() { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
283 ttyLocker ttyl; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
284 print_base(); |
20430 | 285 tty->print(" bool %s", _option); |
286 tty->print(" = %s", _value ? "true" : "false"); | |
287 tty->cr(); | |
288 }; | |
289 | |
290 template<> | |
291 void TypedMethodOptionMatcher<ccstr>::print() { | |
292 ttyLocker ttyl; | |
293 print_base(); | |
294 tty->print(" const char* %s", _option); | |
295 tty->print(" = '%s'", _value); | |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
296 tty->cr(); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
297 }; |
0 | 298 |
299 // this must parallel the command_names below | |
300 enum OracleCommand { | |
301 UnknownCommand = -1, | |
302 OracleFirstCommand = 0, | |
303 BreakCommand = OracleFirstCommand, | |
304 PrintCommand, | |
305 ExcludeCommand, | |
306 InlineCommand, | |
307 DontInlineCommand, | |
308 CompileOnlyCommand, | |
309 LogCommand, | |
310 OptionCommand, | |
311 QuietCommand, | |
312 HelpCommand, | |
313 OracleCommandCount | |
314 }; | |
315 | |
316 // this must parallel the enum OracleCommand | |
317 static const char * command_names[] = { | |
318 "break", | |
319 "print", | |
320 "exclude", | |
321 "inline", | |
322 "dontinline", | |
323 "compileonly", | |
324 "log", | |
325 "option", | |
326 "quiet", | |
327 "help" | |
328 }; | |
329 | |
330 class MethodMatcher; | |
331 static MethodMatcher* lists[OracleCommandCount] = { 0, }; | |
332 | |
333 | |
334 static bool check_predicate(OracleCommand command, methodHandle method) { | |
335 return ((lists[command] != NULL) && | |
336 !method.is_null() && | |
337 lists[command]->match(method)); | |
338 } | |
339 | |
340 | |
341 static MethodMatcher* add_predicate(OracleCommand command, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
342 Symbol* class_name, MethodMatcher::Mode c_mode, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
343 Symbol* method_name, MethodMatcher::Mode m_mode, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
344 Symbol* signature) { |
0 | 345 assert(command != OptionCommand, "must use add_option_string"); |
346 if (command == LogCommand && !LogCompilation && lists[LogCommand] == NULL) | |
347 tty->print_cr("Warning: +LogCompilation must be enabled in order for individual methods to be logged."); | |
348 lists[command] = new MethodMatcher(class_name, c_mode, method_name, m_mode, signature, lists[command]); | |
349 return lists[command]; | |
350 } | |
351 | |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
352 template<typename T> |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
353 static MethodMatcher* add_option_string(Symbol* class_name, MethodMatcher::Mode c_mode, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
354 Symbol* method_name, MethodMatcher::Mode m_mode, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
355 Symbol* signature, |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
356 const char* option, |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
357 T value) { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
358 lists[OptionCommand] = new TypedMethodOptionMatcher<T>(class_name, c_mode, method_name, m_mode, |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
359 signature, option, value, lists[OptionCommand]); |
0 | 360 return lists[OptionCommand]; |
361 } | |
362 | |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
363 template<typename T> |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
364 static bool get_option_value(methodHandle method, const char* option, T& value) { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
365 TypedMethodOptionMatcher<T>* m; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
366 if (lists[OptionCommand] != NULL |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
367 && (m = ((TypedMethodOptionMatcher<T>*)lists[OptionCommand])->match(method, option)) != NULL |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
368 && m->get_type() == get_type_for<T>()) { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
369 value = m->value(); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
370 return true; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
371 } else { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
372 return false; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
373 } |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
374 } |
0 | 375 |
376 bool CompilerOracle::has_option_string(methodHandle method, const char* option) { | |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
377 bool value = false; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
378 get_option_value(method, option, value); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
379 return value; |
0 | 380 } |
381 | |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
382 template<typename T> |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
383 bool CompilerOracle::has_option_value(methodHandle method, const char* option, T& value) { |
20431
e09c0676c53f
8057129: Fix AIX build after the Extend CompileCommand=option change 8055286
simonis
parents:
20430
diff
changeset
|
384 return ::get_option_value(method, option, value); |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
385 } |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
386 |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
387 // Explicit instantiation for all OptionTypes supported. |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
388 template bool CompilerOracle::has_option_value<intx>(methodHandle method, const char* option, intx& value); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
389 template bool CompilerOracle::has_option_value<uintx>(methodHandle method, const char* option, uintx& value); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
390 template bool CompilerOracle::has_option_value<bool>(methodHandle method, const char* option, bool& value); |
20430 | 391 template bool CompilerOracle::has_option_value<ccstr>(methodHandle method, const char* option, ccstr& value); |
0 | 392 |
393 bool CompilerOracle::should_exclude(methodHandle method, bool& quietly) { | |
394 quietly = true; | |
395 if (lists[ExcludeCommand] != NULL) { | |
396 if (lists[ExcludeCommand]->match(method)) { | |
397 quietly = _quiet; | |
398 return true; | |
399 } | |
400 } | |
401 | |
402 if (lists[CompileOnlyCommand] != NULL) { | |
403 return !lists[CompileOnlyCommand]->match(method); | |
404 } | |
405 return false; | |
406 } | |
407 | |
408 | |
409 bool CompilerOracle::should_inline(methodHandle method) { | |
410 return (check_predicate(InlineCommand, method)); | |
411 } | |
412 | |
413 | |
414 bool CompilerOracle::should_not_inline(methodHandle method) { | |
415 return (check_predicate(DontInlineCommand, method)); | |
416 } | |
417 | |
418 | |
419 bool CompilerOracle::should_print(methodHandle method) { | |
420 return (check_predicate(PrintCommand, method)); | |
421 } | |
422 | |
423 | |
424 bool CompilerOracle::should_log(methodHandle method) { | |
425 if (!LogCompilation) return false; | |
426 if (lists[LogCommand] == NULL) return true; // by default, log all | |
427 return (check_predicate(LogCommand, method)); | |
428 } | |
429 | |
430 | |
431 bool CompilerOracle::should_break_at(methodHandle method) { | |
432 return check_predicate(BreakCommand, method); | |
433 } | |
434 | |
435 | |
436 static OracleCommand parse_command_name(const char * line, int* bytes_read) { | |
437 assert(ARRAY_SIZE(command_names) == OracleCommandCount, | |
438 "command_names size mismatch"); | |
439 | |
440 *bytes_read = 0; | |
2077
781072b12368
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
1972
diff
changeset
|
441 char command[33]; |
0 | 442 int result = sscanf(line, "%32[a-z]%n", command, bytes_read); |
443 for (uint i = 0; i < ARRAY_SIZE(command_names); i++) { | |
444 if (strcmp(command, command_names[i]) == 0) { | |
445 return (OracleCommand)i; | |
446 } | |
447 } | |
448 return UnknownCommand; | |
449 } | |
450 | |
451 | |
452 static void usage() { | |
453 tty->print_cr(" CompileCommand and the CompilerOracle allows simple control over"); | |
454 tty->print_cr(" what's allowed to be compiled. The standard supported directives"); | |
455 tty->print_cr(" are exclude and compileonly. The exclude directive stops a method"); | |
456 tty->print_cr(" from being compiled and compileonly excludes all methods except for"); | |
457 tty->print_cr(" the ones mentioned by compileonly directives. The basic form of"); | |
458 tty->print_cr(" all commands is a command name followed by the name of the method"); | |
459 tty->print_cr(" in one of two forms: the standard class file format as in"); | |
460 tty->print_cr(" class/name.methodName or the PrintCompilation format"); | |
461 tty->print_cr(" class.name::methodName. The method name can optionally be followed"); | |
462 tty->print_cr(" by a space then the signature of the method in the class file"); | |
463 tty->print_cr(" format. Otherwise the directive applies to all methods with the"); | |
464 tty->print_cr(" same name and class regardless of signature. Leading and trailing"); | |
465 tty->print_cr(" *'s in the class and/or method name allows a small amount of"); | |
466 tty->print_cr(" wildcarding. "); | |
467 tty->cr(); | |
468 tty->print_cr(" Examples:"); | |
469 tty->cr(); | |
470 tty->print_cr(" exclude java/lang/StringBuffer.append"); | |
471 tty->print_cr(" compileonly java/lang/StringBuffer.toString ()Ljava/lang/String;"); | |
472 tty->print_cr(" exclude java/lang/String*.*"); | |
473 tty->print_cr(" exclude *.toString"); | |
474 } | |
475 | |
476 | |
477 // The characters allowed in a class or method name. All characters > 0x7f | |
478 // are allowed in order to handle obfuscated class files (e.g. Volano) | |
479 #define RANGEBASE "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$_<>" \ | |
480 "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" \ | |
481 "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" \ | |
482 "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" \ | |
483 "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" \ | |
484 "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" \ | |
485 "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" \ | |
486 "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef" \ | |
487 "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff" | |
488 | |
489 #define RANGE0 "[*" RANGEBASE "]" | |
490 #define RANGEDOT "[*" RANGEBASE ".]" | |
491 #define RANGESLASH "[*" RANGEBASE "/]" | |
492 | |
493 | |
494 // Accept several syntaxes for these patterns | |
495 // original syntax | |
496 // cmd java.lang.String foo | |
497 // PrintCompilation syntax | |
498 // cmd java.lang.String::foo | |
499 // VM syntax | |
500 // cmd java/lang/String[. ]foo | |
501 // | |
502 | |
503 static const char* patterns[] = { | |
504 "%*[ \t]%255" RANGEDOT " " "%255" RANGE0 "%n", | |
505 "%*[ \t]%255" RANGEDOT "::" "%255" RANGE0 "%n", | |
506 "%*[ \t]%255" RANGESLASH "%*[ .]" "%255" RANGE0 "%n", | |
507 }; | |
508 | |
509 static MethodMatcher::Mode check_mode(char name[], const char*& error_msg) { | |
510 int match = MethodMatcher::Exact; | |
1155
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
0
diff
changeset
|
511 while (name[0] == '*') { |
0 | 512 match |= MethodMatcher::Suffix; |
18688
0eba324e27db
strcpy doesn't handle overlapping strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18041
diff
changeset
|
513 // Copy remaining string plus NUL to the beginning |
18695
5281f8e34a4a
Use memmove for overlapping copy
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18688
diff
changeset
|
514 memmove(name, name + 1, strlen(name + 1) + 1); |
0 | 515 } |
516 | |
1155
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
0
diff
changeset
|
517 if (strcmp(name, "*") == 0) return MethodMatcher::Any; |
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
0
diff
changeset
|
518 |
0 | 519 size_t len = strlen(name); |
1155
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
0
diff
changeset
|
520 while (len > 0 && name[len - 1] == '*') { |
0 | 521 match |= MethodMatcher::Prefix; |
1155
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
0
diff
changeset
|
522 name[--len] = '\0'; |
0 | 523 } |
524 | |
525 if (strstr(name, "*") != NULL) { | |
526 error_msg = " Embedded * not allowed"; | |
527 return MethodMatcher::Unknown; | |
528 } | |
529 return (MethodMatcher::Mode)match; | |
530 } | |
531 | |
532 static bool scan_line(const char * line, | |
533 char class_name[], MethodMatcher::Mode* c_mode, | |
534 char method_name[], MethodMatcher::Mode* m_mode, | |
535 int* bytes_read, const char*& error_msg) { | |
536 *bytes_read = 0; | |
537 error_msg = NULL; | |
538 for (uint i = 0; i < ARRAY_SIZE(patterns); i++) { | |
539 if (2 == sscanf(line, patterns[i], class_name, method_name, bytes_read)) { | |
540 *c_mode = check_mode(class_name, error_msg); | |
541 *m_mode = check_mode(method_name, error_msg); | |
542 return *c_mode != MethodMatcher::Unknown && *m_mode != MethodMatcher::Unknown; | |
543 } | |
544 } | |
545 return false; | |
546 } | |
547 | |
548 | |
549 | |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
550 // Scan next flag and value in line, return MethodMatcher object on success, NULL on failure. |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
551 // On failure, error_msg contains description for the first error. |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
552 // For future extensions: set error_msg on first error. |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
553 static MethodMatcher* scan_flag_and_value(const char* type, const char* line, int& total_bytes_read, |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
554 Symbol* c_name, MethodMatcher::Mode c_match, |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
555 Symbol* m_name, MethodMatcher::Mode m_match, |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
556 Symbol* signature, |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
557 char* errorbuf, const int buf_size) { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
558 total_bytes_read = 0; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
559 int bytes_read = 0; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
560 char flag[256]; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
561 |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
562 // Read flag name. |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
563 if (sscanf(line, "%*[ \t]%255[a-zA-Z0-9]%n", flag, &bytes_read) == 1) { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
564 line += bytes_read; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
565 total_bytes_read += bytes_read; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
566 |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
567 // Read value. |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
568 if (strcmp(type, "intx") == 0) { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
569 intx value; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
570 if (sscanf(line, "%*[ \t]" INTX_FORMAT "%n", &value, &bytes_read) == 1) { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
571 total_bytes_read += bytes_read; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
572 return add_option_string(c_name, c_match, m_name, m_match, signature, flag, value); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
573 } else { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
574 jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s ", flag, type); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
575 } |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
576 } else if (strcmp(type, "uintx") == 0) { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
577 uintx value; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
578 if (sscanf(line, "%*[ \t]" UINTX_FORMAT "%n", &value, &bytes_read) == 1) { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
579 total_bytes_read += bytes_read; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
580 return add_option_string(c_name, c_match, m_name, m_match, signature, flag, value); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
581 } else { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
582 jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s", flag, type); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
583 } |
20430 | 584 } else if (strcmp(type, "ccstr") == 0) { |
585 ResourceMark rm; | |
586 char* value = NEW_RESOURCE_ARRAY(char, strlen(line) + 1); | |
587 if (sscanf(line, "%*[ \t]%255[_a-zA-Z0-9]%n", value, &bytes_read) == 1) { | |
588 total_bytes_read += bytes_read; | |
589 return add_option_string(c_name, c_match, m_name, m_match, signature, flag, (ccstr)value); | |
590 } else { | |
591 jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s", flag, type); | |
592 } | |
593 } else if (strcmp(type, "ccstrlist") == 0) { | |
594 // Accumulates several strings into one. The internal type is ccstr. | |
595 ResourceMark rm; | |
596 char* value = NEW_RESOURCE_ARRAY(char, strlen(line) + 1); | |
597 char* next_value = value; | |
598 if (sscanf(line, "%*[ \t]%255[_a-zA-Z0-9]%n", next_value, &bytes_read) == 1) { | |
599 total_bytes_read += bytes_read; | |
600 line += bytes_read; | |
601 next_value += bytes_read; | |
602 char* end_value = next_value-1; | |
603 while (sscanf(line, "%*[ \t]%255[_a-zA-Z0-9]%n", next_value, &bytes_read) == 1) { | |
604 total_bytes_read += bytes_read; | |
605 line += bytes_read; | |
606 *end_value = ' '; // override '\0' | |
607 next_value += bytes_read; | |
608 end_value = next_value-1; | |
609 } | |
610 return add_option_string(c_name, c_match, m_name, m_match, signature, flag, (ccstr)value); | |
611 } else { | |
612 jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s", flag, type); | |
613 } | |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
614 } else if (strcmp(type, "bool") == 0) { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
615 char value[256]; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
616 if (sscanf(line, "%*[ \t]%255[a-zA-Z]%n", value, &bytes_read) == 1) { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
617 if (strcmp(value, "true") == 0) { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
618 total_bytes_read += bytes_read; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
619 return add_option_string(c_name, c_match, m_name, m_match, signature, flag, true); |
20430 | 620 } else if (strcmp(value, "false") == 0) { |
621 total_bytes_read += bytes_read; | |
622 return add_option_string(c_name, c_match, m_name, m_match, signature, flag, false); | |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
623 } else { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
624 jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s", flag, type); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
625 } |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
626 } else { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
627 jio_snprintf(errorbuf, sizeof(errorbuf), " Value cannot be read for flag %s of type %s", flag, type); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
628 } |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
629 } else { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
630 jio_snprintf(errorbuf, sizeof(errorbuf), " Type %s not supported ", type); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
631 } |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
632 } else { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
633 jio_snprintf(errorbuf, sizeof(errorbuf), " Flag name for type %s should be alphanumeric ", type); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
634 } |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
635 return NULL; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
636 } |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
637 |
0 | 638 void CompilerOracle::parse_from_line(char* line) { |
639 if (line[0] == '\0') return; | |
640 if (line[0] == '#') return; | |
641 | |
642 bool have_colon = (strstr(line, "::") != NULL); | |
643 for (char* lp = line; *lp != '\0'; lp++) { | |
644 // Allow '.' to separate the class name from the method name. | |
645 // This is the preferred spelling of methods: | |
646 // exclude java/lang/String.indexOf(I)I | |
647 // Allow ',' for spaces (eases command line quoting). | |
648 // exclude,java/lang/String.indexOf | |
649 // For backward compatibility, allow space as separator also. | |
650 // exclude java/lang/String indexOf | |
651 // exclude,java/lang/String,indexOf | |
652 // For easy cut-and-paste of method names, allow VM output format | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6204
diff
changeset
|
653 // as produced by Method::print_short_name: |
0 | 654 // exclude java.lang.String::indexOf |
655 // For simple implementation convenience here, convert them all to space. | |
656 if (have_colon) { | |
657 if (*lp == '.') *lp = '/'; // dots build the package prefix | |
658 if (*lp == ':') *lp = ' '; | |
659 } | |
660 if (*lp == ',' || *lp == '.') *lp = ' '; | |
661 } | |
662 | |
663 char* original_line = line; | |
664 int bytes_read; | |
665 OracleCommand command = parse_command_name(line, &bytes_read); | |
666 line += bytes_read; | |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
667 ResourceMark rm; |
0 | 668 |
2077
781072b12368
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
1972
diff
changeset
|
669 if (command == UnknownCommand) { |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
670 ttyLocker ttyl; |
2077
781072b12368
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
1972
diff
changeset
|
671 tty->print_cr("CompilerOracle: unrecognized line"); |
781072b12368
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
1972
diff
changeset
|
672 tty->print_cr(" \"%s\"", original_line); |
781072b12368
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
1972
diff
changeset
|
673 return; |
781072b12368
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
1972
diff
changeset
|
674 } |
781072b12368
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
1972
diff
changeset
|
675 |
0 | 676 if (command == QuietCommand) { |
677 _quiet = true; | |
678 return; | |
679 } | |
680 | |
681 if (command == HelpCommand) { | |
682 usage(); | |
683 return; | |
684 } | |
685 | |
686 MethodMatcher::Mode c_match = MethodMatcher::Exact; | |
687 MethodMatcher::Mode m_match = MethodMatcher::Exact; | |
688 char class_name[256]; | |
689 char method_name[256]; | |
690 char sig[1024]; | |
691 char errorbuf[1024]; | |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
692 const char* error_msg = NULL; // description of first error that appears |
0 | 693 MethodMatcher* match = NULL; |
694 | |
695 if (scan_line(line, class_name, &c_match, method_name, &m_match, &bytes_read, error_msg)) { | |
696 EXCEPTION_MARK; | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
697 Symbol* c_name = SymbolTable::new_symbol(class_name, CHECK); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
698 Symbol* m_name = SymbolTable::new_symbol(method_name, CHECK); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
699 Symbol* signature = NULL; |
0 | 700 |
701 line += bytes_read; | |
702 // there might be a signature following the method. | |
703 // signatures always begin with ( so match that by hand | |
2077
781072b12368
6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents:
1972
diff
changeset
|
704 if (1 == sscanf(line, "%*[ \t](%254[[);/" RANGEBASE "]%n", sig + 1, &bytes_read)) { |
0 | 705 sig[0] = '('; |
706 line += bytes_read; | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
707 signature = SymbolTable::new_symbol(sig, CHECK); |
0 | 708 } |
709 | |
710 if (command == OptionCommand) { | |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
711 // Look for trailing options. |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
712 // |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
713 // Two types of trailing options are |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
714 // supported: |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
715 // |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
716 // (1) CompileCommand=option,Klass::method,flag |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
717 // (2) CompileCommand=option,Klass::method,type,flag,value |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
718 // |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
719 // Type (1) is used to support ciMethod::has_option("someflag") |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
720 // (i.e., to check if a flag "someflag" is enabled for a method). |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
721 // |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
722 // Type (2) is used to support options with a value. Values can have the |
20430 | 723 // the following types: intx, uintx, bool, ccstr, and ccstrlist. |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
724 // |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
725 // For future extensions: extend scan_flag_and_value() |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
726 char option[256]; // stores flag for Type (1) and type of Type (2) |
0 | 727 while (sscanf(line, "%*[ \t]%255[a-zA-Z0-9]%n", option, &bytes_read) == 1) { |
728 if (match != NULL && !_quiet) { | |
729 // Print out the last match added | |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
730 ttyLocker ttyl; |
0 | 731 tty->print("CompilerOracle: %s ", command_names[command]); |
732 match->print(); | |
733 } | |
734 line += bytes_read; | |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
735 |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
736 if (strcmp(option, "intx") == 0 |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
737 || strcmp(option, "uintx") == 0 |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
738 || strcmp(option, "bool") == 0 |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
739 || strcmp(option, "ccstr") == 0 |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
740 || strcmp(option, "ccstrlist") == 0 |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
741 ) { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
742 |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
743 // Type (2) option: parse flag name and value. |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
744 match = scan_flag_and_value(option, line, bytes_read, |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
745 c_name, c_match, m_name, m_match, signature, |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
746 errorbuf, sizeof(errorbuf)); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
747 if (match == NULL) { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
748 error_msg = errorbuf; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
749 break; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
750 } |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
751 line += bytes_read; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
752 } else { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
753 // Type (1) option |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
754 match = add_option_string(c_name, c_match, m_name, m_match, signature, option, true); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
755 } |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
756 } // while( |
0 | 757 } else { |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
758 match = add_predicate(command, c_name, c_match, m_name, m_match, signature); |
0 | 759 } |
760 } | |
761 | |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
762 ttyLocker ttyl; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
763 if (error_msg != NULL) { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
764 // an error has happened |
0 | 765 tty->print_cr("CompilerOracle: unrecognized line"); |
766 tty->print_cr(" \"%s\"", original_line); | |
767 if (error_msg != NULL) { | |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
14223
diff
changeset
|
768 tty->print_cr("%s", error_msg); |
0 | 769 } |
20429
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
770 } else { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
771 // check for remaining characters |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
772 bytes_read = 0; |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
773 sscanf(line, "%*[ \t]%n", &bytes_read); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
774 if (line[bytes_read] != '\0') { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
775 tty->print_cr("CompilerOracle: unrecognized line"); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
776 tty->print_cr(" \"%s\"", original_line); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
777 tty->print_cr(" Unrecognized text %s after command ", line); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
778 } else if (match != NULL && !_quiet) { |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
779 tty->print("CompilerOracle: %s ", command_names[command]); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
780 match->print(); |
14b356bbca27
8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents:
17937
diff
changeset
|
781 } |
0 | 782 } |
783 } | |
784 | |
6196
3759236eea14
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
6150
diff
changeset
|
785 static const char* default_cc_file = ".hotspot_compiler"; |
3759236eea14
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
6150
diff
changeset
|
786 |
0 | 787 static const char* cc_file() { |
6150
1e76463170b3
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
2426
diff
changeset
|
788 #ifdef ASSERT |
0 | 789 if (CompileCommandFile == NULL) |
6196
3759236eea14
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
6150
diff
changeset
|
790 return default_cc_file; |
6150
1e76463170b3
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
2426
diff
changeset
|
791 #endif |
0 | 792 return CompileCommandFile; |
793 } | |
6150
1e76463170b3
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
2426
diff
changeset
|
794 |
1e76463170b3
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
2426
diff
changeset
|
795 bool CompilerOracle::has_command_file() { |
1e76463170b3
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
2426
diff
changeset
|
796 return cc_file() != NULL; |
1e76463170b3
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
2426
diff
changeset
|
797 } |
1e76463170b3
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
2426
diff
changeset
|
798 |
0 | 799 bool CompilerOracle::_quiet = false; |
800 | |
801 void CompilerOracle::parse_from_file() { | |
6150
1e76463170b3
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
2426
diff
changeset
|
802 assert(has_command_file(), "command file must be specified"); |
0 | 803 FILE* stream = fopen(cc_file(), "rt"); |
804 if (stream == NULL) return; | |
805 | |
806 char token[1024]; | |
807 int pos = 0; | |
808 int c = getc(stream); | |
6901 | 809 while(c != EOF && pos < (int)(sizeof(token)-1)) { |
0 | 810 if (c == '\n') { |
811 token[pos++] = '\0'; | |
812 parse_from_line(token); | |
813 pos = 0; | |
814 } else { | |
815 token[pos++] = c; | |
816 } | |
817 c = getc(stream); | |
818 } | |
819 token[pos++] = '\0'; | |
820 parse_from_line(token); | |
821 | |
822 fclose(stream); | |
823 } | |
824 | |
825 void CompilerOracle::parse_from_string(const char* str, void (*parse_line)(char*)) { | |
826 char token[1024]; | |
827 int pos = 0; | |
828 const char* sp = str; | |
829 int c = *sp++; | |
6901 | 830 while (c != '\0' && pos < (int)(sizeof(token)-1)) { |
0 | 831 if (c == '\n') { |
832 token[pos++] = '\0'; | |
833 parse_line(token); | |
834 pos = 0; | |
835 } else { | |
836 token[pos++] = c; | |
837 } | |
838 c = *sp++; | |
839 } | |
840 token[pos++] = '\0'; | |
841 parse_line(token); | |
842 } | |
843 | |
844 void CompilerOracle::append_comment_to_file(const char* message) { | |
6150
1e76463170b3
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
2426
diff
changeset
|
845 assert(has_command_file(), "command file must be specified"); |
0 | 846 fileStream stream(fopen(cc_file(), "at")); |
847 stream.print("# "); | |
848 for (int index = 0; message[index] != '\0'; index++) { | |
849 stream.put(message[index]); | |
850 if (message[index] == '\n') stream.print("# "); | |
851 } | |
852 stream.cr(); | |
853 } | |
854 | |
855 void CompilerOracle::append_exclude_to_file(methodHandle method) { | |
6150
1e76463170b3
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
2426
diff
changeset
|
856 assert(has_command_file(), "command file must be specified"); |
0 | 857 fileStream stream(fopen(cc_file(), "at")); |
858 stream.print("exclude "); | |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6909
diff
changeset
|
859 method->method_holder()->name()->print_symbol_on(&stream); |
0 | 860 stream.print("."); |
861 method->name()->print_symbol_on(&stream); | |
862 method->signature()->print_symbol_on(&stream); | |
863 stream.cr(); | |
864 stream.cr(); | |
865 } | |
866 | |
867 | |
868 void compilerOracle_init() { | |
869 CompilerOracle::parse_from_string(CompileCommand, CompilerOracle::parse_from_line); | |
870 CompilerOracle::parse_from_string(CompileOnly, CompilerOracle::parse_compile_only); | |
6150
1e76463170b3
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
2426
diff
changeset
|
871 if (CompilerOracle::has_command_file()) { |
1e76463170b3
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
2426
diff
changeset
|
872 CompilerOracle::parse_from_file(); |
6196
3759236eea14
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
6150
diff
changeset
|
873 } else { |
3759236eea14
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
6150
diff
changeset
|
874 struct stat buf; |
3759236eea14
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
6150
diff
changeset
|
875 if (os::stat(default_cc_file, &buf) == 0) { |
3759236eea14
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
6150
diff
changeset
|
876 warning("%s file is present but has been ignored. " |
3759236eea14
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
6150
diff
changeset
|
877 "Run with -XX:CompileCommandFile=%s to load the file.", |
3759236eea14
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
6150
diff
changeset
|
878 default_cc_file, default_cc_file); |
3759236eea14
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
6150
diff
changeset
|
879 } |
6150
1e76463170b3
7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents:
2426
diff
changeset
|
880 } |
1155
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
0
diff
changeset
|
881 if (lists[PrintCommand] != NULL) { |
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
0
diff
changeset
|
882 if (PrintAssembly) { |
6196
3759236eea14
7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents:
6150
diff
changeset
|
883 warning("CompileCommand and/or %s file contains 'print' commands, but PrintAssembly is also enabled", default_cc_file); |
1155
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
0
diff
changeset
|
884 } else if (FLAG_IS_DEFAULT(DebugNonSafepoints)) { |
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
0
diff
changeset
|
885 warning("printing of assembly code is enabled; turning on DebugNonSafepoints to gain additional output"); |
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
0
diff
changeset
|
886 DebugNonSafepoints = true; |
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
0
diff
changeset
|
887 } |
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
0
diff
changeset
|
888 } |
0 | 889 } |
890 | |
891 | |
892 void CompilerOracle::parse_compile_only(char * line) { | |
893 int i; | |
894 char name[1024]; | |
895 const char* className = NULL; | |
896 const char* methodName = NULL; | |
897 | |
898 bool have_colon = (strstr(line, "::") != NULL); | |
899 char method_sep = have_colon ? ':' : '.'; | |
900 | |
901 if (Verbose) { | |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
14223
diff
changeset
|
902 tty->print_cr("%s", line); |
0 | 903 } |
904 | |
905 ResourceMark rm; | |
906 while (*line != '\0') { | |
907 MethodMatcher::Mode c_match = MethodMatcher::Exact; | |
908 MethodMatcher::Mode m_match = MethodMatcher::Exact; | |
909 | |
910 for (i = 0; | |
911 i < 1024 && *line != '\0' && *line != method_sep && *line != ',' && !isspace(*line); | |
912 line++, i++) { | |
913 name[i] = *line; | |
914 if (name[i] == '.') name[i] = '/'; // package prefix uses '/' | |
915 } | |
916 | |
917 if (i > 0) { | |
918 char* newName = NEW_RESOURCE_ARRAY( char, i + 1); | |
919 if (newName == NULL) | |
920 return; | |
921 strncpy(newName, name, i); | |
922 newName[i] = '\0'; | |
923 | |
924 if (className == NULL) { | |
925 className = newName; | |
926 c_match = MethodMatcher::Prefix; | |
927 } else { | |
928 methodName = newName; | |
929 } | |
930 } | |
931 | |
932 if (*line == method_sep) { | |
933 if (className == NULL) { | |
934 className = ""; | |
935 c_match = MethodMatcher::Any; | |
936 } else { | |
937 // foo/bar.blah is an exact match on foo/bar, bar.blah is a suffix match on bar | |
938 if (strchr(className, '/') != NULL) { | |
939 c_match = MethodMatcher::Exact; | |
940 } else { | |
941 c_match = MethodMatcher::Suffix; | |
942 } | |
943 } | |
944 } else { | |
945 // got foo or foo/bar | |
946 if (className == NULL) { | |
947 ShouldNotReachHere(); | |
948 } else { | |
949 // got foo or foo/bar | |
950 if (strchr(className, '/') != NULL) { | |
951 c_match = MethodMatcher::Prefix; | |
952 } else if (className[0] == '\0') { | |
953 c_match = MethodMatcher::Any; | |
954 } else { | |
955 c_match = MethodMatcher::Substring; | |
956 } | |
957 } | |
958 } | |
959 | |
960 // each directive is terminated by , or NUL or . followed by NUL | |
961 if (*line == ',' || *line == '\0' || (line[0] == '.' && line[1] == '\0')) { | |
962 if (methodName == NULL) { | |
963 methodName = ""; | |
964 if (*line != method_sep) { | |
965 m_match = MethodMatcher::Any; | |
966 } | |
967 } | |
968 | |
969 EXCEPTION_MARK; | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
970 Symbol* c_name = SymbolTable::new_symbol(className, CHECK); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
971 Symbol* m_name = SymbolTable::new_symbol(methodName, CHECK); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2077
diff
changeset
|
972 Symbol* signature = NULL; |
0 | 973 |
974 add_predicate(CompileOnlyCommand, c_name, c_match, m_name, m_match, signature); | |
975 if (PrintVMOptions) { | |
976 tty->print("CompileOnly: compileonly "); | |
977 lists[CompileOnlyCommand]->print(); | |
978 } | |
979 | |
980 className = NULL; | |
981 methodName = NULL; | |
982 } | |
983 | |
984 line = *line == '\0' ? line : line + 1; | |
985 } | |
986 } |