--- old/src/share/vm/runtime/arguments.cpp 2015-01-15 17:50:19.736636672 -0500 +++ new/src/share/vm/runtime/arguments.cpp 2015-01-15 17:50:18.732579601 -0500 @@ -247,21 +247,60 @@ new SystemProperty("java.vm.vendor", VM_Version::vm_vendor(), false)); } -/** - * Provide a slightly more user-friendly way of eliminating -XX flags. - * When a flag is eliminated, it can be added to this list in order to - * continue accepting this flag on the command-line, while issuing a warning - * and ignoring the value. Once the JDK version reaches the 'accept_until' - * limit, we flatly refuse to admit the existence of the flag. This allows - * a flag to die correctly over JDK releases using HSX. +/* + * -XX argument processing: + * + * -XX arguments are usually defined in globals.hpp, globals_.hpp, globals_.hpp, _globals.hpp, or _globals.hpp. + * -XX arguments are parsed in parse_argument(). + * -XX argument bounds checking is done in check_vm_args_consistency(). + * + * Over time -XX arguments may change. There are mechanisms to handle common cases: + * + * ALIAS: An option may be renamed or replaced by another option. The old name can be supported by adding + * the old and new option names to the "aliased_jvm_flags" table. Delete the old variable from globals.hpp. + * This is often part of the process of deprecating a flag, but not all aliases need to be deprecated. + * + * DEPRECATED: An option may be supported, but a warning is printed to let the user know that support may be removed + * in the future. Both regular and aliased options may be deprecated. + * Add a deprecation warning for an option (or alias) by adding an entry in the "deprecated_jvm_flags" table. + * Specify the option name, the jdk version that deprecated the option, and the jdk version that will + * expire the option (if removal has been scheduled). + * + * OBSOLETE: An option may be removed (and deleted from globals.hpp), but still be accepted on the command line. + * A warning is printed to let the user know that support may be removed in the future. + * Add an obsolete warning for an option (or alias) by adding an entry in the "obsolete_jvm_flags" table. + * Specify the option name, the jdk version that obsoleted the option, and the jdk version that will + * expire the option (if removal has been scheduled). + * + * EXPIRED: When the current JDK version is equal or greater to the "accept_until" version of a deprecated or obsolete + * option, the system will flatly refuse to admit the existence of the flag. This allows a flag to die correctly + * over JDK releases using HSX. + * Note that manual cleanup of expired options should be done at major JDK version upgrades: + * - Expired options can be removed from the obsolete_jvm_flags, deprecated_jvm_flags tables, and aliased_jvm_flags tables. + * - Expired deprecated options may still have global variable definitions that should be removed (in globals.hpp, etc). + * + * Tests: Aliases are tested in VMAliasOptions.java. Deprecated options in VMDeprecatedOptions.java. Obsolete options are tested in various files. */ + +// Obsolete or deprecated -XX flag. typedef struct { const char* name; - JDK_Version obsoleted_in; // when the flag went away - JDK_Version accept_until; // which version to start denying the existence -} ObsoleteFlag; - -static ObsoleteFlag obsolete_jvm_flags[] = { + JDK_Version obsoleted_in; // When the warning started (obsolete or deprecated). + JDK_Version accept_until; // Which version to start denying the existence of the flag (if scheduled). + + static const uint8_t _removal_unscheduled = 0; + + bool is_removal_scheduled() const { + return accept_until.major_version() != _removal_unscheduled; + } + +} SpecialFlag; + +// When a flag is eliminated, it can be added to this list in order to +// continue accepting this flag on the command-line, while issuing a warning +// and ignoring the value. Once the JDK version reaches the 'accept_until' +// limit, we flatly refuse to admit the existence of the flag. +static SpecialFlag const obsolete_jvm_flags[] = { { "UseTrainGC", JDK_Version::jdk(5), JDK_Version::jdk(7) }, { "UseSpecialLargeObjectHandling", JDK_Version::jdk(5), JDK_Version::jdk(7) }, { "UseOversizedCarHandling", JDK_Version::jdk(5), JDK_Version::jdk(7) }, @@ -294,16 +333,17 @@ JDK_Version::jdk_update(6,27), JDK_Version::jdk(8) }, { "AllowTransitionalJSR292", JDK_Version::jdk(7), JDK_Version::jdk(8) }, { "UseCompressedStrings", JDK_Version::jdk(7), JDK_Version::jdk(8) }, - { "CMSPermGenPrecleaningEnabled", JDK_Version::jdk(8), JDK_Version::jdk(9) }, - { "CMSTriggerPermRatio", JDK_Version::jdk(8), JDK_Version::jdk(9) }, - { "CMSInitiatingPermOccupancyFraction", JDK_Version::jdk(8), JDK_Version::jdk(9) }, - { "AdaptivePermSizeWeight", JDK_Version::jdk(8), JDK_Version::jdk(9) }, - { "PermGenPadding", JDK_Version::jdk(8), JDK_Version::jdk(9) }, - { "PermMarkSweepDeadRatio", JDK_Version::jdk(8), JDK_Version::jdk(9) }, - { "PermSize", JDK_Version::jdk(8), JDK_Version::jdk(9) }, - { "MaxPermSize", JDK_Version::jdk(8), JDK_Version::jdk(9) }, - { "MinPermHeapExpansion", JDK_Version::jdk(8), JDK_Version::jdk(9) }, - { "MaxPermHeapExpansion", JDK_Version::jdk(8), JDK_Version::jdk(9) }, + { "CMSPermGenPrecleaningEnabled", JDK_Version::jdk(8), JDK_Version::jdk(9) }, + { "CMSTriggerPermRatio", JDK_Version::jdk(8), JDK_Version::jdk(9) }, + { "CMSInitiatingPermOccupancyFraction", + JDK_Version::jdk(8), JDK_Version::jdk(9) }, + { "AdaptivePermSizeWeight", JDK_Version::jdk(8), JDK_Version::jdk(9) }, + { "PermGenPadding", JDK_Version::jdk(8), JDK_Version::jdk(9) }, + { "PermMarkSweepDeadRatio", JDK_Version::jdk(8), JDK_Version::jdk(9) }, + { "PermSize", JDK_Version::jdk(8), JDK_Version::jdk(9) }, + { "MaxPermSize", JDK_Version::jdk(8), JDK_Version::jdk(9) }, + { "MinPermHeapExpansion", JDK_Version::jdk(8), JDK_Version::jdk(9) }, + { "MaxPermHeapExpansion", JDK_Version::jdk(8), JDK_Version::jdk(9) }, { "CMSRevisitStackSize", JDK_Version::jdk(8), JDK_Version::jdk(9) }, { "PrintRevisitStats", JDK_Version::jdk(8), JDK_Version::jdk(9) }, { "UseVectoredExceptions", JDK_Version::jdk(8), JDK_Version::jdk(9) }, @@ -315,8 +355,7 @@ { "UseOldInlining", JDK_Version::jdk(9), JDK_Version::jdk(10) }, { "SafepointPollOffset", JDK_Version::jdk(9), JDK_Version::jdk(10) }, #ifdef PRODUCT - { "DesiredMethodLimit", - JDK_Version::jdk_update(7, 2), JDK_Version::jdk(8) }, + { "DesiredMethodLimit", JDK_Version::jdk_update(7, 2), JDK_Version::jdk(8) }, #endif // PRODUCT { "UseVMInterruptibleIO", JDK_Version::jdk(8), JDK_Version::jdk(9) }, { "UseBoundThreads", JDK_Version::jdk(9), JDK_Version::jdk(10) }, @@ -338,31 +377,90 @@ { NULL, JDK_Version(0), JDK_Version(0) } }; -// Returns true if the flag is obsolete and fits into the range specified -// for being ignored. In the case that the flag is ignored, the 'version' -// value is filled in with the version number when the flag became -// obsolete so that that value can be displayed to the user. -bool Arguments::is_newly_obsolete(const char *s, JDK_Version* version) { +// When a flag is deprecated, it can be added to this list in order to issuing a warning when the flag is used. +// Once the JDK version reaches the 'accept_until' limit, we flatly refuse to admit the existence of the flag. +static SpecialFlag const deprecated_jvm_flags[] = { + // deprecated non-alias flags: + { "MaxGCMinorPauseMillis", JDK_Version::jdk(8), JDK_Version::jdk(SpecialFlag::_removal_unscheduled) }, + { "UseParNewGC", JDK_Version::jdk(9), JDK_Version::jdk(10) }, + + // deprecated alias flags (see also aliased_jvm_flags): + { "DefaultMaxRAMFraction", JDK_Version::jdk(8), JDK_Version::jdk(SpecialFlag::_removal_unscheduled) }, + { "CMSMarkStackSizeMax", JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "CMSMarkStackSize", JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "G1MarkStackSize", JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "ParallelMarkingThreads", JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "ParallelCMSThreads", JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { NULL, JDK_Version(0), JDK_Version(0) } +}; + +// Flags that are aliases for other flags. +typedef struct { + const char* alias_name; + const char* real_name; +} AliasedFlag; + +static AliasedFlag const aliased_jvm_flags[] = { + { "DefaultMaxRAMFraction", "MaxRAMFraction" }, + { "CMSMarkStackSizeMax", "MarkStackSizeMax" }, + { "CMSMarkStackSize", "MarkStackSize" }, + { "G1MarkStackSize", "MarkStackSize" }, + { "ParallelMarkingThreads", "ConcGCThreads" }, + { "ParallelCMSThreads", "ConcGCThreads" }, + { NULL, NULL} +}; + +// Returns 1 if the flag is special and jdk version is in the range specified. +// In this case the 'version' buffer is filled in with the version number when +// the flag became special. +// Returns -1 if the flag is special and has expired (should be ignored). +// Returns 0 if the flag is not special. +static int is_special_flag(const SpecialFlag special_table[], const char *s, JDK_Version* version) { int i = 0; assert(version != NULL, "Must provide a version buffer"); - while (obsolete_jvm_flags[i].name != NULL) { - const ObsoleteFlag& flag_status = obsolete_jvm_flags[i]; + while (special_table[i].name != NULL) { + const SpecialFlag& flag_status = special_table[i]; // =xxx form // [-|+] form size_t len = strlen(flag_status.name); if (((strncmp(flag_status.name, s, len) == 0) && - (strlen(s) == len)) || - ((s[0] == '+' || s[0] == '-') && - (strncmp(flag_status.name, &s[1], len) == 0) && - (strlen(&s[1]) == len))) { - if (JDK_Version::current().compare(flag_status.accept_until) == -1) { - *version = flag_status.obsoleted_in; - return true; + (strlen(s) == len)) || + ((s[0] == '+' || s[0] == '-') && + (strncmp(flag_status.name, &s[1], len) == 0) && + (strlen(&s[1]) == len))) { + if (!flag_status.is_removal_scheduled() || + JDK_Version::current().compare(flag_status.accept_until) == -1) { + *version = flag_status.obsoleted_in; + return 1; + } else { + return -1; } } i++; } - return false; + return 0; +} + +bool Arguments::is_newly_obsolete(const char *s, JDK_Version* version) { + return (is_special_flag(obsolete_jvm_flags, s, version) == 1); +} + +int Arguments::is_deprecated_flag(const char *s, JDK_Version* version) { + return is_special_flag(deprecated_jvm_flags, s, version); +} + +const char* Arguments::real_flag_name(const char *flag_name) { + int i = 0; + while (aliased_jvm_flags[i].alias_name != NULL) { + const AliasedFlag& flag_status = aliased_jvm_flags[i]; + size_t len = strlen(flag_status.alias_name); + if (((strncmp(flag_status.alias_name, flag_name, len) == 0) && + (strlen(flag_name) == len))) { + return flag_status.real_name; + } + i++; + } + return flag_name; } // Constructs the system class path (aka boot class path) from the following @@ -633,11 +731,11 @@ } } -static bool set_bool_flag(char* name, bool value, Flag::Flags origin) { +static bool set_bool_flag(const char* name, bool value, Flag::Flags origin) { return CommandLineFlags::boolAtPut(name, &value, origin); } -static bool set_fp_numeric_flag(char* name, char* value, Flag::Flags origin) { +static bool set_fp_numeric_flag(const char* name, char* value, Flag::Flags origin) { double v; if (sscanf(value, "%lf", &v) != 1) { return false; @@ -649,7 +747,7 @@ return false; } -static bool set_numeric_flag(char* name, char* value, Flag::Flags origin) { +static bool set_numeric_flag(const char* name, char* value, Flag::Flags origin) { julong v; intx intx_v; bool is_neg = false; @@ -686,14 +784,14 @@ return false; } -static bool set_string_flag(char* name, const char* value, Flag::Flags origin) { +static bool set_string_flag(const char* name, const char* value, Flag::Flags origin) { if (!CommandLineFlags::ccstrAtPut(name, &value, origin)) return false; // Contract: CommandLineFlags always returns a pointer that needs freeing. FREE_C_HEAP_ARRAY(char, value); return true; } -static bool append_to_string_flag(char* name, const char* new_value, Flag::Flags origin) { +static bool append_to_string_flag(const char* name, const char* new_value, Flag::Flags origin) { const char* old_value = ""; if (!CommandLineFlags::ccstrAt(name, &old_value)) return false; size_t old_len = old_value != NULL ? strlen(old_value) : 0; @@ -721,6 +819,31 @@ return true; } +const char* Arguments::handle_aliases_and_deprecation(const char* arg) { + const char* real_name = real_flag_name(arg); + JDK_Version since = JDK_Version(); + switch (is_deprecated_flag(arg, &since)) { + case -1: + return NULL; + case 0: + return real_name; + case 1: { + char version[256]; + since.to_string(version, sizeof(version)); + if (real_name != arg) { + warning("option %s was deprecated in version %s and will likely be removed in a future release. Use option %s instead.", + arg, version, real_name); + } else { + warning("option %s was deprecated in version %s and will likely be removed in a future release.", + arg, version); + } + return real_name; + } + } + ShouldNotReachHere(); + return NULL; +} + bool Arguments::parse_argument(const char* arg, Flag::Flags origin) { // range of acceptable characters spelled out for portability reasons @@ -728,26 +851,41 @@ #define BUFLEN 255 char name[BUFLEN+1]; char dummy; - + const char* real_name; + if (sscanf(arg, "-%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) { - return set_bool_flag(name, false, origin); + real_name = handle_aliases_and_deprecation(name); + if (real_name == NULL) { + return NULL; // "name" is a deprecated option that has expired. + } + return set_bool_flag(real_name, false, origin); } if (sscanf(arg, "+%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) { - return set_bool_flag(name, true, origin); + real_name = handle_aliases_and_deprecation(name); + if (real_name == NULL) { + return NULL; + } + return set_bool_flag(real_name, true, origin); } char punct; if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "%c", name, &punct) == 2 && punct == '=') { const char* value = strchr(arg, '=') + 1; - Flag* flag = Flag::find_flag(name, strlen(name)); + Flag* flag; + + real_name = handle_aliases_and_deprecation(name); + if (real_name == NULL) { + return NULL; + } + flag = Flag::find_flag(real_name, strlen(real_name)); if (flag != NULL && flag->is_ccstr()) { if (flag->ccstr_accumulates()) { - return append_to_string_flag(name, value, origin); + return append_to_string_flag(real_name, value, origin); } else { if (value[0] == '\0') { value = NULL; } - return set_string_flag(name, value, origin); + return set_string_flag(real_name, value, origin); } } } @@ -758,7 +896,11 @@ if (value[0] == '\0') { value = NULL; } - return set_string_flag(name, value, origin); + real_name = handle_aliases_and_deprecation(name); + if (real_name == NULL) { + return NULL; + } + return set_string_flag(real_name, value, origin); } #define SIGNED_FP_NUMBER_RANGE "[-0123456789.]" @@ -769,13 +911,21 @@ if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_NUMBER_RANGE "." "%" XSTR(BUFLEN) NUMBER_RANGE "%c", name, value, value2, &dummy) == 3) { // Looks like a floating-point number -- try again with more lenient format string if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_FP_NUMBER_RANGE "%c", name, value, &dummy) == 2) { - return set_fp_numeric_flag(name, value, origin); + real_name = handle_aliases_and_deprecation(name); + if (real_name == NULL) { + return NULL; + } + return set_fp_numeric_flag(real_name, value, origin); } } #define VALUE_RANGE "[-kmgtxKMGTX0123456789abcdefABCDEF]" if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) VALUE_RANGE "%c", name, value, &dummy) == 2) { - return set_numeric_flag(name, value, origin); + real_name = handle_aliases_and_deprecation(name); + if (real_name == NULL) { + return NULL; + } + return set_numeric_flag(real_name, value, origin); } return false; @@ -1744,7 +1894,6 @@ } else if (UseG1GC) { set_g1_gc_flags(); } - check_deprecated_gc_flags(); if (AssumeMP && !UseSerialGC) { if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) { warning("If the number of processors is expected to increase from one, then" @@ -1774,11 +1923,6 @@ static const uintx DefaultHeapBaseMinAddress = HeapBaseMinAddress; void Arguments::set_heap_size() { - if (!FLAG_IS_DEFAULT(DefaultMaxRAMFraction)) { - // Deprecated flag - FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction); - } - const julong phys_mem = FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM) : (julong)MaxRAM; @@ -2136,20 +2280,6 @@ return true; } -void Arguments::check_deprecated_gc_flags() { - if (FLAG_IS_CMDLINE(UseParNewGC)) { - warning("The UseParNewGC flag is deprecated and will likely be removed in a future release"); - } - if (FLAG_IS_CMDLINE(MaxGCMinorPauseMillis)) { - warning("Using MaxGCMinorPauseMillis as minor pause goal is deprecated" - "and will likely be removed in future release"); - } - if (FLAG_IS_CMDLINE(DefaultMaxRAMFraction)) { - warning("DefaultMaxRAMFraction is deprecated and will likely be removed in a future release. " - "Use MaxRAMFraction instead."); - } -} - // Check stack pages settings bool Arguments::check_stack_pages() { @@ -2386,7 +2516,6 @@ status = status && verify_min_value(MinRAMFraction, 1, "MinRAMFraction"); status = status && verify_min_value(InitialRAMFraction, 1, "InitialRAMFraction"); status = status && verify_min_value(MaxRAMFraction, 1, "MaxRAMFraction"); - status = status && verify_min_value(DefaultMaxRAMFraction, 1, "DefaultMaxRAMFraction"); status = status && verify_interval(AdaptiveTimeWeight, 0, 100, "AdaptiveTimeWeight"); status = status && verify_min_value(AdaptiveSizeDecrementScaleFactor, 1, "AdaptiveSizeDecrementScaleFactor"); @@ -3223,46 +3352,6 @@ // disable scavenge before parallel mark-compact FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false); #endif - } else if (match_option(option, "-XX:CMSMarkStackSize=", &tail) || - match_option(option, "-XX:G1MarkStackSize=", &tail)) { - julong stack_size = 0; - ArgsRange errcode = parse_memory_size(tail, &stack_size, 1); - if (errcode != arg_in_range) { - jio_fprintf(defaultStream::error_stream(), - "Invalid mark stack size: %s\n", option->optionString); - describe_range_error(errcode); - return JNI_EINVAL; - } - jio_fprintf(defaultStream::error_stream(), - "Please use -XX:MarkStackSize in place of " - "-XX:CMSMarkStackSize or -XX:G1MarkStackSize in the future\n"); - FLAG_SET_CMDLINE(uintx, MarkStackSize, stack_size); - } else if (match_option(option, "-XX:CMSMarkStackSizeMax=", &tail)) { - julong max_stack_size = 0; - ArgsRange errcode = parse_memory_size(tail, &max_stack_size, 1); - if (errcode != arg_in_range) { - jio_fprintf(defaultStream::error_stream(), - "Invalid maximum mark stack size: %s\n", - option->optionString); - describe_range_error(errcode); - return JNI_EINVAL; - } - jio_fprintf(defaultStream::error_stream(), - "Please use -XX:MarkStackSizeMax in place of " - "-XX:CMSMarkStackSizeMax in the future\n"); - FLAG_SET_CMDLINE(uintx, MarkStackSizeMax, max_stack_size); - } else if (match_option(option, "-XX:ParallelMarkingThreads=", &tail) || - match_option(option, "-XX:ParallelCMSThreads=", &tail)) { - uintx conc_threads = 0; - if (!parse_uintx(tail, &conc_threads, 1)) { - jio_fprintf(defaultStream::error_stream(), - "Invalid concurrent threads: %s\n", option->optionString); - return JNI_EINVAL; - } - jio_fprintf(defaultStream::error_stream(), - "Please use -XX:ConcGCThreads in place of " - "-XX:ParallelMarkingThreads or -XX:ParallelCMSThreads in the future\n"); - FLAG_SET_CMDLINE(uintx, ConcGCThreads, conc_threads); } else if (match_option(option, "-XX:MaxDirectMemorySize=", &tail)) { julong max_direct_memory_size = 0; ArgsRange errcode = parse_memory_size(tail, &max_direct_memory_size, 0);