Mercurial > hg > graal-compiler
comparison src/share/vm/compiler/compilerOracle.cpp @ 20430:119875f0fc67
8056964: JDK-8055286 changes are incomplete.
Summary: added ccstr and ccstrlist types to compilerOracle 'option' command
Reviewed-by: roland
author | kvn |
---|---|
date | Tue, 02 Sep 2014 10:26:48 -0700 |
parents | 14b356bbca27 |
children | e09c0676c53f |
comparison
equal
deleted
inserted
replaced
20429:14b356bbca27 | 20430:119875f0fc67 |
---|---|
170 enum OptionType { | 170 enum OptionType { |
171 IntxType, | 171 IntxType, |
172 UintxType, | 172 UintxType, |
173 BoolType, | 173 BoolType, |
174 CcstrType, | 174 CcstrType, |
175 CcstrListType, | |
176 UnknownType | 175 UnknownType |
177 }; | 176 }; |
178 | 177 |
179 /* Methods to map real type names to OptionType */ | 178 /* Methods to map real type names to OptionType */ |
180 template<typename T> | 179 template<typename T> |
190 return UintxType; | 189 return UintxType; |
191 } | 190 } |
192 | 191 |
193 template<> OptionType get_type_for<bool>() { | 192 template<> OptionType get_type_for<bool>() { |
194 return BoolType; | 193 return BoolType; |
194 } | |
195 | |
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); | |
195 } | 207 } |
196 | 208 |
197 template <typename T> | 209 template <typename T> |
198 class TypedMethodOptionMatcher : public MethodMatcher { | 210 class TypedMethodOptionMatcher : public MethodMatcher { |
199 const char* _option; | 211 const char* _option; |
204 TypedMethodOptionMatcher(Symbol* class_name, Mode class_mode, | 216 TypedMethodOptionMatcher(Symbol* class_name, Mode class_mode, |
205 Symbol* method_name, Mode method_mode, | 217 Symbol* method_name, Mode method_mode, |
206 Symbol* signature, const char* opt, | 218 Symbol* signature, const char* opt, |
207 const T value, MethodMatcher* next) : | 219 const T value, MethodMatcher* next) : |
208 MethodMatcher(class_name, class_mode, method_name, method_mode, signature, next), | 220 MethodMatcher(class_name, class_mode, method_name, method_mode, signature, next), |
209 _type(get_type_for<T>()), _value(value) { | 221 _type(get_type_for<T>()), _value(copy_value<T>(value)) { |
210 _option = strdup(opt); | 222 _option = strdup(opt); |
211 } | 223 } |
212 | 224 |
213 ~TypedMethodOptionMatcher() { | 225 ~TypedMethodOptionMatcher() { |
214 free((void*)_option); | 226 free((void*)_option); |
250 | 262 |
251 template<> | 263 template<> |
252 void TypedMethodOptionMatcher<intx>::print() { | 264 void TypedMethodOptionMatcher<intx>::print() { |
253 ttyLocker ttyl; | 265 ttyLocker ttyl; |
254 print_base(); | 266 print_base(); |
255 tty->print(" %s", _option); | 267 tty->print(" intx %s", _option); |
256 tty->print(" " INTX_FORMAT, _value); | 268 tty->print(" = " INTX_FORMAT, _value); |
257 tty->cr(); | 269 tty->cr(); |
258 }; | 270 }; |
259 | 271 |
260 template<> | 272 template<> |
261 void TypedMethodOptionMatcher<uintx>::print() { | 273 void TypedMethodOptionMatcher<uintx>::print() { |
262 ttyLocker ttyl; | 274 ttyLocker ttyl; |
263 print_base(); | 275 print_base(); |
264 tty->print(" %s", _option); | 276 tty->print(" uintx %s", _option); |
265 tty->print(" " UINTX_FORMAT, _value); | 277 tty->print(" = " UINTX_FORMAT, _value); |
266 tty->cr(); | 278 tty->cr(); |
267 }; | 279 }; |
268 | 280 |
269 template<> | 281 template<> |
270 void TypedMethodOptionMatcher<bool>::print() { | 282 void TypedMethodOptionMatcher<bool>::print() { |
271 ttyLocker ttyl; | 283 ttyLocker ttyl; |
272 print_base(); | 284 print_base(); |
273 tty->print(" %s", _option); | 285 tty->print(" bool %s", _option); |
274 tty->print(" %s", _value ? "true" : "false"); | 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); | |
275 tty->cr(); | 296 tty->cr(); |
276 }; | 297 }; |
277 | 298 |
278 // this must parallel the command_names below | 299 // this must parallel the command_names below |
279 enum OracleCommand { | 300 enum OracleCommand { |
365 | 386 |
366 // Explicit instantiation for all OptionTypes supported. | 387 // Explicit instantiation for all OptionTypes supported. |
367 template bool CompilerOracle::has_option_value<intx>(methodHandle method, const char* option, intx& value); | 388 template bool CompilerOracle::has_option_value<intx>(methodHandle method, const char* option, intx& value); |
368 template bool CompilerOracle::has_option_value<uintx>(methodHandle method, const char* option, uintx& value); | 389 template bool CompilerOracle::has_option_value<uintx>(methodHandle method, const char* option, uintx& value); |
369 template bool CompilerOracle::has_option_value<bool>(methodHandle method, const char* option, bool& value); | 390 template bool CompilerOracle::has_option_value<bool>(methodHandle method, const char* option, bool& value); |
391 template bool CompilerOracle::has_option_value<ccstr>(methodHandle method, const char* option, ccstr& value); | |
370 | 392 |
371 bool CompilerOracle::should_exclude(methodHandle method, bool& quietly) { | 393 bool CompilerOracle::should_exclude(methodHandle method, bool& quietly) { |
372 quietly = true; | 394 quietly = true; |
373 if (lists[ExcludeCommand] != NULL) { | 395 if (lists[ExcludeCommand] != NULL) { |
374 if (lists[ExcludeCommand]->match(method)) { | 396 if (lists[ExcludeCommand]->match(method)) { |
556 total_bytes_read += bytes_read; | 578 total_bytes_read += bytes_read; |
557 return add_option_string(c_name, c_match, m_name, m_match, signature, flag, value); | 579 return add_option_string(c_name, c_match, m_name, m_match, signature, flag, value); |
558 } else { | 580 } else { |
559 jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s", flag, type); | 581 jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s", flag, type); |
560 } | 582 } |
583 } else if (strcmp(type, "ccstr") == 0) { | |
584 ResourceMark rm; | |
585 char* value = NEW_RESOURCE_ARRAY(char, strlen(line) + 1); | |
586 if (sscanf(line, "%*[ \t]%255[_a-zA-Z0-9]%n", value, &bytes_read) == 1) { | |
587 total_bytes_read += bytes_read; | |
588 return add_option_string(c_name, c_match, m_name, m_match, signature, flag, (ccstr)value); | |
589 } else { | |
590 jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s", flag, type); | |
591 } | |
592 } else if (strcmp(type, "ccstrlist") == 0) { | |
593 // Accumulates several strings into one. The internal type is ccstr. | |
594 ResourceMark rm; | |
595 char* value = NEW_RESOURCE_ARRAY(char, strlen(line) + 1); | |
596 char* next_value = value; | |
597 if (sscanf(line, "%*[ \t]%255[_a-zA-Z0-9]%n", next_value, &bytes_read) == 1) { | |
598 total_bytes_read += bytes_read; | |
599 line += bytes_read; | |
600 next_value += bytes_read; | |
601 char* end_value = next_value-1; | |
602 while (sscanf(line, "%*[ \t]%255[_a-zA-Z0-9]%n", next_value, &bytes_read) == 1) { | |
603 total_bytes_read += bytes_read; | |
604 line += bytes_read; | |
605 *end_value = ' '; // override '\0' | |
606 next_value += bytes_read; | |
607 end_value = next_value-1; | |
608 } | |
609 return add_option_string(c_name, c_match, m_name, m_match, signature, flag, (ccstr)value); | |
610 } else { | |
611 jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s", flag, type); | |
612 } | |
561 } else if (strcmp(type, "bool") == 0) { | 613 } else if (strcmp(type, "bool") == 0) { |
562 char value[256]; | 614 char value[256]; |
563 if (sscanf(line, "%*[ \t]%255[a-zA-Z]%n", value, &bytes_read) == 1) { | 615 if (sscanf(line, "%*[ \t]%255[a-zA-Z]%n", value, &bytes_read) == 1) { |
564 if (strcmp(value, "true") == 0) { | 616 if (strcmp(value, "true") == 0) { |
565 total_bytes_read += bytes_read; | 617 total_bytes_read += bytes_read; |
566 return add_option_string(c_name, c_match, m_name, m_match, signature, flag, true); | 618 return add_option_string(c_name, c_match, m_name, m_match, signature, flag, true); |
619 } else if (strcmp(value, "false") == 0) { | |
620 total_bytes_read += bytes_read; | |
621 return add_option_string(c_name, c_match, m_name, m_match, signature, flag, false); | |
567 } else { | 622 } else { |
568 jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s", flag, type); | 623 jio_snprintf(errorbuf, buf_size, " Value cannot be read for flag %s of type %s", flag, type); |
569 } | 624 } |
570 } else { | 625 } else { |
571 jio_snprintf(errorbuf, sizeof(errorbuf), " Value cannot be read for flag %s of type %s", flag, type); | 626 jio_snprintf(errorbuf, sizeof(errorbuf), " Value cannot be read for flag %s of type %s", flag, type); |
662 // | 717 // |
663 // Type (1) is used to support ciMethod::has_option("someflag") | 718 // Type (1) is used to support ciMethod::has_option("someflag") |
664 // (i.e., to check if a flag "someflag" is enabled for a method). | 719 // (i.e., to check if a flag "someflag" is enabled for a method). |
665 // | 720 // |
666 // Type (2) is used to support options with a value. Values can have the | 721 // Type (2) is used to support options with a value. Values can have the |
667 // the following types: intx, uintx, bool, ccstr, and ccstrlist. Currently, | 722 // the following types: intx, uintx, bool, ccstr, and ccstrlist. |
668 // values of type intx, uintx, and bool are supported. | |
669 // | 723 // |
670 // For future extensions: extend scan_flag_and_value() | 724 // For future extensions: extend scan_flag_and_value() |
671 char option[256]; // stores flag for Type (1) and type of Type (2) | 725 char option[256]; // stores flag for Type (1) and type of Type (2) |
672 while (sscanf(line, "%*[ \t]%255[a-zA-Z0-9]%n", option, &bytes_read) == 1) { | 726 while (sscanf(line, "%*[ \t]%255[a-zA-Z0-9]%n", option, &bytes_read) == 1) { |
673 if (match != NULL && !_quiet) { | 727 if (match != NULL && !_quiet) { |