< prev index next >

src/share/vm/runtime/arguments.cpp

Print this page




 334  *                    definitions removed (from globals.hpp, etc) and related implementations removed.
 335  *
 336  * Recommended approach for removing options:
 337  *
 338  * To remove options commonly used by customers (e.g. product, commercial -XX options), use
 339  * the 3-step model adding major release numbers to the deprecate, obsolete and expire columns.
 340  *
 341  * To remove internal options (e.g. diagnostic, experimental, develop options), use
 342  * a 2-step model adding major release numbers to the obsolete and expire columns.
 343  *
 344  * To change the name of an option, use the alias table as well as a 2-step
 345  * model adding major release numbers to the deprecate and expire columns.
 346  * Think twice about aliasing commonly used customer options.
 347  *
 348  * There are times when it is appropriate to leave a future release number as undefined.
 349  *
 350  * Tests:  Aliases should be tested in VMAliasOptions.java.
 351  *         Deprecated options should be tested in VMDeprecatedOptions.java.
 352  */
 353 
 354 // Obsolete or deprecated -XX flag.
 355 typedef struct {
 356   const char* name;
 357   JDK_Version deprecated_in; // When the deprecation warning started (or "undefined").
 358   JDK_Version obsolete_in;   // When the obsolete warning started (or "undefined").
 359   JDK_Version expired_in;    // When the option expires (or "undefined").
 360 } SpecialFlag;
 361 
 362 // The special_jvm_flags table declares options that are being deprecated and/or obsoleted. The
 363 // "deprecated_in" or "obsolete_in" fields may be set to "undefined", but not both.
 364 // When the JDK version reaches 'deprecated_in' limit, the JVM will process this flag on
 365 // the command-line as usual, but will issue a warning.
 366 // When the JDK version reaches 'obsolete_in' limit, the JVM will continue accepting this flag on
 367 // the command-line, while issuing a warning and ignoring the flag value.
 368 // Once the JDK version reaches 'expired_in' limit, the JVM will flatly refuse to admit the
 369 // existence of the flag.
 370 //
 371 // MANUAL CLEANUP ON JDK VERSION UPDATES:
 372 // This table ensures that the handling of options will update automatically when the JDK
 373 // version is incremented, but the source code needs to be cleanup up manually:
 374 // - As "deprecated" options age into "obsolete" or "expired" options, the associated "globals"
 375 //   variable should be removed, as well as users of the variable.
 376 // - As "deprecated" options age into "obsolete" options, move the entry into the
 377 //   "Obsolete Flags" section of the table.
 378 // - All expired options should be removed from the table.
 379 static SpecialFlag const special_jvm_flags[] = {
 380   // -------------- Deprecated Flags --------------
 381   // --- Non-alias flags - sorted by obsolete_in then expired_in:


 481   { "TraceMonitorMismatch",       "-Xlog:monitormismatch=info" },
 482   { "TraceSafepoint",             "-Xlog:safepoint=debug" },
 483   { "TraceStartupTime",           "-Xlog:startuptime" },
 484   { "TraceVMOperation",           "-Xlog:vmoperation=debug" },
 485   { "PrintVtables",               "-Xlog:vtables=debug" },
 486   { "VerboseVerification",        "-Xlog:verification" },
 487   { NULL, NULL }
 488 };
 489 #endif //PRODUCT
 490 
 491 // Return true if "v" is less than "other", where "other" may be "undefined".
 492 static bool version_less_than(JDK_Version v, JDK_Version other) {
 493   assert(!v.is_undefined(), "must be defined");
 494   if (!other.is_undefined() && v.compare(other) >= 0) {
 495     return false;
 496   } else {
 497     return true;
 498   }
 499 }
 500 


 501 static bool lookup_special_flag(const char *flag_name, SpecialFlag& flag) {





 502   for (size_t i = 0; special_jvm_flags[i].name != NULL; i++) {
 503     if ((strcmp(special_jvm_flags[i].name, flag_name) == 0)) {
 504       flag = special_jvm_flags[i];
 505       return true;
 506     }
 507   }
 508   return false;
 509 }
 510 
 511 bool Arguments::is_obsolete_flag(const char *flag_name, JDK_Version* version) {
 512   assert(version != NULL, "Must provide a version buffer");
 513   SpecialFlag flag;
 514   if (lookup_special_flag(flag_name, flag)) {
 515     if (!flag.obsolete_in.is_undefined()) {
 516       if (version_less_than(JDK_Version::current(), flag.expired_in)) {
 517         *version = flag.obsolete_in;
 518         return true;
 519       }
 520     }
 521   }


1787 #endif // INCLUDE_ALL_GCS
1788   _conservative_max_heap_alignment = MAX4(heap_alignment,
1789                                           (size_t)os::vm_allocation_granularity(),
1790                                           os::max_page_size(),
1791                                           CollectorPolicy::compute_heap_alignment());
1792 }
1793 
1794 bool Arguments::gc_selected() {
1795 #if INCLUDE_ALL_GCS
1796   return UseSerialGC || UseParallelGC || UseParallelOldGC || UseConcMarkSweepGC || UseG1GC;
1797 #else
1798   return UseSerialGC;
1799 #endif // INCLUDE_ALL_GCS
1800 }
1801 
1802 void Arguments::select_gc_ergonomically() {
1803 #if INCLUDE_ALL_GCS
1804   if (os::is_server_class_machine()) {
1805     if (should_auto_select_low_pause_collector()) {
1806       FLAG_SET_ERGO_IF_DEFAULT(bool, UseConcMarkSweepGC, true);


1807     } else {
1808       FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true);
1809     }
1810   } else {
1811     FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
1812   }
1813 #else
1814   UNSUPPORTED_OPTION(UseG1GC);
1815   UNSUPPORTED_OPTION(UseParallelGC);
1816   UNSUPPORTED_OPTION(UseParallelOldGC);
1817   UNSUPPORTED_OPTION(UseConcMarkSweepGC);
1818   UNSUPPORTED_OPTION(UseParNewGC);
1819   FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
1820 #endif // INCLUDE_ALL_GCS
1821 }
1822 
1823 void Arguments::select_gc() {
1824   if (!gc_selected()) {
1825     select_gc_ergonomically();
1826     if (!gc_selected()) {


2853 #else
2854       if (tail != NULL) {
2855         char *options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(tail) + 1, mtArguments), tail);
2856         add_init_agent("instrument", options, false);
2857         // java agents need module java.instrument
2858         if (!create_numbered_property("jdk.module.addmods", "java.instrument", addmods_count++)) {
2859           return JNI_ENOMEM;
2860         }
2861       }
2862 #endif // !INCLUDE_JVMTI
2863     // -Xnoclassgc
2864     } else if (match_option(option, "-Xnoclassgc")) {
2865       if (FLAG_SET_CMDLINE(bool, ClassUnloading, false) != Flag::SUCCESS) {
2866         return JNI_EINVAL;
2867       }
2868     // -Xconcgc
2869     } else if (match_option(option, "-Xconcgc")) {
2870       if (FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, true) != Flag::SUCCESS) {
2871         return JNI_EINVAL;
2872       }

