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;
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
2998 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
2999 UNSUPPORTED_OPTION(ShowRegistersOnAssert);
3000 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
3001
3002 return JNI_OK;
3003 }
3004
3005 // Helper class for controlling the lifetime of JavaVMInitArgs
3006 // objects. The contents of the JavaVMInitArgs are guaranteed to be
3007 // deleted on the destruction of the ScopedVMInitArgs object.
3008 class ScopedVMInitArgs : public StackObj {
3009 private:
3010 JavaVMInitArgs _args;
3011 char* _container_name;
3012 bool _is_set;
3862 #ifdef ZERO
3863 // Clear flags not supported on zero.
3864 FLAG_SET_DEFAULT(ProfileInterpreter, false);
3865 #endif // ZERO
3866
3867 if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3868 warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3869 DebugNonSafepoints = true;
3870 }
3871
3872 if (FLAG_IS_CMDLINE(CompressedClassSpaceSize) && !UseCompressedClassPointers) {
3873 warning("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used");
3874 }
3875
3876 // Treat the odd case where local verification is enabled but remote
3877 // verification is not as if both were enabled.
3878 if (BytecodeVerificationLocal && !BytecodeVerificationRemote) {
3879 log_info(verification)("Turning on remote verification because local verification is on");
3880 FLAG_SET_DEFAULT(BytecodeVerificationRemote, true);
3881 }
3882 if (!is_valhalla_enabled()) {
3883 #define WARN_IF_NOT_DEFAULT_FLAG(flag) \
3884 if (!FLAG_IS_DEFAULT(flag)) { \
3885 warning("Preview-specific flag \"%s\" has no effect when --enable-preview is not specified.", #flag); \
3886 }
3887
3888 #define DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(flag) \
3889 WARN_IF_NOT_DEFAULT_FLAG(flag) \
3890 FLAG_SET_DEFAULT(flag, false);
3891
3892 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(InlineTypePassFieldsAsArgs);
3893 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(InlineTypeReturnedAsFields);
3894 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseArrayFlattening);
3895 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseFieldFlattening);
3896 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullFreeNonAtomicValueFlattening);
3897 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullableAtomicValueFlattening);
3898 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullFreeAtomicValueFlattening);
3899 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullableNonAtomicValueFlattening);
3900 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(PrintInlineLayout);
3901 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(PrintFlatArrayLayout);
3902 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(IgnoreAssertUnsetFields);
3903 WARN_IF_NOT_DEFAULT_FLAG(FlatArrayElementMaxOops);
3904 WARN_IF_NOT_DEFAULT_FLAG(ForceNonTearable);
3905 #ifdef ASSERT
3906 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(StressCallingConvention);
3907 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(PreloadClasses);
3908 WARN_IF_NOT_DEFAULT_FLAG(PrintInlineKlassFields);
3909 #endif
3910 #ifdef COMPILER1
3911 DEBUG_ONLY(DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(C1UseDelayedFlattenedFieldReads);)
3912 #endif
3913 #ifdef COMPILER2
3914 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseArrayLoadStoreProfile);
3915 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseACmpProfile);
3916 #endif
3917 #undef DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT
3918 #undef WARN_IF_NOT_DEFAULT_FLAG
3919 } else {
3920 #define DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(flag, fallback) \
3921 if (!FLAG_IS_DEFAULT(flag) && !UseArrayFlattening && !UseFieldFlattening) { \
3922 warning("Flattening flag \"%s\" has no effect when all flattening modes are disabled.", #flag); \
3923 FLAG_SET_DEFAULT(flag, fallback); \
3924 }
3925
3926 DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(UseNullFreeNonAtomicValueFlattening, false);
3927 DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(UseNullableAtomicValueFlattening, false);
3928 DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(UseNullFreeAtomicValueFlattening, false);
3929 DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(UseNullableNonAtomicValueFlattening, false);
3930 DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(FlatArrayElementMaxOops, 0);
3931 #undef DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING
3932 if (is_interpreter_only() && !CDSConfig::is_dumping_archive() && !UseSharedSpaces) {
3933 // Disable calling convention optimizations if inline types are not supported.
3934 // Also these aren't useful in -Xint. However, don't disable them when dumping or using
3935 // the CDS archive, as the values must match between dumptime and runtime.
3936 FLAG_SET_DEFAULT(InlineTypePassFieldsAsArgs, false);
3937 FLAG_SET_DEFAULT(InlineTypeReturnedAsFields, false);
3938 }
3939 if (!UseNullFreeNonAtomicValueFlattening &&
3940 !UseNullableAtomicValueFlattening &&
3941 !UseNullFreeAtomicValueFlattening &&
3942 !UseNullableNonAtomicValueFlattening) {
3943 // Flattening is disabled
3944 FLAG_SET_DEFAULT(UseArrayFlattening, false);
3945 FLAG_SET_DEFAULT(UseFieldFlattening, false);
3946 }
3947 }
3948
3949 #ifndef PRODUCT
3950 if (!LogVMOutput && FLAG_IS_DEFAULT(LogVMOutput)) {
3951 if (use_vm_log()) {
3952 LogVMOutput = true;
3953 }
3954 }
3955 #endif // PRODUCT
3956
3957 if (PrintCommandLineFlags) {
3958 JVMFlag::printSetFlags(tty);
3959 }
3960
3961 #if COMPILER2_OR_JVMCI
3962 if (!FLAG_IS_DEFAULT(EnableVectorSupport) && !EnableVectorSupport) {
3963 if (!FLAG_IS_DEFAULT(EnableVectorReboxing) && EnableVectorReboxing) {
3964 warning("Disabling EnableVectorReboxing since EnableVectorSupport is turned off.");
3965 }
3966 FLAG_SET_DEFAULT(EnableVectorReboxing, false);
3967
|