< prev index next >

src/hotspot/share/runtime/arguments.cpp

Print this page

  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 static const char _default_java_launcher[] = "generic";
  79 
  80 #define DEFAULT_JAVA_LAUNCHER _default_java_launcher
  81 
  82 char*  Arguments::_jvm_flags_file               = nullptr;
  83 char** Arguments::_jvm_flags_array              = nullptr;
  84 int    Arguments::_num_jvm_flags                = 0;
  85 char** Arguments::_jvm_args_array               = nullptr;
  86 int    Arguments::_num_jvm_args                 = 0;
  87 unsigned int Arguments::_addmods_count          = 0;
  88 #if INCLUDE_JVMCI
  89 bool   Arguments::_jvmci_module_added           = false;
  90 #endif
  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::_executing_unit_tests         = false;

1783     os::free(const_cast<char*>(_sun_java_launcher));
1784   }
1785   _sun_java_launcher = os::strdup_check_oom(launcher);
1786 }
1787 
1788 bool Arguments::created_by_java_launcher() {
1789   assert(_sun_java_launcher != nullptr, "property must have value");
1790   return strcmp(DEFAULT_JAVA_LAUNCHER, _sun_java_launcher) != 0;
1791 }
1792 
1793 bool Arguments::executing_unit_tests() {
1794   return _executing_unit_tests;
1795 }
1796 
1797 //===========================================================================================================
1798 // Parsing of main arguments
1799 
1800 static unsigned int addreads_count = 0;
1801 static unsigned int addexports_count = 0;
1802 static unsigned int addopens_count = 0;
1803 static unsigned int patch_mod_count = 0;
1804 static unsigned int enable_native_access_count = 0;
1805 static unsigned int enable_final_field_mutation = 0;
1806 static bool patch_mod_javabase = false;
1807 
1808 // Check the consistency of vm_init_args
1809 bool Arguments::check_vm_args_consistency() {
1810   // This may modify compiler flags. Must be called before CompilerConfig::check_args_consistency()
1811   if (!CDSConfig::check_vm_args_consistency(patch_mod_javabase, mode_flag_cmd_line)) {
1812     return false;
1813   }
1814 
1815   // Method for adding checks for flag consistency.
1816   // The intent is to warn the user of all possible conflicts,
1817   // before returning an error.
1818   // Note: Needs platform-dependent factoring.
1819   bool status = true;
1820 
1821   if (TLABRefillWasteFraction == 0) {
1822     jio_fprintf(defaultStream::error_stream(),
1823                 "TLABRefillWasteFraction should be a denominator, "
1824                 "not %zu\n",
1825                 TLABRefillWasteFraction);
1826     status = false;
1827   }
1828 
1829   status = CompilerConfig::check_args_consistency(status);
1830 #if INCLUDE_JVMCI
1831   if (status && EnableJVMCI) {

2040   return false;
2041 }
2042 #endif
2043 
2044 int Arguments::process_patch_mod_option(const char* patch_mod_tail) {
2045   // --patch-module=<module>=<file>(<pathsep><file>)*
2046   assert(patch_mod_tail != nullptr, "Unexpected null patch-module value");
2047   // Find the equal sign between the module name and the path specification
2048   const char* module_equal = strchr(patch_mod_tail, '=');
2049   if (module_equal == nullptr) {
2050     jio_fprintf(defaultStream::output_stream(), "Missing '=' in --patch-module specification\n");
2051     return JNI_ERR;
2052   } else {
2053     // Pick out the module name
2054     size_t module_len = module_equal - patch_mod_tail;
2055     char* module_name = NEW_C_HEAP_ARRAY_RETURN_NULL(char, module_len+1, mtArguments);
2056     if (module_name != nullptr) {
2057       memcpy(module_name, patch_mod_tail, module_len);
2058       *(module_name + module_len) = '\0';
2059       // The path piece begins one past the module_equal sign
2060       add_patch_mod_prefix(module_name, module_equal + 1);
2061       FREE_C_HEAP_ARRAY(char, module_name);
2062       if (!create_numbered_module_property("jdk.module.patch", patch_mod_tail, patch_mod_count++)) {
2063         return JNI_ENOMEM;
2064       }
2065     } else {
2066       return JNI_ENOMEM;
2067     }
2068   }
2069   return JNI_OK;
2070 }
2071 























2072 // Parse -Xss memory string parameter and convert to ThreadStackSize in K.
2073 jint Arguments::parse_xss(const JavaVMOption* option, const char* tail, intx* out_ThreadStackSize) {
2074   // The min and max sizes match the values in globals.hpp, but scaled
2075   // with K. The values have been chosen so that alignment with page
2076   // size doesn't change the max value, which makes the conversions
2077   // back and forth between Xss value and ThreadStackSize value easier.
2078   // The values have also been chosen to fit inside a 32-bit signed type.
2079   const julong min_ThreadStackSize = 0;
2080   const julong max_ThreadStackSize = 1 * M;
2081 
2082   // Make sure the above values match the range set in globals.hpp
2083   const JVMTypedFlagLimit<intx>* limit = JVMFlagLimit::get_range_at(FLAG_MEMBER_ENUM(ThreadStackSize))->cast<intx>();
2084   assert(min_ThreadStackSize == static_cast<julong>(limit->min()), "must be");
2085   assert(max_ThreadStackSize == static_cast<julong>(limit->max()), "must be");
2086 
2087   const julong min_size = min_ThreadStackSize * K;
2088   const julong max_size = max_ThreadStackSize * K;
2089 
2090   assert(is_aligned(max_size, os::vm_page_size()), "Implementation assumption");
2091 

2843   }
2844 
2845   // PrintSharedArchiveAndExit will turn on
2846   //   -Xshare:on
2847   //   -Xlog:class+path=info
2848   if (PrintSharedArchiveAndExit) {
2849     UseSharedSpaces = true;
2850     RequireSharedSpaces = true;
2851     LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(class, path));
2852   }
2853 
2854   fix_appclasspath();
2855 
2856   return JNI_OK;
2857 }
2858 
2859 void Arguments::set_ext_dirs(char *value) {
2860   _ext_dirs = os::strdup_check_oom(value);
2861 }
2862 
2863 void Arguments::add_patch_mod_prefix(const char* module_name, const char* path) {
2864   // For java.base check for duplicate --patch-module options being specified on the command line.
2865   // This check is only required for java.base, all other duplicate module specifications
2866   // will be checked during module system initialization.  The module system initialization
2867   // will throw an ExceptionInInitializerError if this situation occurs.
2868   if (strcmp(module_name, JAVA_BASE_NAME) == 0) {
2869     if (patch_mod_javabase) {
2870       vm_exit_during_initialization("Cannot specify " JAVA_BASE_NAME " more than once to --patch-module");
2871     } else {
2872       patch_mod_javabase = true;
2873     }
2874   }
2875 
2876   // Create GrowableArray lazily, only if --patch-module has been specified
2877   if (_patch_mod_prefix == nullptr) {
2878     _patch_mod_prefix = new (mtArguments) GrowableArray<ModulePatchPath*>(10, mtArguments);
2879   }
2880 
2881   _patch_mod_prefix->push(new ModulePatchPath(module_name, path));

















2882 }
2883 
2884 // Remove all empty paths from the app classpath (if IgnoreEmptyClassPaths is enabled)
2885 //
2886 // This is necessary because some apps like to specify classpath like -cp foo.jar:${XYZ}:bar.jar
2887 // in their start-up scripts. If XYZ is empty, the classpath will look like "-cp foo.jar::bar.jar".
2888 // Java treats such empty paths as if the user specified "-cp foo.jar:.:bar.jar". I.e., an empty
2889 // path is treated as the current directory.
2890 //
2891 // This causes problems with CDS, which requires that all directories specified in the classpath
2892 // must be empty. In most cases, applications do NOT want to load classes from the current
2893 // directory anyway. Adding -XX:+IgnoreEmptyClassPaths will make these applications' start-up
2894 // scripts compatible with CDS.
2895 void Arguments::fix_appclasspath() {
2896   if (IgnoreEmptyClassPaths) {
2897     const char separator = *os::path_separator();
2898     const char* src = _java_class_path->value();
2899 
2900     // skip over all the leading empty paths
2901     while (*src == separator) {

2974   }
2975 
2976 #if !COMPILER2_OR_JVMCI
2977   // Don't degrade server performance for footprint
2978   if (FLAG_IS_DEFAULT(UseLargePages) &&
2979       MaxHeapSize < LargePageHeapSizeThreshold) {
2980     // No need for large granularity pages w/small heaps.
2981     // Note that large pages are enabled/disabled for both the
2982     // Java heap and the code cache.
2983     FLAG_SET_DEFAULT(UseLargePages, false);
2984   }
2985 
2986   UNSUPPORTED_OPTION(ProfileInterpreter);
2987 #endif
2988 
2989   // Parse the CompilationMode flag
2990   if (!CompilationModeFlag::initialize()) {
2991     return JNI_ERR;
2992   }
2993 
2994   if (!check_vm_args_consistency()) {



2995     return JNI_ERR;
2996   }
2997 



2998 
2999 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
3000   UNSUPPORTED_OPTION(ShowRegistersOnAssert);
3001 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
3002 
3003   return JNI_OK;
3004 }
3005 
3006 // Helper class for controlling the lifetime of JavaVMInitArgs
3007 // objects.  The contents of the JavaVMInitArgs are guaranteed to be
3008 // deleted on the destruction of the ScopedVMInitArgs object.
3009 class ScopedVMInitArgs : public StackObj {
3010  private:
3011   JavaVMInitArgs _args;
3012   char*          _container_name;
3013   bool           _is_set;
3014   char*          _vm_options_file_arg;
3015 
3016  public:
3017   ScopedVMInitArgs(const char *container_name) {

3863 #ifdef ZERO
3864   // Clear flags not supported on zero.
3865   FLAG_SET_DEFAULT(ProfileInterpreter, false);
3866 #endif // ZERO
3867 
3868   if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3869     warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3870     DebugNonSafepoints = true;
3871   }
3872 
3873   if (FLAG_IS_CMDLINE(CompressedClassSpaceSize) && !UseCompressedClassPointers) {
3874     warning("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used");
3875   }
3876 
3877   // Treat the odd case where local verification is enabled but remote
3878   // verification is not as if both were enabled.
3879   if (BytecodeVerificationLocal && !BytecodeVerificationRemote) {
3880     log_info(verification)("Turning on remote verification because local verification is on");
3881     FLAG_SET_DEFAULT(BytecodeVerificationRemote, true);
3882   }

















































3883 
3884 #ifndef PRODUCT
3885   if (!LogVMOutput && FLAG_IS_DEFAULT(LogVMOutput)) {
3886     if (use_vm_log()) {
3887       LogVMOutput = true;
3888     }
3889   }
3890 #endif // PRODUCT
3891 
3892   if (PrintCommandLineFlags) {
3893     JVMFlag::printSetFlags(tty);
3894   }
3895 
3896 #if COMPILER2_OR_JVMCI
3897   if (!FLAG_IS_DEFAULT(EnableVectorSupport) && !EnableVectorSupport) {
3898     if (!FLAG_IS_DEFAULT(EnableVectorReboxing) && EnableVectorReboxing) {
3899       warning("Disabling EnableVectorReboxing since EnableVectorSupport is turned off.");
3900     }
3901     FLAG_SET_DEFAULT(EnableVectorReboxing, false);
3902 

  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 #if INCLUDE_JVMCI
  91 bool   Arguments::_jvmci_module_added           = false;
  92 #endif
  93 char*  Arguments::_java_command                 = nullptr;
  94 SystemProperty* Arguments::_system_properties   = nullptr;
  95 size_t Arguments::_conservative_max_heap_alignment = 0;
  96 Arguments::Mode Arguments::_mode                = _mixed;
  97 const char*  Arguments::_java_vendor_url_bug    = nullptr;
  98 const char*  Arguments::_sun_java_launcher      = DEFAULT_JAVA_LAUNCHER;
  99 bool   Arguments::_executing_unit_tests         = false;

1785     os::free(const_cast<char*>(_sun_java_launcher));
1786   }
1787   _sun_java_launcher = os::strdup_check_oom(launcher);
1788 }
1789 
1790 bool Arguments::created_by_java_launcher() {
1791   assert(_sun_java_launcher != nullptr, "property must have value");
1792   return strcmp(DEFAULT_JAVA_LAUNCHER, _sun_java_launcher) != 0;
1793 }
1794 
1795 bool Arguments::executing_unit_tests() {
1796   return _executing_unit_tests;
1797 }
1798 
1799 //===========================================================================================================
1800 // Parsing of main arguments
1801 
1802 static unsigned int addreads_count = 0;
1803 static unsigned int addexports_count = 0;
1804 static unsigned int addopens_count = 0;

1805 static unsigned int enable_native_access_count = 0;
1806 static unsigned int enable_final_field_mutation = 0;
1807 static bool patch_mod_javabase = false;
1808 
1809 // Check the consistency of vm_init_args
1810 bool Arguments::check_vm_args_consistency() {
1811   // This may modify compiler flags. Must be called before CompilerConfig::check_args_consistency()
1812   if (!CDSConfig::check_vm_args_consistency(mode_flag_cmd_line)) {
1813     return false;
1814   }
1815 
1816   // Method for adding checks for flag consistency.
1817   // The intent is to warn the user of all possible conflicts,
1818   // before returning an error.
1819   // Note: Needs platform-dependent factoring.
1820   bool status = true;
1821 
1822   if (TLABRefillWasteFraction == 0) {
1823     jio_fprintf(defaultStream::error_stream(),
1824                 "TLABRefillWasteFraction should be a denominator, "
1825                 "not %zu\n",
1826                 TLABRefillWasteFraction);
1827     status = false;
1828   }
1829 
1830   status = CompilerConfig::check_args_consistency(status);
1831 #if INCLUDE_JVMCI
1832   if (status && EnableJVMCI) {

2041   return false;
2042 }
2043 #endif
2044 
2045 int Arguments::process_patch_mod_option(const char* patch_mod_tail) {
2046   // --patch-module=<module>=<file>(<pathsep><file>)*
2047   assert(patch_mod_tail != nullptr, "Unexpected null patch-module value");
2048   // Find the equal sign between the module name and the path specification
2049   const char* module_equal = strchr(patch_mod_tail, '=');
2050   if (module_equal == nullptr) {
2051     jio_fprintf(defaultStream::output_stream(), "Missing '=' in --patch-module specification\n");
2052     return JNI_ERR;
2053   } else {
2054     // Pick out the module name
2055     size_t module_len = module_equal - patch_mod_tail;
2056     char* module_name = NEW_C_HEAP_ARRAY_RETURN_NULL(char, module_len+1, mtArguments);
2057     if (module_name != nullptr) {
2058       memcpy(module_name, patch_mod_tail, module_len);
2059       *(module_name + module_len) = '\0';
2060       // The path piece begins one past the module_equal sign
2061       add_patch_mod_prefix(module_name, module_equal + 1, false /* no append */, false /* no cds */);
2062       FREE_C_HEAP_ARRAY(char, module_name);



2063     } else {
2064       return JNI_ENOMEM;
2065     }
2066   }
2067   return JNI_OK;
2068 }
2069 
2070 // Finalize --patch-module args and --enable-preview related to value class module patches.
2071 // Create all numbered properties passing module patches.
2072 int Arguments::finalize_patch_module() {
2073   // Create numbered properties for each module that has been patched by --patch-module.
2074   // Format is "jdk.module.patch.<n>=<module_name>=<path>"
2075   if (_patch_mod_prefix != nullptr) {
2076     char * prop_value = AllocateHeap(JVM_MAXPATHLEN + JVM_MAXPATHLEN + 1, mtArguments);
2077     unsigned int patch_mod_count = 0;
2078 
2079     for (GrowableArrayIterator<ModulePatchPath *> it = _patch_mod_prefix->begin();
2080             it != _patch_mod_prefix->end(); ++it) {
2081       jio_snprintf(prop_value, JVM_MAXPATHLEN + JVM_MAXPATHLEN + 1, "%s=%s",
2082                    (*it)->module_name(), (*it)->path_string());
2083       if (!create_numbered_module_property("jdk.module.patch", prop_value, patch_mod_count++)) {
2084         FreeHeap(prop_value);
2085         return JNI_ENOMEM;
2086       }
2087     }
2088     FreeHeap(prop_value);
2089   }
2090   return JNI_OK;
2091 }
2092 
2093 // Parse -Xss memory string parameter and convert to ThreadStackSize in K.
2094 jint Arguments::parse_xss(const JavaVMOption* option, const char* tail, intx* out_ThreadStackSize) {
2095   // The min and max sizes match the values in globals.hpp, but scaled
2096   // with K. The values have been chosen so that alignment with page
2097   // size doesn't change the max value, which makes the conversions
2098   // back and forth between Xss value and ThreadStackSize value easier.
2099   // The values have also been chosen to fit inside a 32-bit signed type.
2100   const julong min_ThreadStackSize = 0;
2101   const julong max_ThreadStackSize = 1 * M;
2102 
2103   // Make sure the above values match the range set in globals.hpp
2104   const JVMTypedFlagLimit<intx>* limit = JVMFlagLimit::get_range_at(FLAG_MEMBER_ENUM(ThreadStackSize))->cast<intx>();
2105   assert(min_ThreadStackSize == static_cast<julong>(limit->min()), "must be");
2106   assert(max_ThreadStackSize == static_cast<julong>(limit->max()), "must be");
2107 
2108   const julong min_size = min_ThreadStackSize * K;
2109   const julong max_size = max_ThreadStackSize * K;
2110 
2111   assert(is_aligned(max_size, os::vm_page_size()), "Implementation assumption");
2112 

2864   }
2865 
2866   // PrintSharedArchiveAndExit will turn on
2867   //   -Xshare:on
2868   //   -Xlog:class+path=info
2869   if (PrintSharedArchiveAndExit) {
2870     UseSharedSpaces = true;
2871     RequireSharedSpaces = true;
2872     LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(class, path));
2873   }
2874 
2875   fix_appclasspath();
2876 
2877   return JNI_OK;
2878 }
2879 
2880 void Arguments::set_ext_dirs(char *value) {
2881   _ext_dirs = os::strdup_check_oom(value);
2882 }
2883 
2884 void Arguments::add_patch_mod_prefix(const char* module_name, const char* path, bool allow_append, bool allow_cds) {
2885   if (!allow_cds) {
2886     CDSConfig::set_module_patching_disables_cds();
2887     if (strcmp(module_name, JAVA_BASE_NAME) == 0) {
2888       CDSConfig::set_java_base_module_patching_disables_cds();





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

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

3902 #ifdef ZERO
3903   // Clear flags not supported on zero.
3904   FLAG_SET_DEFAULT(ProfileInterpreter, false);
3905 #endif // ZERO
3906 
3907   if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3908     warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3909     DebugNonSafepoints = true;
3910   }
3911 
3912   if (FLAG_IS_CMDLINE(CompressedClassSpaceSize) && !UseCompressedClassPointers) {
3913     warning("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used");
3914   }
3915 
3916   // Treat the odd case where local verification is enabled but remote
3917   // verification is not as if both were enabled.
3918   if (BytecodeVerificationLocal && !BytecodeVerificationRemote) {
3919     log_info(verification)("Turning on remote verification because local verification is on");
3920     FLAG_SET_DEFAULT(BytecodeVerificationRemote, true);
3921   }
3922   if (!is_valhalla_enabled()) {
3923 #define WARN_IF_NOT_DEFAULT_FLAG(flag)                                                                       \
3924     if (!FLAG_IS_DEFAULT(flag)) {                                                                            \
3925       warning("Valhalla-specific flag \"%s\" has no effect when --enable-preview is not specified.", #flag); \
3926     }
3927 
3928 #define DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(flag)  \
3929     WARN_IF_NOT_DEFAULT_FLAG(flag)                  \
3930     FLAG_SET_DEFAULT(flag, false);
3931 
3932     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(InlineTypePassFieldsAsArgs);
3933     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(InlineTypeReturnedAsFields);
3934     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseArrayFlattening);
3935     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseFieldFlattening);
3936     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNonAtomicValueFlattening);
3937     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullableValueFlattening);
3938     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseAtomicValueFlattening);
3939     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(PrintInlineLayout);
3940     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(PrintFlatArrayLayout);
3941     WARN_IF_NOT_DEFAULT_FLAG(FlatArrayElementMaxOops);
3942     WARN_IF_NOT_DEFAULT_FLAG(UseAltSubstitutabilityMethod);
3943 #ifdef ASSERT
3944     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(StressCallingConvention);
3945     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(PreloadClasses);
3946     WARN_IF_NOT_DEFAULT_FLAG(PrintInlineKlassFields);
3947 #endif
3948 #ifdef COMPILER1
3949     DEBUG_ONLY(DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(C1UseDelayedFlattenedFieldReads);)
3950 #endif
3951 #ifdef COMPILER2
3952     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseArrayLoadStoreProfile);
3953     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseACmpProfile);
3954 #endif
3955 #undef DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT
3956 #undef WARN_IF_NOT_DEFAULT_FLAG
3957   } else {
3958     if (is_interpreter_only() && !CDSConfig::is_dumping_archive() && !UseSharedSpaces) {
3959       // Disable calling convention optimizations if inline types are not supported.
3960       // Also these aren't useful in -Xint. However, don't disable them when dumping or using
3961       // the CDS archive, as the values must match between dumptime and runtime.
3962       FLAG_SET_DEFAULT(InlineTypePassFieldsAsArgs, false);
3963       FLAG_SET_DEFAULT(InlineTypeReturnedAsFields, false);
3964     }
3965     if (!UseNonAtomicValueFlattening && !UseNullableValueFlattening && !UseAtomicValueFlattening) {
3966       // Flattening is disabled
3967       FLAG_SET_DEFAULT(UseArrayFlattening, false);
3968       FLAG_SET_DEFAULT(UseFieldFlattening, false);
3969     }
3970   }
3971 
3972 #ifndef PRODUCT
3973   if (!LogVMOutput && FLAG_IS_DEFAULT(LogVMOutput)) {
3974     if (use_vm_log()) {
3975       LogVMOutput = true;
3976     }
3977   }
3978 #endif // PRODUCT
3979 
3980   if (PrintCommandLineFlags) {
3981     JVMFlag::printSetFlags(tty);
3982   }
3983 
3984 #if COMPILER2_OR_JVMCI
3985   if (!FLAG_IS_DEFAULT(EnableVectorSupport) && !EnableVectorSupport) {
3986     if (!FLAG_IS_DEFAULT(EnableVectorReboxing) && EnableVectorReboxing) {
3987       warning("Disabling EnableVectorReboxing since EnableVectorSupport is turned off.");
3988     }
3989     FLAG_SET_DEFAULT(EnableVectorReboxing, false);
3990 
< prev index next >