2873     // -Xnoconcgc
2874     } else if (match_option(option, "-Xnoconcgc")) {
2875       if (FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, false) != Flag::SUCCESS) {
2876         return JNI_EINVAL;
2877       }

2878     // -Xbatch
2879     } else if (match_option(option, "-Xbatch")) {
2880       if (FLAG_SET_CMDLINE(bool, BackgroundCompilation, false) != Flag::SUCCESS) {
2881         return JNI_EINVAL;
2882       }
2883     // -Xmn for compatibility with other JVM vendors
2884     } else if (match_option(option, "-Xmn", &tail)) {
2885       julong long_initial_young_size = 0;
2886       ArgsRange errcode = parse_memory_size(tail, &long_initial_young_size, 1);
2887       if (errcode != arg_in_range) {
2888         jio_fprintf(defaultStream::error_stream(),
2889                     "Invalid initial young generation size: %s\n", option->optionString);
2890         describe_range_error(errcode);
2891         return JNI_EINVAL;
2892       }
2893       if (FLAG_SET_CMDLINE(size_t, MaxNewSize, (size_t)long_initial_young_size) != Flag::SUCCESS) {
2894         return JNI_EINVAL;
2895       }
2896       if (FLAG_SET_CMDLINE(size_t, NewSize, (size_t)long_initial_young_size) != Flag::SUCCESS) {
2897         return JNI_EINVAL;


4142 
4143 bool Arguments::handle_deprecated_print_gc_flags() {
4144   if (PrintGC) {
4145     log_warning(gc)("-XX:+PrintGC is deprecated. Will use -Xlog:gc instead.");
4146   }
4147   if (PrintGCDetails) {
4148     log_warning(gc)("-XX:+PrintGCDetails is deprecated. Will use -Xlog:gc* instead.");
4149   }
4150 
4151   if (_gc_log_filename != NULL) {
4152     // -Xloggc was used to specify a filename
4153     const char* gc_conf = PrintGCDetails ? "gc*" : "gc";
4154 
4155     LogTarget(Error, logging) target;
4156     LogStreamCHeap errstream(target);
4157     return LogConfiguration::parse_log_arguments(_gc_log_filename, gc_conf, NULL, NULL, &errstream);
4158   } else if (PrintGC || PrintGCDetails) {
4159     LogConfiguration::configure_stdout(LogLevel::Info, !PrintGCDetails, LOG_TAGS(gc));
4160   }
4161   return true;









4162 }
4163 
4164 // Parse entry point called from JNI_CreateJavaVM
4165 
4166 jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) {
4167   assert(verify_special_jvm_flags(), "deprecated and obsolete flag table inconsistent");
4168 
4169   // Initialize ranges, constraints and writeables
4170   CommandLineFlagRangeList::init();
4171   CommandLineFlagConstraintList::init();
4172   CommandLineFlagWriteableList::init();
4173 
4174   // If flag "-XX:Flags=flags-file" is used it will be the first option to be processed.
4175   const char* hotspotrc = ".hotspotrc";
4176   bool settings_file_specified = false;
4177   bool needs_hotspotrc_warning = false;
4178   ScopedVMInitArgs initial_java_tool_options_args("env_var='JAVA_TOOL_OPTIONS'");
4179   ScopedVMInitArgs initial_java_options_args("env_var='_JAVA_OPTIONS'");
4180 
4181   // Pointers to current working set of containers




 334  *                    definitions removed (from globals.hpp, etc) and related implementations removed.
 335  *
 336  * Recommended approach for removing options:
 337  *
 338  * To remove options commonly used by customers (e.g. product, commercial -XX options), use
 339  * the 3-step model adding major release numbers to the deprecate, obsolete and expire columns.
 340  *
 341  * To remove internal options (e.g. diagnostic, experimental, develop options), use
 342  * a 2-step model adding major release numbers to the obsolete and expire columns.
 343  *
 344  * To change the name of an option, use the alias table as well as a 2-step
 345  * model adding major release numbers to the deprecate and expire columns.
 346  * Think twice about aliasing commonly used customer options.
 347  *
 348  * There are times when it is appropriate to leave a future release number as undefined.
 349  *
 350  * Tests:  Aliases should be tested in VMAliasOptions.java.
 351  *         Deprecated options should be tested in VMDeprecatedOptions.java.
 352  */
 353 








 354 // The special_jvm_flags table declares options that are being deprecated and/or obsoleted. The
 355 // "deprecated_in" or "obsolete_in" fields may be set to "undefined", but not both.
 356 // When the JDK version reaches 'deprecated_in' limit, the JVM will process this flag on
 357 // the command-line as usual, but will issue a warning.
 358 // When the JDK version reaches 'obsolete_in' limit, the JVM will continue accepting this flag on
 359 // the command-line, while issuing a warning and ignoring the flag value.
 360 // Once the JDK version reaches 'expired_in' limit, the JVM will flatly refuse to admit the
 361 // existence of the flag.
 362 //
 363 // MANUAL CLEANUP ON JDK VERSION UPDATES:
 364 // This table ensures that the handling of options will update automatically when the JDK
 365 // version is incremented, but the source code needs to be cleanup up manually:
 366 // - As "deprecated" options age into "obsolete" or "expired" options, the associated "globals"
 367 //   variable should be removed, as well as users of the variable.
 368 // - As "deprecated" options age into "obsolete" options, move the entry into the
 369 //   "Obsolete Flags" section of the table.
 370 // - All expired options should be removed from the table.
 371 static SpecialFlag const special_jvm_flags[] = {
 372   // -------------- Deprecated Flags --------------
 373   // --- Non-alias flags - sorted by obsolete_in then expired_in:


 473   { "TraceMonitorMismatch",       "-Xlog:monitormismatch=info" },
 474   { "TraceSafepoint",             "-Xlog:safepoint=debug" },
 475   { "TraceStartupTime",           "-Xlog:startuptime" },
 476   { "TraceVMOperation",           "-Xlog:vmoperation=debug" },
 477   { "PrintVtables",               "-Xlog:vtables=debug" },
 478   { "VerboseVerification",        "-Xlog:verification" },
 479   { NULL, NULL }
 480 };
 481 #endif //PRODUCT
 482 
 483 // Return true if "v" is less than "other", where "other" may be "undefined".
 484 static bool version_less_than(JDK_Version v, JDK_Version other) {
 485   assert(!v.is_undefined(), "must be defined");
 486   if (!other.is_undefined() && v.compare(other) >= 0) {
 487     return false;
 488   } else {
 489     return true;
 490   }
 491 }
 492 
 493 extern bool lookup_special_flag_ext(const char *flag_name, SpecialFlag& flag);
 494 
 495 static bool lookup_special_flag(const char *flag_name, SpecialFlag& flag) {
 496   // Allow extensions to have priority
 497   if (lookup_special_flag_ext(flag_name, flag)) {
 498     return true;
 499   }
 500 
 501   for (size_t i = 0; special_jvm_flags[i].name != NULL; i++) {
 502     if ((strcmp(special_jvm_flags[i].name, flag_name) == 0)) {
 503       flag = special_jvm_flags[i];
 504       return true;
 505     }
 506   }
 507   return false;
 508 }
 509 
 510 bool Arguments::is_obsolete_flag(const char *flag_name, JDK_Version* version) {
 511   assert(version != NULL, "Must provide a version buffer");
 512   SpecialFlag flag;
 513   if (lookup_special_flag(flag_name, flag)) {
 514     if (!flag.obsolete_in.is_undefined()) {
 515       if (version_less_than(JDK_Version::current(), flag.expired_in)) {
 516         *version = flag.obsolete_in;
 517         return true;
 518       }
 519     }
 520   }


1786 #endif // INCLUDE_ALL_GCS
1787   _conservative_max_heap_alignment = MAX4(heap_alignment,
1788                                           (size_t)os::vm_allocation_granularity(),
1789                                           os::max_page_size(),
1790                                           CollectorPolicy::compute_heap_alignment());
1791 }
1792 
1793 bool Arguments::gc_selected() {
1794 #if INCLUDE_ALL_GCS
1795   return UseSerialGC || UseParallelGC || UseParallelOldGC || UseConcMarkSweepGC || UseG1GC;
1796 #else
1797   return UseSerialGC;
1798 #endif // INCLUDE_ALL_GCS
1799 }
1800 
1801 void Arguments::select_gc_ergonomically() {
1802 #if INCLUDE_ALL_GCS
1803   if (os::is_server_class_machine()) {
1804     if (should_auto_select_low_pause_collector()) {
1805       FLAG_SET_ERGO_IF_DEFAULT(bool, UseConcMarkSweepGC, true);
1806       FLAG_SET_ERGO_IF_DEFAULT(bool, UseParNewGC, true);
1807       handle_extra_cms_flags("UseAutoGCSelectPolicy uses UseConcMarkSweepGC");
1808     } else {
1809       FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true);
1810     }
1811   } else {
1812     FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
1813   }
1814 #else
1815   UNSUPPORTED_OPTION(UseG1GC);
1816   UNSUPPORTED_OPTION(UseParallelGC);
1817   UNSUPPORTED_OPTION(UseParallelOldGC);
1818   UNSUPPORTED_OPTION(UseConcMarkSweepGC);
1819   UNSUPPORTED_OPTION(UseParNewGC);
1820   FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
1821 #endif // INCLUDE_ALL_GCS
1822 }
1823 
1824 void Arguments::select_gc() {
1825   if (!gc_selected()) {
1826     select_gc_ergonomically();
1827     if (!gc_selected()) {


2854 #else
2855       if (tail != NULL) {
2856         char *options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(tail) + 1, mtArguments), tail);
2857         add_init_agent("instrument", options, false);
2858         // java agents need module java.instrument
2859         if (!create_numbered_property("jdk.module.addmods", "java.instrument", addmods_count++)) {
2860           return JNI_ENOMEM;
2861         }
2862       }
2863 #endif // !INCLUDE_JVMTI
2864     // -Xnoclassgc
2865     } else if (match_option(option, "-Xnoclassgc")) {
2866       if (FLAG_SET_CMDLINE(bool, ClassUnloading, false) != Flag::SUCCESS) {
2867         return JNI_EINVAL;
2868       }
2869     // -Xconcgc
2870     } else if (match_option(option, "-Xconcgc")) {
2871       if (FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, true) != Flag::SUCCESS) {
2872         return JNI_EINVAL;
2873       }
2874       handle_extra_cms_flags("-Xconcgc uses UseConcMarkSweepGC");
2875     // -Xnoconcgc
2876     } else if (match_option(option, "-Xnoconcgc")) {
2877       if (FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, false) != Flag::SUCCESS) {
2878         return JNI_EINVAL;
2879       }
2880       handle_extra_cms_flags("-Xnoconcgc uses UseConcMarkSweepGC");
2881     // -Xbatch
2882     } else if (match_option(option, "-Xbatch")) {
2883       if (FLAG_SET_CMDLINE(bool, BackgroundCompilation, false) != Flag::SUCCESS) {
2884         return JNI_EINVAL;
2885       }
2886     // -Xmn for compatibility with other JVM vendors
2887     } else if (match_option(option, "-Xmn", &tail)) {
2888       julong long_initial_young_size = 0;
2889       ArgsRange errcode = parse_memory_size(tail, &long_initial_young_size, 1);
2890       if (errcode != arg_in_range) {
2891         jio_fprintf(defaultStream::error_stream(),
2892                     "Invalid initial young generation size: %s\n", option->optionString);
2893         describe_range_error(errcode);
2894         return JNI_EINVAL;
2895       }
2896       if (FLAG_SET_CMDLINE(size_t, MaxNewSize, (size_t)long_initial_young_size) != Flag::SUCCESS) {
2897         return JNI_EINVAL;
2898       }
2899       if (FLAG_SET_CMDLINE(size_t, NewSize, (size_t)long_initial_young_size) != Flag::SUCCESS) {
2900         return JNI_EINVAL;


4145 
4146 bool Arguments::handle_deprecated_print_gc_flags() {
4147   if (PrintGC) {
4148     log_warning(gc)("-XX:+PrintGC is deprecated. Will use -Xlog:gc instead.");
4149   }
4150   if (PrintGCDetails) {
4151     log_warning(gc)("-XX:+PrintGCDetails is deprecated. Will use -Xlog:gc* instead.");
4152   }
4153 
4154   if (_gc_log_filename != NULL) {
4155     // -Xloggc was used to specify a filename
4156     const char* gc_conf = PrintGCDetails ? "gc*" : "gc";
4157 
4158     LogTarget(Error, logging) target;
4159     LogStreamCHeap errstream(target);
4160     return LogConfiguration::parse_log_arguments(_gc_log_filename, gc_conf, NULL, NULL, &errstream);
4161   } else if (PrintGC || PrintGCDetails) {
4162     LogConfiguration::configure_stdout(LogLevel::Info, !PrintGCDetails, LOG_TAGS(gc));
4163   }
4164   return true;
4165 }
4166 
4167 void Arguments::handle_extra_cms_flags(const char* msg) {
4168   SpecialFlag flag;
4169   const char *flag_name = "UseConcMarkSweepGC";
4170   if (lookup_special_flag(flag_name, flag)) {
4171     handle_aliases_and_deprecation(flag_name, /* print warning */ true);
4172     warning("%s", msg);
4173   }
4174 }
4175 
4176 // Parse entry point called from JNI_CreateJavaVM
4177 
4178 jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) {
4179   assert(verify_special_jvm_flags(), "deprecated and obsolete flag table inconsistent");
4180 
4181   // Initialize ranges, constraints and writeables
4182   CommandLineFlagRangeList::init();
4183   CommandLineFlagConstraintList::init();
4184   CommandLineFlagWriteableList::init();
4185 
4186   // If flag "-XX:Flags=flags-file" is used it will be the first option to be processed.
4187   const char* hotspotrc = ".hotspotrc";
4188   bool settings_file_specified = false;
4189   bool needs_hotspotrc_warning = false;
4190   ScopedVMInitArgs initial_java_tool_options_args("env_var='JAVA_TOOL_OPTIONS'");
4191   ScopedVMInitArgs initial_java_options_args("env_var='_JAVA_OPTIONS'");
4192 
4193   // Pointers to current working set of containers


< prev index next >