< prev index next >

src/hotspot/share/runtime/arguments.cpp

Print this page

  37 #include "gc/shared/gcConfig.hpp"
  38 #include "gc/shared/stringdedup/stringDedup.hpp"
  39 #include "gc/shared/tlab_globals.hpp"
  40 #include "jvm.h"
  41 #include "logging/log.hpp"
  42 #include "logging/logConfiguration.hpp"
  43 #include "logging/logStream.hpp"
  44 #include "logging/logTag.hpp"
  45 #include "memory/allocation.inline.hpp"
  46 #include "nmt/nmtCommon.hpp"
  47 #include "oops/compressedKlass.hpp"
  48 #include "oops/instanceKlass.hpp"
  49 #include "oops/objLayout.hpp"
  50 #include "oops/oop.inline.hpp"
  51 #include "prims/jvmtiAgentList.hpp"
  52 #include "prims/jvmtiExport.hpp"
  53 #include "runtime/arguments.hpp"
  54 #include "runtime/flags/jvmFlag.hpp"
  55 #include "runtime/flags/jvmFlagAccess.hpp"
  56 #include "runtime/flags/jvmFlagLimit.hpp"

  57 #include "runtime/globals_extension.hpp"
  58 #include "runtime/java.hpp"
  59 #include "runtime/os.hpp"
  60 #include "runtime/safepoint.hpp"
  61 #include "runtime/safepointMechanism.hpp"
  62 #include "runtime/synchronizer.hpp"
  63 #include "runtime/vm_version.hpp"
  64 #include "services/management.hpp"
  65 #include "utilities/align.hpp"
  66 #include "utilities/debug.hpp"
  67 #include "utilities/defaultStream.hpp"
  68 #include "utilities/macros.hpp"
  69 #include "utilities/parseInteger.hpp"
  70 #include "utilities/powerOfTwo.hpp"
  71 #include "utilities/stringUtils.hpp"
  72 #include "utilities/systemMemoryBarrier.hpp"
  73 #if INCLUDE_JFR
  74 #include "jfr/jfr.hpp"
  75 #endif
  76 


  77 static const char _default_java_launcher[] = "generic";
  78 
  79 #define DEFAULT_JAVA_LAUNCHER _default_java_launcher
  80 
  81 char*  Arguments::_jvm_flags_file               = nullptr;
  82 char** Arguments::_jvm_flags_array              = nullptr;
  83 int    Arguments::_num_jvm_flags                = 0;
  84 char** Arguments::_jvm_args_array               = nullptr;
  85 int    Arguments::_num_jvm_args                 = 0;
  86 unsigned int Arguments::_addmods_count          = 0;
  87 #if INCLUDE_JVMCI
  88 bool   Arguments::_jvmci_module_added           = false;
  89 #endif
  90 char*  Arguments::_java_command                 = nullptr;
  91 SystemProperty* Arguments::_system_properties   = nullptr;
  92 size_t Arguments::_conservative_max_heap_alignment = 0;
  93 Arguments::Mode Arguments::_mode                = _mixed;
  94 const char*  Arguments::_java_vendor_url_bug    = nullptr;
  95 const char*  Arguments::_sun_java_launcher      = DEFAULT_JAVA_LAUNCHER;
  96 bool   Arguments::_executing_unit_tests         = false;
  97 
  98 // These parameters are reset in method parse_vm_init_args()
  99 bool   Arguments::_AlwaysCompileLoopMethods     = AlwaysCompileLoopMethods;
 100 bool   Arguments::_UseOnStackReplacement        = UseOnStackReplacement;
 101 bool   Arguments::_BackgroundCompilation        = BackgroundCompilation;
 102 bool   Arguments::_ClipInlining                 = ClipInlining;
 103 size_t Arguments::_default_SharedBaseAddress    = SharedBaseAddress;
 104 
 105 bool   Arguments::_enable_preview               = false;
 106 bool   Arguments::_has_jdwp_agent               = false;
 107 
 108 LegacyGCLogging Arguments::_legacyGCLogging     = { nullptr, 0 };
 109 

