38 #include "gc/shared/genArguments.hpp"
39 #include "gc/shared/stringdedup/stringDedup.hpp"
40 #include "gc/shared/tlab_globals.hpp"
41 #include "jvm.h"
42 #include "logging/log.hpp"
43 #include "logging/logConfiguration.hpp"
44 #include "logging/logStream.hpp"
45 #include "logging/logTag.hpp"
46 #include "memory/allocation.inline.hpp"
47 #include "nmt/nmtCommon.hpp"
48 #include "oops/compressedKlass.hpp"
49 #include "oops/instanceKlass.hpp"
50 #include "oops/objLayout.hpp"
51 #include "oops/oop.inline.hpp"
52 #include "prims/jvmtiAgentList.hpp"
53 #include "prims/jvmtiExport.hpp"
54 #include "runtime/arguments.hpp"
55 #include "runtime/flags/jvmFlag.hpp"
56 #include "runtime/flags/jvmFlagAccess.hpp"
57 #include "runtime/flags/jvmFlagLimit.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 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;
2968 }
2969
2970 #if !COMPILER2_OR_JVMCI
2971 // Don't degrade server performance for footprint
2972 if (FLAG_IS_DEFAULT(UseLargePages) &&
2973 MaxHeapSize < LargePageHeapSizeThreshold) {
2974 // No need for large granularity pages w/small heaps.
2975 // Note that large pages are enabled/disabled for both the
2976 // Java heap and the code cache.
2977 FLAG_SET_DEFAULT(UseLargePages, false);
2978 }
2979
2980 UNSUPPORTED_OPTION(ProfileInterpreter);
2981 #endif
2982
2983 // Parse the CompilationMode flag
2984 if (!CompilationModeFlag::initialize()) {
2985 return JNI_ERR;
2986 }
2987
2988 if (!check_vm_args_consistency()) {
2989 return JNI_ERR;
2990 }
2991
2992
2993 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
2994 UNSUPPORTED_OPTION(ShowRegistersOnAssert);
2995 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
2996
2997 return JNI_OK;
2998 }
2999
3000 // Helper class for controlling the lifetime of JavaVMInitArgs
3001 // objects. The contents of the JavaVMInitArgs are guaranteed to be
3002 // deleted on the destruction of the ScopedVMInitArgs object.
3003 class ScopedVMInitArgs : public StackObj {
3004 private:
3005 JavaVMInitArgs _args;
3006 char* _container_name;
3007 bool _is_set;
3008 char* _vm_options_file_arg;
3009
3010 public:
3011 ScopedVMInitArgs(const char *container_name) {
3012 _args.version = JNI_VERSION_1_2;
3857 #ifdef ZERO
3858 // Clear flags not supported on zero.
3859 FLAG_SET_DEFAULT(ProfileInterpreter, false);
3860 #endif // ZERO
3861
3862 if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3863 warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3864 DebugNonSafepoints = true;
3865 }
3866
3867 if (FLAG_IS_CMDLINE(CompressedClassSpaceSize) && !UseCompressedClassPointers) {
3868 warning("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used");
3869 }
3870
3871 // Treat the odd case where local verification is enabled but remote
3872 // verification is not as if both were enabled.
3873 if (BytecodeVerificationLocal && !BytecodeVerificationRemote) {
3874 log_info(verification)("Turning on remote verification because local verification is on");
3875 FLAG_SET_DEFAULT(BytecodeVerificationRemote, true);
3876 }
3877
3878 #ifndef PRODUCT
3879 if (!LogVMOutput && FLAG_IS_DEFAULT(LogVMOutput)) {
3880 if (use_vm_log()) {
3881 LogVMOutput = true;
3882 }
3883 }
3884 #endif // PRODUCT
3885
3886 if (PrintCommandLineFlags) {
3887 JVMFlag::printSetFlags(tty);
3888 }
3889
3890 #if COMPILER2_OR_JVMCI
3891 if (!FLAG_IS_DEFAULT(EnableVectorSupport) && !EnableVectorSupport) {
3892 if (!FLAG_IS_DEFAULT(EnableVectorReboxing) && EnableVectorReboxing) {
3893 warning("Disabling EnableVectorReboxing since EnableVectorSupport is turned off.");
3894 }
3895 FLAG_SET_DEFAULT(EnableVectorReboxing, false);
3896
|
38 #include "gc/shared/genArguments.hpp"
39 #include "gc/shared/stringdedup/stringDedup.hpp"
40 #include "gc/shared/tlab_globals.hpp"
41 #include "jvm.h"
42 #include "logging/log.hpp"
43 #include "logging/logConfiguration.hpp"
44 #include "logging/logStream.hpp"
45 #include "logging/logTag.hpp"
46 #include "memory/allocation.inline.hpp"
47 #include "nmt/nmtCommon.hpp"
48 #include "oops/compressedKlass.hpp"
49 #include "oops/instanceKlass.hpp"
50 #include "oops/objLayout.hpp"
51 #include "oops/oop.inline.hpp"
52 #include "prims/jvmtiAgentList.hpp"
53 #include "prims/jvmtiExport.hpp"
54 #include "runtime/arguments.hpp"
55 #include "runtime/flags/jvmFlag.hpp"
56 #include "runtime/flags/jvmFlagAccess.hpp"
57 #include "runtime/flags/jvmFlagLimit.hpp"
58 #include "runtime/globals.hpp"
59 #include "runtime/globals_extension.hpp"
60 #include "runtime/java.hpp"
61 #include "runtime/os.hpp"
62 #include "runtime/safepoint.hpp"
63 #include "runtime/safepointMechanism.hpp"
64 #include "runtime/synchronizer.hpp"
65 #include "runtime/vm_version.hpp"
66 #include "services/management.hpp"
67 #include "utilities/align.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;
2971 }
2972
2973 #if !COMPILER2_OR_JVMCI
2974 // Don't degrade server performance for footprint
2975 if (FLAG_IS_DEFAULT(UseLargePages) &&
2976 MaxHeapSize < LargePageHeapSizeThreshold) {
2977 // No need for large granularity pages w/small heaps.
2978 // Note that large pages are enabled/disabled for both the
2979 // Java heap and the code cache.
2980 FLAG_SET_DEFAULT(UseLargePages, false);
2981 }
2982
2983 UNSUPPORTED_OPTION(ProfileInterpreter);
2984 #endif
2985
2986 // Parse the CompilationMode flag
2987 if (!CompilationModeFlag::initialize()) {
2988 return JNI_ERR;
2989 }
2990
2991 ClassLoader::set_preview_mode(is_valhalla_enabled());
2992
2993 if (!check_vm_args_consistency()) {
2994 return JNI_ERR;
2995 }
2996
2997 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
2998 UNSUPPORTED_OPTION(ShowRegistersOnAssert);
2999 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
3000
3001 return JNI_OK;
3002 }
3003
3004 // Helper class for controlling the lifetime of JavaVMInitArgs
3005 // objects. The contents of the JavaVMInitArgs are guaranteed to be
3006 // deleted on the destruction of the ScopedVMInitArgs object.
3007 class ScopedVMInitArgs : public StackObj {
3008 private:
3009 JavaVMInitArgs _args;
3010 char* _container_name;
3011 bool _is_set;
3012 char* _vm_options_file_arg;
3013
3014 public:
3015 ScopedVMInitArgs(const char *container_name) {
3016 _args.version = JNI_VERSION_1_2;
3861 #ifdef ZERO
3862 // Clear flags not supported on zero.
3863 FLAG_SET_DEFAULT(ProfileInterpreter, false);
3864 #endif // ZERO
3865
3866 if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3867 warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3868 DebugNonSafepoints = true;
3869 }
3870
3871 if (FLAG_IS_CMDLINE(CompressedClassSpaceSize) && !UseCompressedClassPointers) {
3872 warning("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used");
3873 }
3874
3875 // Treat the odd case where local verification is enabled but remote
3876 // verification is not as if both were enabled.
3877 if (BytecodeVerificationLocal && !BytecodeVerificationRemote) {
3878 log_info(verification)("Turning on remote verification because local verification is on");
3879 FLAG_SET_DEFAULT(BytecodeVerificationRemote, true);
3880 }
3881 if (!is_valhalla_enabled()) {
3882 #define WARN_IF_NOT_DEFAULT_FLAG(flag) \
3883 if (!FLAG_IS_DEFAULT(flag)) { \
3884 warning("Preview-specific flag \"%s\" has no effect when --enable-preview is not specified.", #flag); \
3885 }
3886
3887 #define DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(flag) \
3888 WARN_IF_NOT_DEFAULT_FLAG(flag) \
3889 FLAG_SET_DEFAULT(flag, false);
3890
3891 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(InlineTypePassFieldsAsArgs);
3892 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(InlineTypeReturnedAsFields);
3893 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseArrayFlattening);
3894 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseFieldFlattening);
3895 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullFreeNonAtomicValueFlattening);
3896 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullableAtomicValueFlattening);
3897 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullFreeAtomicValueFlattening);
3898 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullableNonAtomicValueFlattening);
3899 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(PrintInlineLayout);
3900 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(PrintFlatArrayLayout);
3901 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(IgnoreAssertUnsetFields);
3902 WARN_IF_NOT_DEFAULT_FLAG(FlatArrayElementMaxOops);
3903 WARN_IF_NOT_DEFAULT_FLAG(ForceNonTearable);
3904 #ifdef ASSERT
3905 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(StressCallingConvention);
3906 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(PreloadClasses);
3907 WARN_IF_NOT_DEFAULT_FLAG(PrintInlineKlassFields);
3908 #endif
3909 #ifdef COMPILER1
3910 DEBUG_ONLY(DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(C1UseDelayedFlattenedFieldReads);)
3911 #endif
3912 #ifdef COMPILER2
3913 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseArrayLoadStoreProfile);
3914 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseACmpProfile);
3915 #endif
3916 #undef DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT
3917 #undef WARN_IF_NOT_DEFAULT_FLAG
3918 } else {
3919 #define DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(flag, fallback) \
3920 if (!FLAG_IS_DEFAULT(flag) && !UseArrayFlattening && !UseFieldFlattening) { \
3921 warning("Flattening flag \"%s\" has no effect when all flattening modes are disabled.", #flag); \
3922 FLAG_SET_DEFAULT(flag, fallback); \
3923 }
3924
3925 DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(UseNullFreeNonAtomicValueFlattening, false);
3926 DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(UseNullableAtomicValueFlattening, false);
3927 DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(UseNullFreeAtomicValueFlattening, false);
3928 DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(UseNullableNonAtomicValueFlattening, false);
3929 DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(FlatArrayElementMaxOops, 0);
3930 #undef DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING
3931 if (is_interpreter_only() && !CDSConfig::is_dumping_archive() && !UseSharedSpaces) {
3932 // Disable calling convention optimizations if inline types are not supported.
3933 // Also these aren't useful in -Xint. However, don't disable them when dumping or using
3934 // the CDS archive, as the values must match between dumptime and runtime.
3935 FLAG_SET_DEFAULT(InlineTypePassFieldsAsArgs, false);
3936 FLAG_SET_DEFAULT(InlineTypeReturnedAsFields, false);
3937 }
3938 if (!UseNullFreeNonAtomicValueFlattening &&
3939 !UseNullableAtomicValueFlattening &&
3940 !UseNullFreeAtomicValueFlattening &&
3941 !UseNullableNonAtomicValueFlattening) {
3942 // Flattening is disabled
3943 FLAG_SET_DEFAULT(UseArrayFlattening, false);
3944 FLAG_SET_DEFAULT(UseFieldFlattening, false);
3945 }
3946 }
3947
3948 #ifndef PRODUCT
3949 if (!LogVMOutput && FLAG_IS_DEFAULT(LogVMOutput)) {
3950 if (use_vm_log()) {
3951 LogVMOutput = true;
3952 }
3953 }
3954 #endif // PRODUCT
3955
3956 if (PrintCommandLineFlags) {
3957 JVMFlag::printSetFlags(tty);
3958 }
3959
3960 #if COMPILER2_OR_JVMCI
3961 if (!FLAG_IS_DEFAULT(EnableVectorSupport) && !EnableVectorSupport) {
3962 if (!FLAG_IS_DEFAULT(EnableVectorReboxing) && EnableVectorReboxing) {
3963 warning("Disabling EnableVectorReboxing since EnableVectorSupport is turned off.");
3964 }
3965 FLAG_SET_DEFAULT(EnableVectorReboxing, false);
3966
|