< 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;

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

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




































































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

  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;

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

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

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