@@ -104,7 +104,6 @@ class TypedMethodOptionMatcher : public MethodMatcher {
104
104
private:
105
105
TypedMethodOptionMatcher* _next;
106
106
enum CompileCommand _option;
107
- OptionType _type;
108
107
public:
109
108
110
109
union {
@@ -117,18 +116,16 @@ class TypedMethodOptionMatcher : public MethodMatcher {
117
116
118
117
TypedMethodOptionMatcher () : MethodMatcher(),
119
118
_next (NULL ),
120
- _option(CompileCommand::Unknown),
121
- _type(OptionType::Unknown) {
119
+ _option(CompileCommand::Unknown) {
122
120
memset (&_u, 0 , sizeof (_u));
123
121
}
124
122
125
123
~TypedMethodOptionMatcher ();
126
124
static TypedMethodOptionMatcher* parse_method_pattern (char *& line, char * errorbuf, const int buf_size);
127
- TypedMethodOptionMatcher* match (const methodHandle &method, enum CompileCommand option, OptionType type );
125
+ TypedMethodOptionMatcher* match (const methodHandle &method, enum CompileCommand option);
128
126
129
- void init (enum CompileCommand option, OptionType type, TypedMethodOptionMatcher* next) {
127
+ void init (enum CompileCommand option, TypedMethodOptionMatcher* next) {
130
128
_next = next;
131
- _type = type;
132
129
_option = option;
133
130
}
134
131
@@ -140,7 +137,6 @@ class TypedMethodOptionMatcher : public MethodMatcher {
140
137
141
138
void set_next (TypedMethodOptionMatcher* next) {_next = next; }
142
139
TypedMethodOptionMatcher* next () { return _next; }
143
- OptionType type () { return _type; }
144
140
enum CompileCommand option () { return _option; }
145
141
template <typename T> T value ();
146
142
template <typename T> void set_value (T value);
@@ -194,8 +190,9 @@ void TypedMethodOptionMatcher::print() {
194
190
ttyLocker ttyl;
195
191
print_base (tty);
196
192
const char * name = option2name (_option);
197
- switch (_type) {
198
- case OptionType::Intx:
193
+ enum OptionType type = option2type (_option);
194
+ switch (type) {
195
+ case OptionType::Intx:
199
196
tty->print_cr (" intx %s = " INTX_FORMAT, name, value<intx>());
200
197
break ;
201
198
case OptionType::Uintx:
@@ -208,6 +205,7 @@ void TypedMethodOptionMatcher::print() {
208
205
tty->print_cr (" double %s = %f" , name, value<double >());
209
206
break ;
210
207
case OptionType::Ccstr:
208
+ case OptionType::Ccstrlist:
211
209
tty->print_cr (" const char* %s = '%s'" , name, value<ccstr>());
212
210
break ;
213
211
default :
@@ -244,7 +242,8 @@ TypedMethodOptionMatcher* TypedMethodOptionMatcher::clone() {
244
242
}
245
243
246
244
TypedMethodOptionMatcher::~TypedMethodOptionMatcher () {
247
- if (type () == OptionType::Ccstr) {
245
+ enum OptionType type = option2type (_option);
246
+ if (type == OptionType::Ccstr || type == OptionType::Ccstrlist) {
248
247
ccstr v = value<ccstr>();
249
248
os::free ((void *)v);
250
249
}
@@ -263,7 +262,7 @@ TypedMethodOptionMatcher* TypedMethodOptionMatcher::parse_method_pattern(char*&
263
262
return tom;
264
263
}
265
264
266
- TypedMethodOptionMatcher* TypedMethodOptionMatcher::match (const methodHandle& method, enum CompileCommand option, OptionType type ) {
265
+ TypedMethodOptionMatcher* TypedMethodOptionMatcher::match (const methodHandle& method, enum CompileCommand option) {
267
266
TypedMethodOptionMatcher* current = this ;
268
267
while (current != NULL ) {
269
268
if (current->_option == option) {
@@ -285,12 +284,9 @@ static void register_command(TypedMethodOptionMatcher* matcher,
285
284
tty->print_cr (" Warning: +LogCompilation must be enabled in order for individual methods to be logged with " );
286
285
tty->print_cr (" CompileCommand=log,<method pattern>" );
287
286
}
288
- enum OptionType type = option2type (option);
289
- if (type == OptionType::Ccstrlist) {
290
- type = OptionType::Ccstr; // ccstrlists are stores as ccstr
291
- }
292
- assert (type == get_type_for<T>(), " sanity" );
293
- matcher->init (option, type, option_list);
287
+ assert (CompilerOracle::option_matches_type (option, value), " Value must match option type" );
288
+
289
+ matcher->init (option, option_list);
294
290
matcher->set_value <T>(value);
295
291
option_list = matcher;
296
292
if ((option != CompileCommand::DontInline) &&
@@ -308,26 +304,10 @@ static void register_command(TypedMethodOptionMatcher* matcher,
308
304
}
309
305
310
306
template <typename T>
311
- bool CompilerOracle::has_option_value (const methodHandle& method, enum CompileCommand option, T& value, bool verify_type) {
312
- enum OptionType type = option2type (option);
313
- if (type == OptionType::Unknown) {
314
- return false ; // Can't query options with type Unknown.
315
- }
316
- if (type == OptionType::Ccstrlist) {
317
- type = OptionType::Ccstr; // CCstrList type options are stored as Ccstr
318
- }
319
- if (verify_type) {
320
- if (type != get_type_for<T>()) {
321
- // Whitebox API expects false if option and type doesn't match
322
- return false ;
323
- }
324
- } else {
325
- assert (type == get_type_for<T>(), " Value type (%s) must match option %s (%s)" ,
326
- optiontype2name (get_type_for<T>()),
327
- option2name (option), optiontype2name (option2type (option)));
328
- }
307
+ bool CompilerOracle::has_option_value (const methodHandle& method, enum CompileCommand option, T& value) {
308
+ assert (option_matches_type (option, value), " Value must match option type" );
329
309
if (option_list != NULL ) {
330
- TypedMethodOptionMatcher* m = option_list->match (method, option, type );
310
+ TypedMethodOptionMatcher* m = option_list->match (method, option);
331
311
if (m != NULL ) {
332
312
value = m->value <T>();
333
313
return true ;
@@ -361,11 +341,29 @@ bool CompilerOracle::has_any_command_set() {
361
341
}
362
342
363
343
// Explicit instantiation for all OptionTypes supported.
364
- template bool CompilerOracle::has_option_value<intx>(const methodHandle& method, enum CompileCommand option, intx& value, bool verify_type);
365
- template bool CompilerOracle::has_option_value<uintx>(const methodHandle& method, enum CompileCommand option, uintx& value, bool verify_type);
366
- template bool CompilerOracle::has_option_value<bool >(const methodHandle& method, enum CompileCommand option, bool & value, bool verify_type);
367
- template bool CompilerOracle::has_option_value<ccstr>(const methodHandle& method, enum CompileCommand option, ccstr& value, bool verify_type);
368
- template bool CompilerOracle::has_option_value<double >(const methodHandle& method, enum CompileCommand option, double & value, bool verify_type);
344
+ template bool CompilerOracle::has_option_value<intx>(const methodHandle& method, enum CompileCommand option, intx& value);
345
+ template bool CompilerOracle::has_option_value<uintx>(const methodHandle& method, enum CompileCommand option, uintx& value);
346
+ template bool CompilerOracle::has_option_value<bool >(const methodHandle& method, enum CompileCommand option, bool & value);
347
+ template bool CompilerOracle::has_option_value<ccstr>(const methodHandle& method, enum CompileCommand option, ccstr& value);
348
+ template bool CompilerOracle::has_option_value<double >(const methodHandle& method, enum CompileCommand option, double & value);
349
+
350
+ template <typename T>
351
+ bool CompilerOracle::option_matches_type (enum CompileCommand option, T& value) {
352
+ enum OptionType option_type = option2type (option);
353
+ if (option_type == OptionType::Unknown) {
354
+ return false ; // Can't query options with type Unknown.
355
+ }
356
+ if (option_type == OptionType::Ccstrlist) {
357
+ option_type = OptionType::Ccstr; // CCstrList type options are stored as Ccstr
358
+ }
359
+ return (get_type_for<T>() == option_type);
360
+ }
361
+
362
+ template bool CompilerOracle::option_matches_type<intx>(enum CompileCommand option, intx& value);
363
+ template bool CompilerOracle::option_matches_type<uintx>(enum CompileCommand option, uintx& value);
364
+ template bool CompilerOracle::option_matches_type<bool >(enum CompileCommand option, bool & value);
365
+ template bool CompilerOracle::option_matches_type<ccstr>(enum CompileCommand option, ccstr& value);
366
+ template bool CompilerOracle::option_matches_type<double >(enum CompileCommand option, double & value);
369
367
370
368
bool CompilerOracle::has_option (const methodHandle& method, enum CompileCommand option) {
371
369
bool value = false ;
0 commit comments