< prev index next >

src/hotspot/share/runtime/arguments.cpp

Print this page

  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;

2625 
2626 #ifndef COMPILER2
2627   // Don't degrade server performance for footprint
2628   if (FLAG_IS_DEFAULT(UseLargePages) &&
2629       MaxHeapSize < LargePageHeapSizeThreshold) {
2630     // No need for large granularity pages w/small heaps.
2631     // Note that large pages are enabled/disabled for both the
2632     // Java heap and the code cache.
2633     FLAG_SET_DEFAULT(UseLargePages, false);
2634   }
2635 
2636   UNSUPPORTED_OPTION(ProfileInterpreter);
2637 #endif // !COMPILER2
2638 
2639   // Parse the CompilationMode flag
2640   if (!CompilationModeFlag::initialize()) {
2641     return JNI_ERR;
2642   }
2643 
2644   // Called after ClassLoader::lookup_vm_options() but before class loading begins.
2645   // TODO: Obtain and pass correct preview mode flag value here.
2646   ClassLoader::set_preview_mode(false);
2647 
2648   if (!check_vm_args_consistency()) {
2649     return JNI_ERR;
2650   }
2651 
2652 
2653 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
2654   UNSUPPORTED_OPTION(ShowRegistersOnAssert);
2655 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
2656 
2657   return JNI_OK;
2658 }
2659 
2660 // Helper class for controlling the lifetime of JavaVMInitArgs
2661 // objects.  The contents of the JavaVMInitArgs are guaranteed to be
2662 // deleted on the destruction of the ScopedVMInitArgs object.
2663 class ScopedVMInitArgs : public StackObj {
2664  private:
2665   JavaVMInitArgs _args;
2666   char*          _container_name;

3497     FLAG_SET_DEFAULT(StressSecondarySupers, false);
3498     FLAG_SET_DEFAULT(VerifySecondarySupers, false);
3499   }
3500 
3501 #ifdef ZERO
3502   // Clear flags not supported on zero.
3503   FLAG_SET_DEFAULT(ProfileInterpreter, false);
3504 #endif // ZERO
3505 
3506   if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3507     warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3508     DebugNonSafepoints = true;
3509   }
3510 
3511   // Treat the odd case where local verification is enabled but remote
3512   // verification is not as if both were enabled.
3513   if (BytecodeVerificationLocal && !BytecodeVerificationRemote) {
3514     log_info(verification)("Turning on remote verification because local verification is on");
3515     FLAG_SET_DEFAULT(BytecodeVerificationRemote, true);
3516   }




































