1557 static unsigned int addopens_count = 0;
1558 static unsigned int patch_mod_count = 0;
1559 static unsigned int enable_native_access_count = 0;
1560 static unsigned int enable_final_field_mutation = 0;
1561 static bool patch_mod_javabase = false;
1562 
1563 // Check the consistency of vm_init_args
1564 bool Arguments::check_vm_args_consistency() {
1565   // This may modify compiler flags. Must be called before CompilerConfig::check_args_consistency()
1566   if (!CDSConfig::check_vm_args_consistency(patch_mod_javabase, mode_flag_cmd_line)) {
1567     return false;
1568   }
1569 
1570   // Method for adding checks for flag consistency.
1571   // The intent is to warn the user of all possible conflicts,
1572   // before returning an error.
1573   // Note: Needs platform-dependent factoring.
1574   bool status = true;
1575 
1576   status = CompilerConfig::check_args_consistency(status);
1577 #if INCLUDE_JVMCI
1578   if (status && EnableJVMCI) {
1579     // Add the JVMCI module if not using libjvmci or EnableJVMCI
1580     // was explicitly set on the command line or in the jimage.
1581     if ((!UseJVMCINativeLibrary || FLAG_IS_CMDLINE(EnableJVMCI) || FLAG_IS_JIMAGE_RESOURCE(EnableJVMCI)) && ClassLoader::is_module_observable("jdk.internal.vm.ci") && !_jvmci_module_added) {
1582       if (!create_numbered_module_property("jdk.module.addmods", "jdk.internal.vm.ci", _addmods_count++)) {
1583         return false;
1584       }
1585     }
1586   }
1587 #endif
1588 
1589 #if INCLUDE_JFR
1590   if (status && (FlightRecorderOptions || StartFlightRecording)) {
1591     if (!create_numbered_module_property("jdk.module.addmods", "jdk.jfr", _addmods_count++)) {
1592       return false;
1593     }
1594   }
1595 #endif
1596 
1597 #ifndef SUPPORT_RESERVED_STACK_AREA
1598   if (StackReservedPages != 0) {
1599     FLAG_SET_CMDLINE(StackReservedPages, 0);
1600     warning("Reserved Stack Area not supported on this platform");
1601   }
1602 #endif
1603 
1604   return status;
1605 }
1606 
1607 bool Arguments::is_bad_option(const JavaVMOption* option, jboolean ignore,
1608   const char* option_type) {

1958         JvmtiAgentList::add_xrun(name, options, false);
1959         FREE_C_HEAP_ARRAY(name);
1960         FREE_C_HEAP_ARRAY(options);
1961       }
1962     } else if (match_option(option, "--add-reads=", &tail)) {
1963       if (!create_numbered_module_property("jdk.module.addreads", tail, addreads_count++)) {
1964         return JNI_ENOMEM;
1965       }
1966     } else if (match_option(option, "--add-exports=", &tail)) {
1967       if (!create_numbered_module_property("jdk.module.addexports", tail, addexports_count++)) {
1968         return JNI_ENOMEM;
1969       }
1970     } else if (match_option(option, "--add-opens=", &tail)) {
1971       if (!create_numbered_module_property("jdk.module.addopens", tail, addopens_count++)) {
1972         return JNI_ENOMEM;
1973       }
1974     } else if (match_option(option, "--add-modules=", &tail)) {
1975       if (!create_numbered_module_property("jdk.module.addmods", tail, _addmods_count++)) {
1976         return JNI_ENOMEM;
1977       }
1978 #if INCLUDE_JVMCI
1979       if (!_jvmci_module_added) {
1980         const char *jvmci_module = strstr(tail, "jdk.internal.vm.ci");
1981         if (jvmci_module != nullptr) {
1982           char before = *(jvmci_module - 1);
1983           char after  = *(jvmci_module + strlen("jdk.internal.vm.ci"));
1984           if ((before == '=' || before == ',') && (after == '\0' || after == ',')) {
1985             FLAG_SET_DEFAULT(EnableJVMCI, true);
1986             _jvmci_module_added = true;
1987           }
1988         }
1989       }
1990 #endif
1991     } else if (match_option(option, "--enable-native-access=", &tail)) {
1992       if (!create_numbered_module_property("jdk.module.enable.native.access", tail, enable_native_access_count++)) {
1993         return JNI_ENOMEM;
1994       }
1995     } else if (match_option(option, "--illegal-native-access=", &tail)) {
1996       if (!create_module_property("jdk.module.illegal.native.access", tail, InternalProperty)) {
1997         return JNI_ENOMEM;
1998       }
1999     } else if (match_option(option, "--limit-modules=", &tail)) {
2000       if (!create_module_property("jdk.module.limitmods", tail, InternalProperty)) {
2001         return JNI_ENOMEM;
2002       }
2003     } else if (match_option(option, "--module-path=", &tail)) {
2004       if (!create_module_property("jdk.module.path", tail, ExternalProperty)) {
2005         return JNI_ENOMEM;
2006       }
2007     } else if (match_option(option, "--upgrade-module-path=", &tail)) {
2008       if (!create_module_property("jdk.module.upgrade.path", tail, ExternalProperty)) {
2009         return JNI_ENOMEM;
2010       }

2505       jio_fprintf(defaultStream::error_stream(),
2506                   "DTraceAllocProbes flag is not applicable for this configuration\n");
2507       return JNI_EINVAL;
2508     } else if (match_option(option, "-XX:+DTraceMonitorProbes")) {
2509       jio_fprintf(defaultStream::error_stream(),
2510                   "DTraceMonitorProbes flag is not applicable for this configuration\n");
2511       return JNI_EINVAL;
2512 #endif // !defined(DTRACE_ENABLED)
2513 #ifdef ASSERT
2514     } else if (match_option(option, "-XX:+FullGCALot")) {
2515       if (FLAG_SET_CMDLINE(FullGCALot, true) != JVMFlag::SUCCESS) {
2516         return JNI_EINVAL;
2517       }
2518 #endif
2519 #if !INCLUDE_MANAGEMENT
2520     } else if (match_option(option, "-XX:+ManagementServer")) {
2521         jio_fprintf(defaultStream::error_stream(),
2522           "ManagementServer is not supported in this VM.\n");
2523         return JNI_ERR;
2524 #endif // INCLUDE_MANAGEMENT
2525 #if INCLUDE_JVMCI
2526     } else if (match_option(option, "-XX:-EnableJVMCIProduct") || match_option(option, "-XX:-UseGraalJIT")) {
2527       if (EnableJVMCIProduct) {
2528         jio_fprintf(defaultStream::error_stream(),
2529                   "-XX:-EnableJVMCIProduct or -XX:-UseGraalJIT cannot come after -XX:+EnableJVMCIProduct or -XX:+UseGraalJIT\n");
2530         return JNI_EINVAL;
2531       }
2532     } else if (match_option(option, "-XX:+EnableJVMCIProduct") || match_option(option, "-XX:+UseGraalJIT")) {
2533       bool use_graal_jit = match_option(option, "-XX:+UseGraalJIT");
2534       if (use_graal_jit) {
2535         const char* jvmci_compiler = get_property("jvmci.Compiler");
2536         if (jvmci_compiler != nullptr) {
2537           if (strncmp(jvmci_compiler, "graal", strlen("graal")) != 0) {
2538             jio_fprintf(defaultStream::error_stream(),
2539               "Value of jvmci.Compiler incompatible with +UseGraalJIT: %s\n", jvmci_compiler);
2540             return JNI_ERR;
2541           }
2542         } else if (!add_property("jvmci.Compiler=graal")) {
2543             return JNI_ENOMEM;
2544         }
2545       }
2546 
2547       // Just continue, since "-XX:+EnableJVMCIProduct" or "-XX:+UseGraalJIT" has been specified before
2548       if (EnableJVMCIProduct) {
2549         continue;
2550       }
2551       JVMFlag *jvmciFlag = JVMFlag::find_flag("EnableJVMCIProduct");
2552       // Allow this flag if it has been unlocked.
2553       if (jvmciFlag != nullptr && jvmciFlag->is_unlocked()) {
2554         if (!JVMCIGlobals::enable_jvmci_product_mode(origin, use_graal_jit)) {
2555           jio_fprintf(defaultStream::error_stream(),
2556             "Unable to enable JVMCI in product mode\n");
2557           return JNI_ERR;
2558         }
2559       }
2560       // The flag was locked so process normally to report that error
2561       else if (!process_argument(use_graal_jit ? "UseGraalJIT" : "EnableJVMCIProduct", args->ignoreUnrecognized, origin)) {
2562         return JNI_EINVAL;
2563       }
2564 #endif // INCLUDE_JVMCI
2565 #if INCLUDE_JFR
2566     } else if (match_jfr_option(&option)) {
2567       return JNI_EINVAL;
2568 #endif
2569     } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx
2570       // Skip -XX:Flags= and -XX:VMOptionsFile= since those cases have
2571       // already been handled
2572       if ((strncmp(tail, "Flags=", strlen("Flags=")) != 0) &&
2573           (strncmp(tail, "VMOptionsFile=", strlen("VMOptionsFile=")) != 0)) {
2574         if (!process_argument(tail, args->ignoreUnrecognized, origin)) {
2575           return JNI_EINVAL;
2576         }
2577       }
2578     // Unknown option
2579     } else if (is_bad_option(option, args->ignoreUnrecognized)) {
2580       return JNI_ERR;
2581     }
2582   }
2583 
2584   // PrintSharedArchiveAndExit will turn on

