1763 return strcmp(DEFAULT_JAVA_LAUNCHER, _sun_java_launcher) != 0;
1764 }
1765
1766 bool Arguments::sun_java_launcher_is_altjvm() {
1767 return _sun_java_launcher_is_altjvm;
1768 }
1769
1770 //===========================================================================================================
1771 // Parsing of main arguments
1772
1773 static unsigned int addreads_count = 0;
1774 static unsigned int addexports_count = 0;
1775 static unsigned int addopens_count = 0;
1776 static unsigned int patch_mod_count = 0;
1777 static unsigned int enable_native_access_count = 0;
1778 static bool patch_mod_javabase = false;
1779
1780 // Check the consistency of vm_init_args
1781 bool Arguments::check_vm_args_consistency() {
1782 // This may modify compiler flags. Must be called before CompilerConfig::check_args_consistency()
1783 if (!CDSConfig::check_vm_args_consistency(patch_mod_javabase, mode_flag_cmd_line)) {
1784 return false;
1785 }
1786
1787 // Method for adding checks for flag consistency.
1788 // The intent is to warn the user of all possible conflicts,
1789 // before returning an error.
1790 // Note: Needs platform-dependent factoring.
1791 bool status = true;
1792
1793 if (TLABRefillWasteFraction == 0) {
1794 jio_fprintf(defaultStream::error_stream(),
1795 "TLABRefillWasteFraction should be a denominator, "
1796 "not %zu\n",
1797 TLABRefillWasteFraction);
1798 status = false;
1799 }
1800
1801 status = CompilerConfig::check_args_consistency(status);
1802 #if INCLUDE_JVMCI
1803 if (status && EnableJVMCI) {
2943 if (FLAG_IS_DEFAULT(UseLargePages) &&
2944 MaxHeapSize < LargePageHeapSizeThreshold) {
2945 // No need for large granularity pages w/small heaps.
2946 // Note that large pages are enabled/disabled for both the
2947 // Java heap and the code cache.
2948 FLAG_SET_DEFAULT(UseLargePages, false);
2949 }
2950
2951 UNSUPPORTED_OPTION(ProfileInterpreter);
2952 #endif
2953
2954 // Parse the CompilationMode flag
2955 if (!CompilationModeFlag::initialize()) {
2956 return JNI_ERR;
2957 }
2958
2959 if (!check_vm_args_consistency()) {
2960 return JNI_ERR;
2961 }
2962
2963
2964 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
2965 UNSUPPORTED_OPTION(ShowRegistersOnAssert);
2966 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
2967
2968 return JNI_OK;
2969 }
2970
2971 // Helper class for controlling the lifetime of JavaVMInitArgs
2972 // objects. The contents of the JavaVMInitArgs are guaranteed to be
2973 // deleted on the destruction of the ScopedVMInitArgs object.
2974 class ScopedVMInitArgs : public StackObj {
2975 private:
2976 JavaVMInitArgs _args;
2977 char* _container_name;
2978 bool _is_set;
2979 char* _vm_options_file_arg;
2980
2981 public:
2982 ScopedVMInitArgs(const char *container_name) {
3061 for (int j = 0; j < args_to_insert->nOptions; j++) {
3062 options.push(args_to_insert->options[j]);
3063 }
3064 } else {
3065 options.push(args->options[i]);
3066 }
3067 }
3068 // make into options array
3069 return set_args(&options);
3070 }
3071 };
3072
3073 jint Arguments::parse_java_options_environment_variable(ScopedVMInitArgs* args) {
3074 return parse_options_environment_variable("_JAVA_OPTIONS", args);
3075 }
3076
3077 jint Arguments::parse_java_tool_options_environment_variable(ScopedVMInitArgs* args) {
3078 return parse_options_environment_variable("JAVA_TOOL_OPTIONS", args);
3079 }
3080
3081 jint Arguments::parse_options_environment_variable(const char* name,
3082 ScopedVMInitArgs* vm_args) {
3083 char *buffer = ::getenv(name);
3084
3085 // Don't check this environment variable if user has special privileges
3086 // (e.g. unix su command).
3087 if (buffer == nullptr || os::have_special_privileges()) {
3088 return JNI_OK;
3089 }
3090
3091 if ((buffer = os::strdup(buffer)) == nullptr) {
3092 return JNI_ENOMEM;
3093 }
3094
3095 jio_fprintf(defaultStream::error_stream(),
3096 "Picked up %s: %s\n", name, buffer);
3097
3098 int retcode = parse_options_buffer(name, buffer, strlen(buffer), vm_args);
3099
3100 os::free(buffer);
3719
3720 // Set compiler flags after GC is selected and GC specific
3721 // flags (LoopStripMiningIter) are set.
3722 CompilerConfig::ergo_initialize();
3723
3724 // Set bytecode rewriting flags
3725 set_bytecode_flags();
3726
3727 // Set flags if aggressive optimization flags are enabled
3728 jint code = set_aggressive_opts_flags();
3729 if (code != JNI_OK) {
3730 return code;
3731 }
3732
3733 if (FLAG_IS_DEFAULT(UseSecondarySupersTable)) {
3734 FLAG_SET_DEFAULT(UseSecondarySupersTable, VM_Version::supports_secondary_supers_table());
3735 } else if (UseSecondarySupersTable && !VM_Version::supports_secondary_supers_table()) {
3736 warning("UseSecondarySupersTable is not supported");
3737 FLAG_SET_DEFAULT(UseSecondarySupersTable, false);
3738 }
3739 if (!UseSecondarySupersTable) {
3740 FLAG_SET_DEFAULT(StressSecondarySupers, false);
3741 FLAG_SET_DEFAULT(VerifySecondarySupers, false);
3742 }
3743
3744 #ifdef ZERO
3745 // Clear flags not supported on zero.
3746 FLAG_SET_DEFAULT(ProfileInterpreter, false);
3747 #endif // ZERO
3748
3749 if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3750 warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3751 DebugNonSafepoints = true;
3752 }
3753
3754 if (FLAG_IS_CMDLINE(CompressedClassSpaceSize) && !UseCompressedClassPointers) {
3755 warning("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used");
3756 }
3757
3758 // Treat the odd case where local verification is enabled but remote
3787 } else {
3788 warning("Disabling EnableVectorAggressiveReboxing since EnableVectorSupport is turned off.");
3789 }
3790 }
3791 FLAG_SET_DEFAULT(EnableVectorAggressiveReboxing, false);
3792
3793 if (!FLAG_IS_DEFAULT(UseVectorStubs) && UseVectorStubs) {
3794 warning("Disabling UseVectorStubs since EnableVectorSupport is turned off.");
3795 }
3796 FLAG_SET_DEFAULT(UseVectorStubs, false);
3797 }
3798 #endif // COMPILER2_OR_JVMCI
3799
3800 #ifdef COMPILER2
3801 if (!FLAG_IS_DEFAULT(UseLoopPredicate) && !UseLoopPredicate && UseProfiledLoopPredicate) {
3802 warning("Disabling UseProfiledLoopPredicate since UseLoopPredicate is turned off.");
3803 FLAG_SET_ERGO(UseProfiledLoopPredicate, false);
3804 }
3805 #endif // COMPILER2
3806
3807 if (log_is_enabled(Info, perf, class, link)) {
3808 if (!UsePerfData) {
3809 warning("Disabling -Xlog:perf+class+link since UsePerfData is turned off.");
3810 LogConfiguration::disable_tags(false, LOG_TAGS(perf, class, link));
3811 assert(!log_is_enabled(Info, perf, class, link), "sanity");
3812 }
3813 }
3814
3815 if (FLAG_IS_CMDLINE(DiagnoseSyncOnValueBasedClasses)) {
3816 if (DiagnoseSyncOnValueBasedClasses == ObjectSynchronizer::LOG_WARNING && !log_is_enabled(Info, valuebasedclasses)) {
3817 LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(valuebasedclasses));
3818 }
3819 }
3820 return JNI_OK;
3821 }
3822
3823 jint Arguments::adjust_after_os() {
3824 if (UseNUMA) {
3825 if (UseParallelGC) {
3826 if (FLAG_IS_DEFAULT(MinHeapDeltaBytes)) {
3827 FLAG_SET_DEFAULT(MinHeapDeltaBytes, 64*M);
3828 }
3829 }
3830 }
3831 return JNI_OK;
3832 }
3833
|
1763 return strcmp(DEFAULT_JAVA_LAUNCHER, _sun_java_launcher) != 0;
1764 }
1765
1766 bool Arguments::sun_java_launcher_is_altjvm() {
1767 return _sun_java_launcher_is_altjvm;
1768 }
1769
1770 //===========================================================================================================
1771 // Parsing of main arguments
1772
1773 static unsigned int addreads_count = 0;
1774 static unsigned int addexports_count = 0;
1775 static unsigned int addopens_count = 0;
1776 static unsigned int patch_mod_count = 0;
1777 static unsigned int enable_native_access_count = 0;
1778 static bool patch_mod_javabase = false;
1779
1780 // Check the consistency of vm_init_args
1781 bool Arguments::check_vm_args_consistency() {
1782 // This may modify compiler flags. Must be called before CompilerConfig::check_args_consistency()
1783 if (!CDSConfig::check_vm_args_consistency(patch_mod_javabase, mode_flag_cmd_line, xshare_auto_cmd_line)) {
1784 return false;
1785 }
1786
1787 // Method for adding checks for flag consistency.
1788 // The intent is to warn the user of all possible conflicts,
1789 // before returning an error.
1790 // Note: Needs platform-dependent factoring.
1791 bool status = true;
1792
1793 if (TLABRefillWasteFraction == 0) {
1794 jio_fprintf(defaultStream::error_stream(),
1795 "TLABRefillWasteFraction should be a denominator, "
1796 "not %zu\n",
1797 TLABRefillWasteFraction);
1798 status = false;
1799 }
1800
1801 status = CompilerConfig::check_args_consistency(status);
1802 #if INCLUDE_JVMCI
1803 if (status && EnableJVMCI) {
2943 if (FLAG_IS_DEFAULT(UseLargePages) &&
2944 MaxHeapSize < LargePageHeapSizeThreshold) {
2945 // No need for large granularity pages w/small heaps.
2946 // Note that large pages are enabled/disabled for both the
2947 // Java heap and the code cache.
2948 FLAG_SET_DEFAULT(UseLargePages, false);
2949 }
2950
2951 UNSUPPORTED_OPTION(ProfileInterpreter);
2952 #endif
2953
2954 // Parse the CompilationMode flag
2955 if (!CompilationModeFlag::initialize()) {
2956 return JNI_ERR;
2957 }
2958
2959 if (!check_vm_args_consistency()) {
2960 return JNI_ERR;
2961 }
2962
2963 if (StoreCachedCode) {
2964 FLAG_SET_ERGO_IF_DEFAULT(CachedCodeMaxSize, 512*M);
2965 }
2966
2967 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
2968 UNSUPPORTED_OPTION(ShowRegistersOnAssert);
2969 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
2970
2971 return JNI_OK;
2972 }
2973
2974 // Helper class for controlling the lifetime of JavaVMInitArgs
2975 // objects. The contents of the JavaVMInitArgs are guaranteed to be
2976 // deleted on the destruction of the ScopedVMInitArgs object.
2977 class ScopedVMInitArgs : public StackObj {
2978 private:
2979 JavaVMInitArgs _args;
2980 char* _container_name;
2981 bool _is_set;
2982 char* _vm_options_file_arg;
2983
2984 public:
2985 ScopedVMInitArgs(const char *container_name) {
3064 for (int j = 0; j < args_to_insert->nOptions; j++) {
3065 options.push(args_to_insert->options[j]);
3066 }
3067 } else {
3068 options.push(args->options[i]);
3069 }
3070 }
3071 // make into options array
3072 return set_args(&options);
3073 }
3074 };
3075
3076 jint Arguments::parse_java_options_environment_variable(ScopedVMInitArgs* args) {
3077 return parse_options_environment_variable("_JAVA_OPTIONS", args);
3078 }
3079
3080 jint Arguments::parse_java_tool_options_environment_variable(ScopedVMInitArgs* args) {
3081 return parse_options_environment_variable("JAVA_TOOL_OPTIONS", args);
3082 }
3083
3084 // We return the "initial" options without calling expand_vm_options_as_needed(). The intention is
3085 // that the options will be passed verbatim to the child process that assembles the AOT
3086 // cache (inside JAVA_TOOL_OPTIONS). The child process will do the expansion when processing
3087 // JAVA_TOOL_OPTIONS.
3088 jint Arguments::parse_aot_tool_options_environment_variable(GrowableArray<const char*>* options) {
3089 ScopedVMInitArgs initial_args("env_var='AOT_TOOL_OPTIONS'");
3090 jint code = parse_options_environment_variable("AOT_TOOL_OPTIONS", &initial_args);
3091 if (code != JNI_OK) {
3092 return code;
3093 }
3094
3095 JavaVMInitArgs* args = initial_args.get();
3096 for (int index = 0; index < args->nOptions; index++) {
3097 const JavaVMOption *option = args->options + index;
3098 const char* optionString = option->optionString;
3099 char* s = NEW_RESOURCE_ARRAY(char, strlen(optionString) + 1);
3100 strcpy(s, optionString);
3101 options->append(s);
3102 }
3103
3104 return JNI_OK;
3105 }
3106
3107 jint Arguments::parse_options_environment_variable(const char* name,
3108 ScopedVMInitArgs* vm_args) {
3109 char *buffer = ::getenv(name);
3110
3111 // Don't check this environment variable if user has special privileges
3112 // (e.g. unix su command).
3113 if (buffer == nullptr || os::have_special_privileges()) {
3114 return JNI_OK;
3115 }
3116
3117 if ((buffer = os::strdup(buffer)) == nullptr) {
3118 return JNI_ENOMEM;
3119 }
3120
3121 jio_fprintf(defaultStream::error_stream(),
3122 "Picked up %s: %s\n", name, buffer);
3123
3124 int retcode = parse_options_buffer(name, buffer, strlen(buffer), vm_args);
3125
3126 os::free(buffer);
3745
3746 // Set compiler flags after GC is selected and GC specific
3747 // flags (LoopStripMiningIter) are set.
3748 CompilerConfig::ergo_initialize();
3749
3750 // Set bytecode rewriting flags
3751 set_bytecode_flags();
3752
3753 // Set flags if aggressive optimization flags are enabled
3754 jint code = set_aggressive_opts_flags();
3755 if (code != JNI_OK) {
3756 return code;
3757 }
3758
3759 if (FLAG_IS_DEFAULT(UseSecondarySupersTable)) {
3760 FLAG_SET_DEFAULT(UseSecondarySupersTable, VM_Version::supports_secondary_supers_table());
3761 } else if (UseSecondarySupersTable && !VM_Version::supports_secondary_supers_table()) {
3762 warning("UseSecondarySupersTable is not supported");
3763 FLAG_SET_DEFAULT(UseSecondarySupersTable, false);
3764 }
3765 UseSecondarySupersTable = false; // FIXME: Disabled for Leyden. Neet to fix SCAddressTable::id_for_address()
3766 if (!UseSecondarySupersTable) {
3767 FLAG_SET_DEFAULT(StressSecondarySupers, false);
3768 FLAG_SET_DEFAULT(VerifySecondarySupers, false);
3769 }
3770
3771 #ifdef ZERO
3772 // Clear flags not supported on zero.
3773 FLAG_SET_DEFAULT(ProfileInterpreter, false);
3774 #endif // ZERO
3775
3776 if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3777 warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3778 DebugNonSafepoints = true;
3779 }
3780
3781 if (FLAG_IS_CMDLINE(CompressedClassSpaceSize) && !UseCompressedClassPointers) {
3782 warning("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used");
3783 }
3784
3785 // Treat the odd case where local verification is enabled but remote
3814 } else {
3815 warning("Disabling EnableVectorAggressiveReboxing since EnableVectorSupport is turned off.");
3816 }
3817 }
3818 FLAG_SET_DEFAULT(EnableVectorAggressiveReboxing, false);
3819
3820 if (!FLAG_IS_DEFAULT(UseVectorStubs) && UseVectorStubs) {
3821 warning("Disabling UseVectorStubs since EnableVectorSupport is turned off.");
3822 }
3823 FLAG_SET_DEFAULT(UseVectorStubs, false);
3824 }
3825 #endif // COMPILER2_OR_JVMCI
3826
3827 #ifdef COMPILER2
3828 if (!FLAG_IS_DEFAULT(UseLoopPredicate) && !UseLoopPredicate && UseProfiledLoopPredicate) {
3829 warning("Disabling UseProfiledLoopPredicate since UseLoopPredicate is turned off.");
3830 FLAG_SET_ERGO(UseProfiledLoopPredicate, false);
3831 }
3832 #endif // COMPILER2
3833
3834 if (log_is_enabled(Info, init)) {
3835 if (FLAG_IS_DEFAULT(ProfileVMLocks)) {
3836 FLAG_SET_DEFAULT(ProfileVMLocks, true);
3837 }
3838 if (UsePerfData && !log_is_enabled(Info, perf, class, link)) {
3839 // automatically enable -Xlog:perf+class+link
3840 LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(perf, class, link));
3841 }
3842 // Don't turn on ProfileVMCalls and ProfileRuntimeCalls by default.
3843 } else {
3844 if (!FLAG_IS_DEFAULT(ProfileVMLocks) && ProfileVMLocks) {
3845 warning("Disabling ProfileVMLocks since logging is turned off.");
3846 FLAG_SET_DEFAULT(ProfileVMLocks, false);
3847 }
3848 if (!FLAG_IS_DEFAULT(ProfileVMCalls) && ProfileVMCalls) {
3849 warning("Disabling ProfileVMCalls since logging is turned off.");
3850 FLAG_SET_DEFAULT(ProfileVMCalls, false);
3851 }
3852 if (!FLAG_IS_DEFAULT(ProfileRuntimeCalls) && ProfileRuntimeCalls) {
3853 warning("Disabling ProfileRuntimeCalls since logging is turned off.");
3854 FLAG_SET_DEFAULT(ProfileRuntimeCalls, false);
3855 }
3856 if (log_is_enabled(Info, perf, class, link)) {
3857 warning("Disabling -Xlog:perf+class+link since logging is turned off.");
3858 LogConfiguration::disable_tags(false, LOG_TAGS(perf, class, link));
3859 assert(!log_is_enabled(Info, perf, class, link), "sanity");
3860 }
3861 }
3862 if (FLAG_IS_DEFAULT(PerfDataMemorySize)) {
3863 if (ProfileVMLocks || ProfileVMCalls || ProfileRuntimeCalls) {
3864 FLAG_SET_DEFAULT(PerfDataMemorySize, 128*K); // reserve more space for extra perf counters
3865 }
3866 }
3867
3868 if (FLAG_IS_CMDLINE(DiagnoseSyncOnValueBasedClasses)) {
3869 if (DiagnoseSyncOnValueBasedClasses == ObjectSynchronizer::LOG_WARNING && !log_is_enabled(Info, valuebasedclasses)) {
3870 LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(valuebasedclasses));
3871 }
3872 }
3873 return JNI_OK;
3874 }
3875
3876 jint Arguments::adjust_after_os() {
3877 if (UseNUMA) {
3878 if (UseParallelGC) {
3879 if (FLAG_IS_DEFAULT(MinHeapDeltaBytes)) {
3880 FLAG_SET_DEFAULT(MinHeapDeltaBytes, 64*M);
3881 }
3882 }
3883 }
3884 return JNI_OK;
3885 }
3886
|