< prev index next >

src/share/vm/runtime/arguments.cpp

Print this page




 761   struct dirent *entry;
 762   char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory), mtArguments);
 763   while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL) {
 764     const char* name = entry->d_name;
 765     const char* ext = name + strlen(name) - 4;
 766     bool isJarOrZip = ext > name &&
 767       (os::file_name_strcmp(ext, ".jar") == 0 ||
 768        os::file_name_strcmp(ext, ".zip") == 0);
 769     if (isJarOrZip) {
 770       char* jarpath = NEW_C_HEAP_ARRAY(char, directory_len + 2 + strlen(name), mtArguments);
 771       sprintf(jarpath, "%s%s%s", directory, dir_sep, name);
 772       path = add_to_path(path, jarpath, false);
 773       FREE_C_HEAP_ARRAY(char, jarpath);
 774     }
 775   }
 776   FREE_C_HEAP_ARRAY(char, dbuf);
 777   os::closedir(dir);
 778   return path;
 779 }
 780 
 781 // Parses a memory size specification string.
 782 static bool atomull(const char *s, julong* result) {
 783   julong n = 0;
 784   int args_read = 0;
 785   bool is_hex = false;
 786   // Skip leading 0[xX] for hexadecimal
 787   if (*s =='0' && (*(s+1) == 'x' || *(s+1) == 'X')) {
 788     s += 2;
 789     is_hex = true;
 790     args_read = sscanf(s, JULONG_FORMAT_X, &n);
 791   } else {
 792     args_read = sscanf(s, JULONG_FORMAT, &n);
 793   }
 794   if (args_read != 1) {
 795     return false;
 796   }
 797   while (*s != '\0' && (isdigit(*s) || (is_hex && isxdigit(*s)))) {
 798     s++;
 799   }
 800   // 4705540: illegal if more characters are found after the first non-digit
 801   if (strlen(s) > 1) {
 802     return false;


 868     return false;
 869   }
 870 
 871   if (CommandLineFlags::doubleAtPut(name, &v, origin) == Flag::SUCCESS) {
 872     return true;
 873   }
 874   return false;
 875 }
 876 
 877 static bool set_numeric_flag(const char* name, char* value, Flag::Flags origin) {
 878   julong v;
 879   int int_v;
 880   intx intx_v;
 881   bool is_neg = false;
 882   Flag* result = Flag::find_flag(name, strlen(name));
 883 
 884   if (result == NULL) {
 885     return false;
 886   }
 887 
 888   // Check the sign first since atomull() parses only unsigned values.
 889   if (*value == '-') {
 890     if (!result->is_intx() && !result->is_int()) {
 891       return false;
 892     }
 893     value++;
 894     is_neg = true;
 895   }
 896   if (!atomull(value, &v)) {
 897     return false;
 898   }
 899   if (result->is_int()) {
 900     int_v = (int) v;
 901     if (is_neg) {
 902       int_v = -int_v;
 903     }
 904     return CommandLineFlags::intAtPut(result, &int_v, origin) == Flag::SUCCESS;
 905   } else if (result->is_uint()) {
 906     uint uint_v = (uint) v;
 907     return CommandLineFlags::uintAtPut(result, &uint_v, origin) == Flag::SUCCESS;
 908   } else if (result->is_intx()) {
 909     intx_v = (intx) v;
 910     if (is_neg) {
 911       intx_v = -intx_v;
 912     }
 913     return CommandLineFlags::intxAtPut(result, &intx_v, origin) == Flag::SUCCESS;
 914   } else if (result->is_uintx()) {
 915     uintx uintx_v = (uintx) v;
 916     return CommandLineFlags::uintxAtPut(result, &uintx_v, origin) == Flag::SUCCESS;


2640   } else {
2641     jio_fprintf(defaultStream::error_stream(),
2642                 "Unrecognized %s%soption: %s\n", option_type, spacer,
2643       option->optionString);
2644     return true;
2645   }
2646 }
2647 
2648 static const char* user_assertion_options[] = {
2649   "-da", "-ea", "-disableassertions", "-enableassertions", 0
2650 };
2651 
2652 static const char* system_assertion_options[] = {
2653   "-dsa", "-esa", "-disablesystemassertions", "-enablesystemassertions", 0
2654 };
2655 
2656 bool Arguments::parse_uintx(const char* value,
2657                             uintx* uintx_arg,
2658                             uintx min_size) {
2659 
2660   // Check the sign first since atomull() parses only unsigned values.
2661   bool value_is_positive = !(*value == '-');
2662 
2663   if (value_is_positive) {
2664     julong n;
2665     bool good_return = atomull(value, &n);
2666     if (good_return) {
2667       bool above_minimum = n >= min_size;
2668       bool value_is_too_large = n > max_uintx;
2669 
2670       if (above_minimum && !value_is_too_large) {
2671         *uintx_arg = n;
2672         return true;
2673       }
2674     }
2675   }
2676   return false;
2677 }
2678 
2679 Arguments::ArgsRange Arguments::parse_memory_size(const char* s,
2680                                                   julong* long_arg,
2681                                                   julong min_size) {
2682   if (!atomull(s, long_arg)) return arg_unreadable;
2683   return check_memory_size(*long_arg, min_size);
2684 }
2685 
2686 // Parse JavaVMInitArgs structure
2687 
2688 jint Arguments::parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args,
2689                                    const JavaVMInitArgs *java_options_args,
2690                                    const JavaVMInitArgs *cmd_line_args) {
2691   // For components of the system classpath.
2692   ArgumentBootClassPath bcp(Arguments::get_sysclasspath());
2693   bool bcp_assembly_required = false;
2694 
2695   // Save default settings for some mode flags
2696   Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods;
2697   Arguments::_UseOnStackReplacement    = UseOnStackReplacement;
2698   Arguments::_ClipInlining             = ClipInlining;
2699   Arguments::_BackgroundCompilation    = BackgroundCompilation;
2700   if (TieredCompilation) {
2701     Arguments::_Tier3InvokeNotifyFreqLog = Tier3InvokeNotifyFreqLog;
2702     Arguments::_Tier4InvocationThreshold = Tier4InvocationThreshold;




 761   struct dirent *entry;
 762   char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory), mtArguments);
 763   while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL) {
 764     const char* name = entry->d_name;
 765     const char* ext = name + strlen(name) - 4;
 766     bool isJarOrZip = ext > name &&
 767       (os::file_name_strcmp(ext, ".jar") == 0 ||
 768        os::file_name_strcmp(ext, ".zip") == 0);
 769     if (isJarOrZip) {
 770       char* jarpath = NEW_C_HEAP_ARRAY(char, directory_len + 2 + strlen(name), mtArguments);
 771       sprintf(jarpath, "%s%s%s", directory, dir_sep, name);
 772       path = add_to_path(path, jarpath, false);
 773       FREE_C_HEAP_ARRAY(char, jarpath);
 774     }
 775   }
 776   FREE_C_HEAP_ARRAY(char, dbuf);
 777   os::closedir(dir);
 778   return path;
 779 }
 780 
 781 // Parses a size specification string.
 782 bool Arguments::atojulong(const char *s, julong* result) {
 783   julong n = 0;
 784   int args_read = 0;
 785   bool is_hex = false;
 786   // Skip leading 0[xX] for hexadecimal
 787   if (*s =='0' && (*(s+1) == 'x' || *(s+1) == 'X')) {
 788     s += 2;
 789     is_hex = true;
 790     args_read = sscanf(s, JULONG_FORMAT_X, &n);
 791   } else {
 792     args_read = sscanf(s, JULONG_FORMAT, &n);
 793   }
 794   if (args_read != 1) {
 795     return false;
 796   }
 797   while (*s != '\0' && (isdigit(*s) || (is_hex && isxdigit(*s)))) {
 798     s++;
 799   }
 800   // 4705540: illegal if more characters are found after the first non-digit
 801   if (strlen(s) > 1) {
 802     return false;


 868     return false;
 869   }
 870 
 871   if (CommandLineFlags::doubleAtPut(name, &v, origin) == Flag::SUCCESS) {
 872     return true;
 873   }
 874   return false;
 875 }
 876 
 877 static bool set_numeric_flag(const char* name, char* value, Flag::Flags origin) {
 878   julong v;
 879   int int_v;
 880   intx intx_v;
 881   bool is_neg = false;
 882   Flag* result = Flag::find_flag(name, strlen(name));
 883 
 884   if (result == NULL) {
 885     return false;
 886   }
 887 
 888   // Check the sign first since atojulong() parses only unsigned values.
 889   if (*value == '-') {
 890     if (!result->is_intx() && !result->is_int()) {
 891       return false;
 892     }
 893     value++;
 894     is_neg = true;
 895   }
 896   if (!Arguments::atojulong(value, &v)) {
 897     return false;
 898   }
 899   if (result->is_int()) {
 900     int_v = (int) v;
 901     if (is_neg) {
 902       int_v = -int_v;
 903     }
 904     return CommandLineFlags::intAtPut(result, &int_v, origin) == Flag::SUCCESS;
 905   } else if (result->is_uint()) {
 906     uint uint_v = (uint) v;
 907     return CommandLineFlags::uintAtPut(result, &uint_v, origin) == Flag::SUCCESS;
 908   } else if (result->is_intx()) {
 909     intx_v = (intx) v;
 910     if (is_neg) {
 911       intx_v = -intx_v;
 912     }
 913     return CommandLineFlags::intxAtPut(result, &intx_v, origin) == Flag::SUCCESS;
 914   } else if (result->is_uintx()) {
 915     uintx uintx_v = (uintx) v;
 916     return CommandLineFlags::uintxAtPut(result, &uintx_v, origin) == Flag::SUCCESS;


2640   } else {
2641     jio_fprintf(defaultStream::error_stream(),
2642                 "Unrecognized %s%soption: %s\n", option_type, spacer,
2643       option->optionString);
2644     return true;
2645   }
2646 }
2647 
2648 static const char* user_assertion_options[] = {
2649   "-da", "-ea", "-disableassertions", "-enableassertions", 0
2650 };
2651 
2652 static const char* system_assertion_options[] = {
2653   "-dsa", "-esa", "-disablesystemassertions", "-enablesystemassertions", 0
2654 };
2655 
2656 bool Arguments::parse_uintx(const char* value,
2657                             uintx* uintx_arg,
2658                             uintx min_size) {
2659 
2660   // Check the sign first since atojulong() parses only unsigned values.
2661   bool value_is_positive = !(*value == '-');
2662 
2663   if (value_is_positive) {
2664     julong n;
2665     bool good_return = atojulong(value, &n);
2666     if (good_return) {
2667       bool above_minimum = n >= min_size;
2668       bool value_is_too_large = n > max_uintx;
2669 
2670       if (above_minimum && !value_is_too_large) {
2671         *uintx_arg = n;
2672         return true;
2673       }
2674     }
2675   }
2676   return false;
2677 }
2678 
2679 Arguments::ArgsRange Arguments::parse_memory_size(const char* s,
2680                                                   julong* long_arg,
2681                                                   julong min_size) {
2682   if (!atojulong(s, long_arg)) return arg_unreadable;
2683   return check_memory_size(*long_arg, min_size);
2684 }
2685 
2686 // Parse JavaVMInitArgs structure
2687 
2688 jint Arguments::parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args,
2689                                    const JavaVMInitArgs *java_options_args,
2690                                    const JavaVMInitArgs *cmd_line_args) {
2691   // For components of the system classpath.
2692   ArgumentBootClassPath bcp(Arguments::get_sysclasspath());
2693   bool bcp_assembly_required = false;
2694 
2695   // Save default settings for some mode flags
2696   Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods;
2697   Arguments::_UseOnStackReplacement    = UseOnStackReplacement;
2698   Arguments::_ClipInlining             = ClipInlining;
2699   Arguments::_BackgroundCompilation    = BackgroundCompilation;
2700   if (TieredCompilation) {
2701     Arguments::_Tier3InvokeNotifyFreqLog = Tier3InvokeNotifyFreqLog;
2702     Arguments::_Tier4InvocationThreshold = Tier4InvocationThreshold;


< prev index next >