2685     return JNI_ERR;
2686   }
2687 
2688   // CompileThresholdScaling == 0.0 is same as -Xint: Disable compilation (enable interpreter-only mode),
2689   // but like -Xint, leave compilation thresholds unaffected.
2690   // With tiered compilation disabled, setting CompileThreshold to 0 disables compilation as well.
2691   if ((CompileThresholdScaling == 0.0) || (!TieredCompilation && CompileThreshold == 0)) {
2692     set_mode_flags(_int);
2693   }
2694 
2695 #ifdef ZERO
2696   // Zero always runs in interpreted mode
2697   set_mode_flags(_int);
2698 #endif
2699 
2700   // eventually fix up InitialTenuringThreshold if only MaxTenuringThreshold is set
2701   if (FLAG_IS_DEFAULT(InitialTenuringThreshold) && (InitialTenuringThreshold > MaxTenuringThreshold)) {
2702     FLAG_SET_ERGO(InitialTenuringThreshold, MaxTenuringThreshold);
2703   }
2704 
2705 #if !COMPILER2_OR_JVMCI
2706   // Don't degrade server performance for footprint
2707   if (FLAG_IS_DEFAULT(UseLargePages) &&
2708       MaxHeapSize < LargePageHeapSizeThreshold) {
2709     // No need for large granularity pages w/small heaps.
2710     // Note that large pages are enabled/disabled for both the
2711     // Java heap and the code cache.
2712     FLAG_SET_DEFAULT(UseLargePages, false);
2713   }
2714 
2715   UNSUPPORTED_OPTION(ProfileInterpreter);
2716 #endif
2717 
2718   // Parse the CompilationMode flag
2719   if (!CompilationModeFlag::initialize()) {
2720     return JNI_ERR;
2721   }
2722 
2723   // Called after ClassLoader::lookup_vm_options() but before class loading begins.
2724   // TODO: Obtain and pass correct preview mode flag value here.
2725   ClassLoader::set_preview_mode(false);
2726 
2727   if (!check_vm_args_consistency()) {
2728     return JNI_ERR;
2729   }
2730 
2731 
2732 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
2733   UNSUPPORTED_OPTION(ShowRegistersOnAssert);
2734 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
2735 
2736   return JNI_OK;
2737 }
2738 
2739 // Helper class for controlling the lifetime of JavaVMInitArgs
2740 // objects.  The contents of the JavaVMInitArgs are guaranteed to be
2741 // deleted on the destruction of the ScopedVMInitArgs object.
2742 class ScopedVMInitArgs : public StackObj {
2743  private:
2744   JavaVMInitArgs _args;
2745   char*          _container_name;

3576     FLAG_SET_DEFAULT(StressSecondarySupers, false);
3577     FLAG_SET_DEFAULT(VerifySecondarySupers, false);
3578   }
3579 
3580 #ifdef ZERO
3581   // Clear flags not supported on zero.
3582   FLAG_SET_DEFAULT(ProfileInterpreter, false);
3583 #endif // ZERO
3584 
3585   if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3586     warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3587     DebugNonSafepoints = true;
3588   }
3589 
3590   // Treat the odd case where local verification is enabled but remote
3591   // verification is not as if both were enabled.
3592   if (BytecodeVerificationLocal && !BytecodeVerificationRemote) {
3593     log_info(verification)("Turning on remote verification because local verification is on");
3594     FLAG_SET_DEFAULT(BytecodeVerificationRemote, true);
3595   }




































































