< prev index next >

src/share/vm/runtime/arguments.cpp

Print this page




 112 
 113 abort_hook_t     Arguments::_abort_hook         = NULL;
 114 exit_hook_t      Arguments::_exit_hook          = NULL;
 115 vfprintf_hook_t  Arguments::_vfprintf_hook      = NULL;
 116 
 117 
 118 SystemProperty *Arguments::_sun_boot_library_path = NULL;
 119 SystemProperty *Arguments::_java_library_path = NULL;
 120 SystemProperty *Arguments::_java_home = NULL;
 121 SystemProperty *Arguments::_java_class_path = NULL;
 122 SystemProperty *Arguments::_sun_boot_class_path = NULL;
 123 
 124 char* Arguments::_meta_index_path = NULL;
 125 char* Arguments::_meta_index_dir = NULL;
 126 char* Arguments::_ext_dirs = NULL;
 127 
 128 // Check if head of 'option' matches 'name', and sets 'tail' to the remaining
 129 // part of the option string.
 130 static bool match_option(const JavaVMOption *option, const char* name,
 131                          const char** tail) {
 132   int len = (int)strlen(name);
 133   if (strncmp(option->optionString, name, len) == 0) {
 134     *tail = option->optionString + len;
 135     return true;
 136   } else {
 137     return false;
 138   }
 139 }
 140 
 141 // Check if 'option' matches 'name'. No "tail" is allowed.
 142 static bool match_option(const JavaVMOption *option, const char* name) {
 143   const char* tail = NULL;
 144   bool result = match_option(option, name, &tail);
 145   if (tail != NULL && *tail == '\0') {
 146     return result;
 147   } else {
 148     return false;
 149   }
 150 }
 151 
 152 // Return true if any of the strings in null-terminated array 'names' matches.


 215   _sun_boot_class_path = new SystemProperty("sun.boot.class.path", NULL,  true);
 216 
 217   _java_class_path = new SystemProperty("java.class.path", "",  true);
 218 
 219   // Add to System Property list.
 220   PropertyList_add(&_system_properties, _sun_boot_library_path);
 221   PropertyList_add(&_system_properties, _java_library_path);
 222   PropertyList_add(&_system_properties, _java_home);
 223   PropertyList_add(&_system_properties, _java_class_path);
 224   PropertyList_add(&_system_properties, _sun_boot_class_path);
 225 
 226   // Set OS specific system properties values
 227   os::init_system_properties_values();
 228 }
 229 
 230 
 231   // Update/Initialize System properties after JDK version number is known
 232 void Arguments::init_version_specific_system_properties() {
 233   enum { bufsz = 16 };
 234   char buffer[bufsz];
 235   const char* spec_vendor = "Sun Microsystems Inc.";
 236   uint32_t spec_version = 0;
 237 
 238   spec_vendor = "Oracle Corporation";
 239   spec_version = JDK_Version::current().major_version();
 240   jio_snprintf(buffer, bufsz, "1." UINT32_FORMAT, spec_version);
 241 
 242   PropertyList_add(&_system_properties,
 243       new SystemProperty("java.vm.specification.vendor",  spec_vendor, false));
 244   PropertyList_add(&_system_properties,
 245       new SystemProperty("java.vm.specification.version", buffer, false));
 246   PropertyList_add(&_system_properties,
 247       new SystemProperty("java.vm.vendor", VM_Version::vm_vendor(),  false));
 248 }
 249 
 250 /**
 251  * Provide a slightly more user-friendly way of eliminating -XX flags.
 252  * When a flag is eliminated, it can be added to this list in order to
 253  * continue accepting this flag on the command-line, while issuing a warning
 254  * and ignoring the value.  Once the JDK version reaches the 'accept_until'
 255  * limit, we flatly refuse to admit the existence of the flag.  This allows
 256  * a flag to die correctly over JDK releases using HSX.


































 257  */


 258 typedef struct {
 259   const char* name;
 260   JDK_Version obsoleted_in; // when the flag went away
 261   JDK_Version accept_until; // which version to start denying the existence
 262 } ObsoleteFlag;
 263 
 264 static ObsoleteFlag obsolete_jvm_flags[] = {




 265   { "UseTrainGC",                    JDK_Version::jdk(5), JDK_Version::jdk(7) },
 266   { "UseSpecialLargeObjectHandling", JDK_Version::jdk(5), JDK_Version::jdk(7) },
 267   { "UseOversizedCarHandling",       JDK_Version::jdk(5), JDK_Version::jdk(7) },
 268   { "TraceCarAllocation",            JDK_Version::jdk(5), JDK_Version::jdk(7) },
 269   { "PrintTrainGCProcessingStats",   JDK_Version::jdk(5), JDK_Version::jdk(7) },
 270   { "LogOfCarSpaceSize",             JDK_Version::jdk(5), JDK_Version::jdk(7) },
 271   { "OversizedCarThreshold",         JDK_Version::jdk(5), JDK_Version::jdk(7) },
 272   { "MinTickInterval",               JDK_Version::jdk(5), JDK_Version::jdk(7) },
 273   { "DefaultTickInterval",           JDK_Version::jdk(5), JDK_Version::jdk(7) },
 274   { "MaxTickInterval",               JDK_Version::jdk(5), JDK_Version::jdk(7) },
 275   { "DelayTickAdjustment",           JDK_Version::jdk(5), JDK_Version::jdk(7) },
 276   { "ProcessingToTenuringRatio",     JDK_Version::jdk(5), JDK_Version::jdk(7) },
 277   { "MinTrainLength",                JDK_Version::jdk(5), JDK_Version::jdk(7) },
 278   { "AppendRatio",         JDK_Version::jdk_update(6,10), JDK_Version::jdk(7) },
 279   { "DefaultMaxRAM",       JDK_Version::jdk_update(6,18), JDK_Version::jdk(7) },
 280   { "DefaultInitialRAMFraction",
 281                            JDK_Version::jdk_update(6,18), JDK_Version::jdk(7) },
 282   { "UseDepthFirstScavengeOrder",
 283                            JDK_Version::jdk_update(6,22), JDK_Version::jdk(7) },
 284   { "HandlePromotionFailure",
 285                            JDK_Version::jdk_update(6,24), JDK_Version::jdk(8) },
 286   { "MaxLiveObjectEvacuationRatio",
 287                            JDK_Version::jdk_update(6,24), JDK_Version::jdk(8) },
 288   { "ForceSharedSpaces",   JDK_Version::jdk_update(6,25), JDK_Version::jdk(8) },
 289   { "UseParallelOldGCCompacting",
 290                            JDK_Version::jdk_update(6,27), JDK_Version::jdk(8) },
 291   { "UseParallelDensePrefixUpdate",
 292                            JDK_Version::jdk_update(6,27), JDK_Version::jdk(8) },
 293   { "UseParallelOldGCDensePrefix",
 294                            JDK_Version::jdk_update(6,27), JDK_Version::jdk(8) },
 295   { "AllowTransitionalJSR292",       JDK_Version::jdk(7), JDK_Version::jdk(8) },
 296   { "UseCompressedStrings",          JDK_Version::jdk(7), JDK_Version::jdk(8) },
 297   { "CMSPermGenPrecleaningEnabled", JDK_Version::jdk(8),  JDK_Version::jdk(9) },
 298   { "CMSTriggerPermRatio", JDK_Version::jdk(8),  JDK_Version::jdk(9) },
 299   { "CMSInitiatingPermOccupancyFraction", JDK_Version::jdk(8),  JDK_Version::jdk(9) },

 300   { "AdaptivePermSizeWeight", JDK_Version::jdk(8),  JDK_Version::jdk(9) },
 301   { "PermGenPadding", JDK_Version::jdk(8),  JDK_Version::jdk(9) },
 302   { "PermMarkSweepDeadRatio", JDK_Version::jdk(8),  JDK_Version::jdk(9) },
 303   { "PermSize", JDK_Version::jdk(8),  JDK_Version::jdk(9) },
 304   { "MaxPermSize", JDK_Version::jdk(8),  JDK_Version::jdk(9) },
 305   { "MinPermHeapExpansion", JDK_Version::jdk(8),  JDK_Version::jdk(9) },
 306   { "MaxPermHeapExpansion", JDK_Version::jdk(8),  JDK_Version::jdk(9) },
 307   { "CMSRevisitStackSize",           JDK_Version::jdk(8), JDK_Version::jdk(9) },
 308   { "PrintRevisitStats",             JDK_Version::jdk(8), JDK_Version::jdk(9) },
 309   { "UseVectoredExceptions",         JDK_Version::jdk(8), JDK_Version::jdk(9) },
 310   { "UseSplitVerifier",              JDK_Version::jdk(8), JDK_Version::jdk(9) },
 311   { "UseISM",                        JDK_Version::jdk(8), JDK_Version::jdk(9) },
 312   { "UsePermISM",                    JDK_Version::jdk(8), JDK_Version::jdk(9) },
 313   { "UseMPSS",                       JDK_Version::jdk(8), JDK_Version::jdk(9) },
 314   { "UseStringCache",                JDK_Version::jdk(8), JDK_Version::jdk(9) },
 315   { "UseOldInlining",                JDK_Version::jdk(9), JDK_Version::jdk(10) },
 316   { "SafepointPollOffset",           JDK_Version::jdk(9), JDK_Version::jdk(10) },
 317 #ifdef PRODUCT
 318   { "DesiredMethodLimit",
 319                            JDK_Version::jdk_update(7, 2), JDK_Version::jdk(8) },
 320 #endif // PRODUCT
 321   { "UseVMInterruptibleIO",          JDK_Version::jdk(8), JDK_Version::jdk(9) },
 322   { "UseBoundThreads",               JDK_Version::jdk(9), JDK_Version::jdk(10) },
 323   { "DefaultThreadPriority",         JDK_Version::jdk(9), JDK_Version::jdk(10) },
 324   { "NoYieldsInMicrolock",           JDK_Version::jdk(9), JDK_Version::jdk(10) },
 325   { "BackEdgeThreshold",             JDK_Version::jdk(9), JDK_Version::jdk(10) },
 326   { "UseNewReflection",              JDK_Version::jdk(9), JDK_Version::jdk(10) },
 327   { "ReflectionWrapResolutionErrors",JDK_Version::jdk(9), JDK_Version::jdk(10) },
 328   { "VerifyReflectionBytecodes",     JDK_Version::jdk(9), JDK_Version::jdk(10) },
 329   { "AutoShutdownNMT",               JDK_Version::jdk(9), JDK_Version::jdk(10) },
 330   { "NmethodSweepFraction",          JDK_Version::jdk(9), JDK_Version::jdk(10) },
 331   { "NmethodSweepCheckInterval",     JDK_Version::jdk(9), JDK_Version::jdk(10) },
 332   { "CodeCacheMinimumFreeSpace",     JDK_Version::jdk(9), JDK_Version::jdk(10) },
 333 #ifndef ZERO
 334   { "UseFastAccessorMethods",        JDK_Version::jdk(9), JDK_Version::jdk(10) },
 335   { "UseFastEmptyMethods",           JDK_Version::jdk(9), JDK_Version::jdk(10) },
 336 #endif // ZERO
 337   { "UseCompilerSafepoints",         JDK_Version::jdk(9), JDK_Version::jdk(10) },
 338   { NULL, JDK_Version(0), JDK_Version(0) }
 339 };
 340 
 341 // Returns true if the flag is obsolete and fits into the range specified
 342 // for being ignored.  In the case that the flag is ignored, the 'version'
 343 // value is filled in with the version number when the flag became
 344 // obsolete so that that value can be displayed to the user.
 345 bool Arguments::is_newly_obsolete(const char *s, JDK_Version* version) {
 346   int i = 0;

































 347   assert(version != NULL, "Must provide a version buffer");
 348   while (obsolete_jvm_flags[i].name != NULL) {
 349     const ObsoleteFlag& flag_status = obsolete_jvm_flags[i];
 350     // <flag>=xxx form
 351     // [-|+]<flag> form
 352     size_t len = strlen(flag_status.name);
 353     if (((strncmp(flag_status.name, s, len) == 0) &&
 354          (strlen(s) == len)) ||
 355         ((s[0] == '+' || s[0] == '-') &&
 356          (strncmp(flag_status.name, &s[1], len) == 0) &&
 357          (strlen(&s[1]) == len))) {
 358       if (JDK_Version::current().compare(flag_status.accept_until) == -1) {
 359           *version = flag_status.obsoleted_in;
 360           return true;


 361       }
 362     }
 363     i++;
 364   }
 365   return false;


















 366 }
 367 
 368 // Constructs the system class path (aka boot class path) from the following
 369 // components, in order:
 370 //
 371 //     prefix           // from -Xbootclasspath/p:...
 372 //     base             // from os::get_system_properties() or -Xbootclasspath=
 373 //     suffix           // from -Xbootclasspath/a:...
 374 //
 375 // This could be AllStatic, but it isn't needed after argument processing is
 376 // complete.
 377 class SysClassPath: public StackObj {
 378 public:
 379   SysClassPath(const char* base);
 380   ~SysClassPath();
 381 
 382   inline void set_base(const char* base);
 383   inline void add_prefix(const char* prefix);
 384   inline void add_suffix_to_prefix(const char* suffix);
 385   inline void add_suffix(const char* suffix);


 616 }
 617 
 618 // Describe an argument out of range error
 619 void Arguments::describe_range_error(ArgsRange errcode) {
 620   switch(errcode) {
 621   case arg_too_big:
 622     jio_fprintf(defaultStream::error_stream(),
 623                 "The specified size exceeds the maximum "
 624                 "representable size.\n");
 625     break;
 626   case arg_too_small:
 627   case arg_unreadable:
 628   case arg_in_range:
 629     // do nothing for now
 630     break;
 631   default:
 632     ShouldNotReachHere();
 633   }
 634 }
 635 
 636 static bool set_bool_flag(char* name, bool value, Flag::Flags origin) {
 637   return CommandLineFlags::boolAtPut(name, &value, origin);
 638 }
 639 
 640 static bool set_fp_numeric_flag(char* name, char* value, Flag::Flags origin) {
 641   double v;
 642   if (sscanf(value, "%lf", &v) != 1) {
 643     return false;
 644   }
 645 
 646   if (CommandLineFlags::doubleAtPut(name, &v, origin)) {
 647     return true;
 648   }
 649   return false;
 650 }
 651 
 652 static bool set_numeric_flag(char* name, char* value, Flag::Flags origin) {
 653   julong v;
 654   intx intx_v;
 655   bool is_neg = false;
 656   // Check the sign first since atomull() parses only unsigned values.
 657   if (*value == '-') {
 658     if (!CommandLineFlags::intxAt(name, &intx_v)) {
 659       return false;
 660     }
 661     value++;
 662     is_neg = true;
 663   }
 664   if (!atomull(value, &v)) {
 665     return false;
 666   }
 667   intx_v = (intx) v;
 668   if (is_neg) {
 669     intx_v = -intx_v;
 670   }
 671   if (CommandLineFlags::intxAtPut(name, &intx_v, origin)) {
 672     return true;
 673   }
 674   uintx uintx_v = (uintx) v;
 675   if (!is_neg && CommandLineFlags::uintxAtPut(name, &uintx_v, origin)) {
 676     return true;
 677   }
 678   uint64_t uint64_t_v = (uint64_t) v;
 679   if (!is_neg && CommandLineFlags::uint64_tAtPut(name, &uint64_t_v, origin)) {
 680     return true;
 681   }
 682   size_t size_t_v = (size_t) v;
 683   if (!is_neg && CommandLineFlags::size_tAtPut(name, &size_t_v, origin)) {
 684     return true;
 685   }
 686   return false;
 687 }
 688 
 689 static bool set_string_flag(char* name, const char* value, Flag::Flags origin) {
 690   if (!CommandLineFlags::ccstrAtPut(name, &value, origin))  return false;
 691   // Contract:  CommandLineFlags always returns a pointer that needs freeing.
 692   FREE_C_HEAP_ARRAY(char, value);
 693   return true;
 694 }
 695 
 696 static bool append_to_string_flag(char* name, const char* new_value, Flag::Flags origin) {
 697   const char* old_value = "";
 698   if (!CommandLineFlags::ccstrAt(name, &old_value))  return false;
 699   size_t old_len = old_value != NULL ? strlen(old_value) : 0;
 700   size_t new_len = strlen(new_value);
 701   const char* value;
 702   char* free_this_too = NULL;
 703   if (old_len == 0) {
 704     value = new_value;
 705   } else if (new_len == 0) {
 706     value = old_value;
 707   } else {
 708     char* buf = NEW_C_HEAP_ARRAY(char, old_len + 1 + new_len + 1, mtInternal);
 709     // each new setting adds another LINE to the switch:
 710     sprintf(buf, "%s\n%s", old_value, new_value);
 711     value = buf;
 712     free_this_too = buf;
 713   }
 714   (void) CommandLineFlags::ccstrAtPut(name, &value, origin);
 715   // CommandLineFlags always returns a pointer that needs freeing.
 716   FREE_C_HEAP_ARRAY(char, value);
 717   if (free_this_too != NULL) {
 718     // CommandLineFlags made its own copy, so I must delete my own temp. buffer.
 719     FREE_C_HEAP_ARRAY(char, free_this_too);
 720   }
 721   return true;
 722 }
 723 



























 724 bool Arguments::parse_argument(const char* arg, Flag::Flags origin) {
 725 
 726   // range of acceptable characters spelled out for portability reasons
 727 #define NAME_RANGE  "[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]"
 728 #define BUFLEN 255
 729   char name[BUFLEN+1];
 730   char dummy;


 731 
 732   if (sscanf(arg, "-%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
 733     return set_bool_flag(name, false, origin);




 734   }
 735   if (sscanf(arg, "+%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
 736     return set_bool_flag(name, true, origin);




 737   }
 738 
 739   char punct;
 740   if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "%c", name, &punct) == 2 && punct == '=') {
 741     const char* value = strchr(arg, '=') + 1;
 742     Flag* flag = Flag::find_flag(name, strlen(name));







 743     if (flag != NULL && flag->is_ccstr()) {
 744       if (flag->ccstr_accumulates()) {
 745         return append_to_string_flag(name, value, origin);
 746       } else {
 747         if (value[0] == '\0') {
 748           value = NULL;
 749         }
 750         return set_string_flag(name, value, origin);
 751       }


 752     }
 753   }
 754 
 755   if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE ":%c", name, &punct) == 2 && punct == '=') {
 756     const char* value = strchr(arg, '=') + 1;
 757     // -XX:Foo:=xxx will reset the string flag to the given value.
 758     if (value[0] == '\0') {
 759       value = NULL;
 760     }
 761     return set_string_flag(name, value, origin);




 762   }
 763 
 764 #define SIGNED_FP_NUMBER_RANGE "[-0123456789.]"
 765 #define SIGNED_NUMBER_RANGE    "[-0123456789]"
 766 #define        NUMBER_RANGE    "[0123456789]"
 767   char value[BUFLEN + 1];
 768   char value2[BUFLEN + 1];
 769   if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_NUMBER_RANGE "." "%" XSTR(BUFLEN) NUMBER_RANGE "%c", name, value, value2, &dummy) == 3) {
 770     // Looks like a floating-point number -- try again with more lenient format string
 771     if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_FP_NUMBER_RANGE "%c", name, value, &dummy) == 2) {
 772       return set_fp_numeric_flag(name, value, origin);




 773     }
 774   }
 775 
 776 #define VALUE_RANGE "[-kmgtxKMGTX0123456789abcdefABCDEF]"
 777   if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) VALUE_RANGE "%c", name, value, &dummy) == 2) {
 778     return set_numeric_flag(name, value, origin);




 779   }
 780 
 781   return false;
 782 }
 783 
 784 void Arguments::add_string(char*** bldarray, int* count, const char* arg) {
 785   assert(bldarray != NULL, "illegal argument");
 786 
 787   if (arg == NULL) {
 788     return;
 789   }
 790 
 791   int new_count = *count + 1;
 792 
 793   // expand the array and add arg to the last element
 794   if (*bldarray == NULL) {
 795     *bldarray = NEW_C_HEAP_ARRAY(char*, new_count, mtInternal);
 796   } else {
 797     *bldarray = REALLOC_C_HEAP_ARRAY(char*, *bldarray, new_count, mtInternal);
 798   }


 858       st->print("%s ", _jvm_args_array[i]);
 859     }
 860     st->cr();
 861   }
 862 }
 863 
 864 bool Arguments::process_argument(const char* arg,
 865     jboolean ignore_unrecognized, Flag::Flags origin) {
 866 
 867   JDK_Version since = JDK_Version();
 868 
 869   if (parse_argument(arg, origin) || ignore_unrecognized) {
 870     return true;
 871   }
 872 
 873   bool has_plus_minus = (*arg == '+' || *arg == '-');
 874   const char* const argname = has_plus_minus ? arg + 1 : arg;
 875   if (is_newly_obsolete(arg, &since)) {
 876     char version[256];
 877     since.to_string(version, sizeof(version));
 878     warning("ignoring option %s; support was removed in %s", argname, version);
 879     return true;
 880   }
 881 
 882   // For locked flags, report a custom error message if available.
 883   // Otherwise, report the standard unrecognized VM option.
 884 
 885   size_t arg_len;
 886   const char* equal_sign = strchr(argname, '=');
 887   if (equal_sign == NULL) {
 888     arg_len = strlen(argname);
 889   } else {
 890     arg_len = equal_sign - argname;
 891   }
 892 
 893   Flag* found_flag = Flag::find_flag((const char*)argname, arg_len, true, true);
 894   if (found_flag != NULL) {
 895     char locked_message_buf[BUFLEN];
 896     found_flag->get_locked_message(locked_message_buf, BUFLEN);
 897     if (strlen(locked_message_buf) == 0) {
 898       if (found_flag->is_bool() && !has_plus_minus) {


1245  *    C1 can be used, so the minimum number of compiler threads is 1.
1246  * 4) The JVM is build using the compilers and tiered compilation is enabled. The option
1247  *    'TieredStopAtLevel = CompLevel_full_optimization' (the default value). As a result,
1248  *    the minimum number of compiler threads is 2.
1249  */
1250 int Arguments::get_min_number_of_compiler_threads() {
1251 #if !defined(COMPILER1) && !defined(COMPILER2) && !defined(SHARK)
1252   return 0;   // case 1
1253 #else
1254   if (!TieredCompilation || (TieredStopAtLevel < CompLevel_full_optimization)) {
1255     return 1; // case 2 or case 3
1256   }
1257   return 2;   // case 4 (tiered)
1258 #endif
1259 }
1260 
1261 #if INCLUDE_ALL_GCS
1262 static void disable_adaptive_size_policy(const char* collector_name) {
1263   if (UseAdaptiveSizePolicy) {
1264     if (FLAG_IS_CMDLINE(UseAdaptiveSizePolicy)) {
1265       warning("disabling UseAdaptiveSizePolicy; it is incompatible with %s.",
1266               collector_name);
1267     }
1268     FLAG_SET_DEFAULT(UseAdaptiveSizePolicy, false);
1269   }
1270 }
1271 
1272 void Arguments::set_parnew_gc_flags() {
1273   assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC && !UseG1GC,
1274          "control point invariant");
1275   assert(UseConcMarkSweepGC, "CMS is expected to be on here");
1276   assert(UseParNewGC, "ParNew should always be used with CMS");
1277 
1278   if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
1279     FLAG_SET_DEFAULT(ParallelGCThreads, Abstract_VM_Version::parallel_worker_threads());
1280     assert(ParallelGCThreads > 0, "We should always have at least one thread by default");
1281   } else if (ParallelGCThreads == 0) {
1282     jio_fprintf(defaultStream::error_stream(),
1283         "The ParNew GC can not be combined with -XX:ParallelGCThreads=0\n");
1284     vm_exit(1);
1285   }


1751 #if !INCLUDE_ALL_GCS
1752 #ifdef ASSERT
1753 static bool verify_serial_gc_flags() {
1754   return (UseSerialGC &&
1755         !(UseParNewGC || (UseConcMarkSweepGC) || UseG1GC ||
1756           UseParallelGC || UseParallelOldGC));
1757 }
1758 #endif // ASSERT
1759 #endif // INCLUDE_ALL_GCS
1760 
1761 void Arguments::set_gc_specific_flags() {
1762 #if INCLUDE_ALL_GCS
1763   // Set per-collector flags
1764   if (UseParallelGC || UseParallelOldGC) {
1765     set_parallel_gc_flags();
1766   } else if (UseConcMarkSweepGC) {
1767     set_cms_and_parnew_gc_flags();
1768   } else if (UseG1GC) {
1769     set_g1_gc_flags();
1770   }
1771   check_deprecated_gc_flags();
1772   if (AssumeMP && !UseSerialGC) {
1773     if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) {
1774       warning("If the number of processors is expected to increase from one, then"
1775               " you should configure the number of parallel GC threads appropriately"
1776               " using -XX:ParallelGCThreads=N");
1777     }
1778   }
1779   if (MinHeapFreeRatio == 100) {
1780     // Keeping the heap 100% free is hard ;-) so limit it to 99%.
1781     FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99);
1782   }
1783 #else // INCLUDE_ALL_GCS
1784   assert(verify_serial_gc_flags(), "SerialGC unset");
1785 #endif // INCLUDE_ALL_GCS
1786 }
1787 
1788 julong Arguments::limit_by_allocatable_memory(julong limit) {
1789   julong max_allocatable;
1790   julong result = limit;
1791   if (os::has_allocatable_memory_limit(&max_allocatable)) {
1792     result = MIN2(result, max_allocatable / MaxVirtMemFraction);
1793   }
1794   return result;
1795 }
1796 
1797 // Use static initialization to get the default before parsing
1798 static const uintx DefaultHeapBaseMinAddress = HeapBaseMinAddress;
1799 
1800 void Arguments::set_heap_size() {
1801   if (!FLAG_IS_DEFAULT(DefaultMaxRAMFraction)) {
1802     // Deprecated flag
1803     FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction);
1804   }
1805 
1806   const julong phys_mem =
1807     FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
1808                             : (julong)MaxRAM;
1809 
1810   // If the maximum heap size has not been set with -Xmx,
1811   // then set it as fraction of the size of physical memory,
1812   // respecting the maximum and minimum sizes of the heap.
1813   if (FLAG_IS_DEFAULT(MaxHeapSize)) {
1814     julong reasonable_max = phys_mem / MaxRAMFraction;
1815 
1816     if (phys_mem <= MaxHeapSize * MinRAMFraction) {
1817       // Small physical memory, so use a minimum fraction of it for the heap
1818       reasonable_max = phys_mem / MinRAMFraction;
1819     } else {
1820       // Not-small physical memory, so require a heap at least
1821       // as large as MaxHeapSize
1822       reasonable_max = MAX2(reasonable_max, (julong)MaxHeapSize);
1823     }
1824     if (!FLAG_IS_DEFAULT(ErgoHeapSizeLimit) && ErgoHeapSizeLimit != 0) {
1825       // Limit the heap size to ErgoHeapSizeLimit


2143     return false;
2144   }
2145 
2146   if (UseConcMarkSweepGC && !UseParNewGC) {
2147     jio_fprintf(defaultStream::error_stream(),
2148         "It is not possible to combine the DefNew young collector with the CMS collector.\n");
2149     return false;
2150   }
2151 
2152   if (UseParNewGC && !UseConcMarkSweepGC) {
2153     // !UseConcMarkSweepGC means that we are using serial old gc. Unfortunately we don't
2154     // set up UseSerialGC properly, so that can't be used in the check here.
2155     jio_fprintf(defaultStream::error_stream(),
2156         "It is not possible to combine the ParNew young collector with the Serial old collector.\n");
2157     return false;
2158   }
2159 
2160   return true;
2161 }
2162 
2163 void Arguments::check_deprecated_gc_flags() {
2164   if (FLAG_IS_CMDLINE(UseParNewGC)) {
2165     warning("The UseParNewGC flag is deprecated and will likely be removed in a future release");
2166   }
2167   if (FLAG_IS_CMDLINE(MaxGCMinorPauseMillis)) {
2168     warning("Using MaxGCMinorPauseMillis as minor pause goal is deprecated"
2169             "and will likely be removed in future release");
2170   }
2171   if (FLAG_IS_CMDLINE(DefaultMaxRAMFraction)) {
2172     warning("DefaultMaxRAMFraction is deprecated and will likely be removed in a future release. "
2173         "Use MaxRAMFraction instead.");
2174   }
2175 }
2176 
2177 // Check stack pages settings
2178 bool Arguments::check_stack_pages()
2179 {
2180   bool status = true;
2181   status = status && verify_min_value(StackYellowPages, 1, "StackYellowPages");
2182   status = status && verify_min_value(StackRedPages, 1, "StackRedPages");
2183   // greater stack shadow pages can't generate instruction to bang stack
2184   status = status && verify_interval(StackShadowPages, 1, 50, "StackShadowPages");
2185   return status;
2186 }
2187 
2188 // Check the consistency of vm_init_args
2189 bool Arguments::check_vm_args_consistency() {
2190   // Method for adding checks for flag consistency.
2191   // The intent is to warn the user of all possible conflicts,
2192   // before returning an error.
2193   // Note: Needs platform-dependent factoring.
2194   bool status = true;
2195 
2196   if (TLABRefillWasteFraction == 0) {


2394                                       "CompressedClassSpaceSize");
2395 
2396   status = status && verify_interval(MarkStackSizeMax,
2397                                   1, (max_jint - 1), "MarkStackSizeMax");
2398   status = status && verify_interval(NUMAChunkResizeWeight, 0, 100, "NUMAChunkResizeWeight");
2399 
2400   status = status && verify_min_value(LogEventsBufferEntries, 1, "LogEventsBufferEntries");
2401 
2402   status = status && verify_min_value(HeapSizePerGCThread, (uintx) os::vm_page_size(), "HeapSizePerGCThread");
2403 
2404   status = status && verify_min_value(GCTaskTimeStampEntries, 1, "GCTaskTimeStampEntries");
2405 
2406   status = status && verify_percentage(ParallelGCBufferWastePct, "ParallelGCBufferWastePct");
2407   status = status && verify_interval(TargetPLABWastePct, 1, 100, "TargetPLABWastePct");
2408 
2409   status = status && verify_min_value(ParGCStridesPerThread, 1, "ParGCStridesPerThread");
2410 
2411   status = status && verify_min_value(MinRAMFraction, 1, "MinRAMFraction");
2412   status = status && verify_min_value(InitialRAMFraction, 1, "InitialRAMFraction");
2413   status = status && verify_min_value(MaxRAMFraction, 1, "MaxRAMFraction");
2414   status = status && verify_min_value(DefaultMaxRAMFraction, 1, "DefaultMaxRAMFraction");
2415 
2416   status = status && verify_interval(AdaptiveTimeWeight, 0, 100, "AdaptiveTimeWeight");
2417   status = status && verify_min_value(AdaptiveSizeDecrementScaleFactor, 1, "AdaptiveSizeDecrementScaleFactor");
2418 
2419   status = status && verify_interval(TLABAllocationWeight, 0, 100, "TLABAllocationWeight");
2420   status = status && verify_min_value(MinTLABSize, 1, "MinTLABSize");
2421   status = status && verify_min_value(TLABRefillWasteFraction, 1, "TLABRefillWasteFraction");
2422 
2423   status = status && verify_percentage(YoungGenerationSizeSupplement, "YoungGenerationSizeSupplement");
2424   status = status && verify_percentage(TenuredGenerationSizeSupplement, "TenuredGenerationSizeSupplement");
2425 
2426   status = status && verify_interval(MaxTenuringThreshold, 0, markOopDesc::max_age + 1, "MaxTenuringThreshold");
2427   status = status && verify_interval(InitialTenuringThreshold, 0, MaxTenuringThreshold, "InitialTenuringThreshold");
2428   status = status && verify_percentage(TargetSurvivorRatio, "TargetSurvivorRatio");
2429   status = status && verify_percentage(MarkSweepDeadRatio, "MarkSweepDeadRatio");
2430 
2431   status = status && verify_min_value(MarkSweepAlwaysCompactCount, 1, "MarkSweepAlwaysCompactCount");
2432 #ifdef COMPILER1
2433   status = status && verify_min_value(ValueMapInitialSize, 1, "ValueMapInitialSize");
2434 #endif


3231     } else if (match_option(option, "-XX:+DisplayVMOutputToStdout")) {
3232       FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, false);
3233       FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, true);
3234     } else if (match_option(option, "-XX:+ExtendedDTraceProbes")) {
3235 #if defined(DTRACE_ENABLED)
3236       FLAG_SET_CMDLINE(bool, ExtendedDTraceProbes, true);
3237       FLAG_SET_CMDLINE(bool, DTraceMethodProbes, true);
3238       FLAG_SET_CMDLINE(bool, DTraceAllocProbes, true);
3239       FLAG_SET_CMDLINE(bool, DTraceMonitorProbes, true);
3240 #else // defined(DTRACE_ENABLED)
3241       jio_fprintf(defaultStream::error_stream(),
3242                   "ExtendedDTraceProbes flag is not applicable for this configuration\n");
3243       return JNI_EINVAL;
3244 #endif // defined(DTRACE_ENABLED)
3245 #ifdef ASSERT
3246     } else if (match_option(option, "-XX:+FullGCALot")) {
3247       FLAG_SET_CMDLINE(bool, FullGCALot, true);
3248       // disable scavenge before parallel mark-compact
3249       FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false);
3250 #endif
3251     } else if (match_option(option, "-XX:CMSMarkStackSize=", &tail) ||
3252                match_option(option, "-XX:G1MarkStackSize=", &tail)) {
3253       julong stack_size = 0;
3254       ArgsRange errcode = parse_memory_size(tail, &stack_size, 1);
3255       if (errcode != arg_in_range) {
3256         jio_fprintf(defaultStream::error_stream(),
3257                     "Invalid mark stack size: %s\n", option->optionString);
3258         describe_range_error(errcode);
3259         return JNI_EINVAL;
3260       }
3261       jio_fprintf(defaultStream::error_stream(),
3262         "Please use -XX:MarkStackSize in place of "
3263         "-XX:CMSMarkStackSize or -XX:G1MarkStackSize in the future\n");
3264       FLAG_SET_CMDLINE(uintx, MarkStackSize, stack_size);
3265     } else if (match_option(option, "-XX:CMSMarkStackSizeMax=", &tail)) {
3266       julong max_stack_size = 0;
3267       ArgsRange errcode = parse_memory_size(tail, &max_stack_size, 1);
3268       if (errcode != arg_in_range) {
3269         jio_fprintf(defaultStream::error_stream(),
3270                     "Invalid maximum mark stack size: %s\n",
3271                     option->optionString);
3272         describe_range_error(errcode);
3273         return JNI_EINVAL;
3274       }
3275       jio_fprintf(defaultStream::error_stream(),
3276          "Please use -XX:MarkStackSizeMax in place of "
3277          "-XX:CMSMarkStackSizeMax in the future\n");
3278       FLAG_SET_CMDLINE(uintx, MarkStackSizeMax, max_stack_size);
3279     } else if (match_option(option, "-XX:ParallelMarkingThreads=", &tail) ||
3280                match_option(option, "-XX:ParallelCMSThreads=", &tail)) {
3281       uintx conc_threads = 0;
3282       if (!parse_uintx(tail, &conc_threads, 1)) {
3283         jio_fprintf(defaultStream::error_stream(),
3284                     "Invalid concurrent threads: %s\n", option->optionString);
3285         return JNI_EINVAL;
3286       }
3287       jio_fprintf(defaultStream::error_stream(),
3288         "Please use -XX:ConcGCThreads in place of "
3289         "-XX:ParallelMarkingThreads or -XX:ParallelCMSThreads in the future\n");
3290       FLAG_SET_CMDLINE(uintx, ConcGCThreads, conc_threads);
3291     } else if (match_option(option, "-XX:MaxDirectMemorySize=", &tail)) {
3292       julong max_direct_memory_size = 0;
3293       ArgsRange errcode = parse_memory_size(tail, &max_direct_memory_size, 0);
3294       if (errcode != arg_in_range) {
3295         jio_fprintf(defaultStream::error_stream(),
3296                     "Invalid maximum direct memory size: %s\n",
3297                     option->optionString);
3298         describe_range_error(errcode);
3299         return JNI_EINVAL;
3300       }
3301       FLAG_SET_CMDLINE(uintx, MaxDirectMemorySize, max_direct_memory_size);
3302 #if !INCLUDE_MANAGEMENT
3303     } else if (match_option(option, "-XX:+ManagementServer")) {
3304         jio_fprintf(defaultStream::error_stream(),
3305           "ManagementServer is not supported in this VM.\n");
3306         return JNI_ERR;
3307 #endif // INCLUDE_MANAGEMENT
3308     } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx
3309       // Skip -XX:Flags= since that case has already been handled
3310       if (strncmp(tail, "Flags=", strlen("Flags=")) != 0) {


3615     vm_args.ignoreUnrecognized = IgnoreUnrecognizedVMOptions;
3616 
3617     if (PrintVMOptions) {
3618       const char* tail;
3619       for (int i = 0; i < vm_args.nOptions; i++) {
3620         const JavaVMOption *option = vm_args.options + i;
3621         if (match_option(option, "-XX:", &tail)) {
3622           logOption(tail);
3623         }
3624       }
3625     }
3626 
3627     return(parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p, Flag::ENVIRON_VAR));
3628   }
3629   return JNI_OK;
3630 }
3631 
3632 void Arguments::set_shared_spaces_flags() {
3633   if (DumpSharedSpaces) {
3634     if (RequireSharedSpaces) {
3635       warning("cannot dump shared archive while using shared archive");
3636     }
3637     UseSharedSpaces = false;
3638 #ifdef _LP64
3639     if (!UseCompressedOops || !UseCompressedClassPointers) {
3640       vm_exit_during_initialization(
3641         "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL);
3642     }
3643   } else {
3644     if (!UseCompressedOops || !UseCompressedClassPointers) {
3645       no_shared_spaces("UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces.");
3646     }
3647 #endif
3648   }
3649 }
3650 
3651 #if !INCLUDE_ALL_GCS
3652 static void force_serial_gc() {
3653   FLAG_SET_DEFAULT(UseSerialGC, true);
3654   UNSUPPORTED_GC_OPTION(UseG1GC);
3655   UNSUPPORTED_GC_OPTION(UseParallelGC);


3851 #if INCLUDE_ALL_GCS
3852   #if (defined JAVASE_EMBEDDED || defined ARM)
3853     UNSUPPORTED_OPTION(UseG1GC, "G1 GC");
3854   #endif
3855 #endif
3856 
3857 #ifndef PRODUCT
3858   if (TraceBytecodesAt != 0) {
3859     TraceBytecodes = true;
3860   }
3861   if (CountCompiledCalls) {
3862     if (UseCounterDecay) {
3863       warning("UseCounterDecay disabled because CountCalls is set");
3864       UseCounterDecay = false;
3865     }
3866   }
3867 #endif // PRODUCT
3868 
3869   if (ScavengeRootsInCode == 0) {
3870     if (!FLAG_IS_DEFAULT(ScavengeRootsInCode)) {
3871       warning("forcing ScavengeRootsInCode non-zero");
3872     }
3873     ScavengeRootsInCode = 1;
3874   }
3875 
3876   if (PrintGCDetails) {
3877     // Turn on -verbose:gc options as well
3878     PrintGC = true;
3879   }
3880 
3881   // Set object alignment values.
3882   set_object_alignment();
3883 
3884 #if !INCLUDE_ALL_GCS
3885   force_serial_gc();
3886 #endif // INCLUDE_ALL_GCS
3887 #if !INCLUDE_CDS
3888   if (DumpSharedSpaces || RequireSharedSpaces) {
3889     jio_fprintf(defaultStream::error_stream(),
3890       "Shared spaces are not supported in this VM\n");
3891     return JNI_ERR;




 112 
 113 abort_hook_t     Arguments::_abort_hook         = NULL;
 114 exit_hook_t      Arguments::_exit_hook          = NULL;
 115 vfprintf_hook_t  Arguments::_vfprintf_hook      = NULL;
 116 
 117 
 118 SystemProperty *Arguments::_sun_boot_library_path = NULL;
 119 SystemProperty *Arguments::_java_library_path = NULL;
 120 SystemProperty *Arguments::_java_home = NULL;
 121 SystemProperty *Arguments::_java_class_path = NULL;
 122 SystemProperty *Arguments::_sun_boot_class_path = NULL;
 123 
 124 char* Arguments::_meta_index_path = NULL;
 125 char* Arguments::_meta_index_dir = NULL;
 126 char* Arguments::_ext_dirs = NULL;
 127 
 128 // Check if head of 'option' matches 'name', and sets 'tail' to the remaining
 129 // part of the option string.
 130 static bool match_option(const JavaVMOption *option, const char* name,
 131                          const char** tail) {
 132   size_t len = strlen(name);
 133   if (strncmp(option->optionString, name, len) == 0) {
 134     *tail = option->optionString + len;
 135     return true;
 136   } else {
 137     return false;
 138   }
 139 }
 140 
 141 // Check if 'option' matches 'name'. No "tail" is allowed.
 142 static bool match_option(const JavaVMOption *option, const char* name) {
 143   const char* tail = NULL;
 144   bool result = match_option(option, name, &tail);
 145   if (tail != NULL && *tail == '\0') {
 146     return result;
 147   } else {
 148     return false;
 149   }
 150 }
 151 
 152 // Return true if any of the strings in null-terminated array 'names' matches.


 215   _sun_boot_class_path = new SystemProperty("sun.boot.class.path", NULL,  true);
 216 
 217   _java_class_path = new SystemProperty("java.class.path", "",  true);
 218 
 219   // Add to System Property list.
 220   PropertyList_add(&_system_properties, _sun_boot_library_path);
 221   PropertyList_add(&_system_properties, _java_library_path);
 222   PropertyList_add(&_system_properties, _java_home);
 223   PropertyList_add(&_system_properties, _java_class_path);
 224   PropertyList_add(&_system_properties, _sun_boot_class_path);
 225 
 226   // Set OS specific system properties values
 227   os::init_system_properties_values();
 228 }
 229 
 230 
 231   // Update/Initialize System properties after JDK version number is known
 232 void Arguments::init_version_specific_system_properties() {
 233   enum { bufsz = 16 };
 234   char buffer[bufsz];
 235   const char* spec_vendor = "Oracle Corporation";
 236   uint32_t spec_version = JDK_Version::current().major_version();
 237 


 238   jio_snprintf(buffer, bufsz, "1." UINT32_FORMAT, spec_version);
 239 
 240   PropertyList_add(&_system_properties,
 241       new SystemProperty("java.vm.specification.vendor",  spec_vendor, false));
 242   PropertyList_add(&_system_properties,
 243       new SystemProperty("java.vm.specification.version", buffer, false));
 244   PropertyList_add(&_system_properties,
 245       new SystemProperty("java.vm.vendor", VM_Version::vm_vendor(),  false));
 246 }
 247 
 248 /*
 249  *  -XX argument processing:
 250  * 
 251  *  -XX arguments are defined in several places, such as:
 252  *      globals.hpp, globals_<cpu>.hpp, globals_<os>.hpp, <compiler>_globals.hpp, or <gc>_globals.hpp.
 253  *  -XX arguments are parsed in parse_argument().
 254  *  -XX argument bounds checking is done in check_vm_args_consistency().
 255  * 
 256  * Over time -XX arguments may change. There are mechanisms to handle common cases:
 257  * 
 258  *        ALIAS: An option may be renamed or replaced by another option. The old name can be supported by 
 259  *               adding the old and new option names to the "aliased_jvm_flags" table. Delete the old 
 260  *               variable from globals.hpp. This is often part of the process of deprecating a flag, but
 261  *               not all aliases need to be deprecated.
 262  * 
 263  *   DEPRECATED: An option may be supported, but a warning is printed to let the user know that support may
 264  *               be removed in the future. Both regular and aliased options may be deprecated.
 265  *               Add a deprecation warning for an option (or alias) by adding an entry in the 
 266  *               "deprecated_jvm_flags" table. Specify the option name, the jdk version that deprecated the
 267  *               option, and the jdk version that will expire the option (use "undefined()" if removal has
 268  *               been not scheduled).
 269  * 
 270  *     OBSOLETE: An option may be removed (and deleted from globals.hpp), but still be accepted on the command
 271  *               line. A warning is printed to let the user know that support may be removed in the future. 
 272  *               Add an obsolete warning for an option (or alias) by adding an entry in the 
 273  *               "obsolete_jvm_flags" table. Specify the option name, the jdk version that obsoleted the option,
 274  *               and the jdk version that will expire the option (use "undefined()" if removal has been not
 275  *               scheduled).
 276  * 
 277  *      EXPIRED: When the current JDK version is equal or greater to the "accept_until" version of a deprecated
 278  *               or obsolete option, the system will flatly refuse to admit the existence of the flag. This 
 279  *               allows a flag to die correctly over JDK releases using HSX.
 280  *               Note that manual cleanup of expired options should be done at major JDK version upgrades:
 281  *                  - Expired options can be removed from the obsolete_jvm_flags, deprecated_jvm_flags tables,
 282  *                    and aliased_jvm_flags tables.
 283  *                  - Expired deprecated options may still have global variable definitions that should be
 284  *                    removed (in globals.hpp, etc).
 285  * 
 286  * Tests:  Aliases are tested in VMAliasOptions.java.
 287  *         Deprecated options are tested in VMDeprecatedOptions.java. 
 288  *         Obsolete options are tested in various files.
 289  */
 290 
 291 // Obsolete or deprecated -XX flag.
 292 typedef struct {
 293   const char* name;
 294   JDK_Version obsoleted_in; // When the warning started (obsolete or deprecated).
 295   JDK_Version accept_until; // Which version to start denying the existence of the flag (if scheduled).
 296 } SpecialFlag;
 297 
 298 // When a flag is eliminated, it can be added to this list in order to
 299 // continue accepting this flag on the command-line, while issuing a warning
 300 // and ignoring the value.  Once the JDK version reaches the 'accept_until'
 301 // limit, we flatly refuse to admit the existence of the flag.
 302 static SpecialFlag const obsolete_jvm_flags[] = {
 303   { "UseTrainGC",                    JDK_Version::jdk(5), JDK_Version::jdk(7) },
 304   { "UseSpecialLargeObjectHandling", JDK_Version::jdk(5), JDK_Version::jdk(7) },
 305   { "UseOversizedCarHandling",       JDK_Version::jdk(5), JDK_Version::jdk(7) },
 306   { "TraceCarAllocation",            JDK_Version::jdk(5), JDK_Version::jdk(7) },
 307   { "PrintTrainGCProcessingStats",   JDK_Version::jdk(5), JDK_Version::jdk(7) },
 308   { "LogOfCarSpaceSize",             JDK_Version::jdk(5), JDK_Version::jdk(7) },
 309   { "OversizedCarThreshold",         JDK_Version::jdk(5), JDK_Version::jdk(7) },
 310   { "MinTickInterval",               JDK_Version::jdk(5), JDK_Version::jdk(7) },
 311   { "DefaultTickInterval",           JDK_Version::jdk(5), JDK_Version::jdk(7) },
 312   { "MaxTickInterval",               JDK_Version::jdk(5), JDK_Version::jdk(7) },
 313   { "DelayTickAdjustment",           JDK_Version::jdk(5), JDK_Version::jdk(7) },
 314   { "ProcessingToTenuringRatio",     JDK_Version::jdk(5), JDK_Version::jdk(7) },
 315   { "MinTrainLength",                JDK_Version::jdk(5), JDK_Version::jdk(7) },
 316   { "AppendRatio",         JDK_Version::jdk_update(6,10), JDK_Version::jdk(7) },
 317   { "DefaultMaxRAM",       JDK_Version::jdk_update(6,18), JDK_Version::jdk(7) },
 318   { "DefaultInitialRAMFraction",
 319                            JDK_Version::jdk_update(6,18), JDK_Version::jdk(7) },
 320   { "UseDepthFirstScavengeOrder",
 321                            JDK_Version::jdk_update(6,22), JDK_Version::jdk(7) },
 322   { "HandlePromotionFailure",
 323                            JDK_Version::jdk_update(6,24), JDK_Version::jdk(8) },
 324   { "MaxLiveObjectEvacuationRatio",
 325                            JDK_Version::jdk_update(6,24), JDK_Version::jdk(8) },
 326   { "ForceSharedSpaces",   JDK_Version::jdk_update(6,25), JDK_Version::jdk(8) },
 327   { "UseParallelOldGCCompacting",
 328                            JDK_Version::jdk_update(6,27), JDK_Version::jdk(8) },
 329   { "UseParallelDensePrefixUpdate",
 330                            JDK_Version::jdk_update(6,27), JDK_Version::jdk(8) },
 331   { "UseParallelOldGCDensePrefix",
 332                            JDK_Version::jdk_update(6,27), JDK_Version::jdk(8) },
 333   { "AllowTransitionalJSR292",       JDK_Version::jdk(7), JDK_Version::jdk(8) },
 334   { "UseCompressedStrings",          JDK_Version::jdk(7), JDK_Version::jdk(8) },
 335   { "CMSPermGenPrecleaningEnabled",  JDK_Version::jdk(8), JDK_Version::jdk(9) },
 336   { "CMSTriggerPermRatio",           JDK_Version::jdk(8), JDK_Version::jdk(9) },
 337   { "CMSInitiatingPermOccupancyFraction",
 338                                      JDK_Version::jdk(8), JDK_Version::jdk(9) },
 339   { "AdaptivePermSizeWeight",        JDK_Version::jdk(8), JDK_Version::jdk(9) },
 340   { "PermGenPadding",                JDK_Version::jdk(8), JDK_Version::jdk(9) },
 341   { "PermMarkSweepDeadRatio",        JDK_Version::jdk(8), JDK_Version::jdk(9) },
 342   { "PermSize",                      JDK_Version::jdk(8), JDK_Version::jdk(9) },
 343   { "MaxPermSize",                   JDK_Version::jdk(8), JDK_Version::jdk(9) },
 344   { "MinPermHeapExpansion",          JDK_Version::jdk(8), JDK_Version::jdk(9) },
 345   { "MaxPermHeapExpansion",          JDK_Version::jdk(8), JDK_Version::jdk(9) },
 346   { "CMSRevisitStackSize",           JDK_Version::jdk(8), JDK_Version::jdk(9) },
 347   { "PrintRevisitStats",             JDK_Version::jdk(8), JDK_Version::jdk(9) },
 348   { "UseVectoredExceptions",         JDK_Version::jdk(8), JDK_Version::jdk(9) },
 349   { "UseSplitVerifier",              JDK_Version::jdk(8), JDK_Version::jdk(9) },
 350   { "UseISM",                        JDK_Version::jdk(8), JDK_Version::jdk(9) },
 351   { "UsePermISM",                    JDK_Version::jdk(8), JDK_Version::jdk(9) },
 352   { "UseMPSS",                       JDK_Version::jdk(8), JDK_Version::jdk(9) },
 353   { "UseStringCache",                JDK_Version::jdk(8), JDK_Version::jdk(9) },
 354   { "UseOldInlining",                JDK_Version::jdk(9), JDK_Version::jdk(10) },
 355   { "SafepointPollOffset",           JDK_Version::jdk(9), JDK_Version::jdk(10) },
 356 #ifdef PRODUCT
 357   { "DesiredMethodLimit",  JDK_Version::jdk_update(7, 2), JDK_Version::jdk(8) },

 358 #endif // PRODUCT
 359   { "UseVMInterruptibleIO",          JDK_Version::jdk(8), JDK_Version::jdk(9) },
 360   { "UseBoundThreads",               JDK_Version::jdk(9), JDK_Version::jdk(10) },
 361   { "DefaultThreadPriority",         JDK_Version::jdk(9), JDK_Version::jdk(10) },
 362   { "NoYieldsInMicrolock",           JDK_Version::jdk(9), JDK_Version::jdk(10) },
 363   { "BackEdgeThreshold",             JDK_Version::jdk(9), JDK_Version::jdk(10) },
 364   { "UseNewReflection",              JDK_Version::jdk(9), JDK_Version::jdk(10) },
 365   { "ReflectionWrapResolutionErrors",JDK_Version::jdk(9), JDK_Version::jdk(10) },
 366   { "VerifyReflectionBytecodes",     JDK_Version::jdk(9), JDK_Version::jdk(10) },
 367   { "AutoShutdownNMT",               JDK_Version::jdk(9), JDK_Version::jdk(10) },
 368   { "NmethodSweepFraction",          JDK_Version::jdk(9), JDK_Version::jdk(10) },
 369   { "NmethodSweepCheckInterval",     JDK_Version::jdk(9), JDK_Version::jdk(10) },
 370   { "CodeCacheMinimumFreeSpace",     JDK_Version::jdk(9), JDK_Version::jdk(10) },
 371 #ifndef ZERO
 372   { "UseFastAccessorMethods",        JDK_Version::jdk(9), JDK_Version::jdk(10) },
 373   { "UseFastEmptyMethods",           JDK_Version::jdk(9), JDK_Version::jdk(10) },
 374 #endif // ZERO
 375   { "UseCompilerSafepoints",         JDK_Version::jdk(9), JDK_Version::jdk(10) },
 376   { NULL, JDK_Version(0), JDK_Version(0) }
 377 };
 378 
 379 // When a flag is deprecated, it can be added to this list in order to issuing a warning when the flag is used.
 380 // Once the JDK version reaches the 'accept_until' limit, we flatly refuse to admit the existence of the flag.
 381 static SpecialFlag const deprecated_jvm_flags[] = {
 382   // deprecated non-alias flags:
 383   { "MaxGCMinorPauseMillis",        JDK_Version::jdk(8), JDK_Version::undefined() },
 384   { "UseParNewGC",                  JDK_Version::jdk(9), JDK_Version::jdk(10) },
 385   
 386   // deprecated alias flags (see also aliased_jvm_flags):
 387   { "DefaultMaxRAMFraction",        JDK_Version::jdk(8), JDK_Version::undefined() },
 388   { "CMSMarkStackSizeMax",          JDK_Version::jdk(9), JDK_Version::jdk(10) },
 389   { "CMSMarkStackSize",             JDK_Version::jdk(9), JDK_Version::jdk(10) },
 390   { "G1MarkStackSize",              JDK_Version::jdk(9), JDK_Version::jdk(10) },
 391   { "ParallelMarkingThreads",       JDK_Version::jdk(9), JDK_Version::jdk(10) },
 392   { "ParallelCMSThreads",           JDK_Version::jdk(9), JDK_Version::jdk(10) },
 393   { NULL, JDK_Version(0), JDK_Version(0) }
 394 };
 395 
 396 // Flags that are aliases for other flags.
 397 typedef struct {
 398   const char* alias_name;
 399   const char* real_name;
 400 } AliasedFlag;
 401 
 402 static AliasedFlag const aliased_jvm_flags[] = {
 403   { "DefaultMaxRAMFraction",    "MaxRAMFraction"    },
 404   { "CMSMarkStackSizeMax",      "MarkStackSizeMax"  },
 405   { "CMSMarkStackSize",         "MarkStackSize"     },
 406   { "G1MarkStackSize",          "MarkStackSize"     },
 407   { "ParallelMarkingThreads",   "ConcGCThreads"     },
 408   { "ParallelCMSThreads",       "ConcGCThreads"     },
 409   { NULL, NULL}
 410 };
 411 
 412 // Returns 1 if the flag is special and jdk version is in the range specified.
 413 //     In this case the 'version' buffer is filled in with the version number when 
 414 //     the flag became special.
 415 // Returns -1 if the flag is special and has expired (should be ignored).
 416 // Returns 0 if the flag is not special.
 417 static int is_special_flag(const SpecialFlag special_table[], const char *s, JDK_Version* version) {
 418   assert(version != NULL, "Must provide a version buffer");
 419   for (size_t i = 0; special_table[i].name != NULL; i++) {
 420     const SpecialFlag& flag_status = special_table[i];
 421     // <flag>=xxx form
 422     // [-|+]<flag> form
 423     if ((strcmp(flag_status.name, s) == 0) ||


 424         ((s[0] == '+' || s[0] == '-') &&
 425          (strcmp(flag_status.name, &s[1]) == 0))) {
 426       if (flag_status.accept_until.is_undefined() ||
 427           JDK_Version::current().compare(flag_status.accept_until) == -1) {
 428         *version = flag_status.obsoleted_in;
 429         return 1;
 430       } else {
 431         return -1;
 432       }
 433     }

 434   }
 435   return 0;
 436 }
 437 
 438 bool Arguments::is_newly_obsolete(const char *s, JDK_Version* version) {
 439   return (is_special_flag(obsolete_jvm_flags, s, version) == 1);
 440 }
 441 
 442 int Arguments::is_deprecated_flag(const char *s, JDK_Version* version) {
 443   return is_special_flag(deprecated_jvm_flags, s, version);
 444 }
 445 
 446 const char* Arguments::real_flag_name(const char *flag_name) {
 447   for (size_t i = 0; aliased_jvm_flags[i].alias_name != NULL; i++) {
 448     const AliasedFlag& flag_status = aliased_jvm_flags[i];
 449     if (strcmp(flag_status.alias_name, flag_name) == 0) {
 450         return flag_status.real_name;
 451     }
 452   }
 453   return flag_name;
 454 }
 455 
 456 // Constructs the system class path (aka boot class path) from the following
 457 // components, in order:
 458 //
 459 //     prefix           // from -Xbootclasspath/p:...
 460 //     base             // from os::get_system_properties() or -Xbootclasspath=
 461 //     suffix           // from -Xbootclasspath/a:...
 462 //
 463 // This could be AllStatic, but it isn't needed after argument processing is
 464 // complete.
 465 class SysClassPath: public StackObj {
 466 public:
 467   SysClassPath(const char* base);
 468   ~SysClassPath();
 469 
 470   inline void set_base(const char* base);
 471   inline void add_prefix(const char* prefix);
 472   inline void add_suffix_to_prefix(const char* suffix);
 473   inline void add_suffix(const char* suffix);


 704 }
 705 
 706 // Describe an argument out of range error
 707 void Arguments::describe_range_error(ArgsRange errcode) {
 708   switch(errcode) {
 709   case arg_too_big:
 710     jio_fprintf(defaultStream::error_stream(),
 711                 "The specified size exceeds the maximum "
 712                 "representable size.\n");
 713     break;
 714   case arg_too_small:
 715   case arg_unreadable:
 716   case arg_in_range:
 717     // do nothing for now
 718     break;
 719   default:
 720     ShouldNotReachHere();
 721   }
 722 }
 723 
 724 static bool set_bool_flag(const char* name, bool value, Flag::Flags origin) {
 725   return CommandLineFlags::boolAtPut(name, &value, origin);
 726 }
 727 
 728 static bool set_fp_numeric_flag(const char* name, char* value, Flag::Flags origin) {
 729   double v;
 730   if (sscanf(value, "%lf", &v) != 1) {
 731     return false;
 732   }
 733 
 734   if (CommandLineFlags::doubleAtPut(name, &v, origin)) {
 735     return true;
 736   }
 737   return false;
 738 }
 739 
 740 static bool set_numeric_flag(const char* name, char* value, Flag::Flags origin) {
 741   julong v;
 742   intx intx_v;
 743   bool is_neg = false;
 744   // Check the sign first since atomull() parses only unsigned values.
 745   if (*value == '-') {
 746     if (!CommandLineFlags::intxAt(name, &intx_v)) {
 747       return false;
 748     }
 749     value++;
 750     is_neg = true;
 751   }
 752   if (!atomull(value, &v)) {
 753     return false;
 754   }
 755   intx_v = (intx) v;
 756   if (is_neg) {
 757     intx_v = -intx_v;
 758   }
 759   if (CommandLineFlags::intxAtPut(name, &intx_v, origin)) {
 760     return true;
 761   }
 762   uintx uintx_v = (uintx) v;
 763   if (!is_neg && CommandLineFlags::uintxAtPut(name, &uintx_v, origin)) {
 764     return true;
 765   }
 766   uint64_t uint64_t_v = (uint64_t) v;
 767   if (!is_neg && CommandLineFlags::uint64_tAtPut(name, &uint64_t_v, origin)) {
 768     return true;
 769   }
 770   size_t size_t_v = (size_t) v;
 771   if (!is_neg && CommandLineFlags::size_tAtPut(name, &size_t_v, origin)) {
 772     return true;
 773   }
 774   return false;
 775 }
 776 
 777 static bool set_string_flag(const char* name, const char* value, Flag::Flags origin) {
 778   if (!CommandLineFlags::ccstrAtPut(name, &value, origin))  return false;
 779   // Contract:  CommandLineFlags always returns a pointer that needs freeing.
 780   FREE_C_HEAP_ARRAY(char, value);
 781   return true;
 782 }
 783 
 784 static bool append_to_string_flag(const char* name, const char* new_value, Flag::Flags origin) {
 785   const char* old_value = "";
 786   if (!CommandLineFlags::ccstrAt(name, &old_value))  return false;
 787   size_t old_len = old_value != NULL ? strlen(old_value) : 0;
 788   size_t new_len = strlen(new_value);
 789   const char* value;
 790   char* free_this_too = NULL;
 791   if (old_len == 0) {
 792     value = new_value;
 793   } else if (new_len == 0) {
 794     value = old_value;
 795   } else {
 796     char* buf = NEW_C_HEAP_ARRAY(char, old_len + 1 + new_len + 1, mtInternal);
 797     // each new setting adds another LINE to the switch:
 798     sprintf(buf, "%s\n%s", old_value, new_value);
 799     value = buf;
 800     free_this_too = buf;
 801   }
 802   (void) CommandLineFlags::ccstrAtPut(name, &value, origin);
 803   // CommandLineFlags always returns a pointer that needs freeing.
 804   FREE_C_HEAP_ARRAY(char, value);
 805   if (free_this_too != NULL) {
 806     // CommandLineFlags made its own copy, so I must delete my own temp. buffer.
 807     FREE_C_HEAP_ARRAY(char, free_this_too);
 808   }
 809   return true;
 810 }
 811 
 812 const char* Arguments::handle_aliases_and_deprecation(const char* arg, bool warn) {
 813   const char* real_name = real_flag_name(arg);
 814   JDK_Version since = JDK_Version();
 815   switch (is_deprecated_flag(arg, &since)) {
 816     case -1:
 817       return NULL;
 818     case 0:
 819       return real_name;
 820     case 1: {
 821       if (warn) {
 822         char version[256];
 823         since.to_string(version, sizeof(version));
 824         if (real_name != arg) {
 825           warning("Option %s was deprecated in version %s and will likely be removed in a future release. Use option %s instead.",
 826                   arg, version, real_name);
 827         } else {
 828           warning("Option %s was deprecated in version %s and will likely be removed in a future release.",
 829                   arg, version);
 830         }
 831       }
 832       return real_name;
 833     }
 834   }
 835   ShouldNotReachHere();
 836   return NULL;
 837 }
 838 
 839 bool Arguments::parse_argument(const char* arg, Flag::Flags origin) {
 840 
 841   // range of acceptable characters spelled out for portability reasons
 842 #define NAME_RANGE  "[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]"
 843 #define BUFLEN 255
 844   char name[BUFLEN+1];
 845   char dummy;
 846   const char* real_name;
 847   bool warn_if_deprecated = true;
 848   
 849   if (sscanf(arg, "-%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
 850     real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
 851     if (real_name == NULL) {
 852       return false; // "name" is a deprecated option that has expired.
 853     }
 854     return set_bool_flag(real_name, false, origin);
 855   }
 856   if (sscanf(arg, "+%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
 857     real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
 858     if (real_name == NULL) {
 859       return false;
 860     }
 861     return set_bool_flag(real_name, true, origin);
 862   }
 863 
 864   char punct;
 865   if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "%c", name, &punct) == 2 && punct == '=') {
 866     const char* value = strchr(arg, '=') + 1;
 867     Flag* flag;
 868     
 869     // this scanf pattern matches both strings (handled here) and numbers (handled later))
 870     real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
 871     if (real_name == NULL) {
 872       return false;
 873     }
 874     flag = Flag::find_flag(real_name, strlen(real_name));
 875     if (flag != NULL && flag->is_ccstr()) {
 876       if (flag->ccstr_accumulates()) {
 877         return append_to_string_flag(real_name, value, origin);
 878       } else {
 879         if (value[0] == '\0') {
 880           value = NULL;
 881         }
 882         return set_string_flag(real_name, value, origin);
 883       }
 884     } else {
 885       warn_if_deprecated = false; // if arg is deprecated, we've already done warning...
 886     }
 887   }
 888 
 889   if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE ":%c", name, &punct) == 2 && punct == '=') {
 890     const char* value = strchr(arg, '=') + 1;
 891     // -XX:Foo:=xxx will reset the string flag to the given value.
 892     if (value[0] == '\0') {
 893       value = NULL;
 894     }
 895     real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
 896     if (real_name == NULL) {
 897       return false;
 898     }
 899     return set_string_flag(real_name, value, origin);
 900   }
 901 
 902 #define SIGNED_FP_NUMBER_RANGE "[-0123456789.]"
 903 #define SIGNED_NUMBER_RANGE    "[-0123456789]"
 904 #define        NUMBER_RANGE    "[0123456789]"
 905   char value[BUFLEN + 1];
 906   char value2[BUFLEN + 1];
 907   if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_NUMBER_RANGE "." "%" XSTR(BUFLEN) NUMBER_RANGE "%c", name, value, value2, &dummy) == 3) {
 908     // Looks like a floating-point number -- try again with more lenient format string
 909     if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_FP_NUMBER_RANGE "%c", name, value, &dummy) == 2) {
 910       real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
 911       if (real_name == NULL) {
 912         return false;
 913       }
 914       return set_fp_numeric_flag(real_name, value, origin);
 915     }
 916   }
 917 
 918 #define VALUE_RANGE "[-kmgtxKMGTX0123456789abcdefABCDEF]"
 919   if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) VALUE_RANGE "%c", name, value, &dummy) == 2) {
 920     real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
 921     if (real_name == NULL) {
 922       return false;
 923     }
 924     return set_numeric_flag(real_name, value, origin);
 925   }
 926 
 927   return false;
 928 }
 929 
 930 void Arguments::add_string(char*** bldarray, int* count, const char* arg) {
 931   assert(bldarray != NULL, "illegal argument");
 932 
 933   if (arg == NULL) {
 934     return;
 935   }
 936 
 937   int new_count = *count + 1;
 938 
 939   // expand the array and add arg to the last element
 940   if (*bldarray == NULL) {
 941     *bldarray = NEW_C_HEAP_ARRAY(char*, new_count, mtInternal);
 942   } else {
 943     *bldarray = REALLOC_C_HEAP_ARRAY(char*, *bldarray, new_count, mtInternal);
 944   }


1004       st->print("%s ", _jvm_args_array[i]);
1005     }
1006     st->cr();
1007   }
1008 }
1009 
1010 bool Arguments::process_argument(const char* arg,
1011     jboolean ignore_unrecognized, Flag::Flags origin) {
1012 
1013   JDK_Version since = JDK_Version();
1014 
1015   if (parse_argument(arg, origin) || ignore_unrecognized) {
1016     return true;
1017   }
1018 
1019   bool has_plus_minus = (*arg == '+' || *arg == '-');
1020   const char* const argname = has_plus_minus ? arg + 1 : arg;
1021   if (is_newly_obsolete(arg, &since)) {
1022     char version[256];
1023     since.to_string(version, sizeof(version));
1024     warning("Ignoring option %s; support was removed in %s", argname, version);
1025     return true;
1026   }
1027 
1028   // For locked flags, report a custom error message if available.
1029   // Otherwise, report the standard unrecognized VM option.
1030 
1031   size_t arg_len;
1032   const char* equal_sign = strchr(argname, '=');
1033   if (equal_sign == NULL) {
1034     arg_len = strlen(argname);
1035   } else {
1036     arg_len = equal_sign - argname;
1037   }
1038 
1039   Flag* found_flag = Flag::find_flag((const char*)argname, arg_len, true, true);
1040   if (found_flag != NULL) {
1041     char locked_message_buf[BUFLEN];
1042     found_flag->get_locked_message(locked_message_buf, BUFLEN);
1043     if (strlen(locked_message_buf) == 0) {
1044       if (found_flag->is_bool() && !has_plus_minus) {


1391  *    C1 can be used, so the minimum number of compiler threads is 1.
1392  * 4) The JVM is build using the compilers and tiered compilation is enabled. The option
1393  *    'TieredStopAtLevel = CompLevel_full_optimization' (the default value). As a result,
1394  *    the minimum number of compiler threads is 2.
1395  */
1396 int Arguments::get_min_number_of_compiler_threads() {
1397 #if !defined(COMPILER1) && !defined(COMPILER2) && !defined(SHARK)
1398   return 0;   // case 1
1399 #else
1400   if (!TieredCompilation || (TieredStopAtLevel < CompLevel_full_optimization)) {
1401     return 1; // case 2 or case 3
1402   }
1403   return 2;   // case 4 (tiered)
1404 #endif
1405 }
1406 
1407 #if INCLUDE_ALL_GCS
1408 static void disable_adaptive_size_policy(const char* collector_name) {
1409   if (UseAdaptiveSizePolicy) {
1410     if (FLAG_IS_CMDLINE(UseAdaptiveSizePolicy)) {
1411       warning("Disabling UseAdaptiveSizePolicy; it is incompatible with %s.",
1412               collector_name);
1413     }
1414     FLAG_SET_DEFAULT(UseAdaptiveSizePolicy, false);
1415   }
1416 }
1417 
1418 void Arguments::set_parnew_gc_flags() {
1419   assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC && !UseG1GC,
1420          "control point invariant");
1421   assert(UseConcMarkSweepGC, "CMS is expected to be on here");
1422   assert(UseParNewGC, "ParNew should always be used with CMS");
1423 
1424   if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
1425     FLAG_SET_DEFAULT(ParallelGCThreads, Abstract_VM_Version::parallel_worker_threads());
1426     assert(ParallelGCThreads > 0, "We should always have at least one thread by default");
1427   } else if (ParallelGCThreads == 0) {
1428     jio_fprintf(defaultStream::error_stream(),
1429         "The ParNew GC can not be combined with -XX:ParallelGCThreads=0\n");
1430     vm_exit(1);
1431   }


1897 #if !INCLUDE_ALL_GCS
1898 #ifdef ASSERT
1899 static bool verify_serial_gc_flags() {
1900   return (UseSerialGC &&
1901         !(UseParNewGC || (UseConcMarkSweepGC) || UseG1GC ||
1902           UseParallelGC || UseParallelOldGC));
1903 }
1904 #endif // ASSERT
1905 #endif // INCLUDE_ALL_GCS
1906 
1907 void Arguments::set_gc_specific_flags() {
1908 #if INCLUDE_ALL_GCS
1909   // Set per-collector flags
1910   if (UseParallelGC || UseParallelOldGC) {
1911     set_parallel_gc_flags();
1912   } else if (UseConcMarkSweepGC) {
1913     set_cms_and_parnew_gc_flags();
1914   } else if (UseG1GC) {
1915     set_g1_gc_flags();
1916   }

1917   if (AssumeMP && !UseSerialGC) {
1918     if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) {
1919       warning("If the number of processors is expected to increase from one, then"
1920               " you should configure the number of parallel GC threads appropriately"
1921               " using -XX:ParallelGCThreads=N");
1922     }
1923   }
1924   if (MinHeapFreeRatio == 100) {
1925     // Keeping the heap 100% free is hard ;-) so limit it to 99%.
1926     FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99);
1927   }
1928 #else // INCLUDE_ALL_GCS
1929   assert(verify_serial_gc_flags(), "SerialGC unset");
1930 #endif // INCLUDE_ALL_GCS
1931 }
1932 
1933 julong Arguments::limit_by_allocatable_memory(julong limit) {
1934   julong max_allocatable;
1935   julong result = limit;
1936   if (os::has_allocatable_memory_limit(&max_allocatable)) {
1937     result = MIN2(result, max_allocatable / MaxVirtMemFraction);
1938   }
1939   return result;
1940 }
1941 
1942 // Use static initialization to get the default before parsing
1943 static const uintx DefaultHeapBaseMinAddress = HeapBaseMinAddress;
1944 
1945 void Arguments::set_heap_size() {





1946   const julong phys_mem =
1947     FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
1948                             : (julong)MaxRAM;
1949 
1950   // If the maximum heap size has not been set with -Xmx,
1951   // then set it as fraction of the size of physical memory,
1952   // respecting the maximum and minimum sizes of the heap.
1953   if (FLAG_IS_DEFAULT(MaxHeapSize)) {
1954     julong reasonable_max = phys_mem / MaxRAMFraction;
1955 
1956     if (phys_mem <= MaxHeapSize * MinRAMFraction) {
1957       // Small physical memory, so use a minimum fraction of it for the heap
1958       reasonable_max = phys_mem / MinRAMFraction;
1959     } else {
1960       // Not-small physical memory, so require a heap at least
1961       // as large as MaxHeapSize
1962       reasonable_max = MAX2(reasonable_max, (julong)MaxHeapSize);
1963     }
1964     if (!FLAG_IS_DEFAULT(ErgoHeapSizeLimit) && ErgoHeapSizeLimit != 0) {
1965       // Limit the heap size to ErgoHeapSizeLimit


2283     return false;
2284   }
2285 
2286   if (UseConcMarkSweepGC && !UseParNewGC) {
2287     jio_fprintf(defaultStream::error_stream(),
2288         "It is not possible to combine the DefNew young collector with the CMS collector.\n");
2289     return false;
2290   }
2291 
2292   if (UseParNewGC && !UseConcMarkSweepGC) {
2293     // !UseConcMarkSweepGC means that we are using serial old gc. Unfortunately we don't
2294     // set up UseSerialGC properly, so that can't be used in the check here.
2295     jio_fprintf(defaultStream::error_stream(),
2296         "It is not possible to combine the ParNew young collector with the Serial old collector.\n");
2297     return false;
2298   }
2299 
2300   return true;
2301 }
2302 














2303 // Check stack pages settings
2304 bool Arguments::check_stack_pages()
2305 {
2306   bool status = true;
2307   status = status && verify_min_value(StackYellowPages, 1, "StackYellowPages");
2308   status = status && verify_min_value(StackRedPages, 1, "StackRedPages");
2309   // greater stack shadow pages can't generate instruction to bang stack
2310   status = status && verify_interval(StackShadowPages, 1, 50, "StackShadowPages");
2311   return status;
2312 }
2313 
2314 // Check the consistency of vm_init_args
2315 bool Arguments::check_vm_args_consistency() {
2316   // Method for adding checks for flag consistency.
2317   // The intent is to warn the user of all possible conflicts,
2318   // before returning an error.
2319   // Note: Needs platform-dependent factoring.
2320   bool status = true;
2321 
2322   if (TLABRefillWasteFraction == 0) {


2520                                       "CompressedClassSpaceSize");
2521 
2522   status = status && verify_interval(MarkStackSizeMax,
2523                                   1, (max_jint - 1), "MarkStackSizeMax");
2524   status = status && verify_interval(NUMAChunkResizeWeight, 0, 100, "NUMAChunkResizeWeight");
2525 
2526   status = status && verify_min_value(LogEventsBufferEntries, 1, "LogEventsBufferEntries");
2527 
2528   status = status && verify_min_value(HeapSizePerGCThread, (uintx) os::vm_page_size(), "HeapSizePerGCThread");
2529 
2530   status = status && verify_min_value(GCTaskTimeStampEntries, 1, "GCTaskTimeStampEntries");
2531 
2532   status = status && verify_percentage(ParallelGCBufferWastePct, "ParallelGCBufferWastePct");
2533   status = status && verify_interval(TargetPLABWastePct, 1, 100, "TargetPLABWastePct");
2534 
2535   status = status && verify_min_value(ParGCStridesPerThread, 1, "ParGCStridesPerThread");
2536 
2537   status = status && verify_min_value(MinRAMFraction, 1, "MinRAMFraction");
2538   status = status && verify_min_value(InitialRAMFraction, 1, "InitialRAMFraction");
2539   status = status && verify_min_value(MaxRAMFraction, 1, "MaxRAMFraction");

2540 
2541   status = status && verify_interval(AdaptiveTimeWeight, 0, 100, "AdaptiveTimeWeight");
2542   status = status && verify_min_value(AdaptiveSizeDecrementScaleFactor, 1, "AdaptiveSizeDecrementScaleFactor");
2543 
2544   status = status && verify_interval(TLABAllocationWeight, 0, 100, "TLABAllocationWeight");
2545   status = status && verify_min_value(MinTLABSize, 1, "MinTLABSize");
2546   status = status && verify_min_value(TLABRefillWasteFraction, 1, "TLABRefillWasteFraction");
2547 
2548   status = status && verify_percentage(YoungGenerationSizeSupplement, "YoungGenerationSizeSupplement");
2549   status = status && verify_percentage(TenuredGenerationSizeSupplement, "TenuredGenerationSizeSupplement");
2550 
2551   status = status && verify_interval(MaxTenuringThreshold, 0, markOopDesc::max_age + 1, "MaxTenuringThreshold");
2552   status = status && verify_interval(InitialTenuringThreshold, 0, MaxTenuringThreshold, "InitialTenuringThreshold");
2553   status = status && verify_percentage(TargetSurvivorRatio, "TargetSurvivorRatio");
2554   status = status && verify_percentage(MarkSweepDeadRatio, "MarkSweepDeadRatio");
2555 
2556   status = status && verify_min_value(MarkSweepAlwaysCompactCount, 1, "MarkSweepAlwaysCompactCount");
2557 #ifdef COMPILER1
2558   status = status && verify_min_value(ValueMapInitialSize, 1, "ValueMapInitialSize");
2559 #endif


3356     } else if (match_option(option, "-XX:+DisplayVMOutputToStdout")) {
3357       FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, false);
3358       FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, true);
3359     } else if (match_option(option, "-XX:+ExtendedDTraceProbes")) {
3360 #if defined(DTRACE_ENABLED)
3361       FLAG_SET_CMDLINE(bool, ExtendedDTraceProbes, true);
3362       FLAG_SET_CMDLINE(bool, DTraceMethodProbes, true);
3363       FLAG_SET_CMDLINE(bool, DTraceAllocProbes, true);
3364       FLAG_SET_CMDLINE(bool, DTraceMonitorProbes, true);
3365 #else // defined(DTRACE_ENABLED)
3366       jio_fprintf(defaultStream::error_stream(),
3367                   "ExtendedDTraceProbes flag is not applicable for this configuration\n");
3368       return JNI_EINVAL;
3369 #endif // defined(DTRACE_ENABLED)
3370 #ifdef ASSERT
3371     } else if (match_option(option, "-XX:+FullGCALot")) {
3372       FLAG_SET_CMDLINE(bool, FullGCALot, true);
3373       // disable scavenge before parallel mark-compact
3374       FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false);
3375 #endif








































