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/objLayout.hpp"
50 #include "oops/oop.inline.hpp"
51 #include "prims/jvmtiAgentList.hpp"
52 #include "prims/jvmtiExport.hpp"
53 #include "runtime/arguments.hpp"
54 #include "runtime/flags/jvmFlag.hpp"
55 #include "runtime/flags/jvmFlagAccess.hpp"
56 #include "runtime/flags/jvmFlagLimit.hpp"
57 #include "runtime/globals_extension.hpp"
58 #include "runtime/java.hpp"
59 #include "runtime/os.hpp"
60 #include "runtime/safepoint.hpp"
61 #include "runtime/safepointMechanism.hpp"
62 #include "runtime/synchronizer.hpp"
63 #include "runtime/vm_version.hpp"
64 #include "services/management.hpp"
65 #include "utilities/align.hpp"
66 #include "utilities/debug.hpp"
67 #include "utilities/defaultStream.hpp"
68 #include "utilities/macros.hpp"
69 #include "utilities/parseInteger.hpp"
70 #include "utilities/powerOfTwo.hpp"
71 #include "utilities/stringUtils.hpp"
72 #include "utilities/systemMemoryBarrier.hpp"
73 #if INCLUDE_JFR
74 #include "jfr/jfr.hpp"
75 #endif
76
77 static const char _default_java_launcher[] = "generic";
78
79 #define DEFAULT_JAVA_LAUNCHER _default_java_launcher
80
81 char* Arguments::_jvm_flags_file = nullptr;
82 char** Arguments::_jvm_flags_array = nullptr;
83 int Arguments::_num_jvm_flags = 0;
84 char** Arguments::_jvm_args_array = nullptr;
85 int Arguments::_num_jvm_args = 0;
86 unsigned int Arguments::_addmods_count = 0;
87 char* Arguments::_java_command = nullptr;
88 SystemProperty* Arguments::_system_properties = nullptr;
89 size_t Arguments::_conservative_max_heap_alignment = 0;
90 Arguments::Mode Arguments::_mode = _mixed;
91 const char* Arguments::_java_vendor_url_bug = nullptr;
92 const char* Arguments::_sun_java_launcher = DEFAULT_JAVA_LAUNCHER;
93 bool Arguments::_executing_unit_tests = false;
94
95 // These parameters are reset in method parse_vm_init_args()
96 bool Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods;
2644
2645 #ifndef COMPILER2
2646 // Don't degrade server performance for footprint
2647 if (FLAG_IS_DEFAULT(UseLargePages) &&
2648 MaxHeapSize < LargePageHeapSizeThreshold) {
2649 // No need for large granularity pages w/small heaps.
2650 // Note that large pages are enabled/disabled for both the
2651 // Java heap and the code cache.
2652 FLAG_SET_DEFAULT(UseLargePages, false);
2653 }
2654
2655 UNSUPPORTED_OPTION(ProfileInterpreter);
2656 #endif // !COMPILER2
2657
2658 // Parse the CompilationMode flag
2659 if (!CompilationModeFlag::initialize()) {
2660 return JNI_ERR;
2661 }
2662
2663 // Called after ClassLoader::lookup_vm_options() but before class loading begins.
2664 // TODO: Obtain and pass correct preview mode flag value here.
2665 ClassLoader::set_preview_mode(false);
2666
2667 if (!check_vm_args_consistency()) {
2668 return JNI_ERR;
2669 }
2670
2671
2672 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
2673 UNSUPPORTED_OPTION(ShowRegistersOnAssert);
2674 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
2675
2676 return JNI_OK;
2677 }
2678
2679 // Helper class for controlling the lifetime of JavaVMInitArgs
2680 // objects. The contents of the JavaVMInitArgs are guaranteed to be
2681 // deleted on the destruction of the ScopedVMInitArgs object.
2682 class ScopedVMInitArgs : public StackObj {
2683 private:
2684 JavaVMInitArgs _args;
2685 char* _container_name;
3516 FLAG_SET_DEFAULT(StressSecondarySupers, false);
3517 FLAG_SET_DEFAULT(VerifySecondarySupers, false);
3518 }
3519
3520 #ifdef ZERO
3521 // Clear flags not supported on zero.
3522 FLAG_SET_DEFAULT(ProfileInterpreter, false);
3523 #endif // ZERO
3524
3525 if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3526 warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3527 DebugNonSafepoints = true;
3528 }
3529
3530 // Treat the odd case where local verification is enabled but remote
3531 // verification is not as if both were enabled.
3532 if (BytecodeVerificationLocal && !BytecodeVerificationRemote) {
3533 log_info(verification)("Turning on remote verification because local verification is on");
3534 FLAG_SET_DEFAULT(BytecodeVerificationRemote, true);
3535 }
3536
3537 #ifndef PRODUCT
3538 if (!LogVMOutput && FLAG_IS_DEFAULT(LogVMOutput)) {
3539 if (use_vm_log()) {
3540 LogVMOutput = true;
3541 }
3542 }
3543 #endif // PRODUCT
3544
3545 if (PrintCommandLineFlags) {
3546 JVMFlag::printSetFlags(tty);
3547 }
3548
3549 #ifdef COMPILER2
3550 if (!FLAG_IS_DEFAULT(EnableVectorSupport) && !EnableVectorSupport) {
3551 if (!FLAG_IS_DEFAULT(EnableVectorReboxing) && EnableVectorReboxing) {
3552 warning("Disabling EnableVectorReboxing since EnableVectorSupport is turned off.");
3553 }
3554 FLAG_SET_DEFAULT(EnableVectorReboxing, false);
3555
|
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/objLayout.hpp"
50 #include "oops/oop.inline.hpp"
51 #include "prims/jvmtiAgentList.hpp"
52 #include "prims/jvmtiExport.hpp"
53 #include "runtime/arguments.hpp"
54 #include "runtime/flags/jvmFlag.hpp"
55 #include "runtime/flags/jvmFlagAccess.hpp"
56 #include "runtime/flags/jvmFlagLimit.hpp"
57 #include "runtime/globals.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 #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 char* Arguments::_java_command = nullptr;
91 SystemProperty* Arguments::_system_properties = nullptr;
92 size_t Arguments::_conservative_max_heap_alignment = 0;
93 Arguments::Mode Arguments::_mode = _mixed;
94 const char* Arguments::_java_vendor_url_bug = nullptr;
95 const char* Arguments::_sun_java_launcher = DEFAULT_JAVA_LAUNCHER;
96 bool Arguments::_executing_unit_tests = false;
97
98 // These parameters are reset in method parse_vm_init_args()
99 bool Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods;
2647
2648 #ifndef COMPILER2
2649 // Don't degrade server performance for footprint
2650 if (FLAG_IS_DEFAULT(UseLargePages) &&
2651 MaxHeapSize < LargePageHeapSizeThreshold) {
2652 // No need for large granularity pages w/small heaps.
2653 // Note that large pages are enabled/disabled for both the
2654 // Java heap and the code cache.
2655 FLAG_SET_DEFAULT(UseLargePages, false);
2656 }
2657
2658 UNSUPPORTED_OPTION(ProfileInterpreter);
2659 #endif // !COMPILER2
2660
2661 // Parse the CompilationMode flag
2662 if (!CompilationModeFlag::initialize()) {
2663 return JNI_ERR;
2664 }
2665
2666 // Called after ClassLoader::lookup_vm_options() but before class loading begins.
2667 ClassLoader::set_preview_mode(is_valhalla_enabled());
2668
2669 if (!check_vm_args_consistency()) {
2670 return JNI_ERR;
2671 }
2672
2673
2674 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
2675 UNSUPPORTED_OPTION(ShowRegistersOnAssert);
2676 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
2677
2678 return JNI_OK;
2679 }
2680
2681 // Helper class for controlling the lifetime of JavaVMInitArgs
2682 // objects. The contents of the JavaVMInitArgs are guaranteed to be
2683 // deleted on the destruction of the ScopedVMInitArgs object.
2684 class ScopedVMInitArgs : public StackObj {
2685 private:
2686 JavaVMInitArgs _args;
2687 char* _container_name;
3518 FLAG_SET_DEFAULT(StressSecondarySupers, false);
3519 FLAG_SET_DEFAULT(VerifySecondarySupers, false);
3520 }
3521
3522 #ifdef ZERO
3523 // Clear flags not supported on zero.
3524 FLAG_SET_DEFAULT(ProfileInterpreter, false);
3525 #endif // ZERO
3526
3527 if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3528 warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3529 DebugNonSafepoints = true;
3530 }
3531
3532 // Treat the odd case where local verification is enabled but remote
3533 // verification is not as if both were enabled.
3534 if (BytecodeVerificationLocal && !BytecodeVerificationRemote) {
3535 log_info(verification)("Turning on remote verification because local verification is on");
3536 FLAG_SET_DEFAULT(BytecodeVerificationRemote, true);
3537 }
3538 if (!is_valhalla_enabled()) {
3539 #define WARN_IF_NOT_DEFAULT_FLAG(flag) \
3540 if (!FLAG_IS_DEFAULT(flag)) { \
3541 warning("Preview-specific flag \"%s\" has no effect when --enable-preview is not specified.", #flag); \
3542 }
3543
3544 #define DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(flag) \
3545 WARN_IF_NOT_DEFAULT_FLAG(flag) \
3546 FLAG_SET_DEFAULT(flag, false);
3547
3548 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(InlineTypePassFieldsAsArgs);
3549 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(InlineTypeReturnedAsFields);
3550 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseArrayFlattening);
3551 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseFieldFlattening);
3552 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullFreeNonAtomicValueFlattening);
3553 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullableAtomicValueFlattening);
3554 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullFreeAtomicValueFlattening);
3555 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullableNonAtomicValueFlattening);
3556 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseAcmpFastPath);
3557 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(PrintInlineLayout);
3558 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(PrintFlatArrayLayout);
3559 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(IgnoreAssertUnsetFields);
3560 WARN_IF_NOT_DEFAULT_FLAG(FlatArrayElementMaxOops);
3561 WARN_IF_NOT_DEFAULT_FLAG(ForceNonTearable);
3562 #ifdef ASSERT
3563 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(StressCallingConvention);
3564 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(PreloadClasses);
3565 WARN_IF_NOT_DEFAULT_FLAG(PrintInlineKlassFields);
3566 #endif
3567 #ifdef COMPILER1
3568 DEBUG_ONLY(DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(C1UseDelayedFlattenedFieldReads);)
3569 #endif
3570 #ifdef COMPILER2
3571 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseArrayLoadStoreProfile);
3572 DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseACmpProfile);
3573 #endif
3574 #undef DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT
3575 #undef WARN_IF_NOT_DEFAULT_FLAG
3576 } else {
3577 #define DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(flag, fallback) \
3578 if (!FLAG_IS_DEFAULT(flag) && !UseArrayFlattening && !UseFieldFlattening) { \
3579 warning("Flattening flag \"%s\" has no effect when all flattening modes are disabled.", #flag); \
3580 FLAG_SET_DEFAULT(flag, fallback); \
3581 }
3582
3583 DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(UseNullFreeNonAtomicValueFlattening, false);
3584 DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(UseNullableAtomicValueFlattening, false);
3585 DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(UseNullFreeAtomicValueFlattening, false);
3586 DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(UseNullableNonAtomicValueFlattening, false);
3587 DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(FlatArrayElementMaxOops, 0);
3588 DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(FlatteningBudget, 0);
3589 #undef DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING
3590 if (is_interpreter_only() && !CDSConfig::is_dumping_archive() && !UseSharedSpaces) {
3591 // Disable calling convention optimizations if inline types are not supported.
3592 // Also these aren't useful in -Xint. However, don't disable them when dumping or using
3593 // the CDS archive, as the values must match between dumptime and runtime.
3594 FLAG_SET_DEFAULT(InlineTypePassFieldsAsArgs, false);
3595 FLAG_SET_DEFAULT(InlineTypeReturnedAsFields, false);
3596 }
3597 if (!UseNullFreeNonAtomicValueFlattening &&
3598 !UseNullableAtomicValueFlattening &&
3599 !UseNullFreeAtomicValueFlattening &&
3600 !UseNullableNonAtomicValueFlattening) {
3601 // Flattening is disabled
3602 FLAG_SET_DEFAULT(UseArrayFlattening, false);
3603 FLAG_SET_DEFAULT(UseFieldFlattening, false);
3604 }
3605 }
3606
3607 #ifndef PRODUCT
3608 if (!LogVMOutput && FLAG_IS_DEFAULT(LogVMOutput)) {
3609 if (use_vm_log()) {
3610 LogVMOutput = true;
3611 }
3612 }
3613 #endif // PRODUCT
3614
3615 if (PrintCommandLineFlags) {
3616 JVMFlag::printSetFlags(tty);
3617 }
3618
3619 #ifdef COMPILER2
3620 if (!FLAG_IS_DEFAULT(EnableVectorSupport) && !EnableVectorSupport) {
3621 if (!FLAG_IS_DEFAULT(EnableVectorReboxing) && EnableVectorReboxing) {
3622 warning("Disabling EnableVectorReboxing since EnableVectorSupport is turned off.");
3623 }
3624 FLAG_SET_DEFAULT(EnableVectorReboxing, false);
3625
|