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/checkedCast.hpp"
68 #include "utilities/debug.hpp"
69 #include "utilities/defaultStream.hpp"
70 #include "utilities/macros.hpp"
71 #include "utilities/parseInteger.hpp"
72 #include "utilities/powerOfTwo.hpp"
73 #include "utilities/stringUtils.hpp"
74 #include "utilities/systemMemoryBarrier.hpp"
75 #if INCLUDE_JFR
76 #include "jfr/jfr.hpp"
77 #endif
78
79 static const char _default_java_launcher[] = "generic";
80
81 #define DEFAULT_JAVA_LAUNCHER _default_java_launcher
82
83 char* Arguments::_jvm_flags_file = nullptr;
84 char** Arguments::_jvm_flags_array = nullptr;
85 int Arguments::_num_jvm_flags = 0;
86 char** Arguments::_jvm_args_array = nullptr;
87 int Arguments::_num_jvm_args = 0;
88 unsigned int Arguments::_addmods_count = 0;
89 #if INCLUDE_JVMCI
90 bool Arguments::_jvmci_module_added = false;
91 #endif
92 char* Arguments::_java_command = nullptr;
93 SystemProperty* Arguments::_system_properties = nullptr;
94 size_t Arguments::_conservative_max_heap_alignment = 0;
95 Arguments::Mode Arguments::_mode = _mixed;
96 const char* Arguments::_java_vendor_url_bug = nullptr;
97 const char* Arguments::_sun_java_launcher = DEFAULT_JAVA_LAUNCHER;
98 bool Arguments::_executing_unit_tests = false;
1778 os::free(const_cast<char*>(_sun_java_launcher));
1779 }
1780 _sun_java_launcher = os::strdup_check_oom(launcher);
1781 }
1782
1783 bool Arguments::created_by_java_launcher() {
1784 assert(_sun_java_launcher != nullptr, "property must have value");
1785 return strcmp(DEFAULT_JAVA_LAUNCHER, _sun_java_launcher) != 0;
1786 }
1787
1788 bool Arguments::executing_unit_tests() {
1789 return _executing_unit_tests;
1790 }
1791
1792 //===========================================================================================================
1793 // Parsing of main arguments
1794
1795 static unsigned int addreads_count = 0;
1796 static unsigned int addexports_count = 0;
1797 static unsigned int addopens_count = 0;
1798 static unsigned int patch_mod_count = 0;
1799 static unsigned int enable_native_access_count = 0;
1800 static unsigned int enable_final_field_mutation = 0;
1801 static bool patch_mod_javabase = false;
1802
1803 // Check the consistency of vm_init_args
1804 bool Arguments::check_vm_args_consistency() {
1805 // This may modify compiler flags. Must be called before CompilerConfig::check_args_consistency()
1806 if (!CDSConfig::check_vm_args_consistency(patch_mod_javabase, mode_flag_cmd_line)) {
1807 return false;
1808 }
1809
1810 // Method for adding checks for flag consistency.
1811 // The intent is to warn the user of all possible conflicts,
1812 // before returning an error.
1813 // Note: Needs platform-dependent factoring.
1814 bool status = true;
1815
1816 if (TLABRefillWasteFraction == 0) {
1817 jio_fprintf(defaultStream::error_stream(),
1818 "TLABRefillWasteFraction should be a denominator, "
1819 "not %zu\n",
1820 TLABRefillWasteFraction);
1821 status = false;
1822 }
1823
1824 status = CompilerConfig::check_args_consistency(status);
1825 #if INCLUDE_JVMCI
1826 if (status && EnableJVMCI) {
1953
1954 // Remember the default value of SharedBaseAddress.
1955 Arguments::_default_SharedBaseAddress = SharedBaseAddress;
1956
1957 // Setup flags for mixed which is the default
1958 set_mode_flags(_mixed);
1959
1960 jint result;
1961 for (int i = 0; i < all_args->length(); i++) {
1962 result = parse_each_vm_init_arg(all_args->at(i)._args, all_args->at(i)._origin);
1963 if (result != JNI_OK) {
1964 return result;
1965 }
1966 }
1967
1968 // Disable CDS for exploded image
1969 if (!has_jimage()) {
1970 no_shared_spaces("CDS disabled on exploded JDK");
1971 }
1972
1973 // We need to ensure processor and memory resources have been properly
1974 // configured - which may rely on arguments we just processed - before
1975 // doing the final argument processing. Any argument processing that
1976 // needs to know about processor and memory resources must occur after
1977 // this point.
1978
1979 os::init_container_support();
1980
1981 SystemMemoryBarrier::initialize();
1982
1983 // Do final processing now that all arguments have been parsed
1984 result = finalize_vm_init_args();
1985 if (result != JNI_OK) {
1986 return result;
1987 }
1988
1989 return JNI_OK;
1990 }
1991
1992 #if !INCLUDE_JVMTI || INCLUDE_CDS
2035 return false;
2036 }
2037 #endif
2038
2039 int Arguments::process_patch_mod_option(const char* patch_mod_tail) {
2040 // --patch-module=<module>=<file>(<pathsep><file>)*
2041 assert(patch_mod_tail != nullptr, "Unexpected null patch-module value");
2042 // Find the equal sign between the module name and the path specification
2043 const char* module_equal = strchr(patch_mod_tail, '=');
2044 if (module_equal == nullptr) {
2045 jio_fprintf(defaultStream::output_stream(), "Missing '=' in --patch-module specification\n");
2046 return JNI_ERR;
2047 } else {
2048 // Pick out the module name
2049 size_t module_len = module_equal - patch_mod_tail;
2050 char* module_name = NEW_C_HEAP_ARRAY_RETURN_NULL(char, module_len+1, mtArguments);
2051 if (module_name != nullptr) {
2052 memcpy(module_name, patch_mod_tail, module_len);
2053 *(module_name + module_len) = '\0';
2054 // The path piece begins one past the module_equal sign
2055 add_patch_mod_prefix(module_name, module_equal + 1);
2056 FREE_C_HEAP_ARRAY(char, module_name);
2057 if (!create_numbered_module_property("jdk.module.patch", patch_mod_tail, patch_mod_count++)) {
2058 return JNI_ENOMEM;
2059 }
2060 } else {
2061 return JNI_ENOMEM;
2062 }
2063 }
2064 return JNI_OK;
2065 }
2066
2067 // Parse -Xss memory string parameter and convert to ThreadStackSize in K.
2068 jint Arguments::parse_xss(const JavaVMOption* option, const char* tail, intx* out_ThreadStackSize) {
2069 // The min and max sizes match the values in globals.hpp, but scaled
2070 // with K. The values have been chosen so that alignment with page
2071 // size doesn't change the max value, which makes the conversions
2072 // back and forth between Xss value and ThreadStackSize value easier.
2073 // The values have also been chosen to fit inside a 32-bit signed type.
2074 const julong min_ThreadStackSize = 0;
2075 const julong max_ThreadStackSize = 1 * M;
2076
2077 // Make sure the above values match the range set in globals.hpp
2078 const JVMTypedFlagLimit<intx>* limit = JVMFlagLimit::get_range_at(FLAG_MEMBER_ENUM(ThreadStackSize))->cast<intx>();
2079 assert(min_ThreadStackSize == static_cast<julong>(limit->min()), "must be");
2080 assert(max_ThreadStackSize == static_cast<julong>(limit->max()), "must be");
2081
2082 const julong min_size = min_ThreadStackSize * K;
2083 const julong max_size = max_ThreadStackSize * K;
2084
2085 assert(is_aligned(max_size, os::vm_page_size()), "Implementation assumption");
2086
2838 }
2839
2840 // PrintSharedArchiveAndExit will turn on
2841 // -Xshare:on
2842 // -Xlog:class+path=info
2843 if (PrintSharedArchiveAndExit) {
2844 UseSharedSpaces = true;
2845 RequireSharedSpaces = true;
2846 LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(class, path));
2847 }
2848
2849 fix_appclasspath();
2850
2851 return JNI_OK;
2852 }
2853
2854 void Arguments::set_ext_dirs(char *value) {
2855 _ext_dirs = os::strdup_check_oom(value);
2856 }
2857
2858 void Arguments::add_patch_mod_prefix(const char* module_name, const char* path) {
2859 // For java.base check for duplicate --patch-module options being specified on the command line.
2860 // This check is only required for java.base, all other duplicate module specifications
2861 // will be checked during module system initialization. The module system initialization
2862 // will throw an ExceptionInInitializerError if this situation occurs.
2863 if (strcmp(module_name, JAVA_BASE_NAME) == 0) {
2864 if (patch_mod_javabase) {
2865 vm_exit_during_initialization("Cannot specify " JAVA_BASE_NAME " more than once to --patch-module");
2866 } else {
2867 patch_mod_javabase = true;
2868 }
2869 }
2870
2871 // Create GrowableArray lazily, only if --patch-module has been specified
2872 if (_patch_mod_prefix == nullptr) {
2873 _patch_mod_prefix = new (mtArguments) GrowableArray<ModulePatchPath*>(10, mtArguments);
2874 }
2875
2876 _patch_mod_prefix->push(new ModulePatchPath(module_name, path));
2877 }
2878
2879 // Remove all empty paths from the app classpath (if IgnoreEmptyClassPaths is enabled)
2880 //
2881 // This is necessary because some apps like to specify classpath like -cp foo.jar:${XYZ}:bar.jar
2882 // in their start-up scripts. If XYZ is empty, the classpath will look like "-cp foo.jar::bar.jar".
2883 // Java treats such empty paths as if the user specified "-cp foo.jar:.:bar.jar". I.e., an empty
2884 // path is treated as the current directory.
2885 //
2886 // This causes problems with CDS, which requires that all directories specified in the classpath
2887 // must be empty. In most cases, applications do NOT want to load classes from the current
2888 // directory anyway. Adding -XX:+IgnoreEmptyClassPaths will make these applications' start-up
2889 // scripts compatible with CDS.
2890 void Arguments::fix_appclasspath() {
2891 if (IgnoreEmptyClassPaths) {
2892 const char separator = *os::path_separator();
2893 const char* src = _java_class_path->value();
2894
2895 // skip over all the leading empty paths
2896 while (*src == separator) {
2969 }
2970
2971 #if !COMPILER2_OR_JVMCI
2972 // Don't degrade server performance for footprint
2973 if (FLAG_IS_DEFAULT(UseLargePages) &&
2974 MaxHeapSize < LargePageHeapSizeThreshold) {
2975 // No need for large granularity pages w/small heaps.
2976 // Note that large pages are enabled/disabled for both the
2977 // Java heap and the code cache.
2978 FLAG_SET_DEFAULT(UseLargePages, false);
2979 }
2980
2981 UNSUPPORTED_OPTION(ProfileInterpreter);
2982 #endif
2983
2984 // Parse the CompilationMode flag
2985 if (!CompilationModeFlag::initialize()) {
2986 return JNI_ERR;
2987 }
2988
2989 if (!check_vm_args_consistency()) {
2990 return JNI_ERR;
2991 }
2992
2993
2994 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
2995 UNSUPPORTED_OPTION(ShowRegistersOnAssert);
2996 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
2997
2998 return JNI_OK;
2999 }
3000
3001 // Helper class for controlling the lifetime of JavaVMInitArgs
3002 // objects. The contents of the JavaVMInitArgs are guaranteed to be
3003 // deleted on the destruction of the ScopedVMInitArgs object.
3004 class ScopedVMInitArgs : public StackObj {
3005 private:
3006 JavaVMInitArgs _args;
3007 char* _container_name;
3008 bool _is_set;
3009 char* _vm_options_file_arg;
3010
3011 public:
3012 ScopedVMInitArgs(const char *container_name) {
3858 #ifdef ZERO
3859 // Clear flags not supported on zero.
3860 FLAG_SET_DEFAULT(ProfileInterpreter, false);
3861 #endif // ZERO
3862
3863 if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3864 warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3865 DebugNonSafepoints = true;
3866 }
3867
3868 if (FLAG_IS_CMDLINE(CompressedClassSpaceSize) && !UseCompressedClassPointers) {
3869 warning("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used");
3870 }
3871
3872 // Treat the odd case where local verification is enabled but remote
3873 // verification is not as if both were enabled.
3874 if (BytecodeVerificationLocal && !BytecodeVerificationRemote) {
3875 log_info(verification)("Turning on remote verification because local verification is on");
3876 FLAG_SET_DEFAULT(BytecodeVerificationRemote, true);
3877 }
3878
3879 #ifndef PRODUCT
3880 if (!LogVMOutput && FLAG_IS_DEFAULT(LogVMOutput)) {
3881 if (use_vm_log()) {
3882 LogVMOutput = true;
3883 }
3884 }
3885 #endif // PRODUCT
3886
3887 if (PrintCommandLineFlags) {
3888 JVMFlag::printSetFlags(tty);
3889 }
3890
3891 #if COMPILER2_OR_JVMCI
3892 if (!FLAG_IS_DEFAULT(EnableVectorSupport) && !EnableVectorSupport) {
3893 if (!FLAG_IS_DEFAULT(EnableVectorReboxing) && EnableVectorReboxing) {
3894 warning("Disabling EnableVectorReboxing since EnableVectorSupport is turned off.");
3895 }
3896 FLAG_SET_DEFAULT(EnableVectorReboxing, false);
3897
|
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/checkedCast.hpp"
68 #include "utilities/debug.hpp"
69 #include "utilities/defaultStream.hpp"
70 #include "utilities/macros.hpp"
71 #include "utilities/parseInteger.hpp"
72 #include "utilities/powerOfTwo.hpp"
73 #include "utilities/stringUtils.hpp"
74 #include "utilities/systemMemoryBarrier.hpp"
75 #if INCLUDE_JFR
76 #include "jfr/jfr.hpp"
77 #endif
78
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 #if INCLUDE_JVMCI
92 bool Arguments::_jvmci_module_added = false;
93 #endif
94 char* Arguments::_java_command = nullptr;
95 SystemProperty* Arguments::_system_properties = nullptr;
96 size_t Arguments::_conservative_max_heap_alignment = 0;
97 Arguments::Mode Arguments::_mode = _mixed;
98 const char* Arguments::_java_vendor_url_bug = nullptr;
99 const char* Arguments::_sun_java_launcher = DEFAULT_JAVA_LAUNCHER;
100 bool Arguments::_executing_unit_tests = false;
1780 os::free(const_cast<char*>(_sun_java_launcher));
1781 }
1782 _sun_java_launcher = os::strdup_check_oom(launcher);
1783 }
1784
1785 bool Arguments::created_by_java_launcher() {
1786 assert(_sun_java_launcher != nullptr, "property must have value");
1787 return strcmp(DEFAULT_JAVA_LAUNCHER, _sun_java_launcher) != 0;
1788 }
1789
1790 bool Arguments::executing_unit_tests() {
1791 return _executing_unit_tests;
1792 }
1793
1794 //===========================================================================================================
1795 // Parsing of main arguments
1796
1797 static unsigned int addreads_count = 0;
1798 static unsigned int addexports_count = 0;
1799 static unsigned int addopens_count = 0;
1800 static unsigned int enable_native_access_count = 0;
1801 static unsigned int enable_final_field_mutation = 0;
1802 static bool patch_mod_javabase = false;
1803
1804 // Check the consistency of vm_init_args
1805 bool Arguments::check_vm_args_consistency() {
1806 // This may modify compiler flags. Must be called before CompilerConfig::check_args_consistency()
1807 if (!CDSConfig::check_vm_args_consistency(mode_flag_cmd_line)) {
1808 return false;
1809 }
1810
1811 // Method for adding checks for flag consistency.
1812 // The intent is to warn the user of all possible conflicts,
1813 // before returning an error.
1814 // Note: Needs platform-dependent factoring.
1815 bool status = true;
1816
1817 if (TLABRefillWasteFraction == 0) {
1818 jio_fprintf(defaultStream::error_stream(),
1819 "TLABRefillWasteFraction should be a denominator, "
1820 "not %zu\n",
1821 TLABRefillWasteFraction);
1822 status = false;
1823 }
1824
1825 status = CompilerConfig::check_args_consistency(status);
1826 #if INCLUDE_JVMCI
1827 if (status && EnableJVMCI) {
1954
1955 // Remember the default value of SharedBaseAddress.
1956 Arguments::_default_SharedBaseAddress = SharedBaseAddress;
1957
1958 // Setup flags for mixed which is the default
1959 set_mode_flags(_mixed);
1960
1961 jint result;
1962 for (int i = 0; i < all_args->length(); i++) {
1963 result = parse_each_vm_init_arg(all_args->at(i)._args, all_args->at(i)._origin);
1964 if (result != JNI_OK) {
1965 return result;
1966 }
1967 }
1968
1969 // Disable CDS for exploded image
1970 if (!has_jimage()) {
1971 no_shared_spaces("CDS disabled on exploded JDK");
1972 }
1973
1974 if (UseAltSubstitutabilityMethod) {
1975 no_shared_spaces("Alternate substitutability method doesn't work with CDS yet");
1976 }
1977
1978 // We need to ensure processor and memory resources have been properly
1979 // configured - which may rely on arguments we just processed - before
1980 // doing the final argument processing. Any argument processing that
1981 // needs to know about processor and memory resources must occur after
1982 // this point.
1983
1984 os::init_container_support();
1985
1986 SystemMemoryBarrier::initialize();
1987
1988 // Do final processing now that all arguments have been parsed
1989 result = finalize_vm_init_args();
1990 if (result != JNI_OK) {
1991 return result;
1992 }
1993
1994 return JNI_OK;
1995 }
1996
1997 #if !INCLUDE_JVMTI || INCLUDE_CDS
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, false /* no append */, false /* no cds */);
2061 FREE_C_HEAP_ARRAY(char, module_name);
2062 } else {
2063 return JNI_ENOMEM;
2064 }
2065 }
2066 return JNI_OK;
2067 }
2068
2069 // Finalize --patch-module args and --enable-preview related to value class module patches.
2070 // Create all numbered properties passing module patches.
2071 int Arguments::finalize_patch_module() {
2072 // Create numbered properties for each module that has been patched by --patch-module.
2073 // Format is "jdk.module.patch.<n>=<module_name>=<path>"
2074 if (_patch_mod_prefix != nullptr) {
2075 char * prop_value = AllocateHeap(JVM_MAXPATHLEN + JVM_MAXPATHLEN + 1, mtArguments);
2076 unsigned int patch_mod_count = 0;
2077
2078 for (GrowableArrayIterator<ModulePatchPath *> it = _patch_mod_prefix->begin();
2079 it != _patch_mod_prefix->end(); ++it) {
2080 jio_snprintf(prop_value, JVM_MAXPATHLEN + JVM_MAXPATHLEN + 1, "%s=%s",
2081 (*it)->module_name(), (*it)->path_string());
2082 if (!create_numbered_module_property("jdk.module.patch", prop_value, patch_mod_count++)) {
2083 FreeHeap(prop_value);
2084 return JNI_ENOMEM;
2085 }
2086 }
2087 FreeHeap(prop_value);
2088 }
2089 return JNI_OK;
2090 }
2091
2092 // Parse -Xss memory string parameter and convert to ThreadStackSize in K.
2093 jint Arguments::parse_xss(const JavaVMOption* option, const char* tail, intx* out_ThreadStackSize) {
2094 // The min and max sizes match the values in globals.hpp, but scaled
2095 // with K. The values have been chosen so that alignment with page
2096 // size doesn't change the max value, which makes the conversions
2097 // back and forth between Xss value and ThreadStackSize value easier.
2098 // The values have also been chosen to fit inside a 32-bit signed type.
2099 const julong min_ThreadStackSize = 0;
2100 const julong max_ThreadStackSize = 1 * M;
2101
2102 // Make sure the above values match the range set in globals.hpp
2103 const JVMTypedFlagLimit<intx>* limit = JVMFlagLimit::get_range_at(FLAG_MEMBER_ENUM(ThreadStackSize))->cast<intx>();
2104 assert(min_ThreadStackSize == static_cast<julong>(limit->min()), "must be");
2105 assert(max_ThreadStackSize == static_cast<julong>(limit->max()), "must be");
2106
2107 const julong min_size = min_ThreadStackSize * K;
2108 const julong max_size = max_ThreadStackSize * K;
2109
2110 assert(is_aligned(max_size, os::vm_page_size()), "Implementation assumption");
2111
2863 }
2864
2865 // PrintSharedArchiveAndExit will turn on
2866 // -Xshare:on
2867 // -Xlog:class+path=info
2868 if (PrintSharedArchiveAndExit) {
2869 UseSharedSpaces = true;
2870 RequireSharedSpaces = true;
2871 LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(class, path));
2872 }
2873
2874 fix_appclasspath();
2875
2876 return JNI_OK;
2877 }
2878
2879 void Arguments::set_ext_dirs(char *value) {
2880 _ext_dirs = os::strdup_check_oom(value);
2881 }
2882
2883 void Arguments::add_patch_mod_prefix(const char* module_name, const char* path, bool allow_append, bool allow_cds) {
2884 if (!allow_cds) {
2885 CDSConfig::set_module_patching_disables_cds();
2886 if (strcmp(module_name, JAVA_BASE_NAME) == 0) {
2887 CDSConfig::set_java_base_module_patching_disables_cds();
2888 }
2889 }
2890
2891 // Create GrowableArray lazily, only if --patch-module has been specified
2892 if (_patch_mod_prefix == nullptr) {
2893 _patch_mod_prefix = new (mtArguments) GrowableArray<ModulePatchPath*>(10, mtArguments);
2894 }
2895
2896 // Scan patches for matching module
2897 int i = _patch_mod_prefix->find_if([&](ModulePatchPath* patch) {
2898 return (strcmp(module_name, patch->module_name()) == 0);
2899 });
2900 if (i == -1) {
2901 _patch_mod_prefix->push(new ModulePatchPath(module_name, path));
2902 } else {
2903 if (allow_append) {
2904 // append path to existing module entry
2905 _patch_mod_prefix->at(i)->append_path(path);
2906 } else {
2907 if (strcmp(module_name, JAVA_BASE_NAME) == 0) {
2908 vm_exit_during_initialization("Cannot specify " JAVA_BASE_NAME " more than once to --patch-module");
2909 } else {
2910 vm_exit_during_initialization("Cannot specify a module more than once to --patch-module", module_name);
2911 }
2912 }
2913 }
2914 }
2915
2916 // Remove all empty paths from the app classpath (if IgnoreEmptyClassPaths is enabled)
2917 //
2918 // This is necessary because some apps like to specify classpath like -cp foo.jar:${XYZ}:bar.jar
2919 // in their start-up scripts. If XYZ is empty, the classpath will look like "-cp foo.jar::bar.jar".
2920 // Java treats such empty paths as if the user specified "-cp foo.jar:.:bar.jar". I.e., an empty
2921 // path is treated as the current directory.
2922 //
2923 // This causes problems with CDS, which requires that all directories specified in the classpath
2924 // must be empty. In most cases, applications do NOT want to load classes from the current
2925 // directory anyway. Adding -XX:+IgnoreEmptyClassPaths will make these applications' start-up
2926 // scripts compatible with CDS.
2927 void Arguments::fix_appclasspath() {
2928 if (IgnoreEmptyClassPaths) {
2929 const char separator = *os::path_separator();
2930 const char* src = _java_class_path->value();
2931
2932 // skip over all the leading empty paths
2933 while (*src == separator) {
3006 }
3007
3008 #if !COMPILER2_OR_JVMCI
3009 // Don't degrade server performance for footprint
3010 if (FLAG_IS_DEFAULT(UseLargePages) &&
3011 MaxHeapSize < LargePageHeapSizeThreshold) {
3012 // No need for large granularity pages w/small heaps.
3013 // Note that large pages are enabled/disabled for both the
3014 // Java heap and the code cache.
3015 FLAG_SET_DEFAULT(UseLargePages, false);
3016 }
3017
3018 UNSUPPORTED_OPTION(ProfileInterpreter);
3019 #endif
3020
3021 // Parse the CompilationMode flag
3022 if (!CompilationModeFlag::initialize()) {
3023 return JNI_ERR;
3024 }
3025
3026 ClassLoader::set_preview_mode(is_valhalla_enabled());
3027
3028 // finalize --module-patch.
3029 if (finalize_patch_module() != JNI_OK) {
3030 return JNI_ERR;
3031 }
3032
3033 if (!check_vm_args_consistency()) {
3034 return JNI_ERR;
3035 }
3036
3037 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
3038 UNSUPPORTED_OPTION(ShowRegistersOnAssert);
3039 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
3040
3041 return JNI_OK;
3042 }
3043
3044 // Helper class for controlling the lifetime of JavaVMInitArgs
3045 // objects. The contents of the JavaVMInitArgs are guaranteed to be
3046 // deleted on the destruction of the ScopedVMInitArgs object.
3047 class ScopedVMInitArgs : public StackObj {
3048 private:
3049 JavaVMInitArgs _args;
3050 char* _container_name;
3051 bool _is_set;
3052 char* _vm_options_file_arg;
3053
3054 public:
3055 ScopedVMInitArgs(const char *container_name) {
3901 #ifdef ZERO
3902 // Clear flags not supported on zero.
3903 FLAG_SET_DEFAULT(ProfileInterpreter, false);
3904 #endif // ZERO
3905
3906 if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3907 warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3908 DebugNonSafepoints = true;
3909 }
3910
3911 if (FLAG_IS_CMDLINE(CompressedClassSpaceSize) && !UseCompressedClassPointers) {
3912 warning("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used");
3913 }
3914
3915 // Treat the odd case where local verification is enabled but remote
3916 // verification is not as if both were enabled.
3917 if (BytecodeVerificationLocal && !BytecodeVerificationRemote) {
3918 log_info(verification)("Turning on remote verification because local verification is on");
3919 FLAG_SET_DEFAULT(BytecodeVerificationRemote, true);
3920 }
3921 if (!is_valhalla_enabled()) {
3922 #define WARN_IF_NOT_DEFAULT_FLAG(flag) \
3923 if (!FLAG_IS_DEFAULT(flag)) { \
3924 warning("Valhalla-specific flag \"%s\" has no effect when --enable-preview is not specified.", #flag); \
3925 }
3926
3927 #define DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(flag) \
3928 WARN_IF_NOT_DEFAULT_FLAG(flag) \
3929 FLAG_SET_DEFAULT(flag, false);
3930
3931 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(InlineTypePassFieldsAsArgs);
3932 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(InlineTypeReturnedAsFields);
3933 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseArrayFlattening);
3934 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseFieldFlattening);
3935 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNonAtomicValueFlattening);
3936 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullableValueFlattening);
3937 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseAtomicValueFlattening);
3938 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(PrintInlineLayout);
3939 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(PrintFlatArrayLayout);
3940 WARN_IF_NOT_DEFAULT_FLAG(FlatArrayElementMaxOops);
3941 WARN_IF_NOT_DEFAULT_FLAG(UseAltSubstitutabilityMethod);
3942 #ifdef ASSERT
3943 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(StressCallingConvention);
3944 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(PreloadClasses);
3945 WARN_IF_NOT_DEFAULT_FLAG(PrintInlineKlassFields);
3946 #endif
3947 #ifdef COMPILER1
3948 DEBUG_ONLY(DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(C1UseDelayedFlattenedFieldReads);)
3949 #endif
3950 #ifdef COMPILER2
3951 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseArrayLoadStoreProfile);
3952 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseACmpProfile);
3953 #endif
3954 #undef DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT
3955 #undef WARN_IF_NOT_DEFAULT_FLAG
3956 } else {
3957 if (is_interpreter_only() && !CDSConfig::is_dumping_archive() && !UseSharedSpaces) {
3958 // Disable calling convention optimizations if inline types are not supported.
3959 // Also these aren't useful in -Xint. However, don't disable them when dumping or using
3960 // the CDS archive, as the values must match between dumptime and runtime.
3961 FLAG_SET_DEFAULT(InlineTypePassFieldsAsArgs, false);
3962 FLAG_SET_DEFAULT(InlineTypeReturnedAsFields, false);
3963 }
3964 if (!UseNonAtomicValueFlattening && !UseNullableValueFlattening && !UseAtomicValueFlattening) {
3965 // Flattening is disabled
3966 FLAG_SET_DEFAULT(UseArrayFlattening, false);
3967 FLAG_SET_DEFAULT(UseFieldFlattening, false);
3968 }
3969 }
3970
3971 #ifndef PRODUCT
3972 if (!LogVMOutput && FLAG_IS_DEFAULT(LogVMOutput)) {
3973 if (use_vm_log()) {
3974 LogVMOutput = true;
3975 }
3976 }
3977 #endif // PRODUCT
3978
3979 if (PrintCommandLineFlags) {
3980 JVMFlag::printSetFlags(tty);
3981 }
3982
3983 #if COMPILER2_OR_JVMCI
3984 if (!FLAG_IS_DEFAULT(EnableVectorSupport) && !EnableVectorSupport) {
3985 if (!FLAG_IS_DEFAULT(EnableVectorReboxing) && EnableVectorReboxing) {
3986 warning("Disabling EnableVectorReboxing since EnableVectorSupport is turned off.");
3987 }
3988 FLAG_SET_DEFAULT(EnableVectorReboxing, false);
3989
|