< prev index next >

src/hotspot/share/runtime/arguments.cpp

Print this page

   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/genArguments.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"

1755   return strcmp(DEFAULT_JAVA_LAUNCHER, _sun_java_launcher) != 0;
1756 }
1757 
1758 bool Arguments::sun_java_launcher_is_altjvm() {
1759   return _sun_java_launcher_is_altjvm;
1760 }
1761 
1762 //===========================================================================================================
1763 // Parsing of main arguments
1764 
1765 static unsigned int addreads_count = 0;
1766 static unsigned int addexports_count = 0;
1767 static unsigned int addopens_count = 0;
1768 static unsigned int patch_mod_count = 0;
1769 static unsigned int enable_native_access_count = 0;
1770 static bool patch_mod_javabase = false;
1771 
1772 // Check the consistency of vm_init_args
1773 bool Arguments::check_vm_args_consistency() {
1774   // This may modify compiler flags. Must be called before CompilerConfig::check_args_consistency()
1775   if (!CDSConfig::check_vm_args_consistency(patch_mod_javabase, mode_flag_cmd_line)) {
1776     return false;
1777   }
1778 
1779   // Method for adding checks for flag consistency.
1780   // The intent is to warn the user of all possible conflicts,
1781   // before returning an error.
1782   // Note: Needs platform-dependent factoring.
1783   bool status = true;
1784 
1785   if (TLABRefillWasteFraction == 0) {
1786     jio_fprintf(defaultStream::error_stream(),
1787                 "TLABRefillWasteFraction should be a denominator, "
1788                 "not " SIZE_FORMAT "\n",
1789                 TLABRefillWasteFraction);
1790     status = false;
1791   }
1792 
1793   status = CompilerConfig::check_args_consistency(status);
1794 #if INCLUDE_JVMCI
1795   if (status && EnableJVMCI) {

2931   if (FLAG_IS_DEFAULT(UseLargePages) &&
2932       MaxHeapSize < LargePageHeapSizeThreshold) {
2933     // No need for large granularity pages w/small heaps.
2934     // Note that large pages are enabled/disabled for both the
2935     // Java heap and the code cache.
2936     FLAG_SET_DEFAULT(UseLargePages, false);
2937   }
2938 
2939   UNSUPPORTED_OPTION(ProfileInterpreter);
2940 #endif
2941 
2942   // Parse the CompilationMode flag
2943   if (!CompilationModeFlag::initialize()) {
2944     return JNI_ERR;
2945   }
2946 
2947   if (!check_vm_args_consistency()) {
2948     return JNI_ERR;
2949   }
2950 



2951 
2952 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
2953   UNSUPPORTED_OPTION(ShowRegistersOnAssert);
2954 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
2955 
2956   return JNI_OK;
2957 }
2958 
2959 // Helper class for controlling the lifetime of JavaVMInitArgs
2960 // objects.  The contents of the JavaVMInitArgs are guaranteed to be
2961 // deleted on the destruction of the ScopedVMInitArgs object.
2962 class ScopedVMInitArgs : public StackObj {
2963  private:
2964   JavaVMInitArgs _args;
2965   char*          _container_name;
2966   bool           _is_set;
2967   char*          _vm_options_file_arg;
2968 
2969  public:
2970   ScopedVMInitArgs(const char *container_name) {

3707 
3708   // Set compiler flags after GC is selected and GC specific
3709   // flags (LoopStripMiningIter) are set.
3710   CompilerConfig::ergo_initialize();
3711 
3712   // Set bytecode rewriting flags
3713   set_bytecode_flags();
3714 
3715   // Set flags if aggressive optimization flags are enabled
3716   jint code = set_aggressive_opts_flags();
3717   if (code != JNI_OK) {
3718     return code;
3719   }
3720 
3721   if (FLAG_IS_DEFAULT(UseSecondarySupersTable)) {
3722     FLAG_SET_DEFAULT(UseSecondarySupersTable, VM_Version::supports_secondary_supers_table());
3723   } else if (UseSecondarySupersTable && !VM_Version::supports_secondary_supers_table()) {
3724     warning("UseSecondarySupersTable is not supported");
3725     FLAG_SET_DEFAULT(UseSecondarySupersTable, false);
3726   }

3727   if (!UseSecondarySupersTable) {
3728     FLAG_SET_DEFAULT(StressSecondarySupers, false);
3729     FLAG_SET_DEFAULT(VerifySecondarySupers, false);
3730   }
3731 
3732 #ifdef ZERO
3733   // Clear flags not supported on zero.
3734   FLAG_SET_DEFAULT(ProfileInterpreter, false);
3735 #endif // ZERO
3736 
3737   if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3738     warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3739     DebugNonSafepoints = true;
3740   }
3741 
3742   if (FLAG_IS_CMDLINE(CompressedClassSpaceSize) && !UseCompressedClassPointers) {
3743     warning("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used");
3744   }
3745 
3746   // Treat the odd case where local verification is enabled but remote

3768       warning("Disabling EnableVectorReboxing since EnableVectorSupport is turned off.");
3769     }
3770     FLAG_SET_DEFAULT(EnableVectorReboxing, false);
3771 
3772     if (!FLAG_IS_DEFAULT(EnableVectorAggressiveReboxing) && EnableVectorAggressiveReboxing) {
3773       if (!EnableVectorReboxing) {
3774         warning("Disabling EnableVectorAggressiveReboxing since EnableVectorReboxing is turned off.");
3775       } else {
3776         warning("Disabling EnableVectorAggressiveReboxing since EnableVectorSupport is turned off.");
3777       }
3778     }
3779     FLAG_SET_DEFAULT(EnableVectorAggressiveReboxing, false);
3780 
3781     if (!FLAG_IS_DEFAULT(UseVectorStubs) && UseVectorStubs) {
3782       warning("Disabling UseVectorStubs since EnableVectorSupport is turned off.");
3783     }
3784     FLAG_SET_DEFAULT(UseVectorStubs, false);
3785   }
3786 #endif // COMPILER2_OR_JVMCI
3787 
3788   if (log_is_enabled(Info, perf, class, link)) {
3789     if (!UsePerfData) {
3790       warning("Disabling -Xlog:perf+class+link since UsePerfData is turned off.");





















3791       LogConfiguration::configure_stdout(LogLevel::Off, false, LOG_TAGS(perf, class, link));
3792     }
3793   }





