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