< 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 #if INCLUDE_JVMCI
  88 bool   Arguments::_jvmci_module_added           = false;
  89 #endif
  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;

2704 
2705 #if !COMPILER2_OR_JVMCI
2706   // Don't degrade server performance for footprint
2707   if (FLAG_IS_DEFAULT(UseLargePages) &&
2708       MaxHeapSize < LargePageHeapSizeThreshold) {
2709     // No need for large granularity pages w/small heaps.
2710     // Note that large pages are enabled/disabled for both the
2711     // Java heap and the code cache.
2712     FLAG_SET_DEFAULT(UseLargePages, false);
2713   }
2714 
2715   UNSUPPORTED_OPTION(ProfileInterpreter);
2716 #endif
2717 
2718   // Parse the CompilationMode flag
2719   if (!CompilationModeFlag::initialize()) {
2720     return JNI_ERR;
2721   }
2722 
2723   // Called after ClassLoader::lookup_vm_options() but before class loading begins.
2724   // TODO: Obtain and pass correct preview mode flag value here.
2725   ClassLoader::set_preview_mode(false);
2726 
2727   if (!check_vm_args_consistency()) {
2728     return JNI_ERR;
2729   }
2730 
2731 
2732 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
2733   UNSUPPORTED_OPTION(ShowRegistersOnAssert);
2734 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
2735 
2736   return JNI_OK;
2737 }
2738 
2739 // Helper class for controlling the lifetime of JavaVMInitArgs
2740 // objects.  The contents of the JavaVMInitArgs are guaranteed to be
2741 // deleted on the destruction of the ScopedVMInitArgs object.
2742 class ScopedVMInitArgs : public StackObj {
2743  private:
2744   JavaVMInitArgs _args;
2745   char*          _container_name;

3576     FLAG_SET_DEFAULT(StressSecondarySupers, false);
3577     FLAG_SET_DEFAULT(VerifySecondarySupers, false);
3578   }
3579 
3580 #ifdef ZERO
3581   // Clear flags not supported on zero.
3582   FLAG_SET_DEFAULT(ProfileInterpreter, false);
3583 #endif // ZERO
3584 
3585   if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3586     warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3587     DebugNonSafepoints = true;
3588   }
3589 
3590   // Treat the odd case where local verification is enabled but remote
3591   // verification is not as if both were enabled.
3592   if (BytecodeVerificationLocal && !BytecodeVerificationRemote) {
3593     log_info(verification)("Turning on remote verification because local verification is on");
3594     FLAG_SET_DEFAULT(BytecodeVerificationRemote, true);
3595   }




































