3794 
3795   if (FLAG_IS_CMDLINE(DiagnoseSyncOnValueBasedClasses)) {
3796     if (DiagnoseSyncOnValueBasedClasses == ObjectSynchronizer::LOG_WARNING && !log_is_enabled(Info, valuebasedclasses)) {
3797       LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(valuebasedclasses));
3798     }
3799   }
3800   return JNI_OK;
3801 }
3802 
3803 jint Arguments::adjust_after_os() {
3804   if (UseNUMA) {
3805     if (UseParallelGC) {
3806       if (FLAG_IS_DEFAULT(MinHeapDeltaBytes)) {
3807          FLAG_SET_DEFAULT(MinHeapDeltaBytes, 64*M);
3808       }
3809     }
3810   }
3811   return JNI_OK;
3812 }
3813 

   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/genArguments.hpp"
  39 #include "gc/shared/stringdedup/stringDedup.hpp"
  40 #include "gc/shared/tlab_globals.hpp"
  41 #include "jvm.h"
  42 #include "logging/log.hpp"
  43 #include "logging/logConfiguration.hpp"
  44 #include "logging/logStream.hpp"
  45 #include "logging/logTag.hpp"
  46 #include "memory/allocation.inline.hpp"
  47 #include "nmt/nmtCommon.hpp"
  48 #include "oops/compressedKlass.hpp"
  49 #include "oops/instanceKlass.hpp"

