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 7698 : 8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
Summary: Fixed whitespace handling and added test cases
Reviewed-by:


 672       // so read integer and fraction part of double value separately.
 673       if (sscanf(line, "%*[ \t]%255[0-9]%*[ /\t]%255[0-9]%n", buffer[0], buffer[1], &bytes_read) == 2) {
 674         char value[512] = "";
 675         strncat(value, buffer[0], 255);
 676         strcat(value, ".");
 677         strncat(value, buffer[1], 255);
 678         total_bytes_read += bytes_read;
 679         return add_option_string(c_name, c_match, m_name, m_match, signature, flag, atof(value));
 680       } else {
 681         jio_snprintf(errorbuf, buf_size, "  Value cannot be read for flag %s of type %s", flag, type);
 682       }
 683     } else {
 684       jio_snprintf(errorbuf, sizeof(errorbuf), "  Type %s not supported ", type);
 685     }
 686   } else {
 687     jio_snprintf(errorbuf, sizeof(errorbuf), "  Flag name for type %s should be alphanumeric ", type);
 688   }
 689   return NULL;
 690 }
 691 







 692 void CompilerOracle::parse_from_line(char* line) {
 693   if (line[0] == '\0') return;
 694   if (line[0] == '#')  return;
 695 
 696   bool have_colon = (strstr(line, "::") != NULL);
 697   for (char* lp = line; *lp != '\0'; lp++) {
 698     // Allow '.' to separate the class name from the method name.
 699     // This is the preferred spelling of methods:
 700     //      exclude java/lang/String.indexOf(I)I
 701     // Allow ',' for spaces (eases command line quoting).
 702     //      exclude,java/lang/String.indexOf
 703     // For backward compatibility, allow space as separator also.
 704     //      exclude java/lang/String indexOf
 705     //      exclude,java/lang/String,indexOf
 706     // For easy cut-and-paste of method names, allow VM output format
 707     // as produced by Method::print_short_name:
 708     //      exclude java.lang.String::indexOf
 709     // For simple implementation convenience here, convert them all to space.
 710     if (have_colon) {
 711       if (*lp == '.')  *lp = '/';   // dots build the package prefix


 738     return;
 739   }
 740 
 741   MethodMatcher::Mode c_match = MethodMatcher::Exact;
 742   MethodMatcher::Mode m_match = MethodMatcher::Exact;
 743   char class_name[256];
 744   char method_name[256];
 745   char sig[1024];
 746   char errorbuf[1024];
 747   const char* error_msg = NULL; // description of first error that appears
 748   MethodMatcher* match = NULL;
 749 
 750   if (scan_line(line, class_name, &c_match, method_name, &m_match, &bytes_read, error_msg)) {
 751     EXCEPTION_MARK;
 752     Symbol* c_name = SymbolTable::new_symbol(class_name, CHECK);
 753     Symbol* m_name = SymbolTable::new_symbol(method_name, CHECK);
 754     Symbol* signature = NULL;
 755 
 756     line += bytes_read;
 757 
 758     // Skip any leading spaces before signature
 759     int whitespace_read = 0;
 760     sscanf(line, "%*[ \t]%n", &whitespace_read);
 761     if (whitespace_read > 0) {
 762       line += whitespace_read;
 763     }
 764 
 765     // there might be a signature following the method.
 766     // signatures always begin with ( so match that by hand

 767     if (1 == sscanf(line, "(%254[[);/" RANGEBASE "]%n", sig + 1, &bytes_read)) {
 768       sig[0] = '(';
 769       line += bytes_read;
 770       signature = SymbolTable::new_symbol(sig, CHECK);
 771     }
 772 
 773     if (command == OptionCommand) {
 774       // Look for trailing options.
 775       //
 776       // Two types of trailing options are
 777       // supported:
 778       //
 779       // (1) CompileCommand=option,Klass::method,flag
 780       // (2) CompileCommand=option,Klass::method,type,flag,value
 781       //
 782       // Type (1) is used to enable a boolean flag for a method.
 783       //
 784       // Type (2) is used to support options with a value. Values can have the
 785       // the following types: intx, uintx, bool, ccstr, ccstrlist, and double.
 786       //
 787       // For future extensions: extend scan_flag_and_value()
 788       char option[256]; // stores flag for Type (1) and type of Type (2)
 789       while (sscanf(line, "%*[ \t]%255[a-zA-Z0-9]%n", option, &bytes_read) == 1) {


 790         if (match != NULL && !_quiet) {
 791           // Print out the last match added
 792           ttyLocker ttyl;
 793           tty->print("CompileCommand: %s ", command_names[command]);
 794           match->print();
 795         }
 796         line += bytes_read;
 797 
 798         if (strcmp(option, "intx") == 0
 799             || strcmp(option, "uintx") == 0
 800             || strcmp(option, "bool") == 0
 801             || strcmp(option, "ccstr") == 0
 802             || strcmp(option, "ccstrlist") == 0
 803             || strcmp(option, "double") == 0
 804             ) {
 805 
 806           // Type (2) option: parse flag name and value.
 807           match = scan_flag_and_value(option, line, bytes_read,
 808                                       c_name, c_match, m_name, m_match, signature,
 809                                       errorbuf, sizeof(errorbuf));
 810           if (match == NULL) {
 811             error_msg = errorbuf;
 812             break;
 813           }
 814           line += bytes_read;
 815         } else {
 816           // Type (1) option
 817           match = add_option_string(c_name, c_match, m_name, m_match, signature, option, true);
 818         }

 819       } // while(
 820     } else {
 821       match = add_predicate(command, c_name, c_match, m_name, m_match, signature);
 822     }
 823   }
 824 
 825   ttyLocker ttyl;
 826   if (error_msg != NULL) {
 827     // an error has happened
 828     tty->print_cr("CompileCommand: An error occured during parsing");
 829     tty->print_cr("  \"%s\"", original_line);
 830     if (error_msg != NULL) {
 831       tty->print_cr("%s", error_msg);
 832     }
 833     CompilerOracle::print_tip();
 834 
 835   } else {
 836     // check for remaining characters
 837     bytes_read = 0;
 838     sscanf(line, "%*[ \t]%n", &bytes_read);




 672       // so read integer and fraction part of double value separately.
 673       if (sscanf(line, "%*[ \t]%255[0-9]%*[ /\t]%255[0-9]%n", buffer[0], buffer[1], &bytes_read) == 2) {
 674         char value[512] = "";
 675         strncat(value, buffer[0], 255);
 676         strcat(value, ".");
 677         strncat(value, buffer[1], 255);
 678         total_bytes_read += bytes_read;
 679         return add_option_string(c_name, c_match, m_name, m_match, signature, flag, atof(value));
 680       } else {
 681         jio_snprintf(errorbuf, buf_size, "  Value cannot be read for flag %s of type %s", flag, type);
 682       }
 683     } else {
 684       jio_snprintf(errorbuf, sizeof(errorbuf), "  Type %s not supported ", type);
 685     }
 686   } else {
 687     jio_snprintf(errorbuf, sizeof(errorbuf), "  Flag name for type %s should be alphanumeric ", type);
 688   }
 689   return NULL;
 690 }
 691 
 692 int skip_whitespace(char* line) {
 693   // Skip any leading spaces
 694   int whitespace_read = 0;
 695   sscanf(line, "%*[ \t]%n", &whitespace_read);
 696   return whitespace_read;
 697 }
 698 
 699 void CompilerOracle::parse_from_line(char* line) {
 700   if (line[0] == '\0') return;
 701   if (line[0] == '#')  return;
 702 
 703   bool have_colon = (strstr(line, "::") != NULL);
 704   for (char* lp = line; *lp != '\0'; lp++) {
 705     // Allow '.' to separate the class name from the method name.
 706     // This is the preferred spelling of methods:
 707     //      exclude java/lang/String.indexOf(I)I
 708     // Allow ',' for spaces (eases command line quoting).
 709     //      exclude,java/lang/String.indexOf
 710     // For backward compatibility, allow space as separator also.
 711     //      exclude java/lang/String indexOf
 712     //      exclude,java/lang/String,indexOf
 713     // For easy cut-and-paste of method names, allow VM output format
 714     // as produced by Method::print_short_name:
 715     //      exclude java.lang.String::indexOf
 716     // For simple implementation convenience here, convert them all to space.
 717     if (have_colon) {
 718       if (*lp == '.')  *lp = '/';   // dots build the package prefix


 745     return;
 746   }
 747 
 748   MethodMatcher::Mode c_match = MethodMatcher::Exact;
 749   MethodMatcher::Mode m_match = MethodMatcher::Exact;
 750   char class_name[256];
 751   char method_name[256];
 752   char sig[1024];
 753   char errorbuf[1024];
 754   const char* error_msg = NULL; // description of first error that appears
 755   MethodMatcher* match = NULL;
 756 
 757   if (scan_line(line, class_name, &c_match, method_name, &m_match, &bytes_read, error_msg)) {
 758     EXCEPTION_MARK;
 759     Symbol* c_name = SymbolTable::new_symbol(class_name, CHECK);
 760     Symbol* m_name = SymbolTable::new_symbol(method_name, CHECK);
 761     Symbol* signature = NULL;
 762 
 763     line += bytes_read;
 764 







 765     // there might be a signature following the method.
 766     // signatures always begin with ( so match that by hand
 767     line += skip_whitespace(line);
 768     if (1 == sscanf(line, "(%254[[);/" RANGEBASE "]%n", sig + 1, &bytes_read)) {
 769       sig[0] = '(';
 770       line += bytes_read;
 771       signature = SymbolTable::new_symbol(sig, CHECK);
 772     }
 773 
 774     if (command == OptionCommand) {
 775       // Look for trailing options.
 776       //
 777       // Two types of trailing options are
 778       // supported:
 779       //
 780       // (1) CompileCommand=option,Klass::method,flag
 781       // (2) CompileCommand=option,Klass::method,type,flag,value
 782       //
 783       // Type (1) is used to enable a boolean flag for a method.
 784       //
 785       // Type (2) is used to support options with a value. Values can have the
 786       // the following types: intx, uintx, bool, ccstr, ccstrlist, and double.
 787       //
 788       // For future extensions: extend scan_flag_and_value()
 789       char option[256]; // stores flag for Type (1) and type of Type (2)
 790 
 791       line += skip_whitespace(line);
 792       while (sscanf(line, "%255[a-zA-Z0-9]%n", option, &bytes_read) == 1) {
 793         if (match != NULL && !_quiet) {
 794           // Print out the last match added
 795           ttyLocker ttyl;
 796           tty->print("CompileCommand: %s ", command_names[command]);
 797           match->print();
 798         }
 799         line += bytes_read;
 800 
 801         if (strcmp(option, "intx") == 0
 802             || strcmp(option, "uintx") == 0
 803             || strcmp(option, "bool") == 0
 804             || strcmp(option, "ccstr") == 0
 805             || strcmp(option, "ccstrlist") == 0
 806             || strcmp(option, "double") == 0
 807             ) {
 808 
 809           // Type (2) option: parse flag name and value.
 810           match = scan_flag_and_value(option, line, bytes_read,
 811                                       c_name, c_match, m_name, m_match, signature,
 812                                       errorbuf, sizeof(errorbuf));
 813           if (match == NULL) {
 814             error_msg = errorbuf;
 815             break;
 816           }
 817           line += bytes_read;
 818         } else {
 819           // Type (1) option
 820           match = add_option_string(c_name, c_match, m_name, m_match, signature, option, true);
 821         }
 822         line += skip_whitespace(line);
 823       } // while(
 824     } else {
 825       match = add_predicate(command, c_name, c_match, m_name, m_match, signature);
 826     }
 827   }
 828 
 829   ttyLocker ttyl;
 830   if (error_msg != NULL) {
 831     // an error has happened
 832     tty->print_cr("CompileCommand: An error occured during parsing");
 833     tty->print_cr("  \"%s\"", original_line);
 834     if (error_msg != NULL) {
 835       tty->print_cr("%s", error_msg);
 836     }
 837     CompilerOracle::print_tip();
 838 
 839   } else {
 840     // check for remaining characters
 841     bytes_read = 0;
 842     sscanf(line, "%*[ \t]%n", &bytes_read);


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