3596 
3597 #ifndef PRODUCT
3598   if (!LogVMOutput && FLAG_IS_DEFAULT(LogVMOutput)) {
3599     if (use_vm_log()) {
3600       LogVMOutput = true;
3601     }
3602   }
3603 #endif // PRODUCT
3604 
3605   if (PrintCommandLineFlags) {
3606     JVMFlag::printSetFlags(tty);
3607   }
3608 
3609 #if COMPILER2_OR_JVMCI
3610   if (!FLAG_IS_DEFAULT(EnableVectorSupport) && !EnableVectorSupport) {
3611     if (!FLAG_IS_DEFAULT(EnableVectorReboxing) && EnableVectorReboxing) {
3612       warning("Disabling EnableVectorReboxing since EnableVectorSupport is turned off.");
3613     }
3614     FLAG_SET_DEFAULT(EnableVectorReboxing, false);
3615 
3616     if (!FLAG_IS_DEFAULT(EnableVectorAggressiveReboxing) && EnableVectorAggressiveReboxing) {
3617       if (!EnableVectorReboxing) {
3618         warning("Disabling EnableVectorAggressiveReboxing since EnableVectorReboxing is turned off.");
3619       } else {
3620         warning("Disabling EnableVectorAggressiveReboxing since EnableVectorSupport is turned off.");
3621       }
3622     }
3623     FLAG_SET_DEFAULT(EnableVectorAggressiveReboxing, false);
3624   }
3625 #endif // COMPILER2_OR_JVMCI
3626 
3627 #ifdef COMPILER2
3628   if (!FLAG_IS_DEFAULT(UseLoopPredicate) && !UseLoopPredicate && UseProfiledLoopPredicate) {
3629     warning("Disabling UseProfiledLoopPredicate since UseLoopPredicate is turned off.");
3630     FLAG_SET_ERGO(UseProfiledLoopPredicate, false);
3631   }
3632 #endif // COMPILER2
3633 
3634   if (log_is_enabled(Info, perf, class, link)) {
3635     if (!UsePerfData) {
3636       warning("Disabling -Xlog:perf+class+link since UsePerfData is turned off.");
3637       LogConfiguration::disable_tags(false, LOG_TAGS(perf, class, link));
3638       assert(!log_is_enabled(Info, perf, class, link), "sanity");
3639     }
3640   }
3641 
3642   if (FLAG_IS_CMDLINE(DiagnoseSyncOnValueBasedClasses)) {
3643     if (DiagnoseSyncOnValueBasedClasses == ObjectSynchronizer::LOG_WARNING && !log_is_enabled(Info, valuebasedclasses)) {
3644       LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(valuebasedclasses));
3645     }
3646   }
3647   return JNI_OK;

  37 #include "gc/shared/gcConfig.hpp"
  38 #include "gc/shared/stringdedup/stringDedup.hpp"
  39 #include "gc/shared/tlab_globals.hpp"
  40 #include "jvm.h"
  41 #include "logging/log.hpp"
  42 #include "logging/logConfiguration.hpp"
  43 #include "logging/logStream.hpp"
  44 #include "logging/logTag.hpp"
  45 #include "memory/allocation.inline.hpp"
  46 #include "nmt/nmtCommon.hpp"
  47 #include "oops/compressedKlass.hpp"
  48 #include "oops/instanceKlass.hpp"
  49 #include "oops/objLayout.hpp"
  50 #include "oops/oop.inline.hpp"
  51 #include "prims/jvmtiAgentList.hpp"
  52 #include "prims/jvmtiExport.hpp"
  53 #include "runtime/arguments.hpp"
  54 #include "runtime/flags/jvmFlag.hpp"
  55 #include "runtime/flags/jvmFlagAccess.hpp"
  56 #include "runtime/flags/jvmFlagLimit.hpp"
  57 #include "runtime/globals.hpp"
  58 #include "runtime/globals_extension.hpp"
  59 #include "runtime/java.hpp"
  60 #include "runtime/os.hpp"
  61 #include "runtime/safepoint.hpp"
  62 #include "runtime/safepointMechanism.hpp"
  63 #include "runtime/synchronizer.hpp"
  64 #include "runtime/vm_version.hpp"
  65 #include "services/management.hpp"
  66 #include "utilities/align.hpp"
  67 #include "utilities/debug.hpp"
  68 #include "utilities/defaultStream.hpp"
  69 #include "utilities/macros.hpp"
  70 #include "utilities/parseInteger.hpp"
  71 #include "utilities/powerOfTwo.hpp"
  72 #include "utilities/stringUtils.hpp"
  73 #include "utilities/systemMemoryBarrier.hpp"
  74 #if INCLUDE_JFR
  75 #include "jfr/jfr.hpp"
  76 #endif
  77 
  78 #include <string.h>
  79 
  80 static const char _default_java_launcher[] = "generic";
  81 
  82 #define DEFAULT_JAVA_LAUNCHER _default_java_launcher
  83 
  84 char*  Arguments::_jvm_flags_file               = nullptr;
  85 char** Arguments::_jvm_flags_array              = nullptr;
  86 int    Arguments::_num_jvm_flags                = 0;
  87 char** Arguments::_jvm_args_array               = nullptr;
  88 int    Arguments::_num_jvm_args                 = 0;
  89 unsigned int Arguments::_addmods_count          = 0;



  90 char*  Arguments::_java_command                 = nullptr;
  91 SystemProperty* Arguments::_system_properties   = nullptr;
  92 size_t Arguments::_conservative_max_heap_alignment = 0;
  93 Arguments::Mode Arguments::_mode                = _mixed;
  94 const char*  Arguments::_java_vendor_url_bug    = nullptr;
  95 const char*  Arguments::_sun_java_launcher      = DEFAULT_JAVA_LAUNCHER;
  96 bool   Arguments::_executing_unit_tests         = false;
  97 
  98 // These parameters are reset in method parse_vm_init_args()
  99 bool   Arguments::_AlwaysCompileLoopMethods     = AlwaysCompileLoopMethods;
 100 bool   Arguments::_UseOnStackReplacement        = UseOnStackReplacement;
 101 bool   Arguments::_BackgroundCompilation        = BackgroundCompilation;
 102 bool   Arguments::_ClipInlining                 = ClipInlining;
 103 size_t Arguments::_default_SharedBaseAddress    = SharedBaseAddress;
 104 
 105 bool   Arguments::_enable_preview               = false;
 106 bool   Arguments::_has_jdwp_agent               = false;
 107 
 108 LegacyGCLogging Arguments::_legacyGCLogging     = { nullptr, 0 };
 109 