3376     } else if (match_option(option, "-XX:MaxDirectMemorySize=", &tail)) {
3377       julong max_direct_memory_size = 0;
3378       ArgsRange errcode = parse_memory_size(tail, &max_direct_memory_size, 0);
3379       if (errcode != arg_in_range) {
3380         jio_fprintf(defaultStream::error_stream(),
3381                     "Invalid maximum direct memory size: %s\n",
3382                     option->optionString);
3383         describe_range_error(errcode);
3384         return JNI_EINVAL;
3385       }
3386       FLAG_SET_CMDLINE(uintx, MaxDirectMemorySize, max_direct_memory_size);
3387 #if !INCLUDE_MANAGEMENT
3388     } else if (match_option(option, "-XX:+ManagementServer")) {
3389         jio_fprintf(defaultStream::error_stream(),
3390           "ManagementServer is not supported in this VM.\n");
3391         return JNI_ERR;
3392 #endif // INCLUDE_MANAGEMENT
3393     } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx
3394       // Skip -XX:Flags= since that case has already been handled
3395       if (strncmp(tail, "Flags=", strlen("Flags=")) != 0) {


3700     vm_args.ignoreUnrecognized = IgnoreUnrecognizedVMOptions;
3701 
3702     if (PrintVMOptions) {
3703       const char* tail;
3704       for (int i = 0; i < vm_args.nOptions; i++) {
3705         const JavaVMOption *option = vm_args.options + i;
3706         if (match_option(option, "-XX:", &tail)) {
3707           logOption(tail);
3708         }
3709       }
3710     }
3711 
3712     return(parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p, Flag::ENVIRON_VAR));
3713   }
3714   return JNI_OK;
3715 }
3716 
3717 void Arguments::set_shared_spaces_flags() {
3718   if (DumpSharedSpaces) {
3719     if (RequireSharedSpaces) {
3720       warning("Cannot dump shared archive while using shared archive");
3721     }
3722     UseSharedSpaces = false;
3723 #ifdef _LP64
3724     if (!UseCompressedOops || !UseCompressedClassPointers) {
3725       vm_exit_during_initialization(
3726         "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL);
3727     }
3728   } else {
3729     if (!UseCompressedOops || !UseCompressedClassPointers) {
3730       no_shared_spaces("UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces.");
3731     }
3732 #endif
3733   }
3734 }
3735 
3736 #if !INCLUDE_ALL_GCS
3737 static void force_serial_gc() {
3738   FLAG_SET_DEFAULT(UseSerialGC, true);
3739   UNSUPPORTED_GC_OPTION(UseG1GC);
3740   UNSUPPORTED_GC_OPTION(UseParallelGC);


3936 #if INCLUDE_ALL_GCS
3937   #if (defined JAVASE_EMBEDDED || defined ARM)
3938     UNSUPPORTED_OPTION(UseG1GC, "G1 GC");
3939   #endif
3940 #endif
3941 
3942 #ifndef PRODUCT
3943   if (TraceBytecodesAt != 0) {
3944     TraceBytecodes = true;
3945   }
3946   if (CountCompiledCalls) {
3947     if (UseCounterDecay) {
3948       warning("UseCounterDecay disabled because CountCalls is set");
3949       UseCounterDecay = false;
3950     }
3951   }
3952 #endif // PRODUCT
3953 
3954   if (ScavengeRootsInCode == 0) {
3955     if (!FLAG_IS_DEFAULT(ScavengeRootsInCode)) {
3956       warning("Forcing ScavengeRootsInCode non-zero");
3957     }
3958     ScavengeRootsInCode = 1;
3959   }
3960 
3961   if (PrintGCDetails) {
3962     // Turn on -verbose:gc options as well
3963     PrintGC = true;
3964   }
3965 
3966   // Set object alignment values.
3967   set_object_alignment();
3968 
3969 #if !INCLUDE_ALL_GCS
3970   force_serial_gc();
3971 #endif // INCLUDE_ALL_GCS
3972 #if !INCLUDE_CDS
3973   if (DumpSharedSpaces || RequireSharedSpaces) {
3974     jio_fprintf(defaultStream::error_stream(),
3975       "Shared spaces are not supported in this VM\n");
3976     return JNI_ERR;


< prev index next >