src/share/vm/compiler/compilerOracle.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/compiler

src/share/vm/compiler/compilerOracle.cpp

Print this page
rev 8995 : 8046155: JEP165: Compiler Control
Summary:
Reviewed-by:


  89 
  90 // this must parallel the enum OracleCommand
  91 static const char * command_names[] = {
  92   "break",
  93   "print",
  94   "exclude",
  95   "inline",
  96   "dontinline",
  97   "compileonly",
  98   "log",
  99   "option",
 100   "quiet",
 101   "help"
 102 };
 103 
 104 class MethodMatcher;
 105 class TypedMethodOptionMatcher;
 106 
 107 static BasicMatcher* lists[OracleCommandCount] = { 0, };
 108 static TypedMethodOptionMatcher* option_list = NULL;

 109 
 110 class TypedMethodOptionMatcher : public MethodMatcher {
 111  private:
 112   TypedMethodOptionMatcher* _next;
 113   const char*   _option;
 114   OptionType    _type;
 115  public:
 116 
 117   union {
 118     bool bool_value;
 119     intx intx_value;
 120     uintx uintx_value;
 121     double double_value;
 122     ccstr ccstr_value;
 123   } _u;
 124 
 125   TypedMethodOptionMatcher() : MethodMatcher(),
 126     _next(NULL),
 127     _type(UnknownType) {
 128       _option = NULL;


 275     if (current->type() == type) {
 276       if (strcmp(current->_option, opt) == 0) {
 277         if (current->matches(method)) {
 278           return current;
 279         }
 280       }
 281     }
 282     current = current->next();
 283   }
 284   return NULL;
 285 }
 286 
 287 template<typename T>
 288 static void add_option_string(TypedMethodOptionMatcher* matcher,
 289                                         const char* option,
 290                                         T value) {
 291   assert(matcher != option_list, "No circular lists please");
 292   matcher->init(option, get_type_for<T>(), option_list);
 293   matcher->set_value<T>(value);
 294   option_list = matcher;

 295   return;
 296 }
 297 
 298 static bool check_predicate(OracleCommand command, methodHandle method) {
 299   return ((lists[command] != NULL) &&
 300           !method.is_null() &&
 301           lists[command]->match(method));
 302 }
 303 
 304 static void add_predicate(OracleCommand command, BasicMatcher* bm) {
 305   assert(command != OptionCommand, "must use add_option_string");
 306   if (command == LogCommand && !LogCompilation && lists[LogCommand] == NULL) {
 307     tty->print_cr("Warning:  +LogCompilation must be enabled in order for individual methods to be logged.");
 308   }
 309   bm->set_next(lists[command]);
 310   lists[command] = bm;
 311 


 312   return;
 313 }
 314 
 315 template<typename T>
 316 bool CompilerOracle::has_option_value(methodHandle method, const char* option, T& value) {
 317   if (option_list != NULL) {
 318     TypedMethodOptionMatcher* m = option_list->match(method, option, get_type_for<T>());
 319     if (m != NULL) {
 320       value = m->value<T>();
 321       return true;
 322     }
 323   }
 324   return false;
 325 }
 326 




 327 // Explicit instantiation for all OptionTypes supported.
 328 template bool CompilerOracle::has_option_value<intx>(methodHandle method, const char* option, intx& value);
 329 template bool CompilerOracle::has_option_value<uintx>(methodHandle method, const char* option, uintx& value);
 330 template bool CompilerOracle::has_option_value<bool>(methodHandle method, const char* option, bool& value);
 331 template bool CompilerOracle::has_option_value<ccstr>(methodHandle method, const char* option, ccstr& value);
 332 template bool CompilerOracle::has_option_value<double>(methodHandle method, const char* option, double& value);
 333 
 334 bool CompilerOracle::has_option_string(methodHandle method, const char* option) {
 335   bool value = false;
 336   has_option_value(method, option, value);
 337   return value;
 338 }
 339 
 340 bool CompilerOracle::should_exclude(methodHandle method, bool& quietly) {
 341   quietly = true;
 342   if (lists[ExcludeCommand] != NULL) {
 343     if (lists[ExcludeCommand]->match(method)) {
 344       quietly = _quiet;
 345       return true;
 346     }
 347   }
 348 
 349   if (lists[CompileOnlyCommand] != NULL) {
 350     return !lists[CompileOnlyCommand]->match(method);
 351   }
 352   return false;
 353 }
 354 
 355 bool CompilerOracle::should_inline(methodHandle method) {
 356   return (check_predicate(InlineCommand, method));
 357 }
 358 
 359 // Check both DontInlineCommand and ExcludeCommand here
 360 // - consistent behavior for all compilers
 361 bool CompilerOracle::should_not_inline(methodHandle method) {
 362   return check_predicate(DontInlineCommand, method) || check_predicate(ExcludeCommand, method);
 363 }
 364 
 365 bool CompilerOracle::should_print(methodHandle method) {
 366   return check_predicate(PrintCommand, method);
 367 }
 368 
 369 bool CompilerOracle::should_print_methods() {
 370   return lists[PrintCommand] != NULL;
 371 }
 372 
 373 bool CompilerOracle::should_log(methodHandle method) {
 374   if (!LogCompilation)            return false;
 375   if (lists[LogCommand] == NULL)  return true;  // by default, log all
 376   return (check_predicate(LogCommand, method));
 377 }
 378 
 379 bool CompilerOracle::should_break_at(methodHandle method) {
 380   return check_predicate(BreakCommand, method);




  89 
  90 // this must parallel the enum OracleCommand
  91 static const char * command_names[] = {
  92   "break",
  93   "print",
  94   "exclude",
  95   "inline",
  96   "dontinline",
  97   "compileonly",
  98   "log",
  99   "option",
 100   "quiet",
 101   "help"
 102 };
 103 
 104 class MethodMatcher;
 105 class TypedMethodOptionMatcher;
 106 
 107 static BasicMatcher* lists[OracleCommandCount] = { 0, };
 108 static TypedMethodOptionMatcher* option_list = NULL;
 109 static bool any_set = false;
 110 
 111 class TypedMethodOptionMatcher : public MethodMatcher {
 112  private:
 113   TypedMethodOptionMatcher* _next;
 114   const char*   _option;
 115   OptionType    _type;
 116  public:
 117 
 118   union {
 119     bool bool_value;
 120     intx intx_value;
 121     uintx uintx_value;
 122     double double_value;
 123     ccstr ccstr_value;
 124   } _u;
 125 
 126   TypedMethodOptionMatcher() : MethodMatcher(),
 127     _next(NULL),
 128     _type(UnknownType) {
 129       _option = NULL;


 276     if (current->type() == type) {
 277       if (strcmp(current->_option, opt) == 0) {
 278         if (current->matches(method)) {
 279           return current;
 280         }
 281       }
 282     }
 283     current = current->next();
 284   }
 285   return NULL;
 286 }
 287 
 288 template<typename T>
 289 static void add_option_string(TypedMethodOptionMatcher* matcher,
 290                                         const char* option,
 291                                         T value) {
 292   assert(matcher != option_list, "No circular lists please");
 293   matcher->init(option, get_type_for<T>(), option_list);
 294   matcher->set_value<T>(value);
 295   option_list = matcher;
 296   any_set = true;
 297   return;
 298 }
 299 
 300 static bool check_predicate(OracleCommand command, methodHandle method) {
 301   return ((lists[command] != NULL) &&
 302           !method.is_null() &&
 303           lists[command]->match(method));
 304 }
 305 
 306 static void add_predicate(OracleCommand command, BasicMatcher* bm) {
 307   assert(command != OptionCommand, "must use add_option_string");
 308   if (command == LogCommand && !LogCompilation && lists[LogCommand] == NULL) {
 309     tty->print_cr("Warning:  +LogCompilation must be enabled in order for individual methods to be logged.");
 310   }
 311   bm->set_next(lists[command]);
 312   lists[command] = bm;
 313   if ((command != DontInlineCommand) && (command != InlineCommand)) {
 314     any_set = true;
 315   }
 316   return;
 317 }
 318 
 319 template<typename T>
 320 bool CompilerOracle::has_option_value(methodHandle method, const char* option, T& value) {
 321   if (option_list != NULL) {
 322     TypedMethodOptionMatcher* m = option_list->match(method, option, get_type_for<T>());
 323     if (m != NULL) {
 324       value = m->value<T>();
 325       return true;
 326     }
 327   }
 328   return false;
 329 }
 330 
 331 bool CompilerOracle::has_any_option() {
 332   return any_set;
 333 }
 334 
 335 // Explicit instantiation for all OptionTypes supported.
 336 template bool CompilerOracle::has_option_value<intx>(methodHandle method, const char* option, intx& value);
 337 template bool CompilerOracle::has_option_value<uintx>(methodHandle method, const char* option, uintx& value);
 338 template bool CompilerOracle::has_option_value<bool>(methodHandle method, const char* option, bool& value);
 339 template bool CompilerOracle::has_option_value<ccstr>(methodHandle method, const char* option, ccstr& value);
 340 template bool CompilerOracle::has_option_value<double>(methodHandle method, const char* option, double& value);
 341 
 342 bool CompilerOracle::has_option_string(methodHandle method, const char* option) {
 343   bool value = false;
 344   has_option_value(method, option, value);
 345   return value;
 346 }
 347 
 348 bool CompilerOracle::should_exclude(methodHandle method) {
 349   if (check_predicate(ExcludeCommand, method)) {



 350     return true;
 351   }


 352   if (lists[CompileOnlyCommand] != NULL) {
 353     return !lists[CompileOnlyCommand]->match(method);
 354   }
 355   return false;
 356 }
 357 
 358 bool CompilerOracle::should_inline(methodHandle method) {
 359   return (check_predicate(InlineCommand, method));
 360 }
 361 


 362 bool CompilerOracle::should_not_inline(methodHandle method) {
 363   return check_predicate(DontInlineCommand, method) || check_predicate(ExcludeCommand, method);
 364 }
 365 
 366 bool CompilerOracle::should_print(methodHandle method) {
 367   return check_predicate(PrintCommand, method);
 368 }
 369 
 370 bool CompilerOracle::should_print_methods() {
 371   return lists[PrintCommand] != NULL;
 372 }
 373 
 374 bool CompilerOracle::should_log(methodHandle method) {
 375   if (!LogCompilation)            return false;
 376   if (lists[LogCommand] == NULL)  return true;  // by default, log all
 377   return (check_predicate(LogCommand, method));
 378 }
 379 
 380 bool CompilerOracle::should_break_at(methodHandle method) {
 381   return check_predicate(BreakCommand, method);


src/share/vm/compiler/compilerOracle.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File