3596 
3597 #ifndef PRODUCT
3598   if (!LogVMOutput && FLAG_IS_DEFAULT(LogVMOutput)) {
3599     if (use_vm_log()) {
3600       LogVMOutput = true;
3601     }
3602   }
3603 #endif // PRODUCT
3604 
3605   if (PrintCommandLineFlags) {
3606     JVMFlag::printSetFlags(tty);
3607   }
3608 
3609 #if COMPILER2_OR_JVMCI
3610   if (!FLAG_IS_DEFAULT(EnableVectorSupport) && !EnableVectorSupport) {
3611     if (!FLAG_IS_DEFAULT(EnableVectorReboxing) && EnableVectorReboxing) {
3612       warning("Disabling EnableVectorReboxing since EnableVectorSupport is turned off.");
3613     }
3614     FLAG_SET_DEFAULT(EnableVectorReboxing, false);
3615 

  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 #if INCLUDE_JVMCI
  91 bool   Arguments::_jvmci_module_added           = false;
  92 #endif
  93 char*  Arguments::_java_command                 = nullptr;
  94 SystemProperty* Arguments::_system_properties   = nullptr;
  95 size_t Arguments::_conservative_max_heap_alignment = 0;
  96 Arguments::Mode Arguments::_mode                = _mixed;
  97 const char*  Arguments::_java_vendor_url_bug    = nullptr;
  98 const char*  Arguments::_sun_java_launcher      = DEFAULT_JAVA_LAUNCHER;
  99 bool   Arguments::_executing_unit_tests         = false;

2707 
2708 #if !COMPILER2_OR_JVMCI
2709   // Don't degrade server performance for footprint
2710   if (FLAG_IS_DEFAULT(UseLargePages) &&
2711       MaxHeapSize < LargePageHeapSizeThreshold) {
2712     // No need for large granularity pages w/small heaps.
2713     // Note that large pages are enabled/disabled for both the
2714     // Java heap and the code cache.
2715     FLAG_SET_DEFAULT(UseLargePages, false);
2716   }
2717 
2718   UNSUPPORTED_OPTION(ProfileInterpreter);
2719 #endif
2720 
2721   // Parse the CompilationMode flag
2722   if (!CompilationModeFlag::initialize()) {
2723     return JNI_ERR;
2724   }
2725 
2726   // Called after ClassLoader::lookup_vm_options() but before class loading begins.
2727   ClassLoader::set_preview_mode(is_valhalla_enabled());

2728 
2729   if (!check_vm_args_consistency()) {
2730     return JNI_ERR;
2731   }
2732 
2733 
2734 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
2735   UNSUPPORTED_OPTION(ShowRegistersOnAssert);
2736 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
2737 
2738   return JNI_OK;
2739 }
2740 
2741 // Helper class for controlling the lifetime of JavaVMInitArgs
2742 // objects.  The contents of the JavaVMInitArgs are guaranteed to be
2743 // deleted on the destruction of the ScopedVMInitArgs object.
2744 class ScopedVMInitArgs : public StackObj {
2745  private:
2746   JavaVMInitArgs _args;
2747   char*          _container_name;

3578     FLAG_SET_DEFAULT(StressSecondarySupers, false);
3579     FLAG_SET_DEFAULT(VerifySecondarySupers, false);
3580   }
3581 
3582 #ifdef ZERO
3583   // Clear flags not supported on zero.
3584   FLAG_SET_DEFAULT(ProfileInterpreter, false);
3585 #endif // ZERO
3586 
3587   if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3588     warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3589     DebugNonSafepoints = true;
3590   }
3591 
3592   // Treat the odd case where local verification is enabled but remote
3593   // verification is not as if both were enabled.
3594   if (BytecodeVerificationLocal && !BytecodeVerificationRemote) {
3595     log_info(verification)("Turning on remote verification because local verification is on");
3596     FLAG_SET_DEFAULT(BytecodeVerificationRemote, true);
3597   }
3598   if (!is_valhalla_enabled()) {
3599 #define WARN_IF_NOT_DEFAULT_FLAG(flag)                                                                       \
3600     if (!FLAG_IS_DEFAULT(flag)) {                                                                            \
3601       warning("Preview-specific flag \"%s\" has no effect when --enable-preview is not specified.", #flag);  \
3602     }
3603 
3604 #define DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(flag)  \
3605     WARN_IF_NOT_DEFAULT_FLAG(flag)                  \
3606     FLAG_SET_DEFAULT(flag, false);
3607 
3608     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(InlineTypePassFieldsAsArgs);
3609     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(InlineTypeReturnedAsFields);
3610     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseArrayFlattening);
3611     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseFieldFlattening);
3612     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullFreeNonAtomicValueFlattening);
3613     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullableAtomicValueFlattening);
3614     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullFreeAtomicValueFlattening);
3615     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseNullableNonAtomicValueFlattening);
3616     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseAcmpFastPath);
3617     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(PrintInlineLayout);
3618     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(PrintFlatArrayLayout);
3619     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(IgnoreAssertUnsetFields);
3620     WARN_IF_NOT_DEFAULT_FLAG(FlatArrayElementMaxOops);
3621     WARN_IF_NOT_DEFAULT_FLAG(ForceNonTearable);
3622 #ifdef ASSERT
3623     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(StressCallingConvention);
3624     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(PreloadClasses);
3625     WARN_IF_NOT_DEFAULT_FLAG(PrintInlineKlassFields);
3626 #endif
3627 #ifdef COMPILER1
3628     DEBUG_ONLY(DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(C1UseDelayedFlattenedFieldReads);)
3629 #endif
3630 #ifdef COMPILER2
3631     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseArrayLoadStoreProfile);
3632     DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT(UseACmpProfile);
3633 #endif
3634 #undef DISABLE_FLAG_AND_WARN_IF_NOT_DEFAULT
3635 #undef WARN_IF_NOT_DEFAULT_FLAG
3636   } else {
3637 #define DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(flag, fallback)                                        \
3638     if (!FLAG_IS_DEFAULT(flag) && !UseArrayFlattening && !UseFieldFlattening) {                       \
3639       warning("Flattening flag \"%s\" has no effect when all flattening modes are disabled.", #flag); \
3640       FLAG_SET_DEFAULT(flag, fallback);                                                               \
3641     }
3642 
3643     DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(UseNullFreeNonAtomicValueFlattening, false);
3644     DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(UseNullableAtomicValueFlattening, false);
3645     DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(UseNullFreeAtomicValueFlattening, false);
3646     DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(UseNullableNonAtomicValueFlattening, false);
3647     DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(FlatArrayElementMaxOops, 0);
3648     DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING(FlatteningBudget, 0);
3649 #undef DISABLE_FLAG_AND_WARN_IF_NO_FLATTENING
3650     if (is_interpreter_only() && !CDSConfig::is_dumping_archive() && !UseSharedSpaces) {
3651       // Disable calling convention optimizations if inline types are not supported.
3652       // Also these aren't useful in -Xint. However, don't disable them when dumping or using
3653       // the CDS archive, as the values must match between dumptime and runtime.
3654       FLAG_SET_DEFAULT(InlineTypePassFieldsAsArgs, false);
3655       FLAG_SET_DEFAULT(InlineTypeReturnedAsFields, false);
3656     }
3657     if (!UseNullFreeNonAtomicValueFlattening &&
3658         !UseNullableAtomicValueFlattening &&
3659         !UseNullFreeAtomicValueFlattening &&
3660         !UseNullableNonAtomicValueFlattening) {
3661       // Flattening is disabled
3662       FLAG_SET_DEFAULT(UseArrayFlattening, false);
3663       FLAG_SET_DEFAULT(UseFieldFlattening, false);
3664     }
3665   }
3666 
3667 #ifndef PRODUCT
3668   if (!LogVMOutput && FLAG_IS_DEFAULT(LogVMOutput)) {
3669     if (use_vm_log()) {
3670       LogVMOutput = true;
3671     }
3672   }
3673 #endif // PRODUCT
3674 
3675   if (PrintCommandLineFlags) {
3676     JVMFlag::printSetFlags(tty);
3677   }
3678 
3679 #if COMPILER2_OR_JVMCI
3680   if (!FLAG_IS_DEFAULT(EnableVectorSupport) && !EnableVectorSupport) {
3681     if (!FLAG_IS_DEFAULT(EnableVectorReboxing) && EnableVectorReboxing) {
3682       warning("Disabling EnableVectorReboxing since EnableVectorSupport is turned off.");
3683     }
3684     FLAG_SET_DEFAULT(EnableVectorReboxing, false);
3685 
< prev index next >