1756   return strcmp(DEFAULT_JAVA_LAUNCHER, _sun_java_launcher) != 0;
1757 }
1758 
1759 bool Arguments::sun_java_launcher_is_altjvm() {
1760   return _sun_java_launcher_is_altjvm;
1761 }
1762 
1763 //===========================================================================================================
1764 // Parsing of main arguments
1765 
1766 static unsigned int addreads_count = 0;
1767 static unsigned int addexports_count = 0;
1768 static unsigned int addopens_count = 0;
1769 static unsigned int patch_mod_count = 0;
1770 static unsigned int enable_native_access_count = 0;
1771 static bool patch_mod_javabase = false;
1772 
1773 // Check the consistency of vm_init_args
1774 bool Arguments::check_vm_args_consistency() {
1775   // This may modify compiler flags. Must be called before CompilerConfig::check_args_consistency()
1776   if (!CDSConfig::check_vm_args_consistency(patch_mod_javabase, mode_flag_cmd_line, xshare_auto_cmd_line)) {
1777     return false;
1778   }
1779 
1780   // Method for adding checks for flag consistency.
1781   // The intent is to warn the user of all possible conflicts,
1782   // before returning an error.
1783   // Note: Needs platform-dependent factoring.
1784   bool status = true;
1785 
1786   if (TLABRefillWasteFraction == 0) {
1787     jio_fprintf(defaultStream::error_stream(),
1788                 "TLABRefillWasteFraction should be a denominator, "
1789                 "not " SIZE_FORMAT "\n",
1790                 TLABRefillWasteFraction);
1791     status = false;
1792   }
1793 
1794   status = CompilerConfig::check_args_consistency(status);
1795 #if INCLUDE_JVMCI
1796   if (status && EnableJVMCI) {

2932   if (FLAG_IS_DEFAULT(UseLargePages) &&
2933       MaxHeapSize < LargePageHeapSizeThreshold) {
2934     // No need for large granularity pages w/small heaps.
2935     // Note that large pages are enabled/disabled for both the
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 (StoreCachedCode) {
2953     FLAG_SET_ERGO_IF_DEFAULT(CachedCodeMaxSize, 512*M);
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) {

3711 
3712   // Set compiler flags after GC is selected and GC specific
3713   // flags (LoopStripMiningIter) are set.
3714   CompilerConfig::ergo_initialize();
3715 
3716   // Set bytecode rewriting flags
3717   set_bytecode_flags();
3718 
3719   // Set flags if aggressive optimization flags are enabled
3720   jint code = set_aggressive_opts_flags();
3721   if (code != JNI_OK) {
3722     return code;
3723   }
3724 
3725   if (FLAG_IS_DEFAULT(UseSecondarySupersTable)) {
3726     FLAG_SET_DEFAULT(UseSecondarySupersTable, VM_Version::supports_secondary_supers_table());
3727   } else if (UseSecondarySupersTable && !VM_Version::supports_secondary_supers_table()) {
3728     warning("UseSecondarySupersTable is not supported");
3729     FLAG_SET_DEFAULT(UseSecondarySupersTable, false);
3730   }
3731   UseSecondarySupersTable = false; // FIXME: Disabled for Leyden. Neet to fix SCAddressTable::id_for_address()
3732   if (!UseSecondarySupersTable) {
3733     FLAG_SET_DEFAULT(StressSecondarySupers, false);
3734     FLAG_SET_DEFAULT(VerifySecondarySupers, false);
3735   }
3736 
3737 #ifdef ZERO
3738   // Clear flags not supported on zero.
3739   FLAG_SET_DEFAULT(ProfileInterpreter, false);
3740 #endif // ZERO
3741 
3742   if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3743     warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3744     DebugNonSafepoints = true;
3745   }
3746 
3747   if (FLAG_IS_CMDLINE(CompressedClassSpaceSize) && !UseCompressedClassPointers) {
3748     warning("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used");
3749   }
3750 
3751   // Treat the odd case where local verification is enabled but remote

3773       warning("Disabling EnableVectorReboxing since EnableVectorSupport is turned off.");
3774     }
3775     FLAG_SET_DEFAULT(EnableVectorReboxing, false);
3776 
3777     if (!FLAG_IS_DEFAULT(EnableVectorAggressiveReboxing) && EnableVectorAggressiveReboxing) {
3778       if (!EnableVectorReboxing) {
3779         warning("Disabling EnableVectorAggressiveReboxing since EnableVectorReboxing is turned off.");
3780       } else {
3781         warning("Disabling EnableVectorAggressiveReboxing since EnableVectorSupport is turned off.");
3782       }
3783     }
3784     FLAG_SET_DEFAULT(EnableVectorAggressiveReboxing, false);
3785 
3786     if (!FLAG_IS_DEFAULT(UseVectorStubs) && UseVectorStubs) {
3787       warning("Disabling UseVectorStubs since EnableVectorSupport is turned off.");
3788     }
3789     FLAG_SET_DEFAULT(UseVectorStubs, false);
3790   }
3791 #endif // COMPILER2_OR_JVMCI
3792 
3793   if (log_is_enabled(Info, init)) {
3794     if (FLAG_IS_DEFAULT(ProfileVMLocks)) {
3795       FLAG_SET_DEFAULT(ProfileVMLocks, true);
3796     }
3797     if (UsePerfData && !log_is_enabled(Info, perf, class, link)) {
3798       // automatically enable -Xlog:perf+class+link
3799       LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(perf, class, link));
3800     }
3801     // Don't turn on ProfileVMCalls and ProfileRuntimeCalls by default.
3802   } else {
3803     if (!FLAG_IS_DEFAULT(ProfileVMLocks) && ProfileVMLocks) {
3804       warning("Disabling ProfileVMLocks since logging is turned off.");
3805       FLAG_SET_DEFAULT(ProfileVMLocks, false);
3806     }
3807     if (!FLAG_IS_DEFAULT(ProfileVMCalls) && ProfileVMCalls) {
3808       warning("Disabling ProfileVMCalls since logging is turned off.");
3809       FLAG_SET_DEFAULT(ProfileVMCalls, false);
3810     }
3811     if (!FLAG_IS_DEFAULT(ProfileRuntimeCalls) && ProfileRuntimeCalls) {
3812       warning("Disabling ProfileRuntimeCalls since logging is turned off.");
3813       FLAG_SET_DEFAULT(ProfileRuntimeCalls, false);
3814     }
3815     if (log_is_enabled(Info, perf, class, link)) {
3816       warning("Disabling -Xlog:perf+class+link since logging is turned off.");
3817       LogConfiguration::configure_stdout(LogLevel::Off, false, LOG_TAGS(perf, class, link));
3818     }
3819   }
3820   if (FLAG_IS_DEFAULT(PerfDataMemorySize)) {
3821     if (ProfileVMLocks || ProfileVMCalls || ProfileRuntimeCalls) {
3822       FLAG_SET_DEFAULT(PerfDataMemorySize, 128*K); // reserve more space for extra perf counters
3823     }
3824   }
3825 
3826   if (FLAG_IS_CMDLINE(DiagnoseSyncOnValueBasedClasses)) {
3827     if (DiagnoseSyncOnValueBasedClasses == ObjectSynchronizer::LOG_WARNING && !log_is_enabled(Info, valuebasedclasses)) {
3828       LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(valuebasedclasses));
3829     }
3830   }
3831   return JNI_OK;
3832 }
3833 
3834 jint Arguments::adjust_after_os() {
3835   if (UseNUMA) {
3836     if (UseParallelGC) {
3837       if (FLAG_IS_DEFAULT(MinHeapDeltaBytes)) {
3838          FLAG_SET_DEFAULT(MinHeapDeltaBytes, 64*M);
3839       }
3840     }
3841   }
3842   return JNI_OK;
3843 }
3844 
< prev index next >