109
110 AgentLibraryList Arguments::_libraryList;
111 AgentLibraryList Arguments::_agentList;
112
113 abort_hook_t Arguments::_abort_hook = NULL;
114 exit_hook_t Arguments::_exit_hook = NULL;
115 vfprintf_hook_t Arguments::_vfprintf_hook = NULL;
116
117
118 SystemProperty *Arguments::_java_ext_dirs = NULL;
119 SystemProperty *Arguments::_java_endorsed_dirs = NULL;
120 SystemProperty *Arguments::_sun_boot_library_path = NULL;
121 SystemProperty *Arguments::_java_library_path = NULL;
122 SystemProperty *Arguments::_java_home = NULL;
123 SystemProperty *Arguments::_java_class_path = NULL;
124 SystemProperty *Arguments::_sun_boot_class_path = NULL;
125
126 char* Arguments::_meta_index_path = NULL;
127 char* Arguments::_meta_index_dir = NULL;
128
129 // Check if head of 'option' matches 'name', and sets 'tail' remaining part of option string
130
131 static bool match_option(const JavaVMOption *option, const char* name,
132 const char** tail) {
133 int len = (int)strlen(name);
134 if (strncmp(option->optionString, name, len) == 0) {
135 *tail = option->optionString + len;
136 return true;
137 } else {
138 return false;
139 }
140 }
141
142 static void logOption(const char* opt) {
143 if (PrintVMOptions) {
144 jio_fprintf(defaultStream::output_stream(), "VM option '%s'\n", opt);
145 }
146 }
147
148 // Process java launcher properties.
149 void Arguments::process_sun_java_launcher_properties(JavaVMInitArgs* args) {
150 // See if sun.java.launcher, sun.java.launcher.is_altjvm or
151 // sun.java.launcher.pid is defined.
152 // Must do this before setting up other system properties,
153 // as some of them may depend on launcher type.
154 for (int index = 0; index < args->nOptions; index++) {
155 const JavaVMOption* option = args->options + index;
156 const char* tail;
157
158 if (match_option(option, "-Dsun.java.launcher=", &tail)) {
159 process_java_launcher_argument(tail, option->extraInfo);
160 continue;
161 }
2559 jio_fprintf(defaultStream::error_stream(),
2560 "Obsolete %s%soption: %s\n", option_type, spacer,
2561 option->optionString);
2562 return false;
2563 } else {
2564 jio_fprintf(defaultStream::error_stream(),
2565 "Unrecognized %s%soption: %s\n", option_type, spacer,
2566 option->optionString);
2567 return true;
2568 }
2569 }
2570
2571 static const char* user_assertion_options[] = {
2572 "-da", "-ea", "-disableassertions", "-enableassertions", 0
2573 };
2574
2575 static const char* system_assertion_options[] = {
2576 "-dsa", "-esa", "-disablesystemassertions", "-enablesystemassertions", 0
2577 };
2578
2579 // Return true if any of the strings in null-terminated array 'names' matches.
2580 // If tail_allowed is true, then the tail must begin with a colon; otherwise,
2581 // the option must match exactly.
2582 static bool match_option(const JavaVMOption* option, const char** names, const char** tail,
2583 bool tail_allowed) {
2584 for (/* empty */; *names != NULL; ++names) {
2585 if (match_option(option, *names, tail)) {
2586 if (**tail == '\0' || tail_allowed && **tail == ':') {
2587 return true;
2588 }
2589 }
2590 }
2591 return false;
2592 }
2593
2594 bool Arguments::parse_uintx(const char* value,
2595 uintx* uintx_arg,
2596 uintx min_size) {
2597
2598 // Check the sign first since atomull() parses only unsigned values.
2599 bool value_is_positive = !(*value == '-');
2600
2601 if (value_is_positive) {
2602 julong n;
2603 bool good_return = atomull(value, &n);
2604 if (good_return) {
2605 bool above_minimum = n >= min_size;
2606 bool value_is_too_large = n > max_uintx;
2607
2608 if (above_minimum && !value_is_too_large) {
2609 *uintx_arg = n;
2610 return true;
2611 }
2612 }
2613 }
2815 jio_fprintf(defaultStream::error_stream(),
2816 "Profiling and debugging agents are not supported in this VM\n");
2817 return JNI_ERR;
2818 }
2819 #endif // !INCLUDE_JVMTI
2820 add_init_agent(name, options, is_absolute_path);
2821 }
2822 // -javaagent
2823 } else if (match_option(option, "-javaagent:", &tail)) {
2824 #if !INCLUDE_JVMTI
2825 jio_fprintf(defaultStream::error_stream(),
2826 "Instrumentation agents are not supported in this VM\n");
2827 return JNI_ERR;
2828 #else
2829 if(tail != NULL) {
2830 char *options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(tail) + 1, mtInternal), tail);
2831 add_init_agent("instrument", options, false);
2832 }
2833 #endif // !INCLUDE_JVMTI
2834 // -Xnoclassgc
2835 } else if (match_option(option, "-Xnoclassgc", &tail)) {
2836 FLAG_SET_CMDLINE(bool, ClassUnloading, false);
2837 // -Xconcgc
2838 } else if (match_option(option, "-Xconcgc", &tail)) {
2839 FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, true);
2840 // -Xnoconcgc
2841 } else if (match_option(option, "-Xnoconcgc", &tail)) {
2842 FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, false);
2843 // -Xbatch
2844 } else if (match_option(option, "-Xbatch", &tail)) {
2845 FLAG_SET_CMDLINE(bool, BackgroundCompilation, false);
2846 // -Xmn for compatibility with other JVM vendors
2847 } else if (match_option(option, "-Xmn", &tail)) {
2848 julong long_initial_young_size = 0;
2849 ArgsRange errcode = parse_memory_size(tail, &long_initial_young_size, 1);
2850 if (errcode != arg_in_range) {
2851 jio_fprintf(defaultStream::error_stream(),
2852 "Invalid initial young generation size: %s\n", option->optionString);
2853 describe_range_error(errcode);
2854 return JNI_EINVAL;
2855 }
2856 FLAG_SET_CMDLINE(uintx, MaxNewSize, (uintx)long_initial_young_size);
2857 FLAG_SET_CMDLINE(uintx, NewSize, (uintx)long_initial_young_size);
2858 // -Xms
2859 } else if (match_option(option, "-Xms", &tail)) {
2860 julong long_initial_heap_size = 0;
2861 // an initial heap size of 0 means automatically determine
2862 ArgsRange errcode = parse_memory_size(tail, &long_initial_heap_size, 0);
2863 if (errcode != arg_in_range) {
2864 jio_fprintf(defaultStream::error_stream(),
2969 julong long_NonProfiledCodeHeapSize = 0;
2970
2971 ArgsRange errcode = parse_memory_size(tail, &long_NonProfiledCodeHeapSize, 1);
2972 if (errcode != arg_in_range) {
2973 jio_fprintf(defaultStream::error_stream(),
2974 "Invalid maximum non-profiled code heap size: %s.\n", option->optionString);
2975 return JNI_EINVAL;
2976 }
2977 FLAG_SET_CMDLINE(uintx, NonProfiledCodeHeapSize, (uintx)long_NonProfiledCodeHeapSize);
2978 //-XX:IncreaseFirstTierCompileThresholdAt=
2979 } else if (match_option(option, "-XX:IncreaseFirstTierCompileThresholdAt=", &tail)) {
2980 uintx uint_IncreaseFirstTierCompileThresholdAt = 0;
2981 if (!parse_uintx(tail, &uint_IncreaseFirstTierCompileThresholdAt, 0) || uint_IncreaseFirstTierCompileThresholdAt > 99) {
2982 jio_fprintf(defaultStream::error_stream(),
2983 "Invalid value for IncreaseFirstTierCompileThresholdAt: %s. Should be between 0 and 99.\n",
2984 option->optionString);
2985 return JNI_EINVAL;
2986 }
2987 FLAG_SET_CMDLINE(uintx, IncreaseFirstTierCompileThresholdAt, (uintx)uint_IncreaseFirstTierCompileThresholdAt);
2988 // -green
2989 } else if (match_option(option, "-green", &tail)) {
2990 jio_fprintf(defaultStream::error_stream(),
2991 "Green threads support not available\n");
2992 return JNI_EINVAL;
2993 // -native
2994 } else if (match_option(option, "-native", &tail)) {
2995 // HotSpot always uses native threads, ignore silently for compatibility
2996 // -Xsqnopause
2997 } else if (match_option(option, "-Xsqnopause", &tail)) {
2998 // EVM option, ignore silently for compatibility
2999 // -Xrs
3000 } else if (match_option(option, "-Xrs", &tail)) {
3001 // Classic/EVM option, new functionality
3002 FLAG_SET_CMDLINE(bool, ReduceSignalUsage, true);
3003 } else if (match_option(option, "-Xusealtsigs", &tail)) {
3004 // change default internal VM signals used - lower case for back compat
3005 FLAG_SET_CMDLINE(bool, UseAltSigs, true);
3006 // -Xoptimize
3007 } else if (match_option(option, "-Xoptimize", &tail)) {
3008 // EVM option, ignore silently for compatibility
3009 // -Xprof
3010 } else if (match_option(option, "-Xprof", &tail)) {
3011 #if INCLUDE_FPROF
3012 _has_profile = true;
3013 #else // INCLUDE_FPROF
3014 jio_fprintf(defaultStream::error_stream(),
3015 "Flat profiling is not supported in this VM.\n");
3016 return JNI_ERR;
3017 #endif // INCLUDE_FPROF
3018 // -Xconcurrentio
3019 } else if (match_option(option, "-Xconcurrentio", &tail)) {
3020 FLAG_SET_CMDLINE(bool, UseLWPSynchronization, true);
3021 FLAG_SET_CMDLINE(bool, BackgroundCompilation, false);
3022 FLAG_SET_CMDLINE(intx, DeferThrSuspendLoopCount, 1);
3023 FLAG_SET_CMDLINE(bool, UseTLAB, false);
3024 FLAG_SET_CMDLINE(uintx, NewSizeThreadIncrease, 16 * K); // 20Kb per thread added to new generation
3025
3026 // -Xinternalversion
3027 } else if (match_option(option, "-Xinternalversion", &tail)) {
3028 jio_fprintf(defaultStream::output_stream(), "%s\n",
3029 VM_Version::internal_vm_info_string());
3030 vm_exit(0);
3031 #ifndef PRODUCT
3032 // -Xprintflags
3033 } else if (match_option(option, "-Xprintflags", &tail)) {
3034 CommandLineFlags::printFlags(tty, false);
3035 vm_exit(0);
3036 #endif
3037 // -D
3038 } else if (match_option(option, "-D", &tail)) {
3039 if (!add_property(tail)) {
3040 return JNI_ENOMEM;
3041 }
3042 // Out of the box management support
3043 if (match_option(option, "-Dcom.sun.management", &tail)) {
3044 #if INCLUDE_MANAGEMENT
3045 FLAG_SET_CMDLINE(bool, ManagementServer, true);
3046 #else
3047 jio_fprintf(defaultStream::output_stream(),
3048 "-Dcom.sun.management is not supported in this VM.\n");
3049 return JNI_ERR;
3050 #endif
3051 }
3052 // -Xint
3053 } else if (match_option(option, "-Xint", &tail)) {
3054 set_mode_flags(_int);
3055 // -Xmixed
3056 } else if (match_option(option, "-Xmixed", &tail)) {
3057 set_mode_flags(_mixed);
3058 // -Xcomp
3059 } else if (match_option(option, "-Xcomp", &tail)) {
3060 // for testing the compiler; turn off all flags that inhibit compilation
3061 set_mode_flags(_comp);
3062 // -Xshare:dump
3063 } else if (match_option(option, "-Xshare:dump", &tail)) {
3064 FLAG_SET_CMDLINE(bool, DumpSharedSpaces, true);
3065 set_mode_flags(_int); // Prevent compilation, which creates objects
3066 // -Xshare:on
3067 } else if (match_option(option, "-Xshare:on", &tail)) {
3068 FLAG_SET_CMDLINE(bool, UseSharedSpaces, true);
3069 FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true);
3070 // -Xshare:auto
3071 } else if (match_option(option, "-Xshare:auto", &tail)) {
3072 FLAG_SET_CMDLINE(bool, UseSharedSpaces, true);
3073 FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false);
3074 // -Xshare:off
3075 } else if (match_option(option, "-Xshare:off", &tail)) {
3076 FLAG_SET_CMDLINE(bool, UseSharedSpaces, false);
3077 FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false);
3078 // -Xverify
3079 } else if (match_option(option, "-Xverify", &tail)) {
3080 if (strcmp(tail, ":all") == 0 || strcmp(tail, "") == 0) {
3081 FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, true);
3082 FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true);
3083 } else if (strcmp(tail, ":remote") == 0) {
3084 FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false);
3085 FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true);
3086 } else if (strcmp(tail, ":none") == 0) {
3087 FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false);
3088 FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, false);
3089 } else if (is_bad_option(option, args->ignoreUnrecognized, "verification")) {
3090 return JNI_EINVAL;
3091 }
3092 // -Xdebug
3093 } else if (match_option(option, "-Xdebug", &tail)) {
3094 // note this flag has been used, then ignore
3095 set_xdebug_mode(true);
3096 // -Xnoagent
3097 } else if (match_option(option, "-Xnoagent", &tail)) {
3098 // For compatibility with classic. HotSpot refuses to load the old style agent.dll.
3099 } else if (match_option(option, "-Xboundthreads", &tail)) {
3100 // Bind user level threads to kernel threads (Solaris only)
3101 FLAG_SET_CMDLINE(bool, UseBoundThreads, true);
3102 } else if (match_option(option, "-Xloggc:", &tail)) {
3103 // Redirect GC output to the file. -Xloggc:<filename>
3104 // ostream_init_log(), when called will use this filename
3105 // to initialize a fileStream.
3106 _gc_log_filename = os::strdup_check_oom(tail);
3107 if (!is_filename_valid(_gc_log_filename)) {
3108 jio_fprintf(defaultStream::output_stream(),
3109 "Invalid file name for use with -Xloggc: Filename can only contain the "
3110 "characters [A-Z][a-z][0-9]-_.%%[p|t] but it has been %s\n"
3111 "Note %%p or %%t can only be used once\n", _gc_log_filename);
3112 return JNI_EINVAL;
3113 }
3114 FLAG_SET_CMDLINE(bool, PrintGC, true);
3115 FLAG_SET_CMDLINE(bool, PrintGCTimeStamps, true);
3116
3117 // JNI hooks
3118 } else if (match_option(option, "-Xcheck", &tail)) {
3119 if (!strcmp(tail, ":jni")) {
3120 #if !INCLUDE_JNI_CHECK
3121 warning("JNI CHECKING is not supported in this VM");
3122 #else
3123 CheckJNICalls = true;
3124 #endif // INCLUDE_JNI_CHECK
3125 } else if (is_bad_option(option, args->ignoreUnrecognized,
3126 "check")) {
3127 return JNI_EINVAL;
3128 }
3129 } else if (match_option(option, "vfprintf", &tail)) {
3130 _vfprintf_hook = CAST_TO_FN_PTR(vfprintf_hook_t, option->extraInfo);
3131 } else if (match_option(option, "exit", &tail)) {
3132 _exit_hook = CAST_TO_FN_PTR(exit_hook_t, option->extraInfo);
3133 } else if (match_option(option, "abort", &tail)) {
3134 _abort_hook = CAST_TO_FN_PTR(abort_hook_t, option->extraInfo);
3135 // -XX:+AggressiveHeap
3136 } else if (match_option(option, "-XX:+AggressiveHeap", &tail)) {
3137
3138 // This option inspects the machine and attempts to set various
3139 // parameters to be optimal for long-running, memory allocation
3140 // intensive jobs. It is intended for machines with large
3141 // amounts of cpu and memory.
3142
3143 // initHeapSize is needed since _initial_heap_size is 4 bytes on a 32 bit
3144 // VM, but we may not be able to represent the total physical memory
3145 // available (like having 8gb of memory on a box but using a 32bit VM).
3146 // Thus, we need to make sure we're using a julong for intermediate
3147 // calculations.
3148 julong initHeapSize;
3149 julong total_memory = os::physical_memory();
3150
3151 if (total_memory < (julong)256*M) {
3152 jio_fprintf(defaultStream::error_stream(),
3153 "You need at least 256mb of memory to use -XX:+AggressiveHeap\n");
3154 vm_exit(1);
3155 }
3156
3207 FLAG_SET_CMDLINE(uintx, OldPLABSize, 8*K); // Note: this is in words
3208
3209 // Enable parallel GC and adaptive generation sizing
3210 FLAG_SET_CMDLINE(bool, UseParallelGC, true);
3211 FLAG_SET_DEFAULT(ParallelGCThreads,
3212 Abstract_VM_Version::parallel_worker_threads());
3213
3214 // Encourage steady state memory management
3215 FLAG_SET_CMDLINE(uintx, ThresholdTolerance, 100);
3216
3217 // This appears to improve mutator locality
3218 FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false);
3219
3220 // Get around early Solaris scheduling bug
3221 // (affinity vs other jobs on system)
3222 // but disallow DR and offlining (5008695).
3223 FLAG_SET_CMDLINE(bool, BindGCTaskThreadsToCPUs, true);
3224
3225 // Need to keep consistency of MaxTenuringThreshold and AlwaysTenure/NeverTenure;
3226 // and the last option wins.
3227 } else if (match_option(option, "-XX:+NeverTenure", &tail)) {
3228 FLAG_SET_CMDLINE(bool, NeverTenure, true);
3229 FLAG_SET_CMDLINE(bool, AlwaysTenure, false);
3230 FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, markOopDesc::max_age + 1);
3231 } else if (match_option(option, "-XX:+AlwaysTenure", &tail)) {
3232 FLAG_SET_CMDLINE(bool, NeverTenure, false);
3233 FLAG_SET_CMDLINE(bool, AlwaysTenure, true);
3234 FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, 0);
3235 } else if (match_option(option, "-XX:MaxTenuringThreshold=", &tail)) {
3236 uintx max_tenuring_thresh = 0;
3237 if(!parse_uintx(tail, &max_tenuring_thresh, 0)) {
3238 jio_fprintf(defaultStream::error_stream(),
3239 "Invalid MaxTenuringThreshold: %s\n", option->optionString);
3240 }
3241 FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, max_tenuring_thresh);
3242
3243 if (MaxTenuringThreshold == 0) {
3244 FLAG_SET_CMDLINE(bool, NeverTenure, false);
3245 FLAG_SET_CMDLINE(bool, AlwaysTenure, true);
3246 } else {
3247 FLAG_SET_CMDLINE(bool, NeverTenure, false);
3248 FLAG_SET_CMDLINE(bool, AlwaysTenure, false);
3249 }
3250 } else if (match_option(option, "-XX:+CMSPermGenSweepingEnabled", &tail) ||
3251 match_option(option, "-XX:-CMSPermGenSweepingEnabled", &tail)) {
3252 jio_fprintf(defaultStream::error_stream(),
3253 "Please use CMSClassUnloadingEnabled in place of "
3254 "CMSPermGenSweepingEnabled in the future\n");
3255 } else if (match_option(option, "-XX:+UseGCTimeLimit", &tail)) {
3256 FLAG_SET_CMDLINE(bool, UseGCOverheadLimit, true);
3257 jio_fprintf(defaultStream::error_stream(),
3258 "Please use -XX:+UseGCOverheadLimit in place of "
3259 "-XX:+UseGCTimeLimit in the future\n");
3260 } else if (match_option(option, "-XX:-UseGCTimeLimit", &tail)) {
3261 FLAG_SET_CMDLINE(bool, UseGCOverheadLimit, false);
3262 jio_fprintf(defaultStream::error_stream(),
3263 "Please use -XX:-UseGCOverheadLimit in place of "
3264 "-XX:-UseGCTimeLimit in the future\n");
3265 // The TLE options are for compatibility with 1.3 and will be
3266 // removed without notice in a future release. These options
3267 // are not to be documented.
3268 } else if (match_option(option, "-XX:MaxTLERatio=", &tail)) {
3269 // No longer used.
3270 } else if (match_option(option, "-XX:+ResizeTLE", &tail)) {
3271 FLAG_SET_CMDLINE(bool, ResizeTLAB, true);
3272 } else if (match_option(option, "-XX:-ResizeTLE", &tail)) {
3273 FLAG_SET_CMDLINE(bool, ResizeTLAB, false);
3274 } else if (match_option(option, "-XX:+PrintTLE", &tail)) {
3275 FLAG_SET_CMDLINE(bool, PrintTLAB, true);
3276 } else if (match_option(option, "-XX:-PrintTLE", &tail)) {
3277 FLAG_SET_CMDLINE(bool, PrintTLAB, false);
3278 } else if (match_option(option, "-XX:TLEFragmentationRatio=", &tail)) {
3279 // No longer used.
3280 } else if (match_option(option, "-XX:TLESize=", &tail)) {
3281 julong long_tlab_size = 0;
3282 ArgsRange errcode = parse_memory_size(tail, &long_tlab_size, 1);
3283 if (errcode != arg_in_range) {
3284 jio_fprintf(defaultStream::error_stream(),
3285 "Invalid TLAB size: %s\n", option->optionString);
3286 describe_range_error(errcode);
3287 return JNI_EINVAL;
3288 }
3289 FLAG_SET_CMDLINE(uintx, TLABSize, long_tlab_size);
3290 } else if (match_option(option, "-XX:TLEThreadRatio=", &tail)) {
3291 // No longer used.
3292 } else if (match_option(option, "-XX:+UseTLE", &tail)) {
3293 FLAG_SET_CMDLINE(bool, UseTLAB, true);
3294 } else if (match_option(option, "-XX:-UseTLE", &tail)) {
3295 FLAG_SET_CMDLINE(bool, UseTLAB, false);
3296 } else if (match_option(option, "-XX:+DisplayVMOutputToStderr", &tail)) {
3297 FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, false);
3298 FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, true);
3299 } else if (match_option(option, "-XX:+DisplayVMOutputToStdout", &tail)) {
3300 FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, false);
3301 FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, true);
3302 } else if (match_option(option, "-XX:+ExtendedDTraceProbes", &tail)) {
3303 #if defined(DTRACE_ENABLED)
3304 FLAG_SET_CMDLINE(bool, ExtendedDTraceProbes, true);
3305 FLAG_SET_CMDLINE(bool, DTraceMethodProbes, true);
3306 FLAG_SET_CMDLINE(bool, DTraceAllocProbes, true);
3307 FLAG_SET_CMDLINE(bool, DTraceMonitorProbes, true);
3308 #else // defined(DTRACE_ENABLED)
3309 jio_fprintf(defaultStream::error_stream(),
3310 "ExtendedDTraceProbes flag is not applicable for this configuration\n");
3311 return JNI_EINVAL;
3312 #endif // defined(DTRACE_ENABLED)
3313 #ifdef ASSERT
3314 } else if (match_option(option, "-XX:+FullGCALot", &tail)) {
3315 FLAG_SET_CMDLINE(bool, FullGCALot, true);
3316 // disable scavenge before parallel mark-compact
3317 FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false);
3318 #endif
3319 } else if (match_option(option, "-XX:CMSParPromoteBlocksToClaim=", &tail)) {
3320 julong cms_blocks_to_claim = (julong)atol(tail);
3321 FLAG_SET_CMDLINE(uintx, CMSParPromoteBlocksToClaim, cms_blocks_to_claim);
3322 jio_fprintf(defaultStream::error_stream(),
3323 "Please use -XX:OldPLABSize in place of "
3324 "-XX:CMSParPromoteBlocksToClaim in the future\n");
3325 } else if (match_option(option, "-XX:ParCMSPromoteBlocksToClaim=", &tail)) {
3326 julong cms_blocks_to_claim = (julong)atol(tail);
3327 FLAG_SET_CMDLINE(uintx, CMSParPromoteBlocksToClaim, cms_blocks_to_claim);
3328 jio_fprintf(defaultStream::error_stream(),
3329 "Please use -XX:OldPLABSize in place of "
3330 "-XX:ParCMSPromoteBlocksToClaim in the future\n");
3331 } else if (match_option(option, "-XX:ParallelGCOldGenAllocBufferSize=", &tail)) {
3332 julong old_plab_size = 0;
3333 ArgsRange errcode = parse_memory_size(tail, &old_plab_size, 1);
3334 if (errcode != arg_in_range) {
3380 match_option(option, "-XX:ParallelCMSThreads=", &tail)) {
3381 uintx conc_threads = 0;
3382 if (!parse_uintx(tail, &conc_threads, 1)) {
3383 jio_fprintf(defaultStream::error_stream(),
3384 "Invalid concurrent threads: %s\n", option->optionString);
3385 return JNI_EINVAL;
3386 }
3387 FLAG_SET_CMDLINE(uintx, ConcGCThreads, conc_threads);
3388 } else if (match_option(option, "-XX:MaxDirectMemorySize=", &tail)) {
3389 julong max_direct_memory_size = 0;
3390 ArgsRange errcode = parse_memory_size(tail, &max_direct_memory_size, 0);
3391 if (errcode != arg_in_range) {
3392 jio_fprintf(defaultStream::error_stream(),
3393 "Invalid maximum direct memory size: %s\n",
3394 option->optionString);
3395 describe_range_error(errcode);
3396 return JNI_EINVAL;
3397 }
3398 FLAG_SET_CMDLINE(uintx, MaxDirectMemorySize, max_direct_memory_size);
3399 #if !INCLUDE_MANAGEMENT
3400 } else if (match_option(option, "-XX:+ManagementServer", &tail)) {
3401 jio_fprintf(defaultStream::error_stream(),
3402 "ManagementServer is not supported in this VM.\n");
3403 return JNI_ERR;
3404 #endif // INCLUDE_MANAGEMENT
3405 } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx
3406 // Skip -XX:Flags= since that case has already been handled
3407 if (strncmp(tail, "Flags=", strlen("Flags=")) != 0) {
3408 if (!process_argument(tail, args->ignoreUnrecognized, origin)) {
3409 return JNI_EINVAL;
3410 }
3411 }
3412 // Unknown option
3413 } else if (is_bad_option(option, args->ignoreUnrecognized)) {
3414 return JNI_ERR;
3415 }
3416 }
3417
3418 // PrintSharedArchiveAndExit will turn on
3419 // -Xshare:on
3420 // -XX:+TraceClassPaths
3737 // Remaining part of option string
3738 const char* tail;
3739
3740 // If flag "-XX:Flags=flags-file" is used it will be the first option to be processed.
3741 const char* hotspotrc = ".hotspotrc";
3742 bool settings_file_specified = false;
3743 bool needs_hotspotrc_warning = false;
3744
3745 const char* flags_file;
3746 int index;
3747 for (index = 0; index < args->nOptions; index++) {
3748 const JavaVMOption *option = args->options + index;
3749 if (ArgumentsExt::process_options(option)) {
3750 continue;
3751 }
3752 if (match_option(option, "-XX:Flags=", &tail)) {
3753 flags_file = tail;
3754 settings_file_specified = true;
3755 continue;
3756 }
3757 if (match_option(option, "-XX:+PrintVMOptions", &tail)) {
3758 PrintVMOptions = true;
3759 continue;
3760 }
3761 if (match_option(option, "-XX:-PrintVMOptions", &tail)) {
3762 PrintVMOptions = false;
3763 continue;
3764 }
3765 if (match_option(option, "-XX:+IgnoreUnrecognizedVMOptions", &tail)) {
3766 IgnoreUnrecognizedVMOptions = true;
3767 continue;
3768 }
3769 if (match_option(option, "-XX:-IgnoreUnrecognizedVMOptions", &tail)) {
3770 IgnoreUnrecognizedVMOptions = false;
3771 continue;
3772 }
3773 if (match_option(option, "-XX:+PrintFlagsInitial", &tail)) {
3774 CommandLineFlags::printFlags(tty, false);
3775 vm_exit(0);
3776 }
3777 #if INCLUDE_NMT
3778 if (match_option(option, "-XX:NativeMemoryTracking", &tail)) {
3779 // The launcher did not setup nmt environment variable properly.
3780 if (!MemTracker::check_launcher_nmt_support(tail)) {
3781 warning("Native Memory Tracking did not setup properly, using wrong launcher?");
3782 }
3783
3784 // Verify if nmt option is valid.
3785 if (MemTracker::verify_nmt_option()) {
3786 // Late initialization, still in single-threaded mode.
3787 if (MemTracker::tracking_level() >= NMT_summary) {
3788 MemTracker::init();
3789 }
3790 } else {
3791 vm_exit_during_initialization("Syntax error, expecting -XX:NativeMemoryTracking=[off|summary|detail]", NULL);
3792 }
3793 continue;
3794 }
3795 #endif
3796
3797
3798 #ifndef PRODUCT
3799 if (match_option(option, "-XX:+PrintFlagsWithComments", &tail)) {
3800 CommandLineFlags::printFlags(tty, true);
3801 vm_exit(0);
3802 }
3803 #endif
3804 }
3805
3806 if (IgnoreUnrecognizedVMOptions) {
3807 // uncast const to modify the flag args->ignoreUnrecognized
3808 *(jboolean*)(&args->ignoreUnrecognized) = true;
3809 }
3810
3811 // Parse specified settings file
3812 if (settings_file_specified) {
3813 if (!process_settings_file(flags_file, true, args->ignoreUnrecognized)) {
3814 return JNI_EINVAL;
3815 }
3816 } else {
3817 #ifdef ASSERT
3818 // Parse default .hotspotrc settings file
3819 if (!process_settings_file(".hotspotrc", false, args->ignoreUnrecognized)) {
|
109
110 AgentLibraryList Arguments::_libraryList;
111 AgentLibraryList Arguments::_agentList;
112
113 abort_hook_t Arguments::_abort_hook = NULL;
114 exit_hook_t Arguments::_exit_hook = NULL;
115 vfprintf_hook_t Arguments::_vfprintf_hook = NULL;
116
117
118 SystemProperty *Arguments::_java_ext_dirs = NULL;
119 SystemProperty *Arguments::_java_endorsed_dirs = NULL;
120 SystemProperty *Arguments::_sun_boot_library_path = NULL;
121 SystemProperty *Arguments::_java_library_path = NULL;
122 SystemProperty *Arguments::_java_home = NULL;
123 SystemProperty *Arguments::_java_class_path = NULL;
124 SystemProperty *Arguments::_sun_boot_class_path = NULL;
125
126 char* Arguments::_meta_index_path = NULL;
127 char* Arguments::_meta_index_dir = NULL;
128
129 // Check if head of 'option' matches 'name', and sets 'tail' to the remaining
130 // part of the option string.
131 static bool match_option(const JavaVMOption *option, const char* name,
132 const char** tail) {
133 int len = (int)strlen(name);
134 if (strncmp(option->optionString, name, len) == 0) {
135 *tail = option->optionString + len;
136 return true;
137 } else {
138 return false;
139 }
140 }
141
142 // Check if 'option' matches 'name'. No "tail" is allowed.
143 static bool match_option(const JavaVMOption *option, const char* name) {
144 const char* tail = NULL;
145 bool result = match_option(option, name, &tail);
146 if (tail != NULL && *tail == '\0') {
147 return result;
148 } else {
149 return false;
150 }
151 }
152
153 // Return true if any of the strings in null-terminated array 'names' matches.
154 // If tail_allowed is true, then the tail must begin with a colon; otherwise,
155 // the option must match exactly.
156 static bool match_option(const JavaVMOption* option, const char** names, const char** tail,
157 bool tail_allowed) {
158 for (/* empty */; *names != NULL; ++names) {
159 if (match_option(option, *names, tail)) {
160 if (**tail == '\0' || tail_allowed && **tail == ':') {
161 return true;
162 }
163 }
164 }
165 return false;
166 }
167
168 static void logOption(const char* opt) {
169 if (PrintVMOptions) {
170 jio_fprintf(defaultStream::output_stream(), "VM option '%s'\n", opt);
171 }
172 }
173
174 // Process java launcher properties.
175 void Arguments::process_sun_java_launcher_properties(JavaVMInitArgs* args) {
176 // See if sun.java.launcher, sun.java.launcher.is_altjvm or
177 // sun.java.launcher.pid is defined.
178 // Must do this before setting up other system properties,
179 // as some of them may depend on launcher type.
180 for (int index = 0; index < args->nOptions; index++) {
181 const JavaVMOption* option = args->options + index;
182 const char* tail;
183
184 if (match_option(option, "-Dsun.java.launcher=", &tail)) {
185 process_java_launcher_argument(tail, option->extraInfo);
186 continue;
187 }
2585 jio_fprintf(defaultStream::error_stream(),
2586 "Obsolete %s%soption: %s\n", option_type, spacer,
2587 option->optionString);
2588 return false;
2589 } else {
2590 jio_fprintf(defaultStream::error_stream(),
2591 "Unrecognized %s%soption: %s\n", option_type, spacer,
2592 option->optionString);
2593 return true;
2594 }
2595 }
2596
2597 static const char* user_assertion_options[] = {
2598 "-da", "-ea", "-disableassertions", "-enableassertions", 0
2599 };
2600
2601 static const char* system_assertion_options[] = {
2602 "-dsa", "-esa", "-disablesystemassertions", "-enablesystemassertions", 0
2603 };
2604
2605 bool Arguments::parse_uintx(const char* value,
2606 uintx* uintx_arg,
2607 uintx min_size) {
2608
2609 // Check the sign first since atomull() parses only unsigned values.
2610 bool value_is_positive = !(*value == '-');
2611
2612 if (value_is_positive) {
2613 julong n;
2614 bool good_return = atomull(value, &n);
2615 if (good_return) {
2616 bool above_minimum = n >= min_size;
2617 bool value_is_too_large = n > max_uintx;
2618
2619 if (above_minimum && !value_is_too_large) {
2620 *uintx_arg = n;
2621 return true;
2622 }
2623 }
2624 }
2826 jio_fprintf(defaultStream::error_stream(),
2827 "Profiling and debugging agents are not supported in this VM\n");
2828 return JNI_ERR;
2829 }
2830 #endif // !INCLUDE_JVMTI
2831 add_init_agent(name, options, is_absolute_path);
2832 }
2833 // -javaagent
2834 } else if (match_option(option, "-javaagent:", &tail)) {
2835 #if !INCLUDE_JVMTI
2836 jio_fprintf(defaultStream::error_stream(),
2837 "Instrumentation agents are not supported in this VM\n");
2838 return JNI_ERR;
2839 #else
2840 if(tail != NULL) {
2841 char *options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(tail) + 1, mtInternal), tail);
2842 add_init_agent("instrument", options, false);
2843 }
2844 #endif // !INCLUDE_JVMTI
2845 // -Xnoclassgc
2846 } else if (match_option(option, "-Xnoclassgc")) {
2847 FLAG_SET_CMDLINE(bool, ClassUnloading, false);
2848 // -Xconcgc
2849 } else if (match_option(option, "-Xconcgc")) {
2850 FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, true);
2851 // -Xnoconcgc
2852 } else if (match_option(option, "-Xnoconcgc")) {
2853 FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, false);
2854 // -Xbatch
2855 } else if (match_option(option, "-Xbatch")) {
2856 FLAG_SET_CMDLINE(bool, BackgroundCompilation, false);
2857 // -Xmn for compatibility with other JVM vendors
2858 } else if (match_option(option, "-Xmn", &tail)) {
2859 julong long_initial_young_size = 0;
2860 ArgsRange errcode = parse_memory_size(tail, &long_initial_young_size, 1);
2861 if (errcode != arg_in_range) {
2862 jio_fprintf(defaultStream::error_stream(),
2863 "Invalid initial young generation size: %s\n", option->optionString);
2864 describe_range_error(errcode);
2865 return JNI_EINVAL;
2866 }
2867 FLAG_SET_CMDLINE(uintx, MaxNewSize, (uintx)long_initial_young_size);
2868 FLAG_SET_CMDLINE(uintx, NewSize, (uintx)long_initial_young_size);
2869 // -Xms
2870 } else if (match_option(option, "-Xms", &tail)) {
2871 julong long_initial_heap_size = 0;
2872 // an initial heap size of 0 means automatically determine
2873 ArgsRange errcode = parse_memory_size(tail, &long_initial_heap_size, 0);
2874 if (errcode != arg_in_range) {
2875 jio_fprintf(defaultStream::error_stream(),
2980 julong long_NonProfiledCodeHeapSize = 0;
2981
2982 ArgsRange errcode = parse_memory_size(tail, &long_NonProfiledCodeHeapSize, 1);
2983 if (errcode != arg_in_range) {
2984 jio_fprintf(defaultStream::error_stream(),
2985 "Invalid maximum non-profiled code heap size: %s.\n", option->optionString);
2986 return JNI_EINVAL;
2987 }
2988 FLAG_SET_CMDLINE(uintx, NonProfiledCodeHeapSize, (uintx)long_NonProfiledCodeHeapSize);
2989 //-XX:IncreaseFirstTierCompileThresholdAt=
2990 } else if (match_option(option, "-XX:IncreaseFirstTierCompileThresholdAt=", &tail)) {
2991 uintx uint_IncreaseFirstTierCompileThresholdAt = 0;
2992 if (!parse_uintx(tail, &uint_IncreaseFirstTierCompileThresholdAt, 0) || uint_IncreaseFirstTierCompileThresholdAt > 99) {
2993 jio_fprintf(defaultStream::error_stream(),
2994 "Invalid value for IncreaseFirstTierCompileThresholdAt: %s. Should be between 0 and 99.\n",
2995 option->optionString);
2996 return JNI_EINVAL;
2997 }
2998 FLAG_SET_CMDLINE(uintx, IncreaseFirstTierCompileThresholdAt, (uintx)uint_IncreaseFirstTierCompileThresholdAt);
2999 // -green
3000 } else if (match_option(option, "-green")) {
3001 jio_fprintf(defaultStream::error_stream(),
3002 "Green threads support not available\n");
3003 return JNI_EINVAL;
3004 // -native
3005 } else if (match_option(option, "-native")) {
3006 // HotSpot always uses native threads, ignore silently for compatibility
3007 // -Xsqnopause
3008 } else if (match_option(option, "-Xsqnopause")) {
3009 // EVM option, ignore silently for compatibility
3010 // -Xrs
3011 } else if (match_option(option, "-Xrs")) {
3012 // Classic/EVM option, new functionality
3013 FLAG_SET_CMDLINE(bool, ReduceSignalUsage, true);
3014 } else if (match_option(option, "-Xusealtsigs")) {
3015 // change default internal VM signals used - lower case for back compat
3016 FLAG_SET_CMDLINE(bool, UseAltSigs, true);
3017 // -Xoptimize
3018 } else if (match_option(option, "-Xoptimize")) {
3019 // EVM option, ignore silently for compatibility
3020 // -Xprof
3021 } else if (match_option(option, "-Xprof")) {
3022 #if INCLUDE_FPROF
3023 _has_profile = true;
3024 #else // INCLUDE_FPROF
3025 jio_fprintf(defaultStream::error_stream(),
3026 "Flat profiling is not supported in this VM.\n");
3027 return JNI_ERR;
3028 #endif // INCLUDE_FPROF
3029 // -Xconcurrentio
3030 } else if (match_option(option, "-Xconcurrentio")) {
3031 FLAG_SET_CMDLINE(bool, UseLWPSynchronization, true);
3032 FLAG_SET_CMDLINE(bool, BackgroundCompilation, false);
3033 FLAG_SET_CMDLINE(intx, DeferThrSuspendLoopCount, 1);
3034 FLAG_SET_CMDLINE(bool, UseTLAB, false);
3035 FLAG_SET_CMDLINE(uintx, NewSizeThreadIncrease, 16 * K); // 20Kb per thread added to new generation
3036
3037 // -Xinternalversion
3038 } else if (match_option(option, "-Xinternalversion")) {
3039 jio_fprintf(defaultStream::output_stream(), "%s\n",
3040 VM_Version::internal_vm_info_string());
3041 vm_exit(0);
3042 #ifndef PRODUCT
3043 // -Xprintflags
3044 } else if (match_option(option, "-Xprintflags")) {
3045 CommandLineFlags::printFlags(tty, false);
3046 vm_exit(0);
3047 #endif
3048 // -D
3049 } else if (match_option(option, "-D", &tail)) {
3050 if (!add_property(tail)) {
3051 return JNI_ENOMEM;
3052 }
3053 // Out of the box management support
3054 if (match_option(option, "-Dcom.sun.management", &tail)) {
3055 #if INCLUDE_MANAGEMENT
3056 FLAG_SET_CMDLINE(bool, ManagementServer, true);
3057 #else
3058 jio_fprintf(defaultStream::output_stream(),
3059 "-Dcom.sun.management is not supported in this VM.\n");
3060 return JNI_ERR;
3061 #endif
3062 }
3063 // -Xint
3064 } else if (match_option(option, "-Xint")) {
3065 set_mode_flags(_int);
3066 // -Xmixed
3067 } else if (match_option(option, "-Xmixed")) {
3068 set_mode_flags(_mixed);
3069 // -Xcomp
3070 } else if (match_option(option, "-Xcomp")) {
3071 // for testing the compiler; turn off all flags that inhibit compilation
3072 set_mode_flags(_comp);
3073 // -Xshare:dump
3074 } else if (match_option(option, "-Xshare:dump")) {
3075 FLAG_SET_CMDLINE(bool, DumpSharedSpaces, true);
3076 set_mode_flags(_int); // Prevent compilation, which creates objects
3077 // -Xshare:on
3078 } else if (match_option(option, "-Xshare:on")) {
3079 FLAG_SET_CMDLINE(bool, UseSharedSpaces, true);
3080 FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true);
3081 // -Xshare:auto
3082 } else if (match_option(option, "-Xshare:auto")) {
3083 FLAG_SET_CMDLINE(bool, UseSharedSpaces, true);
3084 FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false);
3085 // -Xshare:off
3086 } else if (match_option(option, "-Xshare:off")) {
3087 FLAG_SET_CMDLINE(bool, UseSharedSpaces, false);
3088 FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false);
3089 // -Xverify
3090 } else if (match_option(option, "-Xverify", &tail)) {
3091 if (strcmp(tail, ":all") == 0 || strcmp(tail, "") == 0) {
3092 FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, true);
3093 FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true);
3094 } else if (strcmp(tail, ":remote") == 0) {
3095 FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false);
3096 FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true);
3097 } else if (strcmp(tail, ":none") == 0) {
3098 FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false);
3099 FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, false);
3100 } else if (is_bad_option(option, args->ignoreUnrecognized, "verification")) {
3101 return JNI_EINVAL;
3102 }
3103 // -Xdebug
3104 } else if (match_option(option, "-Xdebug")) {
3105 // note this flag has been used, then ignore
3106 set_xdebug_mode(true);
3107 // -Xnoagent
3108 } else if (match_option(option, "-Xnoagent")) {
3109 // For compatibility with classic. HotSpot refuses to load the old style agent.dll.
3110 } else if (match_option(option, "-Xboundthreads")) {
3111 // Bind user level threads to kernel threads (Solaris only)
3112 FLAG_SET_CMDLINE(bool, UseBoundThreads, true);
3113 } else if (match_option(option, "-Xloggc:", &tail)) {
3114 // Redirect GC output to the file. -Xloggc:<filename>
3115 // ostream_init_log(), when called will use this filename
3116 // to initialize a fileStream.
3117 _gc_log_filename = os::strdup_check_oom(tail);
3118 if (!is_filename_valid(_gc_log_filename)) {
3119 jio_fprintf(defaultStream::output_stream(),
3120 "Invalid file name for use with -Xloggc: Filename can only contain the "
3121 "characters [A-Z][a-z][0-9]-_.%%[p|t] but it has been %s\n"
3122 "Note %%p or %%t can only be used once\n", _gc_log_filename);
3123 return JNI_EINVAL;
3124 }
3125 FLAG_SET_CMDLINE(bool, PrintGC, true);
3126 FLAG_SET_CMDLINE(bool, PrintGCTimeStamps, true);
3127
3128 // JNI hooks
3129 } else if (match_option(option, "-Xcheck", &tail)) {
3130 if (!strcmp(tail, ":jni")) {
3131 #if !INCLUDE_JNI_CHECK
3132 warning("JNI CHECKING is not supported in this VM");
3133 #else
3134 CheckJNICalls = true;
3135 #endif // INCLUDE_JNI_CHECK
3136 } else if (is_bad_option(option, args->ignoreUnrecognized,
3137 "check")) {
3138 return JNI_EINVAL;
3139 }
3140 } else if (match_option(option, "vfprintf")) {
3141 _vfprintf_hook = CAST_TO_FN_PTR(vfprintf_hook_t, option->extraInfo);
3142 } else if (match_option(option, "exit")) {
3143 _exit_hook = CAST_TO_FN_PTR(exit_hook_t, option->extraInfo);
3144 } else if (match_option(option, "abort")) {
3145 _abort_hook = CAST_TO_FN_PTR(abort_hook_t, option->extraInfo);
3146 // -XX:+AggressiveHeap
3147 } else if (match_option(option, "-XX:+AggressiveHeap")) {
3148
3149 // This option inspects the machine and attempts to set various
3150 // parameters to be optimal for long-running, memory allocation
3151 // intensive jobs. It is intended for machines with large
3152 // amounts of cpu and memory.
3153
3154 // initHeapSize is needed since _initial_heap_size is 4 bytes on a 32 bit
3155 // VM, but we may not be able to represent the total physical memory
3156 // available (like having 8gb of memory on a box but using a 32bit VM).
3157 // Thus, we need to make sure we're using a julong for intermediate
3158 // calculations.
3159 julong initHeapSize;
3160 julong total_memory = os::physical_memory();
3161
3162 if (total_memory < (julong)256*M) {
3163 jio_fprintf(defaultStream::error_stream(),
3164 "You need at least 256mb of memory to use -XX:+AggressiveHeap\n");
3165 vm_exit(1);
3166 }
3167
3218 FLAG_SET_CMDLINE(uintx, OldPLABSize, 8*K); // Note: this is in words
3219
3220 // Enable parallel GC and adaptive generation sizing
3221 FLAG_SET_CMDLINE(bool, UseParallelGC, true);
3222 FLAG_SET_DEFAULT(ParallelGCThreads,
3223 Abstract_VM_Version::parallel_worker_threads());
3224
3225 // Encourage steady state memory management
3226 FLAG_SET_CMDLINE(uintx, ThresholdTolerance, 100);
3227
3228 // This appears to improve mutator locality
3229 FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false);
3230
3231 // Get around early Solaris scheduling bug
3232 // (affinity vs other jobs on system)
3233 // but disallow DR and offlining (5008695).
3234 FLAG_SET_CMDLINE(bool, BindGCTaskThreadsToCPUs, true);
3235
3236 // Need to keep consistency of MaxTenuringThreshold and AlwaysTenure/NeverTenure;
3237 // and the last option wins.
3238 } else if (match_option(option, "-XX:+NeverTenure")) {
3239 FLAG_SET_CMDLINE(bool, NeverTenure, true);
3240 FLAG_SET_CMDLINE(bool, AlwaysTenure, false);
3241 FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, markOopDesc::max_age + 1);
3242 } else if (match_option(option, "-XX:+AlwaysTenure")) {
3243 FLAG_SET_CMDLINE(bool, NeverTenure, false);
3244 FLAG_SET_CMDLINE(bool, AlwaysTenure, true);
3245 FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, 0);
3246 } else if (match_option(option, "-XX:MaxTenuringThreshold=", &tail)) {
3247 uintx max_tenuring_thresh = 0;
3248 if(!parse_uintx(tail, &max_tenuring_thresh, 0)) {
3249 jio_fprintf(defaultStream::error_stream(),
3250 "Invalid MaxTenuringThreshold: %s\n", option->optionString);
3251 }
3252 FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, max_tenuring_thresh);
3253
3254 if (MaxTenuringThreshold == 0) {
3255 FLAG_SET_CMDLINE(bool, NeverTenure, false);
3256 FLAG_SET_CMDLINE(bool, AlwaysTenure, true);
3257 } else {
3258 FLAG_SET_CMDLINE(bool, NeverTenure, false);
3259 FLAG_SET_CMDLINE(bool, AlwaysTenure, false);
3260 }
3261 } else if (match_option(option, "-XX:+CMSPermGenSweepingEnabled") ||
3262 match_option(option, "-XX:-CMSPermGenSweepingEnabled")) {
3263 jio_fprintf(defaultStream::error_stream(),
3264 "Please use CMSClassUnloadingEnabled in place of "
3265 "CMSPermGenSweepingEnabled in the future\n");
3266 } else if (match_option(option, "-XX:+UseGCTimeLimit")) {
3267 FLAG_SET_CMDLINE(bool, UseGCOverheadLimit, true);
3268 jio_fprintf(defaultStream::error_stream(),
3269 "Please use -XX:+UseGCOverheadLimit in place of "
3270 "-XX:+UseGCTimeLimit in the future\n");
3271 } else if (match_option(option, "-XX:-UseGCTimeLimit")) {
3272 FLAG_SET_CMDLINE(bool, UseGCOverheadLimit, false);
3273 jio_fprintf(defaultStream::error_stream(),
3274 "Please use -XX:-UseGCOverheadLimit in place of "
3275 "-XX:-UseGCTimeLimit in the future\n");
3276 // The TLE options are for compatibility with 1.3 and will be
3277 // removed without notice in a future release. These options
3278 // are not to be documented.
3279 } else if (match_option(option, "-XX:MaxTLERatio=", &tail)) {
3280 // No longer used.
3281 } else if (match_option(option, "-XX:+ResizeTLE")) {
3282 FLAG_SET_CMDLINE(bool, ResizeTLAB, true);
3283 } else if (match_option(option, "-XX:-ResizeTLE")) {
3284 FLAG_SET_CMDLINE(bool, ResizeTLAB, false);
3285 } else if (match_option(option, "-XX:+PrintTLE")) {
3286 FLAG_SET_CMDLINE(bool, PrintTLAB, true);
3287 } else if (match_option(option, "-XX:-PrintTLE")) {
3288 FLAG_SET_CMDLINE(bool, PrintTLAB, false);
3289 } else if (match_option(option, "-XX:TLEFragmentationRatio=", &tail)) {
3290 // No longer used.
3291 } else if (match_option(option, "-XX:TLESize=", &tail)) {
3292 julong long_tlab_size = 0;
3293 ArgsRange errcode = parse_memory_size(tail, &long_tlab_size, 1);
3294 if (errcode != arg_in_range) {
3295 jio_fprintf(defaultStream::error_stream(),
3296 "Invalid TLAB size: %s\n", option->optionString);
3297 describe_range_error(errcode);
3298 return JNI_EINVAL;
3299 }
3300 FLAG_SET_CMDLINE(uintx, TLABSize, long_tlab_size);
3301 } else if (match_option(option, "-XX:TLEThreadRatio=", &tail)) {
3302 // No longer used.
3303 } else if (match_option(option, "-XX:+UseTLE")) {
3304 FLAG_SET_CMDLINE(bool, UseTLAB, true);
3305 } else if (match_option(option, "-XX:-UseTLE")) {
3306 FLAG_SET_CMDLINE(bool, UseTLAB, false);
3307 } else if (match_option(option, "-XX:+DisplayVMOutputToStderr")) {
3308 FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, false);
3309 FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, true);
3310 } else if (match_option(option, "-XX:+DisplayVMOutputToStdout")) {
3311 FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, false);
3312 FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, true);
3313 } else if (match_option(option, "-XX:+ExtendedDTraceProbes")) {
3314 #if defined(DTRACE_ENABLED)
3315 FLAG_SET_CMDLINE(bool, ExtendedDTraceProbes, true);
3316 FLAG_SET_CMDLINE(bool, DTraceMethodProbes, true);
3317 FLAG_SET_CMDLINE(bool, DTraceAllocProbes, true);
3318 FLAG_SET_CMDLINE(bool, DTraceMonitorProbes, true);
3319 #else // defined(DTRACE_ENABLED)
3320 jio_fprintf(defaultStream::error_stream(),
3321 "ExtendedDTraceProbes flag is not applicable for this configuration\n");
3322 return JNI_EINVAL;
3323 #endif // defined(DTRACE_ENABLED)
3324 #ifdef ASSERT
3325 } else if (match_option(option, "-XX:+FullGCALot")) {
3326 FLAG_SET_CMDLINE(bool, FullGCALot, true);
3327 // disable scavenge before parallel mark-compact
3328 FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false);
3329 #endif
3330 } else if (match_option(option, "-XX:CMSParPromoteBlocksToClaim=", &tail)) {
3331 julong cms_blocks_to_claim = (julong)atol(tail);
3332 FLAG_SET_CMDLINE(uintx, CMSParPromoteBlocksToClaim, cms_blocks_to_claim);
3333 jio_fprintf(defaultStream::error_stream(),
3334 "Please use -XX:OldPLABSize in place of "
3335 "-XX:CMSParPromoteBlocksToClaim in the future\n");
3336 } else if (match_option(option, "-XX:ParCMSPromoteBlocksToClaim=", &tail)) {
3337 julong cms_blocks_to_claim = (julong)atol(tail);
3338 FLAG_SET_CMDLINE(uintx, CMSParPromoteBlocksToClaim, cms_blocks_to_claim);
3339 jio_fprintf(defaultStream::error_stream(),
3340 "Please use -XX:OldPLABSize in place of "
3341 "-XX:ParCMSPromoteBlocksToClaim in the future\n");
3342 } else if (match_option(option, "-XX:ParallelGCOldGenAllocBufferSize=", &tail)) {
3343 julong old_plab_size = 0;
3344 ArgsRange errcode = parse_memory_size(tail, &old_plab_size, 1);
3345 if (errcode != arg_in_range) {
3391 match_option(option, "-XX:ParallelCMSThreads=", &tail)) {
3392 uintx conc_threads = 0;
3393 if (!parse_uintx(tail, &conc_threads, 1)) {
3394 jio_fprintf(defaultStream::error_stream(),
3395 "Invalid concurrent threads: %s\n", option->optionString);
3396 return JNI_EINVAL;
3397 }
3398 FLAG_SET_CMDLINE(uintx, ConcGCThreads, conc_threads);
3399 } else if (match_option(option, "-XX:MaxDirectMemorySize=", &tail)) {
3400 julong max_direct_memory_size = 0;
3401 ArgsRange errcode = parse_memory_size(tail, &max_direct_memory_size, 0);
3402 if (errcode != arg_in_range) {
3403 jio_fprintf(defaultStream::error_stream(),
3404 "Invalid maximum direct memory size: %s\n",
3405 option->optionString);
3406 describe_range_error(errcode);
3407 return JNI_EINVAL;
3408 }
3409 FLAG_SET_CMDLINE(uintx, MaxDirectMemorySize, max_direct_memory_size);
3410 #if !INCLUDE_MANAGEMENT
3411 } else if (match_option(option, "-XX:+ManagementServer")) {
3412 jio_fprintf(defaultStream::error_stream(),
3413 "ManagementServer is not supported in this VM.\n");
3414 return JNI_ERR;
3415 #endif // INCLUDE_MANAGEMENT
3416 } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx
3417 // Skip -XX:Flags= since that case has already been handled
3418 if (strncmp(tail, "Flags=", strlen("Flags=")) != 0) {
3419 if (!process_argument(tail, args->ignoreUnrecognized, origin)) {
3420 return JNI_EINVAL;
3421 }
3422 }
3423 // Unknown option
3424 } else if (is_bad_option(option, args->ignoreUnrecognized)) {
3425 return JNI_ERR;
3426 }
3427 }
3428
3429 // PrintSharedArchiveAndExit will turn on
3430 // -Xshare:on
3431 // -XX:+TraceClassPaths
3748 // Remaining part of option string
3749 const char* tail;
3750
3751 // If flag "-XX:Flags=flags-file" is used it will be the first option to be processed.
3752 const char* hotspotrc = ".hotspotrc";
3753 bool settings_file_specified = false;
3754 bool needs_hotspotrc_warning = false;
3755
3756 const char* flags_file;
3757 int index;
3758 for (index = 0; index < args->nOptions; index++) {
3759 const JavaVMOption *option = args->options + index;
3760 if (ArgumentsExt::process_options(option)) {
3761 continue;
3762 }
3763 if (match_option(option, "-XX:Flags=", &tail)) {
3764 flags_file = tail;
3765 settings_file_specified = true;
3766 continue;
3767 }
3768 if (match_option(option, "-XX:+PrintVMOptions")) {
3769 PrintVMOptions = true;
3770 continue;
3771 }
3772 if (match_option(option, "-XX:-PrintVMOptions")) {
3773 PrintVMOptions = false;
3774 continue;
3775 }
3776 if (match_option(option, "-XX:+IgnoreUnrecognizedVMOptions")) {
3777 IgnoreUnrecognizedVMOptions = true;
3778 continue;
3779 }
3780 if (match_option(option, "-XX:-IgnoreUnrecognizedVMOptions")) {
3781 IgnoreUnrecognizedVMOptions = false;
3782 continue;
3783 }
3784 if (match_option(option, "-XX:+PrintFlagsInitial")) {
3785 CommandLineFlags::printFlags(tty, false);
3786 vm_exit(0);
3787 }
3788 #if INCLUDE_NMT
3789 if (match_option(option, "-XX:NativeMemoryTracking", &tail)) {
3790 // The launcher did not setup nmt environment variable properly.
3791 if (!MemTracker::check_launcher_nmt_support(tail)) {
3792 warning("Native Memory Tracking did not setup properly, using wrong launcher?");
3793 }
3794
3795 // Verify if nmt option is valid.
3796 if (MemTracker::verify_nmt_option()) {
3797 // Late initialization, still in single-threaded mode.
3798 if (MemTracker::tracking_level() >= NMT_summary) {
3799 MemTracker::init();
3800 }
3801 } else {
3802 vm_exit_during_initialization("Syntax error, expecting -XX:NativeMemoryTracking=[off|summary|detail]", NULL);
3803 }
3804 continue;
3805 }
3806 #endif
3807
3808
3809 #ifndef PRODUCT
3810 if (match_option(option, "-XX:+PrintFlagsWithComments")) {
3811 CommandLineFlags::printFlags(tty, true);
3812 vm_exit(0);
3813 }
3814 #endif
3815 }
3816
3817 if (IgnoreUnrecognizedVMOptions) {
3818 // uncast const to modify the flag args->ignoreUnrecognized
3819 *(jboolean*)(&args->ignoreUnrecognized) = true;
3820 }
3821
3822 // Parse specified settings file
3823 if (settings_file_specified) {
3824 if (!process_settings_file(flags_file, true, args->ignoreUnrecognized)) {
3825 return JNI_EINVAL;
3826 }
3827 } else {
3828 #ifdef ASSERT
3829 // Parse default .hotspotrc settings file
3830 if (!process_settings_file(".hotspotrc", false, args->ignoreUnrecognized)) {
|