hotspot/src/share/vm/compiler/methodMatcher.cpp
changeset 33626 3c94db05e903
parent 33593 60764a78fa5c
parent 33468 b82c87453d2d
child 37248 11a660dbbb8e
equal deleted inserted replaced
33625:18e7896ca9fe 33626:3c94db05e903
   318   }
   318   }
   319   return false;
   319   return false;
   320 }
   320 }
   321 
   321 
   322 void MethodMatcher::print_symbol(outputStream* st, Symbol* h, Mode mode) {
   322 void MethodMatcher::print_symbol(outputStream* st, Symbol* h, Mode mode) {
   323   ResourceMark rm;
       
   324 
       
   325   if (mode == Suffix || mode == Substring || mode == Any) {
   323   if (mode == Suffix || mode == Substring || mode == Any) {
   326     st->print("*");
   324     st->print("*");
   327   }
   325   }
   328   if (mode != Any) {
   326   if (mode != Any) {
   329     h->print_symbol_on(st);
   327     h->print_utf8_on(st);
   330   }
   328   }
   331   if (mode == Prefix || mode == Substring) {
   329   if (mode == Prefix || mode == Substring) {
   332     st->print("*");
   330     st->print("*");
   333   }
   331   }
   334 }
   332 }
   335 
   333 
   336 void MethodMatcher::print_base(outputStream* st) {
   334 void MethodMatcher::print_base(outputStream* st) {
       
   335   ResourceMark rm;
       
   336 
   337   print_symbol(st, class_name(), _class_mode);
   337   print_symbol(st, class_name(), _class_mode);
   338   st->print(".");
   338   st->print(".");
   339   print_symbol(st, method_name(), _method_mode);
   339   print_symbol(st, method_name(), _method_mode);
   340   if (signature() != NULL) {
   340   if (signature() != NULL) {
   341     signature()->print_symbol_on(st);
   341     signature()->print_utf8_on(st);
   342   }
   342   }
   343 }
   343 }
   344 
   344 
   345 
   345 BasicMatcher* BasicMatcher::parse_method_pattern(char* line, const char*& error_msg) {
   346 
   346   assert(error_msg == NULL, "Don't call here with error_msg already set");
   347 
   347   BasicMatcher* bm = new BasicMatcher();
       
   348   MethodMatcher::parse_method_pattern(line, error_msg, bm);
       
   349   if (error_msg != NULL) {
       
   350     delete bm;
       
   351     return NULL;
       
   352   }
       
   353 
       
   354   // check for bad trailing characters
       
   355   int bytes_read = 0;
       
   356   sscanf(line, "%*[ \t]%n", &bytes_read);
       
   357   if (line[bytes_read] != '\0') {
       
   358     error_msg = "Unrecognized trailing text after method pattern";
       
   359     delete bm;
       
   360     return NULL;
       
   361   }
       
   362   return bm;
       
   363 }
       
   364 
       
   365 bool BasicMatcher::match(const methodHandle& method) {
       
   366   for (BasicMatcher* current = this; current != NULL; current = current->next()) {
       
   367     if (current->matches(method)) {
       
   368       return true;
       
   369     }
       
   370   }
       
   371   return false;
       
   372 }
       
   373 
       
   374 void InlineMatcher::print(outputStream* st) {
       
   375   if (_inline_action == InlineMatcher::force_inline) {
       
   376     st->print("+");
       
   377   } else {
       
   378     st->print("-");
       
   379   }
       
   380   print_base(st);
       
   381 }
       
   382 
       
   383 InlineMatcher* InlineMatcher::parse_method_pattern(char* line, const char*& error_msg) {
       
   384   assert(error_msg == NULL, "Dont call here with error_msg already set");
       
   385   InlineMatcher* im = new InlineMatcher();
       
   386   MethodMatcher::parse_method_pattern(line, error_msg, im);
       
   387   if (error_msg != NULL) {
       
   388     delete im;
       
   389     return NULL;
       
   390   }
       
   391   return im;
       
   392 }
       
   393 
       
   394 bool InlineMatcher::match(const methodHandle& method, int inline_action) {
       
   395   for (InlineMatcher* current = this; current != NULL; current = current->next()) {
       
   396     if (current->matches(method)) {
       
   397       return (current->_inline_action == inline_action);
       
   398     }
       
   399   }
       
   400   return false;
       
   401 }
       
   402 
       
   403 InlineMatcher* InlineMatcher::parse_inline_pattern(char* str, const char*& error_msg) {
       
   404   // check first token is +/-
       
   405   InlineType _inline_action;
       
   406    switch (str[0]) {
       
   407    case '-':
       
   408      _inline_action = InlineMatcher::dont_inline;
       
   409      break;
       
   410    case '+':
       
   411      _inline_action = InlineMatcher::force_inline;
       
   412      break;
       
   413    default:
       
   414      error_msg = "Missing leading inline type (+/-)";
       
   415      return NULL;
       
   416    }
       
   417    str++;
       
   418 
       
   419    int bytes_read = 0;
       
   420    assert(error_msg== NULL, "error_msg must not be set yet");
       
   421    InlineMatcher* im = InlineMatcher::parse_method_pattern(str, error_msg);
       
   422    if (im == NULL) {
       
   423      assert(error_msg != NULL, "Must have error message");
       
   424      return NULL;
       
   425    }
       
   426    im->set_action(_inline_action);
       
   427    return im;
       
   428 }
       
   429 
       
   430 InlineMatcher* InlineMatcher::clone() {
       
   431    InlineMatcher* m = new InlineMatcher();
       
   432    m->_class_mode =  _class_mode;
       
   433    m->_method_mode = _method_mode;
       
   434    m->_inline_action = _inline_action;
       
   435    m->_class_name = _class_name;
       
   436    if(_class_name != NULL) {
       
   437      _class_name->increment_refcount();
       
   438    }
       
   439    m->_method_name = _method_name;
       
   440    if (_method_name != NULL) {
       
   441      _method_name->increment_refcount();
       
   442    }
       
   443    m->_signature = _signature;
       
   444    if (_signature != NULL) {
       
   445      _signature->increment_refcount();
       
   446    }
       
   447    return m;
       
   448 }