475 tty->print_cr(" from being compiled and compileonly excludes all methods except for");
476 tty->print_cr(" the ones mentioned by compileonly directives. The basic form of");
477 tty->print_cr(" all commands is a command name followed by the name of the method");
478 tty->print_cr(" in one of two forms: the standard class file format as in");
479 tty->print_cr(" class/name.methodName or the PrintCompilation format");
480 tty->print_cr(" class.name::methodName. The method name can optionally be followed");
481 tty->print_cr(" by a space then the signature of the method in the class file");
482 tty->print_cr(" format. Otherwise the directive applies to all methods with the");
483 tty->print_cr(" same name and class regardless of signature. Leading and trailing");
484 tty->print_cr(" *'s in the class and/or method name allows a small amount of");
485 tty->print_cr(" wildcarding. ");
486 tty->cr();
487 tty->print_cr(" Examples:");
488 tty->cr();
489 tty->print_cr(" exclude java/lang/StringBuffer.append");
490 tty->print_cr(" compileonly java/lang/StringBuffer.toString ()Ljava/lang/String;");
491 tty->print_cr(" exclude java/lang/String*.*");
492 tty->print_cr(" exclude *.toString");
493 }
494
495
496 // The characters allowed in a class or method name. All characters > 0x7f
497 // are allowed in order to handle obfuscated class files (e.g. Volano)
498 #define RANGEBASE "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$_<>" \
499 "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" \
500 "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" \
501 "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" \
502 "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" \
503 "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" \
504 "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" \
505 "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef" \
506 "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
507
508 #define RANGE0 "[*" RANGEBASE "]"
509 #define RANGESLASH "[*" RANGEBASE "/]"
510
511 static MethodMatcher::Mode check_mode(char name[], const char*& error_msg) {
512 int match = MethodMatcher::Exact;
513 while (name[0] == '*') {
514 match |= MethodMatcher::Suffix;
515 strcpy(name, name + 1);
516 }
517
518 if (strcmp(name, "*") == 0) return MethodMatcher::Any;
519
520 size_t len = strlen(name);
521 while (len > 0 && name[len - 1] == '*') {
522 match |= MethodMatcher::Prefix;
523 name[--len] = '\0';
524 }
525
526 if (strstr(name, "*") != NULL) {
664 // exclude,java/lang/String,indexOf
665 // For easy cut-and-paste of method names, allow VM output format
666 // as produced by Method::print_short_name:
667 // exclude java.lang.String::indexOf
668 // For simple implementation convenience here, convert them all to space.
669 if (have_colon) {
670 if (*lp == '.') *lp = '/'; // dots build the package prefix
671 if (*lp == ':') *lp = ' ';
672 }
673 if (*lp == ',' || *lp == '.') *lp = ' ';
674 }
675
676 char* original_line = line;
677 int bytes_read;
678 OracleCommand command = parse_command_name(line, &bytes_read);
679 line += bytes_read;
680 ResourceMark rm;
681
682 if (command == UnknownCommand) {
683 ttyLocker ttyl;
684 tty->print_cr("CompilerOracle: unrecognized line");
685 tty->print_cr(" \"%s\"", original_line);
686 return;
687 }
688
689 if (command == QuietCommand) {
690 _quiet = true;
691 return;
692 }
693
694 if (command == HelpCommand) {
695 usage();
696 return;
697 }
698
699 MethodMatcher::Mode c_match = MethodMatcher::Exact;
700 MethodMatcher::Mode m_match = MethodMatcher::Exact;
701 char class_name[256];
702 char method_name[256];
703 char sig[1024];
704 char errorbuf[1024];
723 if (command == OptionCommand) {
724 // Look for trailing options.
725 //
726 // Two types of trailing options are
727 // supported:
728 //
729 // (1) CompileCommand=option,Klass::method,flag
730 // (2) CompileCommand=option,Klass::method,type,flag,value
731 //
732 // Type (1) is used to enable a boolean flag for a method.
733 //
734 // Type (2) is used to support options with a value. Values can have the
735 // the following types: intx, uintx, bool, ccstr, ccstrlist, and double.
736 //
737 // For future extensions: extend scan_flag_and_value()
738 char option[256]; // stores flag for Type (1) and type of Type (2)
739 while (sscanf(line, "%*[ \t]%255[a-zA-Z0-9]%n", option, &bytes_read) == 1) {
740 if (match != NULL && !_quiet) {
741 // Print out the last match added
742 ttyLocker ttyl;
743 tty->print("CompilerOracle: %s ", command_names[command]);
744 match->print();
745 }
746 line += bytes_read;
747
748 if (strcmp(option, "intx") == 0
749 || strcmp(option, "uintx") == 0
750 || strcmp(option, "bool") == 0
751 || strcmp(option, "ccstr") == 0
752 || strcmp(option, "ccstrlist") == 0
753 || strcmp(option, "double") == 0
754 ) {
755
756 // Type (2) option: parse flag name and value.
757 match = scan_flag_and_value(option, line, bytes_read,
758 c_name, c_match, m_name, m_match, signature,
759 errorbuf, sizeof(errorbuf));
760 if (match == NULL) {
761 error_msg = errorbuf;
762 break;
763 }
764 line += bytes_read;
765 } else {
766 // Type (1) option
767 match = add_option_string(c_name, c_match, m_name, m_match, signature, option, true);
768 }
769 } // while(
770 } else {
771 match = add_predicate(command, c_name, c_match, m_name, m_match, signature);
772 }
773 }
774
775 ttyLocker ttyl;
776 if (error_msg != NULL) {
777 // an error has happened
778 tty->print_cr("CompilerOracle: unrecognized line");
779 tty->print_cr(" \"%s\"", original_line);
780 if (error_msg != NULL) {
781 tty->print_cr("%s", error_msg);
782 }
783 } else {
784 // check for remaining characters
785 bytes_read = 0;
786 sscanf(line, "%*[ \t]%n", &bytes_read);
787 if (line[bytes_read] != '\0') {
788 tty->print_cr("CompilerOracle: unrecognized line");
789 tty->print_cr(" \"%s\"", original_line);
790 tty->print_cr(" Unrecognized text %s after command ", line);
791 } else if (match != NULL && !_quiet) {
792 tty->print("CompilerOracle: %s ", command_names[command]);
793 match->print();
794 }
795 }
796 }
797
798 static const char* default_cc_file = ".hotspot_compiler";
799
800 static const char* cc_file() {
801 #ifdef ASSERT
802 if (CompileCommandFile == NULL)
803 return default_cc_file;
804 #endif
805 return CompileCommandFile;
806 }
807
808 bool CompilerOracle::has_command_file() {
809 return cc_file() != NULL;
810 }
811
812 bool CompilerOracle::_quiet = false;
|
475 tty->print_cr(" from being compiled and compileonly excludes all methods except for");
476 tty->print_cr(" the ones mentioned by compileonly directives. The basic form of");
477 tty->print_cr(" all commands is a command name followed by the name of the method");
478 tty->print_cr(" in one of two forms: the standard class file format as in");
479 tty->print_cr(" class/name.methodName or the PrintCompilation format");
480 tty->print_cr(" class.name::methodName. The method name can optionally be followed");
481 tty->print_cr(" by a space then the signature of the method in the class file");
482 tty->print_cr(" format. Otherwise the directive applies to all methods with the");
483 tty->print_cr(" same name and class regardless of signature. Leading and trailing");
484 tty->print_cr(" *'s in the class and/or method name allows a small amount of");
485 tty->print_cr(" wildcarding. ");
486 tty->cr();
487 tty->print_cr(" Examples:");
488 tty->cr();
489 tty->print_cr(" exclude java/lang/StringBuffer.append");
490 tty->print_cr(" compileonly java/lang/StringBuffer.toString ()Ljava/lang/String;");
491 tty->print_cr(" exclude java/lang/String*.*");
492 tty->print_cr(" exclude *.toString");
493 }
494
495 // The characters allowed in a class or method name.
496 // Chars in ascii range 0x00-0x7f can only exist in UTF8 single byte encoding.
497 // The range 0xc00-0xf7 is the first byte in a multibyte sequence
498 // The range 0x80-0xbf are for the followers in a multibyte sequence
499 // The range 0xf7-0xff can not exist in any position.
500 // 0x00 is a legal part identifer but we can not support that.
501 // The parser accepts all matching Charachter.isJavaIdentiferPart -
502 // that means some illegal patterns may be specified. They will never
503 // match any method or class.
504
505 #define RANGEBASE "\x1\x2\x3\x4\x5\x6\x7\x8\xe\xf" \
506 "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b" \
507 "\x24" \
508 "\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39" \
509 "\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f" \
510 "\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5f" \
511 "\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f" \
512 "\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7f" \
513 "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" \
514 "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" \
515 "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" \
516 "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" \
517 "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" \
518 "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" \
519 "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef" \
520 "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
521
522 #define RANGE0 "[*" RANGEBASE "]"
523 #define RANGESLASH "[*" RANGEBASE "/]"
524
525 static MethodMatcher::Mode check_mode(char name[], const char*& error_msg) {
526 int match = MethodMatcher::Exact;
527 while (name[0] == '*') {
528 match |= MethodMatcher::Suffix;
529 strcpy(name, name + 1);
530 }
531
532 if (strcmp(name, "*") == 0) return MethodMatcher::Any;
533
534 size_t len = strlen(name);
535 while (len > 0 && name[len - 1] == '*') {
536 match |= MethodMatcher::Prefix;
537 name[--len] = '\0';
538 }
539
540 if (strstr(name, "*") != NULL) {
678 // exclude,java/lang/String,indexOf
679 // For easy cut-and-paste of method names, allow VM output format
680 // as produced by Method::print_short_name:
681 // exclude java.lang.String::indexOf
682 // For simple implementation convenience here, convert them all to space.
683 if (have_colon) {
684 if (*lp == '.') *lp = '/'; // dots build the package prefix
685 if (*lp == ':') *lp = ' ';
686 }
687 if (*lp == ',' || *lp == '.') *lp = ' ';
688 }
689
690 char* original_line = line;
691 int bytes_read;
692 OracleCommand command = parse_command_name(line, &bytes_read);
693 line += bytes_read;
694 ResourceMark rm;
695
696 if (command == UnknownCommand) {
697 ttyLocker ttyl;
698 tty->print_cr("CompileCommand: unrecognized command");
699 tty->print_cr(" \"%s\"", original_line);
700 return;
701 }
702
703 if (command == QuietCommand) {
704 _quiet = true;
705 return;
706 }
707
708 if (command == HelpCommand) {
709 usage();
710 return;
711 }
712
713 MethodMatcher::Mode c_match = MethodMatcher::Exact;
714 MethodMatcher::Mode m_match = MethodMatcher::Exact;
715 char class_name[256];
716 char method_name[256];
717 char sig[1024];
718 char errorbuf[1024];
737 if (command == OptionCommand) {
738 // Look for trailing options.
739 //
740 // Two types of trailing options are
741 // supported:
742 //
743 // (1) CompileCommand=option,Klass::method,flag
744 // (2) CompileCommand=option,Klass::method,type,flag,value
745 //
746 // Type (1) is used to enable a boolean flag for a method.
747 //
748 // Type (2) is used to support options with a value. Values can have the
749 // the following types: intx, uintx, bool, ccstr, ccstrlist, and double.
750 //
751 // For future extensions: extend scan_flag_and_value()
752 char option[256]; // stores flag for Type (1) and type of Type (2)
753 while (sscanf(line, "%*[ \t]%255[a-zA-Z0-9]%n", option, &bytes_read) == 1) {
754 if (match != NULL && !_quiet) {
755 // Print out the last match added
756 ttyLocker ttyl;
757 tty->print("CompileCommand: %s ", command_names[command]);
758 match->print();
759 }
760 line += bytes_read;
761
762 if (strcmp(option, "intx") == 0
763 || strcmp(option, "uintx") == 0
764 || strcmp(option, "bool") == 0
765 || strcmp(option, "ccstr") == 0
766 || strcmp(option, "ccstrlist") == 0
767 || strcmp(option, "double") == 0
768 ) {
769
770 // Type (2) option: parse flag name and value.
771 match = scan_flag_and_value(option, line, bytes_read,
772 c_name, c_match, m_name, m_match, signature,
773 errorbuf, sizeof(errorbuf));
774 if (match == NULL) {
775 error_msg = errorbuf;
776 break;
777 }
778 line += bytes_read;
779 } else {
780 // Type (1) option
781 match = add_option_string(c_name, c_match, m_name, m_match, signature, option, true);
782 }
783 } // while(
784 } else {
785 match = add_predicate(command, c_name, c_match, m_name, m_match, signature);
786 }
787 }
788
789 ttyLocker ttyl;
790 if (error_msg != NULL) {
791 // an error has happened
792 tty->print_cr("CompileCommand: An error occured during parsing");
793 tty->print_cr(" \"%s\"", original_line);
794 if (error_msg != NULL) {
795 tty->print_cr("%s", error_msg);
796 }
797 } else {
798 // check for remaining characters
799 bytes_read = 0;
800 sscanf(line, "%*[ \t]%n", &bytes_read);
801 if (line[bytes_read] != '\0') {
802 tty->print_cr("CompileCommand: Bad pattern");
803 tty->print_cr(" \"%s\"", original_line);
804 tty->print_cr(" Unrecognized text %s after command ", line);
805 } else if (match != NULL && !_quiet) {
806 tty->print("CompilerCommand: %s ", command_names[command]);
807 match->print();
808 }
809 }
810 }
811
812 static const char* default_cc_file = ".hotspot_compiler";
813
814 static const char* cc_file() {
815 #ifdef ASSERT
816 if (CompileCommandFile == NULL)
817 return default_cc_file;
818 #endif
819 return CompileCommandFile;
820 }
821
822 bool CompilerOracle::has_command_file() {
823 return cc_file() != NULL;
824 }
825
826 bool CompilerOracle::_quiet = false;
|