< prev index next >

src/share/vm/runtime/arguments.cpp

Print this page




 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   }


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


2119     return false;
2120   }
2121 
2122   if (UseConcMarkSweepGC && !UseParNewGC) {
2123     jio_fprintf(defaultStream::error_stream(),
2124         "It is not possible to combine the DefNew young collector with the CMS collector.\n");
2125     return false;
2126   }
2127 
2128   if (UseParNewGC && !UseConcMarkSweepGC) {
2129     // !UseConcMarkSweepGC means that we are using serial old gc. Unfortunately we don't
2130     // set up UseSerialGC properly, so that can't be used in the check here.
2131     jio_fprintf(defaultStream::error_stream(),
2132         "It is not possible to combine the ParNew young collector with the Serial old collector.\n");
2133     return false;
2134   }
2135 
2136   return true;
2137 }
2138 
2139 void Arguments::check_deprecated_gc_flags() {
2140   if (FLAG_IS_CMDLINE(UseParNewGC)) {
2141     warning("The UseParNewGC flag is deprecated and will likely be removed in a future release");
2142   }
2143   if (FLAG_IS_CMDLINE(MaxGCMinorPauseMillis)) {
2144     warning("Using MaxGCMinorPauseMillis as minor pause goal is deprecated"
2145             "and will likely be removed in future release");
2146   }
2147   if (FLAG_IS_CMDLINE(DefaultMaxRAMFraction)) {
2148     warning("DefaultMaxRAMFraction is deprecated and will likely be removed in a future release. "
2149         "Use MaxRAMFraction instead.");
2150   }
2151 }
2152 
2153 // Check stack pages settings
2154 bool Arguments::check_stack_pages()
2155 {
2156   bool status = true;
2157   status = status && verify_min_value(StackYellowPages, 1, "StackYellowPages");
2158   status = status && verify_min_value(StackRedPages, 1, "StackRedPages");
2159   // greater stack shadow pages can't generate instruction to bang stack
2160   status = status && verify_interval(StackShadowPages, 1, 50, "StackShadowPages");
2161   return status;
2162 }
2163 
2164 // Check the consistency of vm_init_args
2165 bool Arguments::check_vm_args_consistency() {
2166   // Method for adding checks for flag consistency.
2167   // The intent is to warn the user of all possible conflicts,
2168   // before returning an error.
2169   // Note: Needs platform-dependent factoring.
2170   bool status = true;
2171 
2172   if (TLABRefillWasteFraction == 0) {


2369                                       "CompressedClassSpaceSize");
2370 
2371   status = status && verify_interval(MarkStackSizeMax,
2372                                   1, (max_jint - 1), "MarkStackSizeMax");
2373   status = status && verify_interval(NUMAChunkResizeWeight, 0, 100, "NUMAChunkResizeWeight");
2374 
2375   status = status && verify_min_value(LogEventsBufferEntries, 1, "LogEventsBufferEntries");
2376 
2377   status = status && verify_min_value(HeapSizePerGCThread, (uintx) os::vm_page_size(), "HeapSizePerGCThread");
2378 
2379   status = status && verify_min_value(GCTaskTimeStampEntries, 1, "GCTaskTimeStampEntries");
2380 
2381   status = status && verify_percentage(ParallelGCBufferWastePct, "ParallelGCBufferWastePct");
2382   status = status && verify_interval(TargetPLABWastePct, 1, 100, "TargetPLABWastePct");
2383 
2384   status = status && verify_min_value(ParGCStridesPerThread, 1, "ParGCStridesPerThread");
2385 
2386   status = status && verify_min_value(MinRAMFraction, 1, "MinRAMFraction");
2387   status = status && verify_min_value(InitialRAMFraction, 1, "InitialRAMFraction");
2388   status = status && verify_min_value(MaxRAMFraction, 1, "MaxRAMFraction");
2389   status = status && verify_min_value(DefaultMaxRAMFraction, 1, "DefaultMaxRAMFraction");
2390 
2391   status = status && verify_interval(AdaptiveTimeWeight, 0, 100, "AdaptiveTimeWeight");
2392   status = status && verify_min_value(AdaptiveSizeDecrementScaleFactor, 1, "AdaptiveSizeDecrementScaleFactor");
2393 
2394   status = status && verify_interval(TLABAllocationWeight, 0, 100, "TLABAllocationWeight");
2395   status = status && verify_min_value(MinTLABSize, 1, "MinTLABSize");
2396   status = status && verify_min_value(TLABRefillWasteFraction, 1, "TLABRefillWasteFraction");
2397 
2398   status = status && verify_percentage(YoungGenerationSizeSupplement, "YoungGenerationSizeSupplement");
2399   status = status && verify_percentage(TenuredGenerationSizeSupplement, "TenuredGenerationSizeSupplement");
2400 
2401   status = status && verify_interval(MaxTenuringThreshold, 0, markOopDesc::max_age + 1, "MaxTenuringThreshold");
2402   status = status && verify_interval(InitialTenuringThreshold, 0, MaxTenuringThreshold, "InitialTenuringThreshold");
2403   status = status && verify_percentage(TargetSurvivorRatio, "TargetSurvivorRatio");
2404   status = status && verify_percentage(MarkSweepDeadRatio, "MarkSweepDeadRatio");
2405 
2406   status = status && verify_min_value(MarkSweepAlwaysCompactCount, 1, "MarkSweepAlwaysCompactCount");
2407 #ifdef COMPILER1
2408   status = status && verify_min_value(ValueMapInitialSize, 1, "ValueMapInitialSize");
2409 #endif


3206     } else if (match_option(option, "-XX:+DisplayVMOutputToStdout")) {
3207       FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, false);
3208       FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, true);
3209     } else if (match_option(option, "-XX:+ExtendedDTraceProbes")) {
3210 #if defined(DTRACE_ENABLED)
3211       FLAG_SET_CMDLINE(bool, ExtendedDTraceProbes, true);
3212       FLAG_SET_CMDLINE(bool, DTraceMethodProbes, true);
3213       FLAG_SET_CMDLINE(bool, DTraceAllocProbes, true);
3214       FLAG_SET_CMDLINE(bool, DTraceMonitorProbes, true);
3215 #else // defined(DTRACE_ENABLED)
3216       jio_fprintf(defaultStream::error_stream(),
3217                   "ExtendedDTraceProbes flag is not applicable for this configuration\n");
3218       return JNI_EINVAL;
3219 #endif // defined(DTRACE_ENABLED)
3220 #ifdef ASSERT
3221     } else if (match_option(option, "-XX:+FullGCALot")) {
3222       FLAG_SET_CMDLINE(bool, FullGCALot, true);
3223       // disable scavenge before parallel mark-compact
3224       FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false);
3225 #endif
3226     } else if (match_option(option, "-XX:CMSMarkStackSize=", &tail) ||
3227                match_option(option, "-XX:G1MarkStackSize=", &tail)) {
3228       julong stack_size = 0;
3229       ArgsRange errcode = parse_memory_size(tail, &stack_size, 1);
3230       if (errcode != arg_in_range) {
3231         jio_fprintf(defaultStream::error_stream(),
3232                     "Invalid mark stack size: %s\n", option->optionString);
3233         describe_range_error(errcode);
3234         return JNI_EINVAL;
3235       }
3236       jio_fprintf(defaultStream::error_stream(),
3237         "Please use -XX:MarkStackSize in place of "
3238         "-XX:CMSMarkStackSize or -XX:G1MarkStackSize in the future\n");
3239       FLAG_SET_CMDLINE(uintx, MarkStackSize, stack_size);
3240     } else if (match_option(option, "-XX:CMSMarkStackSizeMax=", &tail)) {
3241       julong max_stack_size = 0;
3242       ArgsRange errcode = parse_memory_size(tail, &max_stack_size, 1);
3243       if (errcode != arg_in_range) {
3244         jio_fprintf(defaultStream::error_stream(),
3245                     "Invalid maximum mark stack size: %s\n",
3246                     option->optionString);
3247         describe_range_error(errcode);
3248         return JNI_EINVAL;
3249       }
3250       jio_fprintf(defaultStream::error_stream(),
3251          "Please use -XX:MarkStackSizeMax in place of "
3252          "-XX:CMSMarkStackSizeMax in the future\n");
3253       FLAG_SET_CMDLINE(uintx, MarkStackSizeMax, max_stack_size);
3254     } else if (match_option(option, "-XX:ParallelMarkingThreads=", &tail) ||
3255                match_option(option, "-XX:ParallelCMSThreads=", &tail)) {
3256       uintx conc_threads = 0;
3257       if (!parse_uintx(tail, &conc_threads, 1)) {
3258         jio_fprintf(defaultStream::error_stream(),
3259                     "Invalid concurrent threads: %s\n", option->optionString);
3260         return JNI_EINVAL;
3261       }
3262       jio_fprintf(defaultStream::error_stream(),
3263         "Please use -XX:ConcGCThreads in place of "
3264         "-XX:ParallelMarkingThreads or -XX:ParallelCMSThreads in the future\n");
3265       FLAG_SET_CMDLINE(uintx, ConcGCThreads, conc_threads);
3266     } else if (match_option(option, "-XX:MaxDirectMemorySize=", &tail)) {
3267       julong max_direct_memory_size = 0;
3268       ArgsRange errcode = parse_memory_size(tail, &max_direct_memory_size, 0);
3269       if (errcode != arg_in_range) {
3270         jio_fprintf(defaultStream::error_stream(),
3271                     "Invalid maximum direct memory size: %s\n",
3272                     option->optionString);
3273         describe_range_error(errcode);
3274         return JNI_EINVAL;
3275       }
3276       FLAG_SET_CMDLINE(uintx, MaxDirectMemorySize, max_direct_memory_size);
3277 #if !INCLUDE_MANAGEMENT
3278     } else if (match_option(option, "-XX:+ManagementServer")) {
3279         jio_fprintf(defaultStream::error_stream(),
3280           "ManagementServer is not supported in this VM.\n");
3281         return JNI_ERR;
3282 #endif // INCLUDE_MANAGEMENT
3283     } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx
3284       // Skip -XX:Flags= since that case has already been handled
3285       if (strncmp(tail, "Flags=", strlen("Flags=")) != 0) {




 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  *  -XX argument processing:
 252  * 
 253  *  -XX arguments are usually defined in globals.hpp, globals_<cpu>.hpp, globals_<os>.hpp, <compiler>_globals.hpp, or <gc>_globals.hpp.
 254  *  -XX arguments are parsed in parse_argument().
 255  *  -XX argument bounds checking is done in check_vm_args_consistency().
 256  * 
 257  * Over time -XX arguments may change. There are mechanisms to handle common cases:
 258  * 
 259  *        ALIAS: An option may be renamed or replaced by another option. The old name can be supported by adding 
 260  *               the old and new option names to the "aliased_jvm_flags" table. Delete the old variable from globals.hpp.
 261  *               This is often part of the process of deprecating a flag, but 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 be removed
 264  *               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 "deprecated_jvm_flags" table. 
 266  *               Specify the option name, the jdk version that deprecated the option, and the jdk version that will
 267  *               expire the option (if removal has been scheduled).
 268  * 
 269  *     OBSOLETE: An option may be removed (and deleted from globals.hpp), but still be accepted on the command line.
 270  *               A warning is printed to let the user know that support may be removed in the future. 
 271  *               Add an obsolete warning for an option (or alias) by adding an entry in the "obsolete_jvm_flags" table. 
 272  *               Specify the option name, the jdk version that obsoleted the option, and the jdk version that will
 273  *               expire the option (if removal has been scheduled).
 274  * 
 275  *      EXPIRED: When the current JDK version is equal or greater to the "accept_until" version of a deprecated or obsolete
 276  *               option, the system will flatly refuse to admit the existence of the flag. This allows a flag to die correctly
 277  *               over JDK releases using HSX.
 278  *               Note that manual cleanup of expired options should be done at major JDK version upgrades:
 279  *                  - Expired options can be removed from the obsolete_jvm_flags, deprecated_jvm_flags tables, and aliased_jvm_flags tables.
 280  *                  - Expired deprecated options may still have global variable definitions that should be removed (in globals.hpp, etc).
 281  * 
 282  * Tests:  Aliases are tested in VMAliasOptions.java. Deprecated options in VMDeprecatedOptions.java. Obsolete options are tested in various files.
 283  */
 284 
 285 // Obsolete or deprecated -XX flag.
 286 typedef struct {
 287   const char* name;
 288   JDK_Version obsoleted_in; // When the warning started (obsolete or deprecated).
 289   JDK_Version accept_until; // Which version to start denying the existence of the flag (if scheduled).

 290   
 291   static const uint8_t _removal_unscheduled = 0;
 292   
 293   bool is_removal_scheduled() const {
 294       return accept_until.major_version() != _removal_unscheduled;
 295   }
 296   
 297 } SpecialFlag;
 298 
 299 // When a flag is eliminated, it can be added to this list in order to
 300 // continue accepting this flag on the command-line, while issuing a warning
 301 // and ignoring the value.  Once the JDK version reaches the 'accept_until'
 302 // limit, we flatly refuse to admit the existence of the flag.
 303 static SpecialFlag const obsolete_jvm_flags[] = {
 304   { "UseTrainGC",                    JDK_Version::jdk(5), JDK_Version::jdk(7) },
 305   { "UseSpecialLargeObjectHandling", JDK_Version::jdk(5), JDK_Version::jdk(7) },
 306   { "UseOversizedCarHandling",       JDK_Version::jdk(5), JDK_Version::jdk(7) },
 307   { "TraceCarAllocation",            JDK_Version::jdk(5), JDK_Version::jdk(7) },
 308   { "PrintTrainGCProcessingStats",   JDK_Version::jdk(5), JDK_Version::jdk(7) },
 309   { "LogOfCarSpaceSize",             JDK_Version::jdk(5), JDK_Version::jdk(7) },
 310   { "OversizedCarThreshold",         JDK_Version::jdk(5), JDK_Version::jdk(7) },
 311   { "MinTickInterval",               JDK_Version::jdk(5), JDK_Version::jdk(7) },
 312   { "DefaultTickInterval",           JDK_Version::jdk(5), JDK_Version::jdk(7) },
 313   { "MaxTickInterval",               JDK_Version::jdk(5), JDK_Version::jdk(7) },
 314   { "DelayTickAdjustment",           JDK_Version::jdk(5), JDK_Version::jdk(7) },
 315   { "ProcessingToTenuringRatio",     JDK_Version::jdk(5), JDK_Version::jdk(7) },
 316   { "MinTrainLength",                JDK_Version::jdk(5), JDK_Version::jdk(7) },
 317   { "AppendRatio",         JDK_Version::jdk_update(6,10), JDK_Version::jdk(7) },
 318   { "DefaultMaxRAM",       JDK_Version::jdk_update(6,18), JDK_Version::jdk(7) },
 319   { "DefaultInitialRAMFraction",
 320                            JDK_Version::jdk_update(6,18), JDK_Version::jdk(7) },
 321   { "UseDepthFirstScavengeOrder",
 322                            JDK_Version::jdk_update(6,22), JDK_Version::jdk(7) },
 323   { "HandlePromotionFailure",
 324                            JDK_Version::jdk_update(6,24), JDK_Version::jdk(8) },
 325   { "MaxLiveObjectEvacuationRatio",
 326                            JDK_Version::jdk_update(6,24), JDK_Version::jdk(8) },
 327   { "ForceSharedSpaces",   JDK_Version::jdk_update(6,25), JDK_Version::jdk(8) },
 328   { "UseParallelOldGCCompacting",
 329                            JDK_Version::jdk_update(6,27), JDK_Version::jdk(8) },
 330   { "UseParallelDensePrefixUpdate",
 331                            JDK_Version::jdk_update(6,27), JDK_Version::jdk(8) },
 332   { "UseParallelOldGCDensePrefix",
 333                            JDK_Version::jdk_update(6,27), JDK_Version::jdk(8) },
 334   { "AllowTransitionalJSR292",       JDK_Version::jdk(7), JDK_Version::jdk(8) },
 335   { "UseCompressedStrings",          JDK_Version::jdk(7), JDK_Version::jdk(8) },
 336   { "CMSPermGenPrecleaningEnabled",  JDK_Version::jdk(8), JDK_Version::jdk(9) },
 337   { "CMSTriggerPermRatio",           JDK_Version::jdk(8), JDK_Version::jdk(9) },
 338   { "CMSInitiatingPermOccupancyFraction",
 339                                      JDK_Version::jdk(8), JDK_Version::jdk(9) },
 340   { "AdaptivePermSizeWeight",        JDK_Version::jdk(8), JDK_Version::jdk(9) },
 341   { "PermGenPadding",                JDK_Version::jdk(8), JDK_Version::jdk(9) },
 342   { "PermMarkSweepDeadRatio",        JDK_Version::jdk(8), JDK_Version::jdk(9) },
 343   { "PermSize",                      JDK_Version::jdk(8), JDK_Version::jdk(9) },
 344   { "MaxPermSize",                   JDK_Version::jdk(8), JDK_Version::jdk(9) },
 345   { "MinPermHeapExpansion",          JDK_Version::jdk(8), JDK_Version::jdk(9) },
 346   { "MaxPermHeapExpansion",          JDK_Version::jdk(8), JDK_Version::jdk(9) },
 347   { "CMSRevisitStackSize",           JDK_Version::jdk(8), JDK_Version::jdk(9) },
 348   { "PrintRevisitStats",             JDK_Version::jdk(8), JDK_Version::jdk(9) },
 349   { "UseVectoredExceptions",         JDK_Version::jdk(8), JDK_Version::jdk(9) },
 350   { "UseSplitVerifier",              JDK_Version::jdk(8), JDK_Version::jdk(9) },
 351   { "UseISM",                        JDK_Version::jdk(8), JDK_Version::jdk(9) },
 352   { "UsePermISM",                    JDK_Version::jdk(8), JDK_Version::jdk(9) },
 353   { "UseMPSS",                       JDK_Version::jdk(8), JDK_Version::jdk(9) },
 354   { "UseStringCache",                JDK_Version::jdk(8), JDK_Version::jdk(9) },
 355   { "UseOldInlining",                JDK_Version::jdk(9), JDK_Version::jdk(10) },
 356   { "SafepointPollOffset",           JDK_Version::jdk(9), JDK_Version::jdk(10) },
 357 #ifdef PRODUCT
 358   { "DesiredMethodLimit",  JDK_Version::jdk_update(7, 2), JDK_Version::jdk(8) },

 359 #endif // PRODUCT
 360   { "UseVMInterruptibleIO",          JDK_Version::jdk(8), JDK_Version::jdk(9) },
 361   { "UseBoundThreads",               JDK_Version::jdk(9), JDK_Version::jdk(10) },
 362   { "DefaultThreadPriority",         JDK_Version::jdk(9), JDK_Version::jdk(10) },
 363   { "NoYieldsInMicrolock",           JDK_Version::jdk(9), JDK_Version::jdk(10) },
 364   { "BackEdgeThreshold",             JDK_Version::jdk(9), JDK_Version::jdk(10) },
 365   { "UseNewReflection",              JDK_Version::jdk(9), JDK_Version::jdk(10) },
 366   { "ReflectionWrapResolutionErrors",JDK_Version::jdk(9), JDK_Version::jdk(10) },
 367   { "VerifyReflectionBytecodes",     JDK_Version::jdk(9), JDK_Version::jdk(10) },
 368   { "AutoShutdownNMT",               JDK_Version::jdk(9), JDK_Version::jdk(10) },
 369   { "NmethodSweepFraction",          JDK_Version::jdk(9), JDK_Version::jdk(10) },
 370   { "NmethodSweepCheckInterval",     JDK_Version::jdk(9), JDK_Version::jdk(10) },
 371   { "CodeCacheMinimumFreeSpace",     JDK_Version::jdk(9), JDK_Version::jdk(10) },
 372 #ifndef ZERO
 373   { "UseFastAccessorMethods",        JDK_Version::jdk(9), JDK_Version::jdk(10) },
 374   { "UseFastEmptyMethods",           JDK_Version::jdk(9), JDK_Version::jdk(10) },
 375 #endif // ZERO
 376   { "UseCompilerSafepoints",         JDK_Version::jdk(9), JDK_Version::jdk(10) },
 377   { NULL, JDK_Version(0), JDK_Version(0) }
 378 };
 379 
 380 // When a flag is deprecated, it can be added to this list in order to issuing a warning when the flag is used.
 381 // Once the JDK version reaches the 'accept_until' limit, we flatly refuse to admit the existence of the flag.
 382 static SpecialFlag const deprecated_jvm_flags[] = {
 383   // deprecated non-alias flags:
 384   { "MaxGCMinorPauseMillis",        JDK_Version::jdk(8), JDK_Version::jdk(SpecialFlag::_removal_unscheduled) },
 385   { "UseParNewGC",                  JDK_Version::jdk(9), JDK_Version::jdk(10) },
 386   
 387   // deprecated alias flags (see also aliased_jvm_flags):
 388   { "DefaultMaxRAMFraction",        JDK_Version::jdk(8), JDK_Version::jdk(SpecialFlag::_removal_unscheduled) },
 389   { "CMSMarkStackSizeMax",          JDK_Version::jdk(9), JDK_Version::jdk(10) },
 390   { "CMSMarkStackSize",             JDK_Version::jdk(9), JDK_Version::jdk(10) },
 391   { "G1MarkStackSize",              JDK_Version::jdk(9), JDK_Version::jdk(10) },
 392   { "ParallelMarkingThreads",       JDK_Version::jdk(9), JDK_Version::jdk(10) },
 393   { "ParallelCMSThreads",           JDK_Version::jdk(9), JDK_Version::jdk(10) },
 394   { NULL, JDK_Version(0), JDK_Version(0) }
 395 };
 396 
 397 // Flags that are aliases for other flags.
 398 typedef struct {
 399   const char* alias_name;
 400   const char* real_name;
 401 } AliasedFlag;
 402 
 403 static AliasedFlag const aliased_jvm_flags[] = {
 404   { "DefaultMaxRAMFraction",    "MaxRAMFraction"    },
 405   { "CMSMarkStackSizeMax",      "MarkStackSizeMax"  },
 406   { "CMSMarkStackSize",         "MarkStackSize"     },
 407   { "G1MarkStackSize",          "MarkStackSize"     },
 408   { "ParallelMarkingThreads",   "ConcGCThreads"     },
 409   { "ParallelCMSThreads",       "ConcGCThreads"     },
 410   { NULL, NULL}
 411 };
 412 
 413 // Returns 1 if the flag is special and jdk version is in the range specified.
 414 //     In this case the 'version' buffer is filled in with the version number when 
 415 //     the flag became special.
 416 // Returns -1 if the flag is special and has expired (should be ignored).
 417 // Returns 0 if the flag is not special.
 418 static int is_special_flag(const SpecialFlag special_table[], const char *s, JDK_Version* version) {
 419   int i = 0;
 420   assert(version != NULL, "Must provide a version buffer");
 421   while (special_table[i].name != NULL) {
 422     const SpecialFlag& flag_status = special_table[i];
 423     // <flag>=xxx form
 424     // [-|+]<flag> form
 425     size_t len = strlen(flag_status.name);
 426     if (((strncmp(flag_status.name, s, len) == 0) &&
 427           (strlen(s) == len)) ||
 428          ((s[0] == '+' || s[0] == '-') &&
 429           (strncmp(flag_status.name, &s[1], len) == 0) &&
 430           (strlen(&s[1]) == len))) {
 431       if (!flag_status.is_removal_scheduled() ||
 432           JDK_Version::current().compare(flag_status.accept_until) == -1) {
 433         *version = flag_status.obsoleted_in;
 434         return 1;
 435       } else {
 436         return -1;
 437       }
 438     }
 439     i++;
 440   }
 441   return 0;
 442 }
 443 
 444 bool Arguments::is_newly_obsolete(const char *s, JDK_Version* version) {
 445   return (is_special_flag(obsolete_jvm_flags, s, version) == 1);
 446 }
 447 
 448 int Arguments::is_deprecated_flag(const char *s, JDK_Version* version) {
 449   return is_special_flag(deprecated_jvm_flags, s, version);
 450 }
 451 
 452 const char* Arguments::real_flag_name(const char *flag_name) {
 453   int i = 0;
 454   while (aliased_jvm_flags[i].alias_name != NULL) {
 455     const AliasedFlag& flag_status = aliased_jvm_flags[i];
 456     size_t len = strlen(flag_status.alias_name);
 457     if (((strncmp(flag_status.alias_name, flag_name, len) == 0) &&
 458          (strlen(flag_name) == len))) {
 459         return flag_status.real_name;
 460     }
 461     i++;
 462   }
 463   return flag_name;
 464 }
 465 
 466 // Constructs the system class path (aka boot class path) from the following
 467 // components, in order:
 468 //
 469 //     prefix           // from -Xbootclasspath/p:...
 470 //     base             // from os::get_system_properties() or -Xbootclasspath=
 471 //     suffix           // from -Xbootclasspath/a:...
 472 //
 473 // This could be AllStatic, but it isn't needed after argument processing is
 474 // complete.
 475 class SysClassPath: public StackObj {
 476 public:
 477   SysClassPath(const char* base);
 478   ~SysClassPath();
 479 
 480   inline void set_base(const char* base);
 481   inline void add_prefix(const char* prefix);
 482   inline void add_suffix_to_prefix(const char* suffix);
 483   inline void add_suffix(const char* suffix);


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


1877 #if !INCLUDE_ALL_GCS
1878 #ifdef ASSERT
1879 static bool verify_serial_gc_flags() {
1880   return (UseSerialGC &&
1881         !(UseParNewGC || (UseConcMarkSweepGC) || UseG1GC ||
1882           UseParallelGC || UseParallelOldGC));
1883 }
1884 #endif // ASSERT
1885 #endif // INCLUDE_ALL_GCS
1886 
1887 void Arguments::set_gc_specific_flags() {
1888 #if INCLUDE_ALL_GCS
1889   // Set per-collector flags
1890   if (UseParallelGC || UseParallelOldGC) {
1891     set_parallel_gc_flags();
1892   } else if (UseConcMarkSweepGC) {
1893     set_cms_and_parnew_gc_flags();
1894   } else if (UseG1GC) {
1895     set_g1_gc_flags();
1896   }

1897   if (AssumeMP && !UseSerialGC) {
1898     if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) {
1899       warning("If the number of processors is expected to increase from one, then"
1900               " you should configure the number of parallel GC threads appropriately"
1901               " using -XX:ParallelGCThreads=N");
1902     }
1903   }
1904   if (MinHeapFreeRatio == 100) {
1905     // Keeping the heap 100% free is hard ;-) so limit it to 99%.
1906     FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99);
1907   }
1908 #else // INCLUDE_ALL_GCS
1909   assert(verify_serial_gc_flags(), "SerialGC unset");
1910 #endif // INCLUDE_ALL_GCS
1911 }
1912 
1913 julong Arguments::limit_by_allocatable_memory(julong limit) {
1914   julong max_allocatable;
1915   julong result = limit;
1916   if (os::has_allocatable_memory_limit(&max_allocatable)) {
1917     result = MIN2(result, max_allocatable / MaxVirtMemFraction);
1918   }
1919   return result;
1920 }
1921 
1922 // Use static initialization to get the default before parsing
1923 static const uintx DefaultHeapBaseMinAddress = HeapBaseMinAddress;
1924 
1925 void Arguments::set_heap_size() {





1926   const julong phys_mem =
1927     FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
1928                             : (julong)MaxRAM;
1929 
1930   // If the maximum heap size has not been set with -Xmx,
1931   // then set it as fraction of the size of physical memory,
1932   // respecting the maximum and minimum sizes of the heap.
1933   if (FLAG_IS_DEFAULT(MaxHeapSize)) {
1934     julong reasonable_max = phys_mem / MaxRAMFraction;
1935 
1936     if (phys_mem <= MaxHeapSize * MinRAMFraction) {
1937       // Small physical memory, so use a minimum fraction of it for the heap
1938       reasonable_max = phys_mem / MinRAMFraction;
1939     } else {
1940       // Not-small physical memory, so require a heap at least
1941       // as large as MaxHeapSize
1942       reasonable_max = MAX2(reasonable_max, (julong)MaxHeapSize);
1943     }
1944     if (!FLAG_IS_DEFAULT(ErgoHeapSizeLimit) && ErgoHeapSizeLimit != 0) {
1945       // Limit the heap size to ErgoHeapSizeLimit


2263     return false;
2264   }
2265 
2266   if (UseConcMarkSweepGC && !UseParNewGC) {
2267     jio_fprintf(defaultStream::error_stream(),
2268         "It is not possible to combine the DefNew young collector with the CMS collector.\n");
2269     return false;
2270   }
2271 
2272   if (UseParNewGC && !UseConcMarkSweepGC) {
2273     // !UseConcMarkSweepGC means that we are using serial old gc. Unfortunately we don't
2274     // set up UseSerialGC properly, so that can't be used in the check here.
2275     jio_fprintf(defaultStream::error_stream(),
2276         "It is not possible to combine the ParNew young collector with the Serial old collector.\n");
2277     return false;
2278   }
2279 
2280   return true;
2281 }
2282 














2283 // Check stack pages settings
2284 bool Arguments::check_stack_pages()
2285 {
2286   bool status = true;
2287   status = status && verify_min_value(StackYellowPages, 1, "StackYellowPages");
2288   status = status && verify_min_value(StackRedPages, 1, "StackRedPages");
2289   // greater stack shadow pages can't generate instruction to bang stack
2290   status = status && verify_interval(StackShadowPages, 1, 50, "StackShadowPages");
2291   return status;
2292 }
2293 
2294 // Check the consistency of vm_init_args
2295 bool Arguments::check_vm_args_consistency() {
2296   // Method for adding checks for flag consistency.
2297   // The intent is to warn the user of all possible conflicts,
2298   // before returning an error.
2299   // Note: Needs platform-dependent factoring.
2300   bool status = true;
2301 
2302   if (TLABRefillWasteFraction == 0) {


2499                                       "CompressedClassSpaceSize");
2500 
2501   status = status && verify_interval(MarkStackSizeMax,
2502                                   1, (max_jint - 1), "MarkStackSizeMax");
2503   status = status && verify_interval(NUMAChunkResizeWeight, 0, 100, "NUMAChunkResizeWeight");
2504 
2505   status = status && verify_min_value(LogEventsBufferEntries, 1, "LogEventsBufferEntries");
2506 
2507   status = status && verify_min_value(HeapSizePerGCThread, (uintx) os::vm_page_size(), "HeapSizePerGCThread");
2508 
2509   status = status && verify_min_value(GCTaskTimeStampEntries, 1, "GCTaskTimeStampEntries");
2510 
2511   status = status && verify_percentage(ParallelGCBufferWastePct, "ParallelGCBufferWastePct");
2512   status = status && verify_interval(TargetPLABWastePct, 1, 100, "TargetPLABWastePct");
2513 
2514   status = status && verify_min_value(ParGCStridesPerThread, 1, "ParGCStridesPerThread");
2515 
2516   status = status && verify_min_value(MinRAMFraction, 1, "MinRAMFraction");
2517   status = status && verify_min_value(InitialRAMFraction, 1, "InitialRAMFraction");
2518   status = status && verify_min_value(MaxRAMFraction, 1, "MaxRAMFraction");

2519 
2520   status = status && verify_interval(AdaptiveTimeWeight, 0, 100, "AdaptiveTimeWeight");
2521   status = status && verify_min_value(AdaptiveSizeDecrementScaleFactor, 1, "AdaptiveSizeDecrementScaleFactor");
2522 
2523   status = status && verify_interval(TLABAllocationWeight, 0, 100, "TLABAllocationWeight");
2524   status = status && verify_min_value(MinTLABSize, 1, "MinTLABSize");
2525   status = status && verify_min_value(TLABRefillWasteFraction, 1, "TLABRefillWasteFraction");
2526 
2527   status = status && verify_percentage(YoungGenerationSizeSupplement, "YoungGenerationSizeSupplement");
2528   status = status && verify_percentage(TenuredGenerationSizeSupplement, "TenuredGenerationSizeSupplement");
2529 
2530   status = status && verify_interval(MaxTenuringThreshold, 0, markOopDesc::max_age + 1, "MaxTenuringThreshold");
2531   status = status && verify_interval(InitialTenuringThreshold, 0, MaxTenuringThreshold, "InitialTenuringThreshold");
2532   status = status && verify_percentage(TargetSurvivorRatio, "TargetSurvivorRatio");
2533   status = status && verify_percentage(MarkSweepDeadRatio, "MarkSweepDeadRatio");
2534 
2535   status = status && verify_min_value(MarkSweepAlwaysCompactCount, 1, "MarkSweepAlwaysCompactCount");
2536 #ifdef COMPILER1
2537   status = status && verify_min_value(ValueMapInitialSize, 1, "ValueMapInitialSize");
2538 #endif


3335     } else if (match_option(option, "-XX:+DisplayVMOutputToStdout")) {
3336       FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, false);
3337       FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, true);
3338     } else if (match_option(option, "-XX:+ExtendedDTraceProbes")) {
3339 #if defined(DTRACE_ENABLED)
3340       FLAG_SET_CMDLINE(bool, ExtendedDTraceProbes, true);
3341       FLAG_SET_CMDLINE(bool, DTraceMethodProbes, true);
3342       FLAG_SET_CMDLINE(bool, DTraceAllocProbes, true);
3343       FLAG_SET_CMDLINE(bool, DTraceMonitorProbes, true);
3344 #else // defined(DTRACE_ENABLED)
3345       jio_fprintf(defaultStream::error_stream(),
3346                   "ExtendedDTraceProbes flag is not applicable for this configuration\n");
3347       return JNI_EINVAL;
3348 #endif // defined(DTRACE_ENABLED)
3349 #ifdef ASSERT
3350     } else if (match_option(option, "-XX:+FullGCALot")) {
3351       FLAG_SET_CMDLINE(bool, FullGCALot, true);
3352       // disable scavenge before parallel mark-compact
3353       FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false);
3354 #endif








































3355     } else if (match_option(option, "-XX:MaxDirectMemorySize=", &tail)) {
3356       julong max_direct_memory_size = 0;
3357       ArgsRange errcode = parse_memory_size(tail, &max_direct_memory_size, 0);
3358       if (errcode != arg_in_range) {
3359         jio_fprintf(defaultStream::error_stream(),
3360                     "Invalid maximum direct memory size: %s\n",
3361                     option->optionString);
3362         describe_range_error(errcode);
3363         return JNI_EINVAL;
3364       }
3365       FLAG_SET_CMDLINE(uintx, MaxDirectMemorySize, max_direct_memory_size);
3366 #if !INCLUDE_MANAGEMENT
3367     } else if (match_option(option, "-XX:+ManagementServer")) {
3368         jio_fprintf(defaultStream::error_stream(),
3369           "ManagementServer is not supported in this VM.\n");
3370         return JNI_ERR;
3371 #endif // INCLUDE_MANAGEMENT
3372     } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx
3373       // Skip -XX:Flags= since that case has already been handled
3374       if (strncmp(tail, "Flags=", strlen("Flags=")) != 0) {


< prev index next >