1557 static unsigned int addopens_count = 0;
1558 static unsigned int patch_mod_count = 0;
1559 static unsigned int enable_native_access_count = 0;
1560 static unsigned int enable_final_field_mutation = 0;
1561 static bool patch_mod_javabase = false;
1562 
1563 // Check the consistency of vm_init_args
1564 bool Arguments::check_vm_args_consistency() {
1565   // This may modify compiler flags. Must be called before CompilerConfig::check_args_consistency()
1566   if (!CDSConfig::check_vm_args_consistency(patch_mod_javabase, mode_flag_cmd_line)) {
1567     return false;
1568   }
1569 
1570   // Method for adding checks for flag consistency.
1571   // The intent is to warn the user of all possible conflicts,
1572   // before returning an error.
1573   // Note: Needs platform-dependent factoring.
1574   bool status = true;
1575 
1576   status = CompilerConfig::check_args_consistency(status);












1577 #if INCLUDE_JFR
1578   if (status && (FlightRecorderOptions || StartFlightRecording)) {
1579     if (!create_numbered_module_property("jdk.module.addmods", "jdk.jfr", _addmods_count++)) {
1580       return false;
1581     }
1582   }
1583 #endif
1584 
1585 #ifndef SUPPORT_RESERVED_STACK_AREA
1586   if (StackReservedPages != 0) {
1587     FLAG_SET_CMDLINE(StackReservedPages, 0);
1588     warning("Reserved Stack Area not supported on this platform");
1589   }
1590 #endif
1591 
1592   return status;
1593 }
1594 
1595 bool Arguments::is_bad_option(const JavaVMOption* option, jboolean ignore,
1596   const char* option_type) {

1946         JvmtiAgentList::add_xrun(name, options, false);
1947         FREE_C_HEAP_ARRAY(name);
1948         FREE_C_HEAP_ARRAY(options);
1949       }
1950     } else if (match_option(option, "--add-reads=", &tail)) {
1951       if (!create_numbered_module_property("jdk.module.addreads", tail, addreads_count++)) {
1952         return JNI_ENOMEM;
1953       }
1954     } else if (match_option(option, "--add-exports=", &tail)) {
1955       if (!create_numbered_module_property("jdk.module.addexports", tail, addexports_count++)) {
1956         return JNI_ENOMEM;
1957       }
1958     } else if (match_option(option, "--add-opens=", &tail)) {
1959       if (!create_numbered_module_property("jdk.module.addopens", tail, addopens_count++)) {
1960         return JNI_ENOMEM;
1961       }
1962     } else if (match_option(option, "--add-modules=", &tail)) {
1963       if (!create_numbered_module_property("jdk.module.addmods", tail, _addmods_count++)) {
1964         return JNI_ENOMEM;
1965       }













1966     } else if (match_option(option, "--enable-native-access=", &tail)) {
1967       if (!create_numbered_module_property("jdk.module.enable.native.access", tail, enable_native_access_count++)) {
1968         return JNI_ENOMEM;
1969       }
1970     } else if (match_option(option, "--illegal-native-access=", &tail)) {
1971       if (!create_module_property("jdk.module.illegal.native.access", tail, InternalProperty)) {
1972         return JNI_ENOMEM;
1973       }
1974     } else if (match_option(option, "--limit-modules=", &tail)) {
1975       if (!create_module_property("jdk.module.limitmods", tail, InternalProperty)) {
1976         return JNI_ENOMEM;
1977       }
1978     } else if (match_option(option, "--module-path=", &tail)) {
1979       if (!create_module_property("jdk.module.path", tail, ExternalProperty)) {
1980         return JNI_ENOMEM;
1981       }
1982     } else if (match_option(option, "--upgrade-module-path=", &tail)) {
1983       if (!create_module_property("jdk.module.upgrade.path", tail, ExternalProperty)) {
1984         return JNI_ENOMEM;
1985       }

2480       jio_fprintf(defaultStream::error_stream(),
2481                   "DTraceAllocProbes flag is not applicable for this configuration\n");
2482       return JNI_EINVAL;
2483     } else if (match_option(option, "-XX:+DTraceMonitorProbes")) {
2484       jio_fprintf(defaultStream::error_stream(),
2485                   "DTraceMonitorProbes flag is not applicable for this configuration\n");
2486       return JNI_EINVAL;
2487 #endif // !defined(DTRACE_ENABLED)
2488 #ifdef ASSERT
2489     } else if (match_option(option, "-XX:+FullGCALot")) {
2490       if (FLAG_SET_CMDLINE(FullGCALot, true) != JVMFlag::SUCCESS) {
2491         return JNI_EINVAL;
2492       }
2493 #endif
2494 #if !INCLUDE_MANAGEMENT
2495     } else if (match_option(option, "-XX:+ManagementServer")) {
2496         jio_fprintf(defaultStream::error_stream(),
2497           "ManagementServer is not supported in this VM.\n");
2498         return JNI_ERR;
2499 #endif // INCLUDE_MANAGEMENT








































2500 #if INCLUDE_JFR
2501     } else if (match_jfr_option(&option)) {
2502       return JNI_EINVAL;
2503 #endif
2504     } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx
2505       // Skip -XX:Flags= and -XX:VMOptionsFile= since those cases have
2506       // already been handled
2507       if ((strncmp(tail, "Flags=", strlen("Flags=")) != 0) &&
2508           (strncmp(tail, "VMOptionsFile=", strlen("VMOptionsFile=")) != 0)) {
2509         if (!process_argument(tail, args->ignoreUnrecognized, origin)) {
2510           return JNI_EINVAL;
2511         }
2512       }
2513     // Unknown option
2514     } else if (is_bad_option(option, args->ignoreUnrecognized)) {
2515       return JNI_ERR;
2516     }
2517   }
2518 
2519   // PrintSharedArchiveAndExit will turn on