3517 
3518 #ifndef PRODUCT
3519   if (!LogVMOutput && FLAG_IS_DEFAULT(LogVMOutput)) {
3520     if (use_vm_log()) {
3521       LogVMOutput = true;
3522     }
3523   }
3524 #endif // PRODUCT
3525 
3526   if (PrintCommandLineFlags) {
3527     JVMFlag::printSetFlags(tty);
3528   }
3529 
3530 #ifdef COMPILER2
3531   if (!FLAG_IS_DEFAULT(EnableVectorSupport) && !EnableVectorSupport) {
3532     if (!FLAG_IS_DEFAULT(EnableVectorReboxing) && EnableVectorReboxing) {
3533       warning("Disabling EnableVectorReboxing since EnableVectorSupport is turned off.");
3534     }
3535     FLAG_SET_DEFAULT(EnableVectorReboxing, false);
3536 

  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;

2628 
2629 #ifndef COMPILER2
2630   // Don't degrade server performance for footprint
2631   if (FLAG_IS_DEFAULT(UseLargePages) &&
2632       MaxHeapSize < LargePageHeapSizeThreshold) {
2633     // No need for large granularity pages w/small heaps.
2634     // Note that large pages are enabled/disabled for both the
2635     // Java heap and the code cache.
2636     FLAG_SET_DEFAULT(UseLargePages, false);
2637   }
2638 
2639   UNSUPPORTED_OPTION(ProfileInterpreter);
2640 #endif // !COMPILER2
2641 
2642   // Parse the CompilationMode flag
2643   if (!CompilationModeFlag::initialize()) {
2644     return JNI_ERR;
2645   }
2646 
2647   // Called after ClassLoader::lookup_vm_options() but before class loading begins.
2648   ClassLoader::set_preview_mode(is_valhalla_enabled());

2649 
2650   if (!check_vm_args_consistency()) {
2651     return JNI_ERR;
2652   }
2653 
2654 
2655 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
2656   UNSUPPORTED_OPTION(ShowRegistersOnAssert);
2657 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
2658 
2659   return JNI_OK;
2660 }
2661 
2662 // Helper class for controlling the lifetime of JavaVMInitArgs
2663 // objects.  The contents of the JavaVMInitArgs are guaranteed to be
2664 // deleted on the destruction of the ScopedVMInitArgs object.
2665 class ScopedVMInitArgs : public StackObj {
2666  private:
2667   JavaVMInitArgs _args;
2668   char*          _container_name;

3499     FLAG_SET_DEFAULT(StressSecondarySupers, false);
3500     FLAG_SET_DEFAULT(VerifySecondarySupers, false);
3501   }
3502 
3503 #ifdef ZERO
3504   // Clear flags not supported on zero.
3505   FLAG_SET_DEFAULT(ProfileInterpreter, false);
3506 #endif // ZERO
3507 
3508   if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3509     warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3510     DebugNonSafepoints = true;
3511   }
3512 
3513   // Treat the odd case where local verification is enabled but remote
3514   // verification is not as if both were enabled.
3515   if (BytecodeVerificationLocal && !BytecodeVerificationRemote) {
3516     log_info(verification)("Turning on remote verification because local verification is on");
3517     FLAG_SET_DEFAULT(BytecodeVerificationRemote, true);
3518   }
3519   if (!is_valhalla_enabled()) {
3520 #define WARN_IF_NOT_DEFAULT_FLAG(flag)                                                                       \
3521     if (!FLAG_IS_DEFAULT(flag)) {                                                                            \
3522       warning("Preview-specific flag \"%s\" has no effect when --enable-preview is not specified.", #flag);  \
3523     }
3524 
3525 #define DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(flag)  \
3526     WARN_IF_NOT_DEFAULT_FLAG(flag)                  \
3527     FLAG_SET_DEFAULT(flag, false);
3528 
3529     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(InlineTypePassFieldsAsArgs);
3530     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(InlineTypeReturnedAsFields);
3531     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseArrayFlattening);
3532     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseFieldFlattening);
3533     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullFreeNonAtomicValueFlattening);
3534     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullableAtomicValueFlattening);
3535     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullFreeAtomicValueFlattening);
3536     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullableNonAtomicValueFlattening);
3537     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseAcmpFastPath);
3538     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(PrintInlineLayout);
3539     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(PrintFlatArrayLayout);
3540     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(IgnoreAssertUnsetFields);
3541     WARN_IF_NOT_DEFAULT_FLAG(FlatArrayElementMaxOops);
3542     WARN_IF_NOT_DEFAULT_FLAG(ForceNonTearable);
3543 #ifdef ASSERT
3544     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(StressCallingConvention);
3545     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(PreloadClasses);
3546     WARN_IF_NOT_DEFAULT_FLAG(PrintInlineKlassFields);
3547 #endif
3548 #ifdef COMPILER1
3549     DEBUG_ONLY(DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(C1UseDelayedFlattenedFieldReads);)
3550 #endif
3551 #ifdef COMPILER2
3552     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseArrayLoadStoreProfile);
3553     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseACmpProfile);
3554 #endif
3555 #undef DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT
3556 #undef WARN_IF_NOT_DEFAULT_FLAG
3557   } else {
3558 #define DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(flag, fallback)                                        \
3559     if (!FLAG_IS_DEFAULT(flag) && !UseArrayFlattening && !UseFieldFlattening) {                       \
3560       warning("Flattening flag \"%s\" has no effect when all flattening modes are disabled.", #flag); \
3561       FLAG_SET_DEFAULT(flag, fallback);                                                               \
3562     }
3563 
3564     DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(UseNullFreeNonAtomicValueFlattening, false);
3565     DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(UseNullableAtomicValueFlattening, false);
3566     DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(UseNullFreeAtomicValueFlattening, false);
3567     DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(UseNullableNonAtomicValueFlattening, false);
3568     DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(FlatArrayElementMaxOops, 0);
3569     DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(FlatteningBudget, 0);
3570 #undef DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING
3571     if (is_interpreter_only() && !CDSConfig::is_dumping_archive() && !UseSharedSpaces) {
3572       // Disable calling convention optimizations if inline types are not supported.
3573       // Also these aren't useful in -Xint. However, don't disable them when dumping or using
3574       // the CDS archive, as the values must match between dumptime and runtime.
3575       FLAG_SET_DEFAULT(InlineTypePassFieldsAsArgs, false);
3576       FLAG_SET_DEFAULT(InlineTypeReturnedAsFields, false);
3577     }
3578     if (!UseNullFreeNonAtomicValueFlattening &&
3579         !UseNullableAtomicValueFlattening &&
3580         !UseNullFreeAtomicValueFlattening &&
3581         !UseNullableNonAtomicValueFlattening) {
3582       // Flattening is disabled
3583       FLAG_SET_DEFAULT(UseArrayFlattening, false);
3584       FLAG_SET_DEFAULT(UseFieldFlattening, false);
3585     }
3586   }
3587 
3588 #ifndef PRODUCT
3589   if (!LogVMOutput && FLAG_IS_DEFAULT(LogVMOutput)) {
3590     if (use_vm_log()) {
3591       LogVMOutput = true;
3592     }
3593   }
3594 #endif // PRODUCT
3595 
3596   if (PrintCommandLineFlags) {
3597     JVMFlag::printSetFlags(tty);
3598   }
3599 
3600 #ifdef COMPILER2
3601   if (!FLAG_IS_DEFAULT(EnableVectorSupport) && !EnableVectorSupport) {
3602     if (!FLAG_IS_DEFAULT(EnableVectorReboxing) && EnableVectorReboxing) {
3603       warning("Disabling EnableVectorReboxing since EnableVectorSupport is turned off.");
3604     }
3605     FLAG_SET_DEFAULT(EnableVectorReboxing, false);
3606 
< prev index next >