9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "cds/cds_globals.hpp"
27 #include "cds/cdsConfig.hpp"
28 #include "cds/filemap.hpp"
29 #include "classfile/classLoader.hpp"
30 #include "classfile/javaAssertions.hpp"
31 #include "classfile/moduleEntry.hpp"
32 #include "classfile/stringTable.hpp"
33 #include "classfile/symbolTable.hpp"
34 #include "compiler/compilerDefinitions.hpp"
35 #include "gc/shared/gcArguments.hpp"
36 #include "gc/shared/gcConfig.hpp"
37 #include "gc/shared/stringdedup/stringDedup.hpp"
38 #include "gc/shared/tlab_globals.hpp"
39 #include "jvm.h"
40 #include "logging/log.hpp"
41 #include "logging/logConfiguration.hpp"
42 #include "logging/logStream.hpp"
43 #include "logging/logTag.hpp"
44 #include "memory/allocation.inline.hpp"
45 #include "nmt/nmtCommon.hpp"
46 #include "oops/compressedKlass.hpp"
47 #include "oops/instanceKlass.hpp"
48 #include "oops/oop.inline.hpp"
1794 bool Arguments::check_vm_args_consistency() {
1795 // Method for adding checks for flag consistency.
1796 // The intent is to warn the user of all possible conflicts,
1797 // before returning an error.
1798 // Note: Needs platform-dependent factoring.
1799 bool status = true;
1800
1801 if (TLABRefillWasteFraction == 0) {
1802 jio_fprintf(defaultStream::error_stream(),
1803 "TLABRefillWasteFraction should be a denominator, "
1804 "not " SIZE_FORMAT "\n",
1805 TLABRefillWasteFraction);
1806 status = false;
1807 }
1808
1809 status = CompilerConfig::check_args_consistency(status);
1810 #if INCLUDE_JVMCI
1811 if (status && EnableJVMCI) {
1812 PropertyList_unique_add(&_system_properties, "jdk.internal.vm.ci.enabled", "true",
1813 AddProperty, UnwriteableProperty, InternalProperty);
1814 if (ClassLoader::is_module_observable("jdk.internal.vm.ci")) {
1815 if (!create_numbered_module_property("jdk.module.addmods", "jdk.internal.vm.ci", addmods_count++)) {
1816 return false;
1817 }
1818 }
1819 }
1820 #endif
1821
1822 #if INCLUDE_JFR
1823 if (status && (FlightRecorderOptions || StartFlightRecording)) {
1824 if (!create_numbered_module_property("jdk.module.addmods", "jdk.jfr", addmods_count++)) {
1825 return false;
1826 }
1827 }
1828 #endif
1829
1830 #ifndef SUPPORT_RESERVED_STACK_AREA
1831 if (StackReservedPages != 0) {
1832 FLAG_SET_CMDLINE(StackReservedPages, 0);
1833 warning("Reserved Stack Area not supported on this platform");
1834 }
2936 // Java heap and the code cache.
2937 FLAG_SET_DEFAULT(UseLargePages, false);
2938 }
2939
2940 UNSUPPORTED_OPTION(ProfileInterpreter);
2941 #endif
2942
2943 // Parse the CompilationMode flag
2944 if (!CompilationModeFlag::initialize()) {
2945 return JNI_ERR;
2946 }
2947
2948 if (!check_vm_args_consistency()) {
2949 return JNI_ERR;
2950 }
2951
2952 if (!CDSConfig::check_vm_args_consistency(patch_mod_javabase, mode_flag_cmd_line)) {
2953 return JNI_ERR;
2954 }
2955
2956 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
2957 UNSUPPORTED_OPTION(ShowRegistersOnAssert);
2958 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
2959
2960 return JNI_OK;
2961 }
2962
2963 // Helper class for controlling the lifetime of JavaVMInitArgs
2964 // objects. The contents of the JavaVMInitArgs are guaranteed to be
2965 // deleted on the destruction of the ScopedVMInitArgs object.
2966 class ScopedVMInitArgs : public StackObj {
2967 private:
2968 JavaVMInitArgs _args;
2969 char* _container_name;
2970 bool _is_set;
2971 char* _vm_options_file_arg;
2972
2973 public:
2974 ScopedVMInitArgs(const char *container_name) {
2975 _args.version = JNI_VERSION_1_2;
3677
3678 // Set compiler flags after GC is selected and GC specific
3679 // flags (LoopStripMiningIter) are set.
3680 CompilerConfig::ergo_initialize();
3681
3682 // Set bytecode rewriting flags
3683 set_bytecode_flags();
3684
3685 // Set flags if aggressive optimization flags are enabled
3686 jint code = set_aggressive_opts_flags();
3687 if (code != JNI_OK) {
3688 return code;
3689 }
3690
3691 if (FLAG_IS_DEFAULT(UseSecondarySupersTable)) {
3692 FLAG_SET_DEFAULT(UseSecondarySupersTable, VM_Version::supports_secondary_supers_table());
3693 } else if (UseSecondarySupersTable && !VM_Version::supports_secondary_supers_table()) {
3694 warning("UseSecondarySupersTable is not supported");
3695 FLAG_SET_DEFAULT(UseSecondarySupersTable, false);
3696 }
3697 if (!UseSecondarySupersTable) {
3698 FLAG_SET_DEFAULT(StressSecondarySupers, false);
3699 FLAG_SET_DEFAULT(VerifySecondarySupers, false);
3700 }
3701
3702 #ifdef ZERO
3703 // Clear flags not supported on zero.
3704 FLAG_SET_DEFAULT(ProfileInterpreter, false);
3705 #endif // ZERO
3706
3707 if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3708 warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3709 DebugNonSafepoints = true;
3710 }
3711
3712 if (FLAG_IS_CMDLINE(CompressedClassSpaceSize) && !UseCompressedClassPointers) {
3713 warning("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used");
3714 }
3715
3716 // Treat the odd case where local verification is enabled but remote
3738 warning("Disabling EnableVectorReboxing since EnableVectorSupport is turned off.");
3739 }
3740 FLAG_SET_DEFAULT(EnableVectorReboxing, false);
3741
3742 if (!FLAG_IS_DEFAULT(EnableVectorAggressiveReboxing) && EnableVectorAggressiveReboxing) {
3743 if (!EnableVectorReboxing) {
3744 warning("Disabling EnableVectorAggressiveReboxing since EnableVectorReboxing is turned off.");
3745 } else {
3746 warning("Disabling EnableVectorAggressiveReboxing since EnableVectorSupport is turned off.");
3747 }
3748 }
3749 FLAG_SET_DEFAULT(EnableVectorAggressiveReboxing, false);
3750
3751 if (!FLAG_IS_DEFAULT(UseVectorStubs) && UseVectorStubs) {
3752 warning("Disabling UseVectorStubs since EnableVectorSupport is turned off.");
3753 }
3754 FLAG_SET_DEFAULT(UseVectorStubs, false);
3755 }
3756 #endif // COMPILER2_OR_JVMCI
3757
3758 if (FLAG_IS_CMDLINE(DiagnoseSyncOnValueBasedClasses)) {
3759 if (DiagnoseSyncOnValueBasedClasses == ObjectSynchronizer::LOG_WARNING && !log_is_enabled(Info, valuebasedclasses)) {
3760 LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(valuebasedclasses));
3761 }
3762 }
3763 return JNI_OK;
3764 }
3765
3766 jint Arguments::adjust_after_os() {
3767 if (UseNUMA) {
3768 if (UseParallelGC) {
3769 if (FLAG_IS_DEFAULT(MinHeapDeltaBytes)) {
3770 FLAG_SET_DEFAULT(MinHeapDeltaBytes, 64*M);
3771 }
3772 }
3773 }
3774 return JNI_OK;
3775 }
3776
3777 int Arguments::PropertyList_count(SystemProperty* pl) {
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "cds/cds_globals.hpp"
27 #include "cds/cdsConfig.hpp"
28 #include "cds/filemap.hpp"
29 #include "cds/heapShared.hpp"
30 #include "classfile/classLoader.hpp"
31 #include "classfile/javaAssertions.hpp"
32 #include "classfile/moduleEntry.hpp"
33 #include "classfile/stringTable.hpp"
34 #include "classfile/symbolTable.hpp"
35 #include "compiler/compilerDefinitions.hpp"
36 #include "gc/shared/gcArguments.hpp"
37 #include "gc/shared/gcConfig.hpp"
38 #include "gc/shared/stringdedup/stringDedup.hpp"
39 #include "gc/shared/tlab_globals.hpp"
40 #include "jvm.h"
41 #include "logging/log.hpp"
42 #include "logging/logConfiguration.hpp"
43 #include "logging/logStream.hpp"
44 #include "logging/logTag.hpp"
45 #include "memory/allocation.inline.hpp"
46 #include "nmt/nmtCommon.hpp"
47 #include "oops/compressedKlass.hpp"
48 #include "oops/instanceKlass.hpp"
49 #include "oops/oop.inline.hpp"
1795 bool Arguments::check_vm_args_consistency() {
1796 // Method for adding checks for flag consistency.
1797 // The intent is to warn the user of all possible conflicts,
1798 // before returning an error.
1799 // Note: Needs platform-dependent factoring.
1800 bool status = true;
1801
1802 if (TLABRefillWasteFraction == 0) {
1803 jio_fprintf(defaultStream::error_stream(),
1804 "TLABRefillWasteFraction should be a denominator, "
1805 "not " SIZE_FORMAT "\n",
1806 TLABRefillWasteFraction);
1807 status = false;
1808 }
1809
1810 status = CompilerConfig::check_args_consistency(status);
1811 #if INCLUDE_JVMCI
1812 if (status && EnableJVMCI) {
1813 PropertyList_unique_add(&_system_properties, "jdk.internal.vm.ci.enabled", "true",
1814 AddProperty, UnwriteableProperty, InternalProperty);
1815 /*
1816 * Ioi - 2023/05/19. There's no need for this with my patch-jdk.sh script, which adds
1817 * jdk.internal.vm.ci as one of the default modules. Using -Djdk.module.addmods will
1818 * cause the full module graph to be disabled and slow down performance.
1819 */
1820 if (!TempDisableAddJVMCIModule && ClassLoader::is_module_observable("jdk.internal.vm.ci")) {
1821 if (!create_numbered_module_property("jdk.module.addmods", "jdk.internal.vm.ci", addmods_count++)) {
1822 return false;
1823 }
1824 }
1825 }
1826 #endif
1827
1828 #if INCLUDE_JFR
1829 if (status && (FlightRecorderOptions || StartFlightRecording)) {
1830 if (!create_numbered_module_property("jdk.module.addmods", "jdk.jfr", addmods_count++)) {
1831 return false;
1832 }
1833 }
1834 #endif
1835
1836 #ifndef SUPPORT_RESERVED_STACK_AREA
1837 if (StackReservedPages != 0) {
1838 FLAG_SET_CMDLINE(StackReservedPages, 0);
1839 warning("Reserved Stack Area not supported on this platform");
1840 }
2942 // Java heap and the code cache.
2943 FLAG_SET_DEFAULT(UseLargePages, false);
2944 }
2945
2946 UNSUPPORTED_OPTION(ProfileInterpreter);
2947 #endif
2948
2949 // Parse the CompilationMode flag
2950 if (!CompilationModeFlag::initialize()) {
2951 return JNI_ERR;
2952 }
2953
2954 if (!check_vm_args_consistency()) {
2955 return JNI_ERR;
2956 }
2957
2958 if (!CDSConfig::check_vm_args_consistency(patch_mod_javabase, mode_flag_cmd_line)) {
2959 return JNI_ERR;
2960 }
2961
2962 if (StoreCachedCode) {
2963 FLAG_SET_ERGO_IF_DEFAULT(CachedCodeMaxSize, 512*M);
2964 }
2965
2966 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
2967 UNSUPPORTED_OPTION(ShowRegistersOnAssert);
2968 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
2969
2970 return JNI_OK;
2971 }
2972
2973 // Helper class for controlling the lifetime of JavaVMInitArgs
2974 // objects. The contents of the JavaVMInitArgs are guaranteed to be
2975 // deleted on the destruction of the ScopedVMInitArgs object.
2976 class ScopedVMInitArgs : public StackObj {
2977 private:
2978 JavaVMInitArgs _args;
2979 char* _container_name;
2980 bool _is_set;
2981 char* _vm_options_file_arg;
2982
2983 public:
2984 ScopedVMInitArgs(const char *container_name) {
2985 _args.version = JNI_VERSION_1_2;
3687
3688 // Set compiler flags after GC is selected and GC specific
3689 // flags (LoopStripMiningIter) are set.
3690 CompilerConfig::ergo_initialize();
3691
3692 // Set bytecode rewriting flags
3693 set_bytecode_flags();
3694
3695 // Set flags if aggressive optimization flags are enabled
3696 jint code = set_aggressive_opts_flags();
3697 if (code != JNI_OK) {
3698 return code;
3699 }
3700
3701 if (FLAG_IS_DEFAULT(UseSecondarySupersTable)) {
3702 FLAG_SET_DEFAULT(UseSecondarySupersTable, VM_Version::supports_secondary_supers_table());
3703 } else if (UseSecondarySupersTable && !VM_Version::supports_secondary_supers_table()) {
3704 warning("UseSecondarySupersTable is not supported");
3705 FLAG_SET_DEFAULT(UseSecondarySupersTable, false);
3706 }
3707 UseSecondarySupersTable = false; // FIXME: Disabled for Leyden. Neet to fix SCAddressTable::id_for_address()
3708 if (!UseSecondarySupersTable) {
3709 FLAG_SET_DEFAULT(StressSecondarySupers, false);
3710 FLAG_SET_DEFAULT(VerifySecondarySupers, false);
3711 }
3712
3713 #ifdef ZERO
3714 // Clear flags not supported on zero.
3715 FLAG_SET_DEFAULT(ProfileInterpreter, false);
3716 #endif // ZERO
3717
3718 if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3719 warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3720 DebugNonSafepoints = true;
3721 }
3722
3723 if (FLAG_IS_CMDLINE(CompressedClassSpaceSize) && !UseCompressedClassPointers) {
3724 warning("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used");
3725 }
3726
3727 // Treat the odd case where local verification is enabled but remote
3749 warning("Disabling EnableVectorReboxing since EnableVectorSupport is turned off.");
3750 }
3751 FLAG_SET_DEFAULT(EnableVectorReboxing, false);
3752
3753 if (!FLAG_IS_DEFAULT(EnableVectorAggressiveReboxing) && EnableVectorAggressiveReboxing) {
3754 if (!EnableVectorReboxing) {
3755 warning("Disabling EnableVectorAggressiveReboxing since EnableVectorReboxing is turned off.");
3756 } else {
3757 warning("Disabling EnableVectorAggressiveReboxing since EnableVectorSupport is turned off.");
3758 }
3759 }
3760 FLAG_SET_DEFAULT(EnableVectorAggressiveReboxing, false);
3761
3762 if (!FLAG_IS_DEFAULT(UseVectorStubs) && UseVectorStubs) {
3763 warning("Disabling UseVectorStubs since EnableVectorSupport is turned off.");
3764 }
3765 FLAG_SET_DEFAULT(UseVectorStubs, false);
3766 }
3767 #endif // COMPILER2_OR_JVMCI
3768
3769 if (log_is_enabled(Info, init)) {
3770 if (FLAG_IS_DEFAULT(ProfileVMLocks)) {
3771 FLAG_SET_DEFAULT(ProfileVMLocks, true);
3772 }
3773 // Don't turn on ProfileVMCalls and ProfileRuntimeCalls by default.
3774 } else {
3775 if (!FLAG_IS_DEFAULT(ProfileVMLocks) && ProfileVMLocks) {
3776 warning("Disabling ProfileVMLocks since logging is turned off.");
3777 FLAG_SET_DEFAULT(ProfileVMLocks, false);
3778 }
3779 if (!FLAG_IS_DEFAULT(ProfileVMCalls) && ProfileVMCalls) {
3780 warning("Disabling ProfileVMCalls since logging is turned off.");
3781 FLAG_SET_DEFAULT(ProfileVMCalls, false);
3782 }
3783 if (!FLAG_IS_DEFAULT(ProfileRuntimeCalls) && ProfileRuntimeCalls) {
3784 warning("Disabling ProfileRuntimeCalls since logging is turned off.");
3785 FLAG_SET_DEFAULT(ProfileRuntimeCalls, false);
3786 }
3787 }
3788 if (FLAG_IS_DEFAULT(PerfDataMemorySize)) {
3789 if (ProfileVMLocks || ProfileVMCalls || ProfileRuntimeCalls) {
3790 FLAG_SET_DEFAULT(PerfDataMemorySize, 128*K); // reserve more space for extra perf counters
3791 }
3792 }
3793
3794 if (FLAG_IS_CMDLINE(DiagnoseSyncOnValueBasedClasses)) {
3795 if (DiagnoseSyncOnValueBasedClasses == ObjectSynchronizer::LOG_WARNING && !log_is_enabled(Info, valuebasedclasses)) {
3796 LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(valuebasedclasses));
3797 }
3798 }
3799 return JNI_OK;
3800 }
3801
3802 jint Arguments::adjust_after_os() {
3803 if (UseNUMA) {
3804 if (UseParallelGC) {
3805 if (FLAG_IS_DEFAULT(MinHeapDeltaBytes)) {
3806 FLAG_SET_DEFAULT(MinHeapDeltaBytes, 64*M);
3807 }
3808 }
3809 }
3810 return JNI_OK;
3811 }
3812
3813 int Arguments::PropertyList_count(SystemProperty* pl) {
|