< prev index next >

src/hotspot/share/runtime/arguments.cpp

Print this page

  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/checkedCast.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 <limits>

  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::_sun_java_launcher_is_altjvm  = false;
  97 
  98 // These parameters are reset in method parse_vm_init_args()

1748     os::free(const_cast<char*>(_sun_java_launcher));
1749   }
1750   _sun_java_launcher = os::strdup_check_oom(launcher);
1751 }
1752 
1753 bool Arguments::created_by_java_launcher() {
1754   assert(_sun_java_launcher != nullptr, "property must have value");
1755   return strcmp(DEFAULT_JAVA_LAUNCHER, _sun_java_launcher) != 0;
1756 }
1757 
1758 bool Arguments::sun_java_launcher_is_altjvm() {
1759   return _sun_java_launcher_is_altjvm;
1760 }
1761 
1762 //===========================================================================================================
1763 // Parsing of main arguments
1764 
1765 static unsigned int addreads_count = 0;
1766 static unsigned int addexports_count = 0;
1767 static unsigned int addopens_count = 0;
1768 static unsigned int patch_mod_count = 0;
1769 static unsigned int enable_native_access_count = 0;
1770 static bool patch_mod_javabase = false;
1771 
1772 // Check the consistency of vm_init_args
1773 bool Arguments::check_vm_args_consistency() {
1774   // This may modify compiler flags. Must be called before CompilerConfig::check_args_consistency()
1775   if (!CDSConfig::check_vm_args_consistency(patch_mod_javabase, mode_flag_cmd_line)) {
1776     return false;
1777   }
1778 
1779   // Method for adding checks for flag consistency.
1780   // The intent is to warn the user of all possible conflicts,
1781   // before returning an error.
1782   // Note: Needs platform-dependent factoring.
1783   bool status = true;
1784 
1785   if (TLABRefillWasteFraction == 0) {
1786     jio_fprintf(defaultStream::error_stream(),
1787                 "TLABRefillWasteFraction should be a denominator, "
1788                 "not " SIZE_FORMAT "\n",
1789                 TLABRefillWasteFraction);
1790     status = false;
1791   }
1792 
1793   status = CompilerConfig::check_args_consistency(status);
1794 #if INCLUDE_JVMCI
1795   if (status && EnableJVMCI) {

2054   return false;
2055 }
2056 #endif
2057 
2058 int Arguments::process_patch_mod_option(const char* patch_mod_tail) {
2059   // --patch-module=<module>=<file>(<pathsep><file>)*
2060   assert(patch_mod_tail != nullptr, "Unexpected null patch-module value");
2061   // Find the equal sign between the module name and the path specification
2062   const char* module_equal = strchr(patch_mod_tail, '=');
2063   if (module_equal == nullptr) {
2064     jio_fprintf(defaultStream::output_stream(), "Missing '=' in --patch-module specification\n");
2065     return JNI_ERR;
2066   } else {
2067     // Pick out the module name
2068     size_t module_len = module_equal - patch_mod_tail;
2069     char* module_name = NEW_C_HEAP_ARRAY_RETURN_NULL(char, module_len+1, mtArguments);
2070     if (module_name != nullptr) {
2071       memcpy(module_name, patch_mod_tail, module_len);
2072       *(module_name + module_len) = '\0';
2073       // The path piece begins one past the module_equal sign
2074       add_patch_mod_prefix(module_name, module_equal + 1);
2075       FREE_C_HEAP_ARRAY(char, module_name);
2076       if (!create_numbered_module_property("jdk.module.patch", patch_mod_tail, patch_mod_count++)) {
2077         return JNI_ENOMEM;
2078       }
2079     } else {
2080       return JNI_ENOMEM;
2081     }
2082   }
2083   return JNI_OK;
2084 }
2085 
































































2086 // Parse -Xss memory string parameter and convert to ThreadStackSize in K.
2087 jint Arguments::parse_xss(const JavaVMOption* option, const char* tail, intx* out_ThreadStackSize) {
2088   // The min and max sizes match the values in globals.hpp, but scaled
2089   // with K. The values have been chosen so that alignment with page
2090   // size doesn't change the max value, which makes the conversions
2091   // back and forth between Xss value and ThreadStackSize value easier.
2092   // The values have also been chosen to fit inside a 32-bit signed type.
2093   const julong min_ThreadStackSize = 0;
2094   const julong max_ThreadStackSize = 1 * M;
2095 
2096   // Make sure the above values match the range set in globals.hpp
2097   const JVMTypedFlagLimit<intx>* limit = JVMFlagLimit::get_range_at(FLAG_MEMBER_ENUM(ThreadStackSize))->cast<intx>();
2098   assert(min_ThreadStackSize == static_cast<julong>(limit->min()), "must be");
2099   assert(max_ThreadStackSize == static_cast<julong>(limit->max()), "must be");
2100 
2101   const julong min_size = min_ThreadStackSize * K;
2102   const julong max_size = max_ThreadStackSize * K;
2103 
2104   assert(is_aligned(max_size, os::vm_page_size()), "Implementation assumption");
2105 

2317       jio_fprintf(defaultStream::error_stream(),
2318         "Instrumentation agents are not supported in this VM\n");
2319       return JNI_ERR;
2320 #else
2321       if (tail != nullptr) {
2322         size_t length = strlen(tail) + 1;
2323         char *options = NEW_C_HEAP_ARRAY(char, length, mtArguments);
2324         jio_snprintf(options, length, "%s", tail);
2325         JvmtiAgentList::add("instrument", options, false);
2326         FREE_C_HEAP_ARRAY(char, options);
2327 
2328         // java agents need module java.instrument
2329         if (!create_numbered_module_property("jdk.module.addmods", "java.instrument", _addmods_count++)) {
2330           return JNI_ENOMEM;
2331         }
2332       }
2333 #endif // !INCLUDE_JVMTI
2334     // --enable_preview
2335     } else if (match_option(option, "--enable-preview")) {
2336       set_enable_preview();




2337     // -Xnoclassgc
2338     } else if (match_option(option, "-Xnoclassgc")) {
2339       if (FLAG_SET_CMDLINE(ClassUnloading, false) != JVMFlag::SUCCESS) {
2340         return JNI_EINVAL;
2341       }
2342     // -Xbatch
2343     } else if (match_option(option, "-Xbatch")) {
2344       if (FLAG_SET_CMDLINE(BackgroundCompilation, false) != JVMFlag::SUCCESS) {
2345         return JNI_EINVAL;
2346       }
2347     // -Xmn for compatibility with other JVM vendors
2348     } else if (match_option(option, "-Xmn", &tail)) {
2349       julong long_initial_young_size = 0;
2350       ArgsRange errcode = parse_memory_size(tail, &long_initial_young_size, 1);
2351       if (errcode != arg_in_range) {
2352         jio_fprintf(defaultStream::error_stream(),
2353                     "Invalid initial young generation size: %s\n", option->optionString);
2354         describe_range_error(errcode);
2355         return JNI_EINVAL;
2356       }

2796     // Unknown option
2797     } else if (is_bad_option(option, args->ignoreUnrecognized)) {
2798       return JNI_ERR;
2799     }
2800   }
2801 
2802   // PrintSharedArchiveAndExit will turn on
2803   //   -Xshare:on
2804   //   -Xlog:class+path=info
2805   if (PrintSharedArchiveAndExit) {
2806     UseSharedSpaces = true;
2807     RequireSharedSpaces = true;
2808     LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(class, path));
2809   }
2810 
2811   fix_appclasspath();
2812 
2813   return JNI_OK;
2814 }
2815 
2816 void Arguments::add_patch_mod_prefix(const char* module_name, const char* path) {
2817   // For java.base check for duplicate --patch-module options being specified on the command line.
2818   // This check is only required for java.base, all other duplicate module specifications
2819   // will be checked during module system initialization.  The module system initialization
2820   // will throw an ExceptionInInitializerError if this situation occurs.
2821   if (strcmp(module_name, JAVA_BASE_NAME) == 0) {
2822     if (patch_mod_javabase) {
2823       vm_exit_during_initialization("Cannot specify " JAVA_BASE_NAME " more than once to --patch-module");
2824     } else {
2825       patch_mod_javabase = true;
2826     }
2827   }
2828 
2829   // Create GrowableArray lazily, only if --patch-module has been specified
2830   if (_patch_mod_prefix == nullptr) {
2831     _patch_mod_prefix = new (mtArguments) GrowableArray<ModulePatchPath*>(10, mtArguments);
2832   }
2833 
2834   _patch_mod_prefix->push(new ModulePatchPath(module_name, path));

















2835 }
2836 
2837 // Remove all empty paths from the app classpath (if IgnoreEmptyClassPaths is enabled)
2838 //
2839 // This is necessary because some apps like to specify classpath like -cp foo.jar:${XYZ}:bar.jar
2840 // in their start-up scripts. If XYZ is empty, the classpath will look like "-cp foo.jar::bar.jar".
2841 // Java treats such empty paths as if the user specified "-cp foo.jar:.:bar.jar". I.e., an empty
2842 // path is treated as the current directory.
2843 //
2844 // This causes problems with CDS, which requires that all directories specified in the classpath
2845 // must be empty. In most cases, applications do NOT want to load classes from the current
2846 // directory anyway. Adding -XX:+IgnoreEmptyClassPaths will make these applications' start-up
2847 // scripts compatible with CDS.
2848 void Arguments::fix_appclasspath() {
2849   if (IgnoreEmptyClassPaths) {
2850     const char separator = *os::path_separator();
2851     const char* src = _java_class_path->value();
2852 
2853     // skip over all the leading empty paths
2854     while (*src == separator) {

2927   }
2928 
2929 #if !COMPILER2_OR_JVMCI
2930   // Don't degrade server performance for footprint
2931   if (FLAG_IS_DEFAULT(UseLargePages) &&
2932       MaxHeapSize < LargePageHeapSizeThreshold) {
2933     // No need for large granularity pages w/small heaps.
2934     // Note that large pages are enabled/disabled for both the
2935     // Java heap and the code cache.
2936     FLAG_SET_DEFAULT(UseLargePages, false);
2937   }
2938 
2939   UNSUPPORTED_OPTION(ProfileInterpreter);
2940 #endif
2941 
2942   // Parse the CompilationMode flag
2943   if (!CompilationModeFlag::initialize()) {
2944     return JNI_ERR;
2945   }
2946 
2947   if (!check_vm_args_consistency()) {

2948     return JNI_ERR;
2949   }
2950 



2951 
2952 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
2953   UNSUPPORTED_OPTION(ShowRegistersOnAssert);
2954 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
2955 
2956   return JNI_OK;
2957 }
2958 
2959 // Helper class for controlling the lifetime of JavaVMInitArgs
2960 // objects.  The contents of the JavaVMInitArgs are guaranteed to be
2961 // deleted on the destruction of the ScopedVMInitArgs object.
2962 class ScopedVMInitArgs : public StackObj {
2963  private:
2964   JavaVMInitArgs _args;
2965   char*          _container_name;
2966   bool           _is_set;
2967   char*          _vm_options_file_arg;
2968 
2969  public:
2970   ScopedVMInitArgs(const char *container_name) {

3732 #ifdef ZERO
3733   // Clear flags not supported on zero.
3734   FLAG_SET_DEFAULT(ProfileInterpreter, false);
3735 #endif // ZERO
3736 
3737   if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3738     warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3739     DebugNonSafepoints = true;
3740   }
3741 
3742   if (FLAG_IS_CMDLINE(CompressedClassSpaceSize) && !UseCompressedClassPointers) {
3743     warning("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used");
3744   }
3745 
3746   // Treat the odd case where local verification is enabled but remote
3747   // verification is not as if both were enabled.
3748   if (BytecodeVerificationLocal && !BytecodeVerificationRemote) {
3749     log_info(verification)("Turning on remote verification because local verification is on");
3750     FLAG_SET_DEFAULT(BytecodeVerificationRemote, true);
3751   }







3752 
3753 #ifndef PRODUCT
3754   if (!LogVMOutput && FLAG_IS_DEFAULT(LogVMOutput)) {
3755     if (use_vm_log()) {
3756       LogVMOutput = true;
3757     }
3758   }
3759 #endif // PRODUCT
3760 
3761   if (PrintCommandLineFlags) {
3762     JVMFlag::printSetFlags(tty);
3763   }
3764 
3765 #if COMPILER2_OR_JVMCI
3766   if (!FLAG_IS_DEFAULT(EnableVectorSupport) && !EnableVectorSupport) {
3767     if (!FLAG_IS_DEFAULT(EnableVectorReboxing) && EnableVectorReboxing) {
3768       warning("Disabling EnableVectorReboxing since EnableVectorSupport is turned off.");
3769     }
3770     FLAG_SET_DEFAULT(EnableVectorReboxing, false);
3771 

  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/checkedCast.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 <limits>
  79 #include <string.h>
  80 
  81 static const char _default_java_launcher[] = "generic";
  82 
  83 #define DEFAULT_JAVA_LAUNCHER _default_java_launcher
  84 
  85 char*  Arguments::_jvm_flags_file               = nullptr;
  86 char** Arguments::_jvm_flags_array              = nullptr;
  87 int    Arguments::_num_jvm_flags                = 0;
  88 char** Arguments::_jvm_args_array               = nullptr;
  89 int    Arguments::_num_jvm_args                 = 0;
  90 unsigned int Arguments::_addmods_count          = 0;
  91 char*  Arguments::_java_command                 = nullptr;
  92 SystemProperty* Arguments::_system_properties   = nullptr;
  93 size_t Arguments::_conservative_max_heap_alignment = 0;
  94 Arguments::Mode Arguments::_mode                = _mixed;
  95 const char*  Arguments::_java_vendor_url_bug    = nullptr;
  96 const char*  Arguments::_sun_java_launcher      = DEFAULT_JAVA_LAUNCHER;
  97 bool   Arguments::_sun_java_launcher_is_altjvm  = false;
  98 
  99 // These parameters are reset in method parse_vm_init_args()

1749     os::free(const_cast<char*>(_sun_java_launcher));
1750   }
1751   _sun_java_launcher = os::strdup_check_oom(launcher);
1752 }
1753 
1754 bool Arguments::created_by_java_launcher() {
1755   assert(_sun_java_launcher != nullptr, "property must have value");
1756   return strcmp(DEFAULT_JAVA_LAUNCHER, _sun_java_launcher) != 0;
1757 }
1758 
1759 bool Arguments::sun_java_launcher_is_altjvm() {
1760   return _sun_java_launcher_is_altjvm;
1761 }
1762 
1763 //===========================================================================================================
1764 // Parsing of main arguments
1765 
1766 static unsigned int addreads_count = 0;
1767 static unsigned int addexports_count = 0;
1768 static unsigned int addopens_count = 0;

1769 static unsigned int enable_native_access_count = 0;
1770 static bool patch_mod_javabase = false;
1771 
1772 // Check the consistency of vm_init_args
1773 bool Arguments::check_vm_args_consistency() {
1774   // This may modify compiler flags. Must be called before CompilerConfig::check_args_consistency()
1775   if (!CDSConfig::check_vm_args_consistency(mode_flag_cmd_line)) {
1776     return false;
1777   }
1778 
1779   // Method for adding checks for flag consistency.
1780   // The intent is to warn the user of all possible conflicts,
1781   // before returning an error.
1782   // Note: Needs platform-dependent factoring.
1783   bool status = true;
1784 
1785   if (TLABRefillWasteFraction == 0) {
1786     jio_fprintf(defaultStream::error_stream(),
1787                 "TLABRefillWasteFraction should be a denominator, "
1788                 "not " SIZE_FORMAT "\n",
1789                 TLABRefillWasteFraction);
1790     status = false;
1791   }
1792 
1793   status = CompilerConfig::check_args_consistency(status);
1794 #if INCLUDE_JVMCI
1795   if (status && EnableJVMCI) {

2054   return false;
2055 }
2056 #endif
2057 
2058 int Arguments::process_patch_mod_option(const char* patch_mod_tail) {
2059   // --patch-module=<module>=<file>(<pathsep><file>)*
2060   assert(patch_mod_tail != nullptr, "Unexpected null patch-module value");
2061   // Find the equal sign between the module name and the path specification
2062   const char* module_equal = strchr(patch_mod_tail, '=');
2063   if (module_equal == nullptr) {
2064     jio_fprintf(defaultStream::output_stream(), "Missing '=' in --patch-module specification\n");
2065     return JNI_ERR;
2066   } else {
2067     // Pick out the module name
2068     size_t module_len = module_equal - patch_mod_tail;
2069     char* module_name = NEW_C_HEAP_ARRAY_RETURN_NULL(char, module_len+1, mtArguments);
2070     if (module_name != nullptr) {
2071       memcpy(module_name, patch_mod_tail, module_len);
2072       *(module_name + module_len) = '\0';
2073       // The path piece begins one past the module_equal sign
2074       add_patch_mod_prefix(module_name, module_equal + 1, false /* no append */, false /* no cds */);
2075       FREE_C_HEAP_ARRAY(char, module_name);



2076     } else {
2077       return JNI_ENOMEM;
2078     }
2079   }
2080   return JNI_OK;
2081 }
2082 
2083 // VALUECLASS_STR must match string used in the build
2084 #define VALUECLASS_STR "valueclasses"
2085 #define VALUECLASS_JAR "-" VALUECLASS_STR ".jar"
2086 
2087 // Finalize --patch-module args and --enable-preview related to value class module patches.
2088 // Create all numbered properties passing module patches.
2089 int Arguments::finalize_patch_module() {
2090   // If --enable-preview and EnableValhalla is true, each module may have value classes that
2091   // are to be patched into the module.
2092   // For each <module>-valueclasses.jar in <JAVA_HOME>/lib/valueclasses/
2093   // appends the equivalent of --patch-module <module>=<JAVA_HOME>/lib/valueclasses/<module>-valueclasses.jar
2094   if (enable_preview() && EnableValhalla) {
2095     char * valueclasses_dir = AllocateHeap(JVM_MAXPATHLEN, mtArguments);
2096     const char * fileSep = os::file_separator();
2097 
2098     jio_snprintf(valueclasses_dir, JVM_MAXPATHLEN, "%s%slib%s" VALUECLASS_STR "%s",
2099                  Arguments::get_java_home(), fileSep, fileSep, fileSep);
2100     DIR* dir = os::opendir(valueclasses_dir);
2101     if (dir != nullptr) {
2102       char * module_name = AllocateHeap(JVM_MAXPATHLEN, mtArguments);
2103       char * path = AllocateHeap(JVM_MAXPATHLEN, mtArguments);
2104 
2105       for (dirent * entry = os::readdir(dir); entry != nullptr; entry = os::readdir(dir)) {
2106         // Test if file ends-with "-valueclasses.jar"
2107         int len = (int)strlen(entry->d_name) - (sizeof(VALUECLASS_JAR) - 1);
2108         if (len <= 0 || strcmp(&entry->d_name[len], VALUECLASS_JAR) != 0) {
2109           continue;         // too short or not the expected suffix
2110         }
2111 
2112         strcpy(module_name, entry->d_name);
2113         module_name[len] = '\0';     // truncate to just module-name
2114 
2115         jio_snprintf(path, JVM_MAXPATHLEN, "%s%s", valueclasses_dir, &entry->d_name);
2116         add_patch_mod_prefix(module_name, path, true /* append */, true /* cds OK*/);
2117         log_info(class)("--enable-preview appending value classes for module %s: %s", module_name, entry->d_name);
2118       }
2119       FreeHeap(module_name);
2120       FreeHeap(path);
2121       os::closedir(dir);
2122     }
2123     FreeHeap(valueclasses_dir);
2124   }
2125 
2126   // Create numbered properties for each module that has been patched either
2127   // by --patch-module or --enable-preview
2128   // Format is "jdk.module.patch.<n>=<module_name>=<path>"
2129   if (_patch_mod_prefix != nullptr) {
2130     char * prop_value = AllocateHeap(JVM_MAXPATHLEN + JVM_MAXPATHLEN + 1, mtArguments);
2131     unsigned int patch_mod_count = 0;
2132 
2133     for (GrowableArrayIterator<ModulePatchPath *> it = _patch_mod_prefix->begin();
2134             it != _patch_mod_prefix->end(); ++it) {
2135       jio_snprintf(prop_value, JVM_MAXPATHLEN + JVM_MAXPATHLEN + 1, "%s=%s",
2136                    (*it)->module_name(), (*it)->path_string());
2137       if (!create_numbered_module_property("jdk.module.patch", prop_value, patch_mod_count++)) {
2138         FreeHeap(prop_value);
2139         return JNI_ENOMEM;
2140       }
2141     }
2142     FreeHeap(prop_value);
2143   }
2144   return JNI_OK;
2145 }
2146 
2147 // Parse -Xss memory string parameter and convert to ThreadStackSize in K.
2148 jint Arguments::parse_xss(const JavaVMOption* option, const char* tail, intx* out_ThreadStackSize) {
2149   // The min and max sizes match the values in globals.hpp, but scaled
2150   // with K. The values have been chosen so that alignment with page
2151   // size doesn't change the max value, which makes the conversions
2152   // back and forth between Xss value and ThreadStackSize value easier.
2153   // The values have also been chosen to fit inside a 32-bit signed type.
2154   const julong min_ThreadStackSize = 0;
2155   const julong max_ThreadStackSize = 1 * M;
2156 
2157   // Make sure the above values match the range set in globals.hpp
2158   const JVMTypedFlagLimit<intx>* limit = JVMFlagLimit::get_range_at(FLAG_MEMBER_ENUM(ThreadStackSize))->cast<intx>();
2159   assert(min_ThreadStackSize == static_cast<julong>(limit->min()), "must be");
2160   assert(max_ThreadStackSize == static_cast<julong>(limit->max()), "must be");
2161 
2162   const julong min_size = min_ThreadStackSize * K;
2163   const julong max_size = max_ThreadStackSize * K;
2164 
2165   assert(is_aligned(max_size, os::vm_page_size()), "Implementation assumption");
2166 

2378       jio_fprintf(defaultStream::error_stream(),
2379         "Instrumentation agents are not supported in this VM\n");
2380       return JNI_ERR;
2381 #else
2382       if (tail != nullptr) {
2383         size_t length = strlen(tail) + 1;
2384         char *options = NEW_C_HEAP_ARRAY(char, length, mtArguments);
2385         jio_snprintf(options, length, "%s", tail);
2386         JvmtiAgentList::add("instrument", options, false);
2387         FREE_C_HEAP_ARRAY(char, options);
2388 
2389         // java agents need module java.instrument
2390         if (!create_numbered_module_property("jdk.module.addmods", "java.instrument", _addmods_count++)) {
2391           return JNI_ENOMEM;
2392         }
2393       }
2394 #endif // !INCLUDE_JVMTI
2395     // --enable_preview
2396     } else if (match_option(option, "--enable-preview")) {
2397       set_enable_preview();
2398       // --enable-preview enables Valhalla, EnableValhalla VM option will eventually be removed before integration
2399       if (FLAG_SET_CMDLINE(EnableValhalla, true) != JVMFlag::SUCCESS) {
2400         return JNI_EINVAL;
2401       }
2402     // -Xnoclassgc
2403     } else if (match_option(option, "-Xnoclassgc")) {
2404       if (FLAG_SET_CMDLINE(ClassUnloading, false) != JVMFlag::SUCCESS) {
2405         return JNI_EINVAL;
2406       }
2407     // -Xbatch
2408     } else if (match_option(option, "-Xbatch")) {
2409       if (FLAG_SET_CMDLINE(BackgroundCompilation, false) != JVMFlag::SUCCESS) {
2410         return JNI_EINVAL;
2411       }
2412     // -Xmn for compatibility with other JVM vendors
2413     } else if (match_option(option, "-Xmn", &tail)) {
2414       julong long_initial_young_size = 0;
2415       ArgsRange errcode = parse_memory_size(tail, &long_initial_young_size, 1);
2416       if (errcode != arg_in_range) {
2417         jio_fprintf(defaultStream::error_stream(),
2418                     "Invalid initial young generation size: %s\n", option->optionString);
2419         describe_range_error(errcode);
2420         return JNI_EINVAL;
2421       }

2861     // Unknown option
2862     } else if (is_bad_option(option, args->ignoreUnrecognized)) {
2863       return JNI_ERR;
2864     }
2865   }
2866 
2867   // PrintSharedArchiveAndExit will turn on
2868   //   -Xshare:on
2869   //   -Xlog:class+path=info
2870   if (PrintSharedArchiveAndExit) {
2871     UseSharedSpaces = true;
2872     RequireSharedSpaces = true;
2873     LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(class, path));
2874   }
2875 
2876   fix_appclasspath();
2877 
2878   return JNI_OK;
2879 }
2880 
2881 void Arguments::add_patch_mod_prefix(const char* module_name, const char* path, bool allow_append, bool allow_cds) {
2882   if (!allow_cds) {
2883     CDSConfig::set_module_patching_disables_cds();
2884     if (strcmp(module_name, JAVA_BASE_NAME) == 0) {
2885       CDSConfig::set_java_base_module_patching_disables_cds();





2886     }
2887   }
2888 
2889   // Create GrowableArray lazily, only if --patch-module has been specified
2890   if (_patch_mod_prefix == nullptr) {
2891     _patch_mod_prefix = new (mtArguments) GrowableArray<ModulePatchPath*>(10, mtArguments);
2892   }
2893 
2894   // Scan patches for matching module
2895   int i = _patch_mod_prefix->find_if([&](ModulePatchPath* patch) {
2896     return (strcmp(module_name, patch->module_name()) == 0);
2897   });
2898   if (i == -1) {
2899     _patch_mod_prefix->push(new ModulePatchPath(module_name, path));
2900   } else {
2901     if (allow_append) {
2902       // append path to existing module entry
2903       _patch_mod_prefix->at(i)->append_path(path);
2904     } else {
2905       if (strcmp(module_name, JAVA_BASE_NAME) == 0) {
2906         vm_exit_during_initialization("Cannot specify " JAVA_BASE_NAME " more than once to --patch-module");
2907       } else {
2908         vm_exit_during_initialization("Cannot specify a module more than once to --patch-module", module_name);
2909       }
2910     }
2911   }
2912 }
2913 
2914 // Remove all empty paths from the app classpath (if IgnoreEmptyClassPaths is enabled)
2915 //
2916 // This is necessary because some apps like to specify classpath like -cp foo.jar:${XYZ}:bar.jar
2917 // in their start-up scripts. If XYZ is empty, the classpath will look like "-cp foo.jar::bar.jar".
2918 // Java treats such empty paths as if the user specified "-cp foo.jar:.:bar.jar". I.e., an empty
2919 // path is treated as the current directory.
2920 //
2921 // This causes problems with CDS, which requires that all directories specified in the classpath
2922 // must be empty. In most cases, applications do NOT want to load classes from the current
2923 // directory anyway. Adding -XX:+IgnoreEmptyClassPaths will make these applications' start-up
2924 // scripts compatible with CDS.
2925 void Arguments::fix_appclasspath() {
2926   if (IgnoreEmptyClassPaths) {
2927     const char separator = *os::path_separator();
2928     const char* src = _java_class_path->value();
2929 
2930     // skip over all the leading empty paths
2931     while (*src == separator) {

3004   }
3005 
3006 #if !COMPILER2_OR_JVMCI
3007   // Don't degrade server performance for footprint
3008   if (FLAG_IS_DEFAULT(UseLargePages) &&
3009       MaxHeapSize < LargePageHeapSizeThreshold) {
3010     // No need for large granularity pages w/small heaps.
3011     // Note that large pages are enabled/disabled for both the
3012     // Java heap and the code cache.
3013     FLAG_SET_DEFAULT(UseLargePages, false);
3014   }
3015 
3016   UNSUPPORTED_OPTION(ProfileInterpreter);
3017 #endif
3018 
3019   // Parse the CompilationMode flag
3020   if (!CompilationModeFlag::initialize()) {
3021     return JNI_ERR;
3022   }
3023 
3024   // finalize --module-patch and related --enable-preview
3025   if (finalize_patch_module() != JNI_OK) {
3026     return JNI_ERR;
3027   }
3028 
3029   if (!check_vm_args_consistency()) {
3030     return JNI_ERR;
3031   }
3032 
3033 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
3034   UNSUPPORTED_OPTION(ShowRegistersOnAssert);
3035 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
3036 
3037   return JNI_OK;
3038 }
3039 
3040 // Helper class for controlling the lifetime of JavaVMInitArgs
3041 // objects.  The contents of the JavaVMInitArgs are guaranteed to be
3042 // deleted on the destruction of the ScopedVMInitArgs object.
3043 class ScopedVMInitArgs : public StackObj {
3044  private:
3045   JavaVMInitArgs _args;
3046   char*          _container_name;
3047   bool           _is_set;
3048   char*          _vm_options_file_arg;
3049 
3050  public:
3051   ScopedVMInitArgs(const char *container_name) {

3813 #ifdef ZERO
3814   // Clear flags not supported on zero.
3815   FLAG_SET_DEFAULT(ProfileInterpreter, false);
3816 #endif // ZERO
3817 
3818   if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3819     warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3820     DebugNonSafepoints = true;
3821   }
3822 
3823   if (FLAG_IS_CMDLINE(CompressedClassSpaceSize) && !UseCompressedClassPointers) {
3824     warning("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used");
3825   }
3826 
3827   // Treat the odd case where local verification is enabled but remote
3828   // verification is not as if both were enabled.
3829   if (BytecodeVerificationLocal && !BytecodeVerificationRemote) {
3830     log_info(verification)("Turning on remote verification because local verification is on");
3831     FLAG_SET_DEFAULT(BytecodeVerificationRemote, true);
3832   }
3833   if (!EnableValhalla || (is_interpreter_only() && !CDSConfig::is_dumping_archive() && !UseSharedSpaces)) {
3834     // Disable calling convention optimizations if inline types are not supported.
3835     // Also these aren't useful in -Xint. However, don't disable them when dumping or using
3836     // the CDS archive, as the values must match between dumptime and runtime.
3837     InlineTypePassFieldsAsArgs = false;
3838     InlineTypeReturnedAsFields = false;
3839   }
3840 
3841 #ifndef PRODUCT
3842   if (!LogVMOutput && FLAG_IS_DEFAULT(LogVMOutput)) {
3843     if (use_vm_log()) {
3844       LogVMOutput = true;
3845     }
3846   }
3847 #endif // PRODUCT
3848 
3849   if (PrintCommandLineFlags) {
3850     JVMFlag::printSetFlags(tty);
3851   }
3852 
3853 #if COMPILER2_OR_JVMCI
3854   if (!FLAG_IS_DEFAULT(EnableVectorSupport) && !EnableVectorSupport) {
3855     if (!FLAG_IS_DEFAULT(EnableVectorReboxing) && EnableVectorReboxing) {
3856       warning("Disabling EnableVectorReboxing since EnableVectorSupport is turned off.");
3857     }
3858     FLAG_SET_DEFAULT(EnableVectorReboxing, false);
3859 
< prev index next >