2620     return JNI_ERR;
2621   }
2622 
2623   // CompileThresholdScaling == 0.0 is same as -Xint: Disable compilation (enable interpreter-only mode),
2624   // but like -Xint, leave compilation thresholds unaffected.
2625   // With tiered compilation disabled, setting CompileThreshold to 0 disables compilation as well.
2626   if ((CompileThresholdScaling == 0.0) || (!TieredCompilation && CompileThreshold == 0)) {
2627     set_mode_flags(_int);
2628   }
2629 
2630 #ifdef ZERO
2631   // Zero always runs in interpreted mode
2632   set_mode_flags(_int);
2633 #endif
2634 
2635   // eventually fix up InitialTenuringThreshold if only MaxTenuringThreshold is set
2636   if (FLAG_IS_DEFAULT(InitialTenuringThreshold) && (InitialTenuringThreshold > MaxTenuringThreshold)) {
2637     FLAG_SET_ERGO(InitialTenuringThreshold, MaxTenuringThreshold);
2638   }
2639 
2640 #ifndef COMPILER2
2641   // Don't degrade server performance for footprint
2642   if (FLAG_IS_DEFAULT(UseLargePages) &&
2643       MaxHeapSize < LargePageHeapSizeThreshold) {
2644     // No need for large granularity pages w/small heaps.
2645     // Note that large pages are enabled/disabled for both the
2646     // Java heap and the code cache.
2647     FLAG_SET_DEFAULT(UseLargePages, false);
2648   }
2649 
2650   UNSUPPORTED_OPTION(ProfileInterpreter);
2651 #endif // !COMPILER2
2652 
2653   // Parse the CompilationMode flag
2654   if (!CompilationModeFlag::initialize()) {
2655     return JNI_ERR;
2656   }
2657 
2658   // Called after ClassLoader::lookup_vm_options() but before class loading begins.
2659   ClassLoader::set_preview_mode(is_valhalla_enabled());

2660 
2661   if (!check_vm_args_consistency()) {
2662     return JNI_ERR;
2663   }
2664 
2665 
2666 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
2667   UNSUPPORTED_OPTION(ShowRegistersOnAssert);
2668 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
2669 
2670   return JNI_OK;
2671 }
2672 
2673 // Helper class for controlling the lifetime of JavaVMInitArgs
2674 // objects.  The contents of the JavaVMInitArgs are guaranteed to be
2675 // deleted on the destruction of the ScopedVMInitArgs object.
2676 class ScopedVMInitArgs : public StackObj {
2677  private:
2678   JavaVMInitArgs _args;
2679   char*          _container_name;

3510     FLAG_SET_DEFAULT(StressSecondarySupers, false);
3511     FLAG_SET_DEFAULT(VerifySecondarySupers, false);
3512   }
3513 
3514 #ifdef ZERO
3515   // Clear flags not supported on zero.
3516   FLAG_SET_DEFAULT(ProfileInterpreter, false);
3517 #endif // ZERO
3518 
3519   if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3520     warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3521     DebugNonSafepoints = true;
3522   }
3523 
3524   // Treat the odd case where local verification is enabled but remote
3525   // verification is not as if both were enabled.
3526   if (BytecodeVerificationLocal && !BytecodeVerificationRemote) {
3527     log_info(verification)("Turning on remote verification because local verification is on");
3528     FLAG_SET_DEFAULT(BytecodeVerificationRemote, true);
3529   }
3530   if (!is_valhalla_enabled()) {
3531 #define WARN_IF_NOT_DEFAULT_FLAG(flag)                                                                       \
3532     if (!FLAG_IS_DEFAULT(flag)) {                                                                            \
3533       warning("Preview-specific flag \"%s\" has no effect when --enable-preview is not specified.", #flag);  \
3534     }
3535 
3536 #define DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(flag)  \
3537     WARN_IF_NOT_DEFAULT_FLAG(flag)                  \
3538     FLAG_SET_DEFAULT(flag, false);
3539 
3540     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(InlineTypePassFieldsAsArgs);
3541     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(InlineTypeReturnedAsFields);
3542     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseArrayFlattening);
3543     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseFieldFlattening);
3544     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullFreeNonAtomicValueFlattening);
3545     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullableAtomicValueFlattening);
3546     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullFreeAtomicValueFlattening);
3547     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullableNonAtomicValueFlattening);
3548     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseAcmpFastPath);
3549     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(PrintInlineLayout);
3550     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(PrintFlatArrayLayout);
3551     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(IgnoreAssertUnsetFields);
3552     WARN_IF_NOT_DEFAULT_FLAG(FlatArrayElementMaxOops);
3553     WARN_IF_NOT_DEFAULT_FLAG(ForceNonTearable);
3554 #ifdef ASSERT
3555     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(StressCallingConvention);
3556     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(PreloadClasses);
3557     WARN_IF_NOT_DEFAULT_FLAG(PrintInlineKlassFields);
3558 #endif
3559 #ifdef COMPILER1
3560     DEBUG_ONLY(DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(C1UseDelayedFlattenedFieldReads);)
3561 #endif
3562 #ifdef COMPILER2
3563     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseArrayLoadStoreProfile);
3564     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseACmpProfile);
3565 #endif
3566 #undef DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT
3567 #undef WARN_IF_NOT_DEFAULT_FLAG
3568   } else {
3569 #define DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(flag, fallback)                                        \
3570     if (!FLAG_IS_DEFAULT(flag) && !UseArrayFlattening && !UseFieldFlattening) {                       \
3571       warning("Flattening flag \"%s\" has no effect when all flattening modes are disabled.", #flag); \
3572       FLAG_SET_DEFAULT(flag, fallback);                                                               \
3573     }
3574 
3575     DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(UseNullFreeNonAtomicValueFlattening, false);
3576     DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(UseNullableAtomicValueFlattening, false);
3577     DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(UseNullFreeAtomicValueFlattening, false);
3578     DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(UseNullableNonAtomicValueFlattening, false);
3579     DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(FlatArrayElementMaxOops, 0);
3580     DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(FlatteningBudget, 0);
3581 #undef DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING
3582     if (is_interpreter_only() && !CDSConfig::is_dumping_archive() && !UseSharedSpaces) {
3583       // Disable calling convention optimizations if inline types are not supported.
3584       // Also these aren't useful in -Xint. However, don't disable them when dumping or using
3585       // the CDS archive, as the values must match between dumptime and runtime.
3586       FLAG_SET_DEFAULT(InlineTypePassFieldsAsArgs, false);
3587       FLAG_SET_DEFAULT(InlineTypeReturnedAsFields, false);
3588     }
3589     if (!UseNullFreeNonAtomicValueFlattening &&
3590         !UseNullableAtomicValueFlattening &&
3591         !UseNullFreeAtomicValueFlattening &&
3592         !UseNullableNonAtomicValueFlattening) {
3593       // Flattening is disabled
3594       FLAG_SET_DEFAULT(UseArrayFlattening, false);
3595       FLAG_SET_DEFAULT(UseFieldFlattening, false);
3596     }
3597   }
3598 
3599 #ifndef PRODUCT
3600   if (!LogVMOutput && FLAG_IS_DEFAULT(LogVMOutput)) {
3601     if (use_vm_log()) {
3602       LogVMOutput = true;
3603     }
3604   }
3605 #endif // PRODUCT
3606 
3607   if (PrintCommandLineFlags) {
3608     JVMFlag::printSetFlags(tty);
3609   }
3610 
3611 #ifdef COMPILER2
3612   if (!FLAG_IS_DEFAULT(EnableVectorSupport) && !EnableVectorSupport) {
3613     if (!FLAG_IS_DEFAULT(EnableVectorReboxing) && EnableVectorReboxing) {
3614       warning("Disabling EnableVectorReboxing since EnableVectorSupport is turned off.");
3615     }
3616     FLAG_SET_DEFAULT(EnableVectorReboxing, false);
3617 
3618     if (!FLAG_IS_DEFAULT(EnableVectorAggressiveReboxing) && EnableVectorAggressiveReboxing) {
3619       if (!EnableVectorReboxing) {
3620         warning("Disabling EnableVectorAggressiveReboxing since EnableVectorReboxing is turned off.");
3621       } else {
3622         warning("Disabling EnableVectorAggressiveReboxing since EnableVectorSupport is turned off.");
3623       }
3624     }
3625     FLAG_SET_DEFAULT(EnableVectorAggressiveReboxing, false);
3626   }

3627 

3628   if (!FLAG_IS_DEFAULT(UseLoopPredicate) && !UseLoopPredicate && UseProfiledLoopPredicate) {
3629     warning("Disabling UseProfiledLoopPredicate since UseLoopPredicate is turned off.");
3630     FLAG_SET_ERGO(UseProfiledLoopPredicate, false);
3631   }
3632 #endif // COMPILER2
3633 
3634   if (log_is_enabled(Info, perf, class, link)) {
3635     if (!UsePerfData) {
3636       warning("Disabling -Xlog:perf+class+link since UsePerfData is turned off.");
3637       LogConfiguration::disable_tags(false, LOG_TAGS(perf, class, link));
3638       assert(!log_is_enabled(Info, perf, class, link), "sanity");
3639     }
3640   }
3641 
3642   if (FLAG_IS_CMDLINE(DiagnoseSyncOnValueBasedClasses)) {
3643     if (DiagnoseSyncOnValueBasedClasses == ObjectSynchronizer::LOG_WARNING && !log_is_enabled(Info, valuebasedclasses)) {
3644       LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(valuebasedclasses));
3645     }
3646   }
3647   return JNI_OK;
< prev index next >