104 AgentLibraryList Arguments::_libraryList;
105 AgentLibraryList Arguments::_agentList;
106
107 abort_hook_t Arguments::_abort_hook = NULL;
108 exit_hook_t Arguments::_exit_hook = NULL;
109 vfprintf_hook_t Arguments::_vfprintf_hook = NULL;
110
111
112 SystemProperty *Arguments::_sun_boot_library_path = NULL;
113 SystemProperty *Arguments::_java_library_path = NULL;
114 SystemProperty *Arguments::_java_home = NULL;
115 SystemProperty *Arguments::_java_class_path = NULL;
116 SystemProperty *Arguments::_sun_boot_class_path = NULL;
117
118 char* Arguments::_ext_dirs = NULL;
119
120 // Check if head of 'option' matches 'name', and sets 'tail' to the remaining
121 // part of the option string.
122 static bool match_option(const JavaVMOption *option, const char* name,
123 const char** tail) {
124 int len = (int)strlen(name);
125 if (strncmp(option->optionString, name, len) == 0) {
126 *tail = option->optionString + len;
127 return true;
128 } else {
129 return false;
130 }
131 }
132
133 // Check if 'option' matches 'name'. No "tail" is allowed.
134 static bool match_option(const JavaVMOption *option, const char* name) {
135 const char* tail = NULL;
136 bool result = match_option(option, name, &tail);
137 if (tail != NULL && *tail == '\0') {
138 return result;
139 } else {
140 return false;
141 }
142 }
143
144 // Return true if any of the strings in null-terminated array 'names' matches.
205 _java_home = new SystemProperty("java.home", NULL, true);
206 _sun_boot_class_path = new SystemProperty("sun.boot.class.path", NULL, true);
207
208 _java_class_path = new SystemProperty("java.class.path", "", true);
209
210 // Add to System Property list.
211 PropertyList_add(&_system_properties, _sun_boot_library_path);
212 PropertyList_add(&_system_properties, _java_library_path);
213 PropertyList_add(&_system_properties, _java_home);
214 PropertyList_add(&_system_properties, _java_class_path);
215 PropertyList_add(&_system_properties, _sun_boot_class_path);
216
217 // Set OS specific system properties values
218 os::init_system_properties_values();
219 }
220
221 // Update/Initialize System properties after JDK version number is known
222 void Arguments::init_version_specific_system_properties() {
223 enum { bufsz = 16 };
224 char buffer[bufsz];
225 const char* spec_vendor = "Sun Microsystems Inc.";
226 uint32_t spec_version = 0;
227
228 spec_vendor = "Oracle Corporation";
229 spec_version = JDK_Version::current().major_version();
230 jio_snprintf(buffer, bufsz, "1." UINT32_FORMAT, spec_version);
231
232 PropertyList_add(&_system_properties,
233 new SystemProperty("java.vm.specification.vendor", spec_vendor, false));
234 PropertyList_add(&_system_properties,
235 new SystemProperty("java.vm.specification.version", buffer, false));
236 PropertyList_add(&_system_properties,
237 new SystemProperty("java.vm.vendor", VM_Version::vm_vendor(), false));
238 }
239
240 /**
241 * Provide a slightly more user-friendly way of eliminating -XX flags.
242 * When a flag is eliminated, it can be added to this list in order to
243 * continue accepting this flag on the command-line, while issuing a warning
244 * and ignoring the value. Once the JDK version reaches the 'accept_until'
245 * limit, we flatly refuse to admit the existence of the flag. This allows
246 * a flag to die correctly over JDK releases using HSX.
247 * But now that HSX is no longer supported only options with a future
248 * accept_until value need to be listed, and the list can be pruned
249 * on each major release.
250 */
251 typedef struct {
252 const char* name;
253 JDK_Version obsoleted_in; // when the flag went away
254 JDK_Version accept_until; // which version to start denying the existence
255 } ObsoleteFlag;
256
257 static ObsoleteFlag obsolete_jvm_flags[] = {
258 { "UseOldInlining", JDK_Version::jdk(9), JDK_Version::jdk(10) },
259 { "SafepointPollOffset", JDK_Version::jdk(9), JDK_Version::jdk(10) },
260 { "UseBoundThreads", JDK_Version::jdk(9), JDK_Version::jdk(10) },
261 { "DefaultThreadPriority", JDK_Version::jdk(9), JDK_Version::jdk(10) },
262 { "NoYieldsInMicrolock", JDK_Version::jdk(9), JDK_Version::jdk(10) },
263 { "BackEdgeThreshold", JDK_Version::jdk(9), JDK_Version::jdk(10) },
264 { "UseNewReflection", JDK_Version::jdk(9), JDK_Version::jdk(10) },
265 { "ReflectionWrapResolutionErrors",JDK_Version::jdk(9), JDK_Version::jdk(10) },
266 { "VerifyReflectionBytecodes", JDK_Version::jdk(9), JDK_Version::jdk(10) },
267 { "AutoShutdownNMT", JDK_Version::jdk(9), JDK_Version::jdk(10) },
268 { "NmethodSweepFraction", JDK_Version::jdk(9), JDK_Version::jdk(10) },
269 { "NmethodSweepCheckInterval", JDK_Version::jdk(9), JDK_Version::jdk(10) },
270 { "CodeCacheMinimumFreeSpace", JDK_Version::jdk(9), JDK_Version::jdk(10) },
271 #ifndef ZERO
272 { "UseFastAccessorMethods", JDK_Version::jdk(9), JDK_Version::jdk(10) },
273 { "UseFastEmptyMethods", JDK_Version::jdk(9), JDK_Version::jdk(10) },
274 #endif // ZERO
275 { "UseCompilerSafepoints", JDK_Version::jdk(9), JDK_Version::jdk(10) },
276 { "AdaptiveSizePausePolicy", JDK_Version::jdk(9), JDK_Version::jdk(10) },
277 { "ParallelGCRetainPLAB", JDK_Version::jdk(9), JDK_Version::jdk(10) },
278 { "ThreadSafetyMargin", JDK_Version::jdk(9), JDK_Version::jdk(10) },
279 { "LazyBootClassLoader", JDK_Version::jdk(9), JDK_Version::jdk(10) },
280 { "StarvationMonitorInterval", JDK_Version::jdk(9), JDK_Version::jdk(10) },
281 { "PreInflateSpin", JDK_Version::jdk(9), JDK_Version::jdk(10) },
282 { NULL, JDK_Version(0), JDK_Version(0) }
283 };
284
285 // Returns true if the flag is obsolete and fits into the range specified
286 // for being ignored. In the case that the flag is ignored, the 'version'
287 // value is filled in with the version number when the flag became
288 // obsolete so that that value can be displayed to the user.
289 bool Arguments::is_newly_obsolete(const char *s, JDK_Version* version) {
290 int i = 0;
291 assert(version != NULL, "Must provide a version buffer");
292 while (obsolete_jvm_flags[i].name != NULL) {
293 const ObsoleteFlag& flag_status = obsolete_jvm_flags[i];
294 // <flag>=xxx form
295 // [-|+]<flag> form
296 size_t len = strlen(flag_status.name);
297 if ((strncmp(flag_status.name, s, len) == 0) &&
298 (strlen(s) == len)){
299 if (JDK_Version::current().compare(flag_status.accept_until) == -1) {
300 *version = flag_status.obsoleted_in;
301 return true;
302 }
303 }
304 i++;
305 }
306 return false;
307 }
308
309 // Constructs the system class path (aka boot class path) from the following
310 // components, in order:
311 //
312 // prefix // from -Xbootclasspath/p:...
313 // base // from os::get_system_properties() or -Xbootclasspath=
314 // suffix // from -Xbootclasspath/a:...
315 //
316 // This could be AllStatic, but it isn't needed after argument processing is
317 // complete.
318 class SysClassPath: public StackObj {
319 public:
320 SysClassPath(const char* base);
321 ~SysClassPath();
322
323 inline void set_base(const char* base);
324 inline void add_prefix(const char* prefix);
325 inline void add_suffix_to_prefix(const char* suffix);
326 inline void add_suffix(const char* suffix);
557 }
558
559 // Describe an argument out of range error
560 void Arguments::describe_range_error(ArgsRange errcode) {
561 switch(errcode) {
562 case arg_too_big:
563 jio_fprintf(defaultStream::error_stream(),
564 "The specified size exceeds the maximum "
565 "representable size.\n");
566 break;
567 case arg_too_small:
568 case arg_unreadable:
569 case arg_in_range:
570 // do nothing for now
571 break;
572 default:
573 ShouldNotReachHere();
574 }
575 }
576
577 static bool set_bool_flag(char* name, bool value, Flag::Flags origin) {
578 if (CommandLineFlags::boolAtPut(name, &value, origin) == Flag::SUCCESS) {
579 return true;
580 } else {
581 return false;
582 }
583 }
584
585 static bool set_fp_numeric_flag(char* name, char* value, Flag::Flags origin) {
586 double v;
587 if (sscanf(value, "%lf", &v) != 1) {
588 return false;
589 }
590
591 if (CommandLineFlags::doubleAtPut(name, &v, origin) == Flag::SUCCESS) {
592 return true;
593 }
594 return false;
595 }
596
597 static bool set_numeric_flag(char* name, char* value, Flag::Flags origin) {
598 julong v;
599 int int_v;
600 intx intx_v;
601 bool is_neg = false;
602 // Check the sign first since atomull() parses only unsigned values.
603 if (*value == '-') {
604 if ((CommandLineFlags::intxAt(name, &intx_v) != Flag::SUCCESS) && (CommandLineFlags::intAt(name, &int_v) != Flag::SUCCESS)) {
605 return false;
606 }
607 value++;
608 is_neg = true;
609 }
610 if (!atomull(value, &v)) {
611 return false;
612 }
613 int_v = (int) v;
614 if (is_neg) {
615 int_v = -int_v;
616 }
617 if (CommandLineFlags::intAtPut(name, &int_v, origin) == Flag::SUCCESS) {
626 intx_v = -intx_v;
627 }
628 if (CommandLineFlags::intxAtPut(name, &intx_v, origin) == Flag::SUCCESS) {
629 return true;
630 }
631 uintx uintx_v = (uintx) v;
632 if (!is_neg && (CommandLineFlags::uintxAtPut(name, &uintx_v, origin) == Flag::SUCCESS)) {
633 return true;
634 }
635 uint64_t uint64_t_v = (uint64_t) v;
636 if (!is_neg && (CommandLineFlags::uint64_tAtPut(name, &uint64_t_v, origin) == Flag::SUCCESS)) {
637 return true;
638 }
639 size_t size_t_v = (size_t) v;
640 if (!is_neg && (CommandLineFlags::size_tAtPut(name, &size_t_v, origin) == Flag::SUCCESS)) {
641 return true;
642 }
643 return false;
644 }
645
646 static bool set_string_flag(char* name, const char* value, Flag::Flags origin) {
647 if (CommandLineFlags::ccstrAtPut(name, &value, origin) != Flag::SUCCESS) return false;
648 // Contract: CommandLineFlags always returns a pointer that needs freeing.
649 FREE_C_HEAP_ARRAY(char, value);
650 return true;
651 }
652
653 static bool append_to_string_flag(char* name, const char* new_value, Flag::Flags origin) {
654 const char* old_value = "";
655 if (CommandLineFlags::ccstrAt(name, &old_value) != Flag::SUCCESS) return false;
656 size_t old_len = old_value != NULL ? strlen(old_value) : 0;
657 size_t new_len = strlen(new_value);
658 const char* value;
659 char* free_this_too = NULL;
660 if (old_len == 0) {
661 value = new_value;
662 } else if (new_len == 0) {
663 value = old_value;
664 } else {
665 char* buf = NEW_C_HEAP_ARRAY(char, old_len + 1 + new_len + 1, mtInternal);
666 // each new setting adds another LINE to the switch:
667 sprintf(buf, "%s\n%s", old_value, new_value);
668 value = buf;
669 free_this_too = buf;
670 }
671 (void) CommandLineFlags::ccstrAtPut(name, &value, origin);
672 // CommandLineFlags always returns a pointer that needs freeing.
673 FREE_C_HEAP_ARRAY(char, value);
674 if (free_this_too != NULL) {
675 // CommandLineFlags made its own copy, so I must delete my own temp. buffer.
676 FREE_C_HEAP_ARRAY(char, free_this_too);
677 }
678 return true;
679 }
680
681 bool Arguments::parse_argument(const char* arg, Flag::Flags origin) {
682
683 // range of acceptable characters spelled out for portability reasons
684 #define NAME_RANGE "[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]"
685 #define BUFLEN 255
686 char name[BUFLEN+1];
687 char dummy;
688
689 if (sscanf(arg, "-%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
690 return set_bool_flag(name, false, origin);
691 }
692 if (sscanf(arg, "+%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
693 return set_bool_flag(name, true, origin);
694 }
695
696 char punct;
697 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "%c", name, &punct) == 2 && punct == '=') {
698 const char* value = strchr(arg, '=') + 1;
699 Flag* flag = Flag::find_flag(name, strlen(name));
700 if (flag != NULL && flag->is_ccstr()) {
701 if (flag->ccstr_accumulates()) {
702 return append_to_string_flag(name, value, origin);
703 } else {
704 if (value[0] == '\0') {
705 value = NULL;
706 }
707 return set_string_flag(name, value, origin);
708 }
709 }
710 }
711
712 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE ":%c", name, &punct) == 2 && punct == '=') {
713 const char* value = strchr(arg, '=') + 1;
714 // -XX:Foo:=xxx will reset the string flag to the given value.
715 if (value[0] == '\0') {
716 value = NULL;
717 }
718 return set_string_flag(name, value, origin);
719 }
720
721 #define SIGNED_FP_NUMBER_RANGE "[-0123456789.]"
722 #define SIGNED_NUMBER_RANGE "[-0123456789]"
723 #define NUMBER_RANGE "[0123456789]"
724 char value[BUFLEN + 1];
725 char value2[BUFLEN + 1];
726 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_NUMBER_RANGE "." "%" XSTR(BUFLEN) NUMBER_RANGE "%c", name, value, value2, &dummy) == 3) {
727 // Looks like a floating-point number -- try again with more lenient format string
728 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_FP_NUMBER_RANGE "%c", name, value, &dummy) == 2) {
729 return set_fp_numeric_flag(name, value, origin);
730 }
731 }
732
733 #define VALUE_RANGE "[-kmgtxKMGTX0123456789abcdefABCDEF]"
734 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) VALUE_RANGE "%c", name, value, &dummy) == 2) {
735 return set_numeric_flag(name, value, origin);
736 }
737
738 return false;
739 }
740
741 void Arguments::add_string(char*** bldarray, int* count, const char* arg) {
742 assert(bldarray != NULL, "illegal argument");
743
744 if (arg == NULL) {
745 return;
746 }
747
748 int new_count = *count + 1;
749
750 // expand the array and add arg to the last element
751 if (*bldarray == NULL) {
752 *bldarray = NEW_C_HEAP_ARRAY(char*, new_count, mtInternal);
753 } else {
754 *bldarray = REALLOC_C_HEAP_ARRAY(char*, *bldarray, new_count, mtInternal);
755 }
823 st->cr();
824 }
825
826 void Arguments::print_jvm_flags_on(outputStream* st) {
827 if (_num_jvm_flags > 0) {
828 for (int i=0; i < _num_jvm_flags; i++) {
829 st->print("%s ", _jvm_flags_array[i]);
830 }
831 }
832 }
833
834 void Arguments::print_jvm_args_on(outputStream* st) {
835 if (_num_jvm_args > 0) {
836 for (int i=0; i < _num_jvm_args; i++) {
837 st->print("%s ", _jvm_args_array[i]);
838 }
839 }
840 }
841
842 bool Arguments::process_argument(const char* arg,
843 jboolean ignore_unrecognized, Flag::Flags origin) {
844
845 JDK_Version since = JDK_Version();
846
847 if (parse_argument(arg, origin) || ignore_unrecognized) {
848 return true;
849 }
850
851 // Determine if the flag has '+', '-', or '=' characters.
852 bool has_plus_minus = (*arg == '+' || *arg == '-');
853 const char* const argname = has_plus_minus ? arg + 1 : arg;
854
855 size_t arg_len;
856 const char* equal_sign = strchr(argname, '=');
857 if (equal_sign == NULL) {
858 arg_len = strlen(argname);
859 } else {
860 arg_len = equal_sign - argname;
861 }
862
863 // Only make the obsolete check for valid arguments.
864 if (arg_len <= BUFLEN) {
865 // Construct a string which consists only of the argument name without '+', '-', or '='.
866 char stripped_argname[BUFLEN+1];
867 strncpy(stripped_argname, argname, arg_len);
868 stripped_argname[arg_len] = '\0'; // strncpy may not null terminate.
869
870 if (is_newly_obsolete(stripped_argname, &since)) {
871 char version[256];
872 since.to_string(version, sizeof(version));
873 warning("ignoring option %s; support was removed in %s", stripped_argname, version);
874 return true;
875 }
876 }
877
878 // For locked flags, report a custom error message if available.
879 // Otherwise, report the standard unrecognized VM option.
880 Flag* found_flag = Flag::find_flag((const char*)argname, arg_len, true, true);
881 if (found_flag != NULL) {
882 char locked_message_buf[BUFLEN];
883 found_flag->get_locked_message(locked_message_buf, BUFLEN);
884 if (strlen(locked_message_buf) == 0) {
885 if (found_flag->is_bool() && !has_plus_minus) {
886 jio_fprintf(defaultStream::error_stream(),
887 "Missing +/- setting for VM option '%s'\n", argname);
888 } else if (!found_flag->is_bool() && has_plus_minus) {
889 jio_fprintf(defaultStream::error_stream(),
890 "Unexpected +/- setting in VM option '%s'\n", argname);
891 } else {
892 jio_fprintf(defaultStream::error_stream(),
893 "Improperly specified VM option '%s'\n", argname);
1213
1214 FLAG_SET_ERGO(intx, Tier2InvokeNotifyFreqLog, scaled_freq_log(Tier2InvokeNotifyFreqLog));
1215 FLAG_SET_ERGO(intx, Tier2BackedgeNotifyFreqLog, scaled_freq_log(Tier2BackedgeNotifyFreqLog));
1216
1217 FLAG_SET_ERGO(intx, Tier3InvokeNotifyFreqLog, scaled_freq_log(Tier3InvokeNotifyFreqLog));
1218 FLAG_SET_ERGO(intx, Tier3BackedgeNotifyFreqLog, scaled_freq_log(Tier3BackedgeNotifyFreqLog));
1219
1220 FLAG_SET_ERGO(intx, Tier23InlineeNotifyFreqLog, scaled_freq_log(Tier23InlineeNotifyFreqLog));
1221
1222 FLAG_SET_ERGO(intx, Tier4InvocationThreshold, scaled_compile_threshold(Tier4InvocationThreshold));
1223 FLAG_SET_ERGO(intx, Tier4MinInvocationThreshold, scaled_compile_threshold(Tier4MinInvocationThreshold));
1224 FLAG_SET_ERGO(intx, Tier4CompileThreshold, scaled_compile_threshold(Tier4CompileThreshold));
1225 FLAG_SET_ERGO(intx, Tier4BackEdgeThreshold, scaled_compile_threshold(Tier4BackEdgeThreshold));
1226 }
1227 }
1228
1229 #if INCLUDE_ALL_GCS
1230 static void disable_adaptive_size_policy(const char* collector_name) {
1231 if (UseAdaptiveSizePolicy) {
1232 if (FLAG_IS_CMDLINE(UseAdaptiveSizePolicy)) {
1233 warning("disabling UseAdaptiveSizePolicy; it is incompatible with %s.",
1234 collector_name);
1235 }
1236 FLAG_SET_DEFAULT(UseAdaptiveSizePolicy, false);
1237 }
1238 }
1239
1240 void Arguments::set_parnew_gc_flags() {
1241 assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC && !UseG1GC,
1242 "control point invariant");
1243 assert(UseConcMarkSweepGC, "CMS is expected to be on here");
1244 assert(UseParNewGC, "ParNew should always be used with CMS");
1245
1246 if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
1247 FLAG_SET_DEFAULT(ParallelGCThreads, Abstract_VM_Version::parallel_worker_threads());
1248 assert(ParallelGCThreads > 0, "We should always have at least one thread by default");
1249 } else if (ParallelGCThreads == 0) {
1250 jio_fprintf(defaultStream::error_stream(),
1251 "The ParNew GC can not be combined with -XX:ParallelGCThreads=0\n");
1252 vm_exit(1);
1253 }
1690 #if !INCLUDE_ALL_GCS
1691 #ifdef ASSERT
1692 static bool verify_serial_gc_flags() {
1693 return (UseSerialGC &&
1694 !(UseParNewGC || (UseConcMarkSweepGC) || UseG1GC ||
1695 UseParallelGC || UseParallelOldGC));
1696 }
1697 #endif // ASSERT
1698 #endif // INCLUDE_ALL_GCS
1699
1700 void Arguments::set_gc_specific_flags() {
1701 #if INCLUDE_ALL_GCS
1702 // Set per-collector flags
1703 if (UseParallelGC || UseParallelOldGC) {
1704 set_parallel_gc_flags();
1705 } else if (UseConcMarkSweepGC) {
1706 set_cms_and_parnew_gc_flags();
1707 } else if (UseG1GC) {
1708 set_g1_gc_flags();
1709 }
1710 check_deprecated_gc_flags();
1711 if (AssumeMP && !UseSerialGC) {
1712 if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) {
1713 warning("If the number of processors is expected to increase from one, then"
1714 " you should configure the number of parallel GC threads appropriately"
1715 " using -XX:ParallelGCThreads=N");
1716 }
1717 }
1718 if (MinHeapFreeRatio == 100) {
1719 // Keeping the heap 100% free is hard ;-) so limit it to 99%.
1720 FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99);
1721 }
1722 #else // INCLUDE_ALL_GCS
1723 assert(verify_serial_gc_flags(), "SerialGC unset");
1724 #endif // INCLUDE_ALL_GCS
1725 }
1726
1727 julong Arguments::limit_by_allocatable_memory(julong limit) {
1728 julong max_allocatable;
1729 julong result = limit;
1730 if (os::has_allocatable_memory_limit(&max_allocatable)) {
1731 result = MIN2(result, max_allocatable / MaxVirtMemFraction);
1732 }
1733 return result;
1734 }
1735
1736 // Use static initialization to get the default before parsing
1737 static const size_t DefaultHeapBaseMinAddress = HeapBaseMinAddress;
1738
1739 void Arguments::set_heap_size() {
1740 if (!FLAG_IS_DEFAULT(DefaultMaxRAMFraction)) {
1741 // Deprecated flag
1742 FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction);
1743 }
1744
1745 const julong phys_mem =
1746 FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
1747 : (julong)MaxRAM;
1748
1749 // If the maximum heap size has not been set with -Xmx,
1750 // then set it as fraction of the size of physical memory,
1751 // respecting the maximum and minimum sizes of the heap.
1752 if (FLAG_IS_DEFAULT(MaxHeapSize)) {
1753 julong reasonable_max = phys_mem / MaxRAMFraction;
1754
1755 if (phys_mem <= MaxHeapSize * MinRAMFraction) {
1756 // Small physical memory, so use a minimum fraction of it for the heap
1757 reasonable_max = phys_mem / MinRAMFraction;
1758 } else {
1759 // Not-small physical memory, so require a heap at least
1760 // as large as MaxHeapSize
1761 reasonable_max = MAX2(reasonable_max, (julong)MaxHeapSize);
1762 }
1763 if (!FLAG_IS_DEFAULT(ErgoHeapSizeLimit) && ErgoHeapSizeLimit != 0) {
1764 // Limit the heap size to ErgoHeapSizeLimit
1827 reasonable_initial = limit_by_allocatable_memory(reasonable_initial);
1828
1829 if (PrintGCDetails && Verbose) {
1830 // Cannot use gclog_or_tty yet.
1831 tty->print_cr(" Initial heap size " SIZE_FORMAT, (size_t)reasonable_initial);
1832 }
1833 FLAG_SET_ERGO(size_t, InitialHeapSize, (size_t)reasonable_initial);
1834 }
1835 // If the minimum heap size has not been set (via -Xms),
1836 // synchronize with InitialHeapSize to avoid errors with the default value.
1837 if (min_heap_size() == 0) {
1838 set_min_heap_size(MIN2((size_t)reasonable_minimum, InitialHeapSize));
1839 if (PrintGCDetails && Verbose) {
1840 // Cannot use gclog_or_tty yet.
1841 tty->print_cr(" Minimum heap size " SIZE_FORMAT, min_heap_size());
1842 }
1843 }
1844 }
1845 }
1846
1847 // Set up runtime image flags
1848 void Arguments::set_runtime_image_flags() {
1849 #ifdef _LP64
1850 // Memory map image file by default on 64 bit machines.
1851 if (FLAG_IS_DEFAULT(MemoryMapImage)) {
1852 FLAG_SET_ERGO(bool, MemoryMapImage, true);
1853 }
1854 #endif
1855 }
1856
1857 // This must be called after ergonomics.
1858 void Arguments::set_bytecode_flags() {
1859 if (!RewriteBytecodes) {
1860 FLAG_SET_DEFAULT(RewriteFrequentPairs, false);
1861 }
1862 }
1863
1864 // Aggressive optimization flags -XX:+AggressiveOpts
1865 void Arguments::set_aggressive_opts_flags() {
1866 #ifdef COMPILER2
1867 if (AggressiveUnboxing) {
2016 "please refer to the release notes for the combinations "
2017 "allowed\n");
2018 return false;
2019 }
2020
2021 if (UseConcMarkSweepGC && !UseParNewGC) {
2022 jio_fprintf(defaultStream::error_stream(),
2023 "It is not possible to combine the DefNew young collector with the CMS collector.\n");
2024 return false;
2025 }
2026
2027 if (UseParNewGC && !UseConcMarkSweepGC) {
2028 jio_fprintf(defaultStream::error_stream(),
2029 "It is not possible to combine the ParNew young collector with any collector other than CMS.\n");
2030 return false;
2031 }
2032
2033 return true;
2034 }
2035
2036 void Arguments::check_deprecated_gc_flags() {
2037 if (FLAG_IS_CMDLINE(UseParNewGC)) {
2038 warning("The UseParNewGC flag is deprecated and will likely be removed in a future release");
2039 }
2040 if (FLAG_IS_CMDLINE(MaxGCMinorPauseMillis)) {
2041 warning("Using MaxGCMinorPauseMillis as minor pause goal is deprecated"
2042 "and will likely be removed in future release");
2043 }
2044 if (FLAG_IS_CMDLINE(DefaultMaxRAMFraction)) {
2045 warning("DefaultMaxRAMFraction is deprecated and will likely be removed in a future release. "
2046 "Use MaxRAMFraction instead.");
2047 }
2048 }
2049
2050 // Check the consistency of vm_init_args
2051 bool Arguments::check_vm_args_consistency() {
2052 // Method for adding checks for flag consistency.
2053 // The intent is to warn the user of all possible conflicts,
2054 // before returning an error.
2055 // Note: Needs platform-dependent factoring.
2056 bool status = true;
2057
2058 if (TLABRefillWasteFraction == 0) {
2059 jio_fprintf(defaultStream::error_stream(),
2060 "TLABRefillWasteFraction should be a denominator, "
2061 "not " SIZE_FORMAT "\n",
2062 TLABRefillWasteFraction);
2063 status = false;
2064 }
2065
2066 if (FullGCALot && FLAG_IS_DEFAULT(MarkSweepAlwaysCompactCount)) {
2067 MarkSweepAlwaysCompactCount = 1; // Move objects every gc.
2068 }
2069
2569 ArgsRange errcode = parse_memory_size(tail, &long_ThreadStackSize, 1000);
2570 if (errcode != arg_in_range) {
2571 jio_fprintf(defaultStream::error_stream(),
2572 "Invalid thread stack size: %s\n", option->optionString);
2573 describe_range_error(errcode);
2574 return JNI_EINVAL;
2575 }
2576 // Internally track ThreadStackSize in units of 1024 bytes.
2577 if (FLAG_SET_CMDLINE(intx, ThreadStackSize,
2578 round_to((int)long_ThreadStackSize, K) / K) != Flag::SUCCESS) {
2579 return JNI_EINVAL;
2580 }
2581 // -Xoss, -Xsqnopause, -Xoptimize, -Xboundthreads
2582 } else if (match_option(option, "-Xoss", &tail) ||
2583 match_option(option, "-Xsqnopause") ||
2584 match_option(option, "-Xoptimize") ||
2585 match_option(option, "-Xboundthreads")) {
2586 // All these options are deprecated in JDK 9 and will be removed in a future release
2587 char version[256];
2588 JDK_Version::jdk(9).to_string(version, sizeof(version));
2589 warning("ignoring option %s; support was removed in %s", option->optionString, version);
2590 } else if (match_option(option, "-XX:CodeCacheExpansionSize=", &tail)) {
2591 julong long_CodeCacheExpansionSize = 0;
2592 ArgsRange errcode = parse_memory_size(tail, &long_CodeCacheExpansionSize, os::vm_page_size());
2593 if (errcode != arg_in_range) {
2594 jio_fprintf(defaultStream::error_stream(),
2595 "Invalid argument: %s. Must be at least %luK.\n", option->optionString,
2596 os::vm_page_size()/K);
2597 return JNI_EINVAL;
2598 }
2599 if (FLAG_SET_CMDLINE(uintx, CodeCacheExpansionSize, (uintx)long_CodeCacheExpansionSize) != Flag::SUCCESS) {
2600 return JNI_EINVAL;
2601 }
2602 } else if (match_option(option, "-Xmaxjitcodesize", &tail) ||
2603 match_option(option, "-XX:ReservedCodeCacheSize=", &tail)) {
2604 julong long_ReservedCodeCacheSize = 0;
2605
2606 ArgsRange errcode = parse_memory_size(tail, &long_ReservedCodeCacheSize, 1);
2607 if (errcode != arg_in_range) {
2608 jio_fprintf(defaultStream::error_stream(),
2609 "Invalid maximum code cache size: %s.\n", option->optionString);
2836 // JNI hooks
2837 } else if (match_option(option, "-Xcheck", &tail)) {
2838 if (!strcmp(tail, ":jni")) {
2839 #if !INCLUDE_JNI_CHECK
2840 warning("JNI CHECKING is not supported in this VM");
2841 #else
2842 CheckJNICalls = true;
2843 #endif // INCLUDE_JNI_CHECK
2844 } else if (is_bad_option(option, args->ignoreUnrecognized,
2845 "check")) {
2846 return JNI_EINVAL;
2847 }
2848 } else if (match_option(option, "vfprintf")) {
2849 _vfprintf_hook = CAST_TO_FN_PTR(vfprintf_hook_t, option->extraInfo);
2850 } else if (match_option(option, "exit")) {
2851 _exit_hook = CAST_TO_FN_PTR(exit_hook_t, option->extraInfo);
2852 } else if (match_option(option, "abort")) {
2853 _abort_hook = CAST_TO_FN_PTR(abort_hook_t, option->extraInfo);
2854 // -XX:+AggressiveHeap
2855 } else if (match_option(option, "-XX:+AggressiveHeap")) {
2856
2857 // This option inspects the machine and attempts to set various
2858 // parameters to be optimal for long-running, memory allocation
2859 // intensive jobs. It is intended for machines with large
2860 // amounts of cpu and memory.
2861
2862 // initHeapSize is needed since _initial_heap_size is 4 bytes on a 32 bit
2863 // VM, but we may not be able to represent the total physical memory
2864 // available (like having 8gb of memory on a box but using a 32bit VM).
2865 // Thus, we need to make sure we're using a julong for intermediate
2866 // calculations.
2867 julong initHeapSize;
2868 julong total_memory = os::physical_memory();
2869
2870 if (total_memory < (julong)256*M) {
2871 jio_fprintf(defaultStream::error_stream(),
2872 "You need at least 256mb of memory to use -XX:+AggressiveHeap\n");
2873 vm_exit(1);
2874 }
2875
2876 // The heap size is half of available memory, or (at most)
2877 // all of possible memory less 160mb (leaving room for the OS
2878 // when using ISM). This is the maximum; because adaptive sizing
2879 // is turned on below, the actual space used may be smaller.
2880
2881 initHeapSize = MIN2(total_memory / (julong)2,
2882 total_memory - (julong)160*M);
2883
2884 initHeapSize = limit_by_allocatable_memory(initHeapSize);
2885
2886 if (FLAG_IS_DEFAULT(MaxHeapSize)) {
2887 if (FLAG_SET_CMDLINE(size_t, MaxHeapSize, initHeapSize) != Flag::SUCCESS) {
2888 return JNI_EINVAL;
2889 }
2890 if (FLAG_SET_CMDLINE(size_t, InitialHeapSize, initHeapSize) != Flag::SUCCESS) {
2891 return JNI_EINVAL;
2892 }
2893 // Currently the minimum size and the initial heap sizes are the same.
2894 set_min_heap_size(initHeapSize);
2895 }
2896 if (FLAG_IS_DEFAULT(NewSize)) {
2897 // Make the young generation 3/8ths of the total heap.
2898 if (FLAG_SET_CMDLINE(size_t, NewSize,
2899 ((julong)MaxHeapSize / (julong)8) * (julong)3) != Flag::SUCCESS) {
2900 return JNI_EINVAL;
2901 }
2902 if (FLAG_SET_CMDLINE(size_t, MaxNewSize, NewSize) != Flag::SUCCESS) {
2903 return JNI_EINVAL;
2904 }
2905 }
2906
2907 #if !defined(_ALLBSD_SOURCE) && !defined(AIX) // UseLargePages is not yet supported on BSD and AIX.
2908 FLAG_SET_DEFAULT(UseLargePages, true);
2909 #endif
2910
2911 // Increase some data structure sizes for efficiency
2912 if (FLAG_SET_CMDLINE(size_t, BaseFootPrintEstimate, MaxHeapSize) != Flag::SUCCESS) {
2913 return JNI_EINVAL;
2914 }
2915 if (FLAG_SET_CMDLINE(bool, ResizeTLAB, false) != Flag::SUCCESS) {
2916 return JNI_EINVAL;
2917 }
2918 if (FLAG_SET_CMDLINE(size_t, TLABSize, 256*K) != Flag::SUCCESS) {
2919 return JNI_EINVAL;
2920 }
2921
2922 // See the OldPLABSize comment below, but replace 'after promotion'
2923 // with 'after copying'. YoungPLABSize is the size of the survivor
2924 // space per-gc-thread buffers. The default is 4kw.
2925 if (FLAG_SET_CMDLINE(size_t, YoungPLABSize, 256*K) != Flag::SUCCESS) { // Note: this is in words
2926 return JNI_EINVAL;
2927 }
2928
2929 // OldPLABSize is the size of the buffers in the old gen that
2930 // UseParallelGC uses to promote live data that doesn't fit in the
2931 // survivor spaces. At any given time, there's one for each gc thread.
2932 // The default size is 1kw. These buffers are rarely used, since the
2933 // survivor spaces are usually big enough. For specjbb, however, there
2934 // are occasions when there's lots of live data in the young gen
2935 // and we end up promoting some of it. We don't have a definite
2936 // explanation for why bumping OldPLABSize helps, but the theory
2937 // is that a bigger PLAB results in retaining something like the
2938 // original allocation order after promotion, which improves mutator
2939 // locality. A minor effect may be that larger PLABs reduce the
2940 // number of PLAB allocation events during gc. The value of 8kw
2941 // was arrived at by experimenting with specjbb.
2942 if (FLAG_SET_CMDLINE(size_t, OldPLABSize, 8*K) != Flag::SUCCESS) { // Note: this is in words
2943 return JNI_EINVAL;
2944 }
2945
2946 // Enable parallel GC and adaptive generation sizing
2947 if (FLAG_SET_CMDLINE(bool, UseParallelGC, true) != Flag::SUCCESS) {
2948 return JNI_EINVAL;
2949 }
2950 FLAG_SET_DEFAULT(ParallelGCThreads,
2951 Abstract_VM_Version::parallel_worker_threads());
2952
2953 // Encourage steady state memory management
2954 if (FLAG_SET_CMDLINE(uintx, ThresholdTolerance, 100) != Flag::SUCCESS) {
2955 return JNI_EINVAL;
2956 }
2957
2958 // This appears to improve mutator locality
2959 if (FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false) != Flag::SUCCESS) {
2960 return JNI_EINVAL;
2961 }
2962
2963 // Get around early Solaris scheduling bug
2964 // (affinity vs other jobs on system)
2965 // but disallow DR and offlining (5008695).
2966 if (FLAG_SET_CMDLINE(bool, BindGCTaskThreadsToCPUs, true) != Flag::SUCCESS) {
2967 return JNI_EINVAL;
2968 }
2969
2970 // Need to keep consistency of MaxTenuringThreshold and AlwaysTenure/NeverTenure;
2971 // and the last option wins.
2972 } else if (match_option(option, "-XX:+NeverTenure")) {
2973 if (FLAG_SET_CMDLINE(bool, NeverTenure, true) != Flag::SUCCESS) {
2974 return JNI_EINVAL;
2975 }
2976 if (FLAG_SET_CMDLINE(bool, AlwaysTenure, false) != Flag::SUCCESS) {
2977 return JNI_EINVAL;
2978 }
2979 if (FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, markOopDesc::max_age + 1) != Flag::SUCCESS) {
2980 return JNI_EINVAL;
2981 }
2982 } else if (match_option(option, "-XX:+AlwaysTenure")) {
2983 if (FLAG_SET_CMDLINE(bool, NeverTenure, false) != Flag::SUCCESS) {
2984 return JNI_EINVAL;
2985 }
2986 if (FLAG_SET_CMDLINE(bool, AlwaysTenure, true) != Flag::SUCCESS) {
2987 return JNI_EINVAL;
2988 }
2989 if (FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, 0) != Flag::SUCCESS) {
3042 return JNI_EINVAL;
3043 }
3044 if (FLAG_SET_CMDLINE(bool, DTraceMonitorProbes, true) != Flag::SUCCESS) {
3045 return JNI_EINVAL;
3046 }
3047 #else // defined(DTRACE_ENABLED)
3048 jio_fprintf(defaultStream::error_stream(),
3049 "ExtendedDTraceProbes flag is not applicable for this configuration\n");
3050 return JNI_EINVAL;
3051 #endif // defined(DTRACE_ENABLED)
3052 #ifdef ASSERT
3053 } else if (match_option(option, "-XX:+FullGCALot")) {
3054 if (FLAG_SET_CMDLINE(bool, FullGCALot, true) != Flag::SUCCESS) {
3055 return JNI_EINVAL;
3056 }
3057 // disable scavenge before parallel mark-compact
3058 if (FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false) != Flag::SUCCESS) {
3059 return JNI_EINVAL;
3060 }
3061 #endif
3062 } else if (match_option(option, "-XX:CMSMarkStackSize=", &tail) ||
3063 match_option(option, "-XX:G1MarkStackSize=", &tail)) {
3064 julong stack_size = 0;
3065 ArgsRange errcode = parse_memory_size(tail, &stack_size, 1);
3066 if (errcode != arg_in_range) {
3067 jio_fprintf(defaultStream::error_stream(),
3068 "Invalid mark stack size: %s\n", option->optionString);
3069 describe_range_error(errcode);
3070 return JNI_EINVAL;
3071 }
3072 jio_fprintf(defaultStream::error_stream(),
3073 "Please use -XX:MarkStackSize in place of "
3074 "-XX:CMSMarkStackSize or -XX:G1MarkStackSize in the future\n");
3075 if (FLAG_SET_CMDLINE(size_t, MarkStackSize, stack_size) != Flag::SUCCESS) {
3076 return JNI_EINVAL;
3077 }
3078 } else if (match_option(option, "-XX:CMSMarkStackSizeMax=", &tail)) {
3079 julong max_stack_size = 0;
3080 ArgsRange errcode = parse_memory_size(tail, &max_stack_size, 1);
3081 if (errcode != arg_in_range) {
3082 jio_fprintf(defaultStream::error_stream(),
3083 "Invalid maximum mark stack size: %s\n",
3084 option->optionString);
3085 describe_range_error(errcode);
3086 return JNI_EINVAL;
3087 }
3088 jio_fprintf(defaultStream::error_stream(),
3089 "Please use -XX:MarkStackSizeMax in place of "
3090 "-XX:CMSMarkStackSizeMax in the future\n");
3091 if (FLAG_SET_CMDLINE(size_t, MarkStackSizeMax, max_stack_size) != Flag::SUCCESS) {
3092 return JNI_EINVAL;
3093 }
3094 } else if (match_option(option, "-XX:ParallelMarkingThreads=", &tail) ||
3095 match_option(option, "-XX:ParallelCMSThreads=", &tail)) {
3096 uintx conc_threads = 0;
3097 if (!parse_uintx(tail, &conc_threads, 1)) {
3098 jio_fprintf(defaultStream::error_stream(),
3099 "Invalid concurrent threads: %s\n", option->optionString);
3100 return JNI_EINVAL;
3101 }
3102 jio_fprintf(defaultStream::error_stream(),
3103 "Please use -XX:ConcGCThreads in place of "
3104 "-XX:ParallelMarkingThreads or -XX:ParallelCMSThreads in the future\n");
3105 if (FLAG_SET_CMDLINE(uint, ConcGCThreads, conc_threads) != Flag::SUCCESS) {
3106 return JNI_EINVAL;
3107 }
3108 } else if (match_option(option, "-XX:MaxDirectMemorySize=", &tail)) {
3109 julong max_direct_memory_size = 0;
3110 ArgsRange errcode = parse_memory_size(tail, &max_direct_memory_size, 0);
3111 if (errcode != arg_in_range) {
3112 jio_fprintf(defaultStream::error_stream(),
3113 "Invalid maximum direct memory size: %s\n",
3114 option->optionString);
3115 describe_range_error(errcode);
3116 return JNI_EINVAL;
3117 }
3118 if (FLAG_SET_CMDLINE(size_t, MaxDirectMemorySize, max_direct_memory_size) != Flag::SUCCESS) {
3119 return JNI_EINVAL;
3120 }
3121 #if !INCLUDE_MANAGEMENT
3122 } else if (match_option(option, "-XX:+ManagementServer")) {
3123 jio_fprintf(defaultStream::error_stream(),
3124 "ManagementServer is not supported in this VM.\n");
3125 return JNI_ERR;
3126 #endif // INCLUDE_MANAGEMENT
3127 // CreateMinidumpOnCrash is removed, and replaced by CreateCoredumpOnCrash
3128 } else if (match_option(option, "-XX:+CreateMinidumpOnCrash")) {
3129 if (FLAG_SET_CMDLINE(bool, CreateCoredumpOnCrash, true) != Flag::SUCCESS) {
3130 return JNI_EINVAL;
3131 }
3132 jio_fprintf(defaultStream::output_stream(),
3133 "CreateMinidumpOnCrash is replaced by CreateCoredumpOnCrash: CreateCoredumpOnCrash is on\n");
3134 } else if (match_option(option, "-XX:-CreateMinidumpOnCrash")) {
3135 if (FLAG_SET_CMDLINE(bool, CreateCoredumpOnCrash, false) != Flag::SUCCESS) {
3136 return JNI_EINVAL;
3137 }
3138 jio_fprintf(defaultStream::output_stream(),
3139 "CreateMinidumpOnCrash is replaced by CreateCoredumpOnCrash: CreateCoredumpOnCrash is off\n");
3140 } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx
3141 // Skip -XX:Flags= since that case has already been handled
3142 if (strncmp(tail, "Flags=", strlen("Flags=")) != 0) {
3143 if (!process_argument(tail, args->ignoreUnrecognized, origin)) {
3144 return JNI_EINVAL;
3145 }
3146 }
3147 // Unknown option
3148 } else if (is_bad_option(option, args->ignoreUnrecognized)) {
3149 return JNI_ERR;
3150 }
3151 }
3152
3153 // PrintSharedArchiveAndExit will turn on
3154 // -Xshare:on
3155 // -XX:+TraceClassPaths
3156 if (PrintSharedArchiveAndExit) {
3157 if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != Flag::SUCCESS) {
3158 return JNI_EINVAL;
3159 }
3496 }
3497 if (*rd != 0) {
3498 // In this case, the assignment to wrt below will make *rd nul,
3499 // which will interfere with the next loop iteration.
3500 rd++;
3501 }
3502 *wrt = 0; // Zero terminate option
3503 }
3504
3505 // Fill out JavaVMInitArgs structure.
3506 jint status = vm_args->set_args(options);
3507
3508 delete options;
3509 os::free(buffer);
3510 return status;
3511 }
3512
3513 void Arguments::set_shared_spaces_flags() {
3514 if (DumpSharedSpaces) {
3515 if (RequireSharedSpaces) {
3516 warning("cannot dump shared archive while using shared archive");
3517 }
3518 UseSharedSpaces = false;
3519 #ifdef _LP64
3520 if (!UseCompressedOops || !UseCompressedClassPointers) {
3521 vm_exit_during_initialization(
3522 "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL);
3523 }
3524 } else {
3525 if (!UseCompressedOops || !UseCompressedClassPointers) {
3526 no_shared_spaces("UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces.");
3527 }
3528 #endif
3529 }
3530 }
3531
3532 #if !INCLUDE_ALL_GCS
3533 static void force_serial_gc() {
3534 FLAG_SET_DEFAULT(UseSerialGC, true);
3535 UNSUPPORTED_GC_OPTION(UseG1GC);
3536 UNSUPPORTED_GC_OPTION(UseParallelGC);
3775 #if defined(_ALLBSD_SOURCE) || defined(AIX) // UseLargePages is not yet supported on BSD and AIX.
3776 UNSUPPORTED_OPTION(UseLargePages, "-XX:+UseLargePages");
3777 #endif
3778
3779 ArgumentsExt::report_unsupported_options();
3780
3781 #ifndef PRODUCT
3782 if (TraceBytecodesAt != 0) {
3783 TraceBytecodes = true;
3784 }
3785 if (CountCompiledCalls) {
3786 if (UseCounterDecay) {
3787 warning("UseCounterDecay disabled because CountCalls is set");
3788 UseCounterDecay = false;
3789 }
3790 }
3791 #endif // PRODUCT
3792
3793 if (ScavengeRootsInCode == 0) {
3794 if (!FLAG_IS_DEFAULT(ScavengeRootsInCode)) {
3795 warning("forcing ScavengeRootsInCode non-zero");
3796 }
3797 ScavengeRootsInCode = 1;
3798 }
3799
3800 if (PrintGCDetails) {
3801 // Turn on -verbose:gc options as well
3802 PrintGC = true;
3803 }
3804
3805 // Set object alignment values.
3806 set_object_alignment();
3807
3808 #if !INCLUDE_ALL_GCS
3809 force_serial_gc();
3810 #endif // INCLUDE_ALL_GCS
3811 #if !INCLUDE_CDS
3812 if (DumpSharedSpaces || RequireSharedSpaces) {
3813 jio_fprintf(defaultStream::error_stream(),
3814 "Shared spaces are not supported in this VM\n");
3815 return JNI_ERR;
|
104 AgentLibraryList Arguments::_libraryList;
105 AgentLibraryList Arguments::_agentList;
106
107 abort_hook_t Arguments::_abort_hook = NULL;
108 exit_hook_t Arguments::_exit_hook = NULL;
109 vfprintf_hook_t Arguments::_vfprintf_hook = NULL;
110
111
112 SystemProperty *Arguments::_sun_boot_library_path = NULL;
113 SystemProperty *Arguments::_java_library_path = NULL;
114 SystemProperty *Arguments::_java_home = NULL;
115 SystemProperty *Arguments::_java_class_path = NULL;
116 SystemProperty *Arguments::_sun_boot_class_path = NULL;
117
118 char* Arguments::_ext_dirs = NULL;
119
120 // Check if head of 'option' matches 'name', and sets 'tail' to the remaining
121 // part of the option string.
122 static bool match_option(const JavaVMOption *option, const char* name,
123 const char** tail) {
124 size_t len = strlen(name);
125 if (strncmp(option->optionString, name, len) == 0) {
126 *tail = option->optionString + len;
127 return true;
128 } else {
129 return false;
130 }
131 }
132
133 // Check if 'option' matches 'name'. No "tail" is allowed.
134 static bool match_option(const JavaVMOption *option, const char* name) {
135 const char* tail = NULL;
136 bool result = match_option(option, name, &tail);
137 if (tail != NULL && *tail == '\0') {
138 return result;
139 } else {
140 return false;
141 }
142 }
143
144 // Return true if any of the strings in null-terminated array 'names' matches.
205 _java_home = new SystemProperty("java.home", NULL, true);
206 _sun_boot_class_path = new SystemProperty("sun.boot.class.path", NULL, true);
207
208 _java_class_path = new SystemProperty("java.class.path", "", true);
209
210 // Add to System Property list.
211 PropertyList_add(&_system_properties, _sun_boot_library_path);
212 PropertyList_add(&_system_properties, _java_library_path);
213 PropertyList_add(&_system_properties, _java_home);
214 PropertyList_add(&_system_properties, _java_class_path);
215 PropertyList_add(&_system_properties, _sun_boot_class_path);
216
217 // Set OS specific system properties values
218 os::init_system_properties_values();
219 }
220
221 // Update/Initialize System properties after JDK version number is known
222 void Arguments::init_version_specific_system_properties() {
223 enum { bufsz = 16 };
224 char buffer[bufsz];
225 const char* spec_vendor = "Oracle Corporation";
226 uint32_t spec_version = JDK_Version::current().major_version();
227
228 jio_snprintf(buffer, bufsz, "1." UINT32_FORMAT, spec_version);
229
230 PropertyList_add(&_system_properties,
231 new SystemProperty("java.vm.specification.vendor", spec_vendor, false));
232 PropertyList_add(&_system_properties,
233 new SystemProperty("java.vm.specification.version", buffer, false));
234 PropertyList_add(&_system_properties,
235 new SystemProperty("java.vm.vendor", VM_Version::vm_vendor(), false));
236 }
237
238 /*
239 * -XX argument processing:
240 *
241 * -XX arguments are defined in several places, such as:
242 * globals.hpp, globals_<cpu>.hpp, globals_<os>.hpp, <compiler>_globals.hpp, or <gc>_globals.hpp.
243 * -XX arguments are parsed in parse_argument().
244 * -XX argument bounds checking is done in check_vm_args_consistency().
245 *
246 * Over time -XX arguments may change. There are mechanisms to handle common cases:
247 *
248 * ALIASED: An option that is simply another name for another option. This is often
249 * part of the process of deprecating a flag, but not all aliases need
250 * to be deprecated.
251 *
252 * Create an alias for an option by adding the old and new option names to the
253 * "aliased_jvm_flags" table. Delete the old variable from globals.hpp (etc),.
254 *
255 * DEPRECATED: An option that is supported, but a warning is printed to let the user know that
256 * support may be removed in the future. Both regular and aliased options may be
257 * deprecated.
258 *
259 * Add a deprecation warning for an option (or alias) by adding an entry in the
260 * "deprecated_jvm_flags" table. Often an option "deprecated" in one major release will
261 * be made "obsolete" in the next. In this case the entry should be removed from the
262 * "deprecated_jvm_flags" table and added to the "obsolete_jvm_flags" table (see below).
263 *
264 * OBSOLETE: An option that has been removed (and deleted from globals.hpp), but is still accepted
265 * on the command line. A warning is printed to let the user know that option might not
266 * be accepted in the future.
267 *
268 * Add an obsolete warning for an option by adding an entry in the "obsolete_jvm_flags"
269 * table.
270 *
271 * EXPIRED: A deprecated or obsolete option that has an "accept_until" version less than or equal
272 * to the current JDK version. The system will flatly refuse to admit the existence of
273 * the flag. This allows a flag to die automatically over JDK releases.
274 *
275 * Note that manual cleanup of expired options should be done at major JDK version upgrades:
276 * - Expired options should be removed from the obsolete_jvm_flags, deprecated_jvm_flags,
277 * and aliased_jvm_flags tables.
278 * - Expired deprecated options should have their global variable definitions removed
279 * (in globals.hpp, etc).
280 *
281 * Tests: Aliases should be tested in VMAliasOptions.java.
282 * Deprecated options should be tested in VMDeprecatedOptions.java.
283 */
284
285 // Obsolete or deprecated -XX flag.
286 typedef struct {
287 const char* name;
288 JDK_Version warning_started_in; // When the warning started (obsolete or deprecated).
289 JDK_Version accept_until; // Which version to start denying the existence of the flag (if scheduled).
290 } SpecialFlag;
291
292 // When a flag is made obsolete, it can be added to this list in order to
293 // continue accepting this flag on the command-line, while issuing a warning
294 // and ignoring the value. Once the JDK version reaches the 'accept_until'
295 // limit, we flatly refuse to admit the existence of the flag. The 'accept_until'
296 // field can be set to undefined() if the expiration date has not yet been set.
297 // This table should be scrubbed of expired options on major JDK releases.
298 static SpecialFlag const obsolete_jvm_flags[] = {
299 { "UseOldInlining", JDK_Version::jdk(9), JDK_Version::jdk(10) },
300 { "SafepointPollOffset", JDK_Version::jdk(9), JDK_Version::jdk(10) },
301 { "UseBoundThreads", JDK_Version::jdk(9), JDK_Version::jdk(10) },
302 { "DefaultThreadPriority", JDK_Version::jdk(9), JDK_Version::jdk(10) },
303 { "NoYieldsInMicrolock", JDK_Version::jdk(9), JDK_Version::jdk(10) },
304 { "BackEdgeThreshold", JDK_Version::jdk(9), JDK_Version::jdk(10) },
305 { "UseNewReflection", JDK_Version::jdk(9), JDK_Version::jdk(10) },
306 { "ReflectionWrapResolutionErrors",JDK_Version::jdk(9), JDK_Version::jdk(10) },
307 { "VerifyReflectionBytecodes", JDK_Version::jdk(9), JDK_Version::jdk(10) },
308 { "AutoShutdownNMT", JDK_Version::jdk(9), JDK_Version::jdk(10) },
309 { "NmethodSweepFraction", JDK_Version::jdk(9), JDK_Version::jdk(10) },
310 { "NmethodSweepCheckInterval", JDK_Version::jdk(9), JDK_Version::jdk(10) },
311 { "CodeCacheMinimumFreeSpace", JDK_Version::jdk(9), JDK_Version::jdk(10) },
312 #ifndef ZERO
313 { "UseFastAccessorMethods", JDK_Version::jdk(9), JDK_Version::jdk(10) },
314 { "UseFastEmptyMethods", JDK_Version::jdk(9), JDK_Version::jdk(10) },
315 #endif // ZERO
316 { "UseCompilerSafepoints", JDK_Version::jdk(9), JDK_Version::jdk(10) },
317 { "AdaptiveSizePausePolicy", JDK_Version::jdk(9), JDK_Version::jdk(10) },
318 { "ParallelGCRetainPLAB", JDK_Version::jdk(9), JDK_Version::jdk(10) },
319 { "ThreadSafetyMargin", JDK_Version::jdk(9), JDK_Version::jdk(10) },
320 { "LazyBootClassLoader", JDK_Version::jdk(9), JDK_Version::jdk(10) },
321 { "StarvationMonitorInterval", JDK_Version::jdk(9), JDK_Version::jdk(10) },
322 { "PreInflateSpin", JDK_Version::jdk(9), JDK_Version::jdk(10) },
323 { NULL, JDK_Version(0), JDK_Version(0) }
324 };
325
326 // When a flag is deprecated, it can be added to this list in order to issue a warning when the flag is used.
327 // Once the JDK version reaches the 'accept_until' limit, we flatly refuse to admit the existence of the flag.
328 // The 'accept_until' field can be set to undefined() if the expiration date has not yet been set.
329 // If a deprecated option should be treated as obsolete before it is expired, it needs to be removed
330 // from this table and added to the obsolete_jvm_flags table.
331 // This table should be scrubbed of expired options on major JDK releases.
332 static SpecialFlag const deprecated_jvm_flags[] = {
333 // deprecated non-alias flags:
334 { "MaxGCMinorPauseMillis", JDK_Version::jdk(8), JDK_Version::undefined() },
335 { "UseParNewGC", JDK_Version::jdk(9), JDK_Version::jdk(10) },
336
337 // deprecated alias flags (see also aliased_jvm_flags):
338 { "DefaultMaxRAMFraction", JDK_Version::jdk(8), JDK_Version::undefined() },
339 { "CMSMarkStackSizeMax", JDK_Version::jdk(9), JDK_Version::jdk(10) },
340 { "CMSMarkStackSize", JDK_Version::jdk(9), JDK_Version::jdk(10) },
341 { "G1MarkStackSize", JDK_Version::jdk(9), JDK_Version::jdk(10) },
342 { "ParallelMarkingThreads", JDK_Version::jdk(9), JDK_Version::jdk(10) },
343 { "ParallelCMSThreads", JDK_Version::jdk(9), JDK_Version::jdk(10) },
344 { "CreateMinidumpOnCrash", JDK_Version::jdk(9), JDK_Version::undefined() },
345 { NULL, JDK_Version(0), JDK_Version(0) }
346 };
347
348 // Flags that are aliases for other flags.
349 typedef struct {
350 const char* alias_name;
351 const char* real_name;
352 } AliasedFlag;
353
354 static AliasedFlag const aliased_jvm_flags[] = {
355 { "DefaultMaxRAMFraction", "MaxRAMFraction" },
356 { "CMSMarkStackSizeMax", "MarkStackSizeMax" },
357 { "CMSMarkStackSize", "MarkStackSize" },
358 { "G1MarkStackSize", "MarkStackSize" },
359 { "ParallelMarkingThreads", "ConcGCThreads" },
360 { "ParallelCMSThreads", "ConcGCThreads" },
361 { "CreateMinidumpOnCrash", "CreateCoredumpOnCrash" },
362 { NULL, NULL}
363 };
364
365 // Returns 1 if the flag is special and jdk version is in the range specified.
366 // In this case the 'version' buffer is filled in with the version number when
367 // the flag became special.
368 // Returns -1 if the flag is special and has expired (should be ignored).
369 // Returns 0 if the flag is not special.
370 // Flag "flag_name" is a flag name stripped of '+', '-', and '='.
371 static int is_special_flag(const SpecialFlag special_table[], const char *flag_name, JDK_Version* version) {
372 assert(version != NULL, "Must provide a version buffer");
373 for (size_t i = 0; special_table[i].name != NULL; i++) {
374 const SpecialFlag& flag_status = special_table[i];
375 if ((strcmp(flag_status.name, flag_name) == 0)) {
376 if (flag_status.accept_until.is_undefined() ||
377 JDK_Version::current().compare(flag_status.accept_until) == -1) {
378 *version = flag_status.warning_started_in;
379 return 1;
380 } else {
381 return -1;
382 }
383 }
384 }
385 return 0;
386 }
387
388 bool Arguments::is_obsolete_flag(const char *flag_name, JDK_Version* version) {
389 return (is_special_flag(obsolete_jvm_flags, flag_name, version) == 1);
390 }
391
392 int Arguments::is_deprecated_flag(const char *flag_name, JDK_Version* version) {
393 return is_special_flag(deprecated_jvm_flags, flag_name, version);
394 }
395
396 const char* Arguments::real_flag_name(const char *flag_name) {
397 for (size_t i = 0; aliased_jvm_flags[i].alias_name != NULL; i++) {
398 const AliasedFlag& flag_status = aliased_jvm_flags[i];
399 if (strcmp(flag_status.alias_name, flag_name) == 0) {
400 return flag_status.real_name;
401 }
402 }
403 return flag_name;
404 }
405
406 // Constructs the system class path (aka boot class path) from the following
407 // components, in order:
408 //
409 // prefix // from -Xbootclasspath/p:...
410 // base // from os::get_system_properties() or -Xbootclasspath=
411 // suffix // from -Xbootclasspath/a:...
412 //
413 // This could be AllStatic, but it isn't needed after argument processing is
414 // complete.
415 class SysClassPath: public StackObj {
416 public:
417 SysClassPath(const char* base);
418 ~SysClassPath();
419
420 inline void set_base(const char* base);
421 inline void add_prefix(const char* prefix);
422 inline void add_suffix_to_prefix(const char* suffix);
423 inline void add_suffix(const char* suffix);
654 }
655
656 // Describe an argument out of range error
657 void Arguments::describe_range_error(ArgsRange errcode) {
658 switch(errcode) {
659 case arg_too_big:
660 jio_fprintf(defaultStream::error_stream(),
661 "The specified size exceeds the maximum "
662 "representable size.\n");
663 break;
664 case arg_too_small:
665 case arg_unreadable:
666 case arg_in_range:
667 // do nothing for now
668 break;
669 default:
670 ShouldNotReachHere();
671 }
672 }
673
674 static bool set_bool_flag(const char* name, bool value, Flag::Flags origin) {
675 if (CommandLineFlags::boolAtPut(name, &value, origin) == Flag::SUCCESS) {
676 return true;
677 } else {
678 return false;
679 }
680 }
681
682 static bool set_fp_numeric_flag(const char* name, char* value, Flag::Flags origin) {
683 double v;
684 if (sscanf(value, "%lf", &v) != 1) {
685 return false;
686 }
687
688 if (CommandLineFlags::doubleAtPut(name, &v, origin) == Flag::SUCCESS) {
689 return true;
690 }
691 return false;
692 }
693
694 static bool set_numeric_flag(const char* name, char* value, Flag::Flags origin) {
695 julong v;
696 int int_v;
697 intx intx_v;
698 bool is_neg = false;
699 // Check the sign first since atomull() parses only unsigned values.
700 if (*value == '-') {
701 if ((CommandLineFlags::intxAt(name, &intx_v) != Flag::SUCCESS) && (CommandLineFlags::intAt(name, &int_v) != Flag::SUCCESS)) {
702 return false;
703 }
704 value++;
705 is_neg = true;
706 }
707 if (!atomull(value, &v)) {
708 return false;
709 }
710 int_v = (int) v;
711 if (is_neg) {
712 int_v = -int_v;
713 }
714 if (CommandLineFlags::intAtPut(name, &int_v, origin) == Flag::SUCCESS) {
723 intx_v = -intx_v;
724 }
725 if (CommandLineFlags::intxAtPut(name, &intx_v, origin) == Flag::SUCCESS) {
726 return true;
727 }
728 uintx uintx_v = (uintx) v;
729 if (!is_neg && (CommandLineFlags::uintxAtPut(name, &uintx_v, origin) == Flag::SUCCESS)) {
730 return true;
731 }
732 uint64_t uint64_t_v = (uint64_t) v;
733 if (!is_neg && (CommandLineFlags::uint64_tAtPut(name, &uint64_t_v, origin) == Flag::SUCCESS)) {
734 return true;
735 }
736 size_t size_t_v = (size_t) v;
737 if (!is_neg && (CommandLineFlags::size_tAtPut(name, &size_t_v, origin) == Flag::SUCCESS)) {
738 return true;
739 }
740 return false;
741 }
742
743 static bool set_string_flag(const char* name, const char* value, Flag::Flags origin) {
744 if (CommandLineFlags::ccstrAtPut(name, &value, origin) != Flag::SUCCESS) return false;
745 // Contract: CommandLineFlags always returns a pointer that needs freeing.
746 FREE_C_HEAP_ARRAY(char, value);
747 return true;
748 }
749
750 static bool append_to_string_flag(const char* name, const char* new_value, Flag::Flags origin) {
751 const char* old_value = "";
752 if (CommandLineFlags::ccstrAt(name, &old_value) != Flag::SUCCESS) return false;
753 size_t old_len = old_value != NULL ? strlen(old_value) : 0;
754 size_t new_len = strlen(new_value);
755 const char* value;
756 char* free_this_too = NULL;
757 if (old_len == 0) {
758 value = new_value;
759 } else if (new_len == 0) {
760 value = old_value;
761 } else {
762 char* buf = NEW_C_HEAP_ARRAY(char, old_len + 1 + new_len + 1, mtInternal);
763 // each new setting adds another LINE to the switch:
764 sprintf(buf, "%s\n%s", old_value, new_value);
765 value = buf;
766 free_this_too = buf;
767 }
768 (void) CommandLineFlags::ccstrAtPut(name, &value, origin);
769 // CommandLineFlags always returns a pointer that needs freeing.
770 FREE_C_HEAP_ARRAY(char, value);
771 if (free_this_too != NULL) {
772 // CommandLineFlags made its own copy, so I must delete my own temp. buffer.
773 FREE_C_HEAP_ARRAY(char, free_this_too);
774 }
775 return true;
776 }
777
778 const char* Arguments::handle_aliases_and_deprecation(const char* arg, bool warn) {
779 const char* real_name = real_flag_name(arg);
780 JDK_Version since = JDK_Version();
781 switch (is_deprecated_flag(arg, &since)) {
782 case -1:
783 return NULL;
784 case 0:
785 return real_name;
786 case 1: {
787 if (warn) {
788 char version[256];
789 since.to_string(version, sizeof(version));
790 if (real_name != arg) {
791 warning("Option %s was deprecated in version %s and will likely be removed in a future release. Use option %s instead.",
792 arg, version, real_name);
793 } else {
794 warning("Option %s was deprecated in version %s and will likely be removed in a future release.",
795 arg, version);
796 }
797 }
798 return real_name;
799 }
800 }
801 ShouldNotReachHere();
802 return NULL;
803 }
804
805 bool Arguments::parse_argument(const char* arg, Flag::Flags origin) {
806
807 // range of acceptable characters spelled out for portability reasons
808 #define NAME_RANGE "[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]"
809 #define BUFLEN 255
810 char name[BUFLEN+1];
811 char dummy;
812 const char* real_name;
813 bool warn_if_deprecated = true;
814
815 if (sscanf(arg, "-%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
816 real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
817 if (real_name == NULL) {
818 return false;
819 }
820 return set_bool_flag(real_name, false, origin);
821 }
822 if (sscanf(arg, "+%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
823 real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
824 if (real_name == NULL) {
825 return false;
826 }
827 return set_bool_flag(real_name, true, origin);
828 }
829
830 char punct;
831 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "%c", name, &punct) == 2 && punct == '=') {
832 const char* value = strchr(arg, '=') + 1;
833 Flag* flag;
834
835 // this scanf pattern matches both strings (handled here) and numbers (handled later))
836 real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
837 if (real_name == NULL) {
838 return false;
839 }
840 flag = Flag::find_flag(real_name);
841 if (flag != NULL && flag->is_ccstr()) {
842 if (flag->ccstr_accumulates()) {
843 return append_to_string_flag(real_name, value, origin);
844 } else {
845 if (value[0] == '\0') {
846 value = NULL;
847 }
848 return set_string_flag(real_name, value, origin);
849 }
850 } else {
851 warn_if_deprecated = false; // if arg is deprecated, we've already done warning...
852 }
853 }
854
855 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE ":%c", name, &punct) == 2 && punct == '=') {
856 const char* value = strchr(arg, '=') + 1;
857 // -XX:Foo:=xxx will reset the string flag to the given value.
858 if (value[0] == '\0') {
859 value = NULL;
860 }
861 real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
862 if (real_name == NULL) {
863 return false;
864 }
865 return set_string_flag(real_name, value, origin);
866 }
867
868 #define SIGNED_FP_NUMBER_RANGE "[-0123456789.]"
869 #define SIGNED_NUMBER_RANGE "[-0123456789]"
870 #define NUMBER_RANGE "[0123456789]"
871 char value[BUFLEN + 1];
872 char value2[BUFLEN + 1];
873 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_NUMBER_RANGE "." "%" XSTR(BUFLEN) NUMBER_RANGE "%c", name, value, value2, &dummy) == 3) {
874 // Looks like a floating-point number -- try again with more lenient format string
875 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_FP_NUMBER_RANGE "%c", name, value, &dummy) == 2) {
876 real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
877 if (real_name == NULL) {
878 return false;
879 }
880 return set_fp_numeric_flag(real_name, value, origin);
881 }
882 }
883
884 #define VALUE_RANGE "[-kmgtxKMGTX0123456789abcdefABCDEF]"
885 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) VALUE_RANGE "%c", name, value, &dummy) == 2) {
886 real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
887 if (real_name == NULL) {
888 return false;
889 }
890 return set_numeric_flag(real_name, value, origin);
891 }
892
893 return false;
894 }
895
896 void Arguments::add_string(char*** bldarray, int* count, const char* arg) {
897 assert(bldarray != NULL, "illegal argument");
898
899 if (arg == NULL) {
900 return;
901 }
902
903 int new_count = *count + 1;
904
905 // expand the array and add arg to the last element
906 if (*bldarray == NULL) {
907 *bldarray = NEW_C_HEAP_ARRAY(char*, new_count, mtInternal);
908 } else {
909 *bldarray = REALLOC_C_HEAP_ARRAY(char*, *bldarray, new_count, mtInternal);
910 }
978 st->cr();
979 }
980
981 void Arguments::print_jvm_flags_on(outputStream* st) {
982 if (_num_jvm_flags > 0) {
983 for (int i=0; i < _num_jvm_flags; i++) {
984 st->print("%s ", _jvm_flags_array[i]);
985 }
986 }
987 }
988
989 void Arguments::print_jvm_args_on(outputStream* st) {
990 if (_num_jvm_args > 0) {
991 for (int i=0; i < _num_jvm_args; i++) {
992 st->print("%s ", _jvm_args_array[i]);
993 }
994 }
995 }
996
997 bool Arguments::process_argument(const char* arg,
998 jboolean ignore_unrecognized,
999 Flag::Flags origin) {
1000 JDK_Version since = JDK_Version();
1001
1002 if (parse_argument(arg, origin) || ignore_unrecognized) {
1003 return true;
1004 }
1005
1006 // Determine if the flag has '+', '-', or '=' characters.
1007 bool has_plus_minus = (*arg == '+' || *arg == '-');
1008 const char* const argname = has_plus_minus ? arg + 1 : arg;
1009
1010 size_t arg_len;
1011 const char* equal_sign = strchr(argname, '=');
1012 if (equal_sign == NULL) {
1013 arg_len = strlen(argname);
1014 } else {
1015 arg_len = equal_sign - argname;
1016 }
1017
1018 // Only make the obsolete check for valid arguments.
1019 if (arg_len <= BUFLEN) {
1020 // Construct a string which consists only of the argument name without '+', '-', or '='.
1021 char stripped_argname[BUFLEN+1];
1022 strncpy(stripped_argname, argname, arg_len);
1023 stripped_argname[arg_len] = '\0'; // strncpy may not null terminate.
1024
1025 if (is_obsolete_flag(stripped_argname, &since)) {
1026 char version[256];
1027 since.to_string(version, sizeof(version));
1028 warning("Ignoring option %s; support was removed in %s", stripped_argname, version);
1029 return true;
1030 }
1031 }
1032
1033 // For locked flags, report a custom error message if available.
1034 // Otherwise, report the standard unrecognized VM option.
1035 Flag* found_flag = Flag::find_flag((const char*)argname, arg_len, true, true);
1036 if (found_flag != NULL) {
1037 char locked_message_buf[BUFLEN];
1038 found_flag->get_locked_message(locked_message_buf, BUFLEN);
1039 if (strlen(locked_message_buf) == 0) {
1040 if (found_flag->is_bool() && !has_plus_minus) {
1041 jio_fprintf(defaultStream::error_stream(),
1042 "Missing +/- setting for VM option '%s'\n", argname);
1043 } else if (!found_flag->is_bool() && has_plus_minus) {
1044 jio_fprintf(defaultStream::error_stream(),
1045 "Unexpected +/- setting in VM option '%s'\n", argname);
1046 } else {
1047 jio_fprintf(defaultStream::error_stream(),
1048 "Improperly specified VM option '%s'\n", argname);
1368
1369 FLAG_SET_ERGO(intx, Tier2InvokeNotifyFreqLog, scaled_freq_log(Tier2InvokeNotifyFreqLog));
1370 FLAG_SET_ERGO(intx, Tier2BackedgeNotifyFreqLog, scaled_freq_log(Tier2BackedgeNotifyFreqLog));
1371
1372 FLAG_SET_ERGO(intx, Tier3InvokeNotifyFreqLog, scaled_freq_log(Tier3InvokeNotifyFreqLog));
1373 FLAG_SET_ERGO(intx, Tier3BackedgeNotifyFreqLog, scaled_freq_log(Tier3BackedgeNotifyFreqLog));
1374
1375 FLAG_SET_ERGO(intx, Tier23InlineeNotifyFreqLog, scaled_freq_log(Tier23InlineeNotifyFreqLog));
1376
1377 FLAG_SET_ERGO(intx, Tier4InvocationThreshold, scaled_compile_threshold(Tier4InvocationThreshold));
1378 FLAG_SET_ERGO(intx, Tier4MinInvocationThreshold, scaled_compile_threshold(Tier4MinInvocationThreshold));
1379 FLAG_SET_ERGO(intx, Tier4CompileThreshold, scaled_compile_threshold(Tier4CompileThreshold));
1380 FLAG_SET_ERGO(intx, Tier4BackEdgeThreshold, scaled_compile_threshold(Tier4BackEdgeThreshold));
1381 }
1382 }
1383
1384 #if INCLUDE_ALL_GCS
1385 static void disable_adaptive_size_policy(const char* collector_name) {
1386 if (UseAdaptiveSizePolicy) {
1387 if (FLAG_IS_CMDLINE(UseAdaptiveSizePolicy)) {
1388 warning("Disabling UseAdaptiveSizePolicy; it is incompatible with %s.",
1389 collector_name);
1390 }
1391 FLAG_SET_DEFAULT(UseAdaptiveSizePolicy, false);
1392 }
1393 }
1394
1395 void Arguments::set_parnew_gc_flags() {
1396 assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC && !UseG1GC,
1397 "control point invariant");
1398 assert(UseConcMarkSweepGC, "CMS is expected to be on here");
1399 assert(UseParNewGC, "ParNew should always be used with CMS");
1400
1401 if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
1402 FLAG_SET_DEFAULT(ParallelGCThreads, Abstract_VM_Version::parallel_worker_threads());
1403 assert(ParallelGCThreads > 0, "We should always have at least one thread by default");
1404 } else if (ParallelGCThreads == 0) {
1405 jio_fprintf(defaultStream::error_stream(),
1406 "The ParNew GC can not be combined with -XX:ParallelGCThreads=0\n");
1407 vm_exit(1);
1408 }
1845 #if !INCLUDE_ALL_GCS
1846 #ifdef ASSERT
1847 static bool verify_serial_gc_flags() {
1848 return (UseSerialGC &&
1849 !(UseParNewGC || (UseConcMarkSweepGC) || UseG1GC ||
1850 UseParallelGC || UseParallelOldGC));
1851 }
1852 #endif // ASSERT
1853 #endif // INCLUDE_ALL_GCS
1854
1855 void Arguments::set_gc_specific_flags() {
1856 #if INCLUDE_ALL_GCS
1857 // Set per-collector flags
1858 if (UseParallelGC || UseParallelOldGC) {
1859 set_parallel_gc_flags();
1860 } else if (UseConcMarkSweepGC) {
1861 set_cms_and_parnew_gc_flags();
1862 } else if (UseG1GC) {
1863 set_g1_gc_flags();
1864 }
1865 if (AssumeMP && !UseSerialGC) {
1866 if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) {
1867 warning("If the number of processors is expected to increase from one, then"
1868 " you should configure the number of parallel GC threads appropriately"
1869 " using -XX:ParallelGCThreads=N");
1870 }
1871 }
1872 if (MinHeapFreeRatio == 100) {
1873 // Keeping the heap 100% free is hard ;-) so limit it to 99%.
1874 FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99);
1875 }
1876 #else // INCLUDE_ALL_GCS
1877 assert(verify_serial_gc_flags(), "SerialGC unset");
1878 #endif // INCLUDE_ALL_GCS
1879 }
1880
1881 julong Arguments::limit_by_allocatable_memory(julong limit) {
1882 julong max_allocatable;
1883 julong result = limit;
1884 if (os::has_allocatable_memory_limit(&max_allocatable)) {
1885 result = MIN2(result, max_allocatable / MaxVirtMemFraction);
1886 }
1887 return result;
1888 }
1889
1890 // Use static initialization to get the default before parsing
1891 static const size_t DefaultHeapBaseMinAddress = HeapBaseMinAddress;
1892
1893 void Arguments::set_heap_size() {
1894 const julong phys_mem =
1895 FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
1896 : (julong)MaxRAM;
1897
1898 // If the maximum heap size has not been set with -Xmx,
1899 // then set it as fraction of the size of physical memory,
1900 // respecting the maximum and minimum sizes of the heap.
1901 if (FLAG_IS_DEFAULT(MaxHeapSize)) {
1902 julong reasonable_max = phys_mem / MaxRAMFraction;
1903
1904 if (phys_mem <= MaxHeapSize * MinRAMFraction) {
1905 // Small physical memory, so use a minimum fraction of it for the heap
1906 reasonable_max = phys_mem / MinRAMFraction;
1907 } else {
1908 // Not-small physical memory, so require a heap at least
1909 // as large as MaxHeapSize
1910 reasonable_max = MAX2(reasonable_max, (julong)MaxHeapSize);
1911 }
1912 if (!FLAG_IS_DEFAULT(ErgoHeapSizeLimit) && ErgoHeapSizeLimit != 0) {
1913 // Limit the heap size to ErgoHeapSizeLimit
1976 reasonable_initial = limit_by_allocatable_memory(reasonable_initial);
1977
1978 if (PrintGCDetails && Verbose) {
1979 // Cannot use gclog_or_tty yet.
1980 tty->print_cr(" Initial heap size " SIZE_FORMAT, (size_t)reasonable_initial);
1981 }
1982 FLAG_SET_ERGO(size_t, InitialHeapSize, (size_t)reasonable_initial);
1983 }
1984 // If the minimum heap size has not been set (via -Xms),
1985 // synchronize with InitialHeapSize to avoid errors with the default value.
1986 if (min_heap_size() == 0) {
1987 set_min_heap_size(MIN2((size_t)reasonable_minimum, InitialHeapSize));
1988 if (PrintGCDetails && Verbose) {
1989 // Cannot use gclog_or_tty yet.
1990 tty->print_cr(" Minimum heap size " SIZE_FORMAT, min_heap_size());
1991 }
1992 }
1993 }
1994 }
1995
1996 // This option inspects the machine and attempts to set various
1997 // parameters to be optimal for long-running, memory allocation
1998 // intensive jobs. It is intended for machines with large
1999 // amounts of cpu and memory.
2000 jint Arguments::set_aggressive_heap_flags() {
2001 // initHeapSize is needed since _initial_heap_size is 4 bytes on a 32 bit
2002 // VM, but we may not be able to represent the total physical memory
2003 // available (like having 8gb of memory on a box but using a 32bit VM).
2004 // Thus, we need to make sure we're using a julong for intermediate
2005 // calculations.
2006 julong initHeapSize;
2007 julong total_memory = os::physical_memory();
2008
2009 if (total_memory < (julong) 256 * M) {
2010 jio_fprintf(defaultStream::error_stream(),
2011 "You need at least 256mb of memory to use -XX:+AggressiveHeap\n");
2012 vm_exit(1);
2013 }
2014
2015 // The heap size is half of available memory, or (at most)
2016 // all of possible memory less 160mb (leaving room for the OS
2017 // when using ISM). This is the maximum; because adaptive sizing
2018 // is turned on below, the actual space used may be smaller.
2019
2020 initHeapSize = MIN2(total_memory / (julong) 2,
2021 total_memory - (julong) 160 * M);
2022
2023 initHeapSize = limit_by_allocatable_memory(initHeapSize);
2024
2025 if (FLAG_IS_DEFAULT(MaxHeapSize)) {
2026 if (FLAG_SET_CMDLINE(size_t, MaxHeapSize, initHeapSize) != Flag::SUCCESS) {
2027 return JNI_EINVAL;
2028 }
2029 if (FLAG_SET_CMDLINE(size_t, InitialHeapSize, initHeapSize) != Flag::SUCCESS) {
2030 return JNI_EINVAL;
2031 }
2032 // Currently the minimum size and the initial heap sizes are the same.
2033 set_min_heap_size(initHeapSize);
2034 }
2035 if (FLAG_IS_DEFAULT(NewSize)) {
2036 // Make the young generation 3/8ths of the total heap.
2037 if (FLAG_SET_CMDLINE(size_t, NewSize,
2038 ((julong) MaxHeapSize / (julong) 8) * (julong) 3) != Flag::SUCCESS) {
2039 return JNI_EINVAL;
2040 }
2041 if (FLAG_SET_CMDLINE(size_t, MaxNewSize, NewSize) != Flag::SUCCESS) {
2042 return JNI_EINVAL;
2043 }
2044 }
2045
2046 #if !defined(_ALLBSD_SOURCE) && !defined(AIX) // UseLargePages is not yet supported on BSD and AIX.
2047 FLAG_SET_DEFAULT(UseLargePages, true);
2048 #endif
2049
2050 // Increase some data structure sizes for efficiency
2051 if (FLAG_SET_CMDLINE(size_t, BaseFootPrintEstimate, MaxHeapSize) != Flag::SUCCESS) {
2052 return JNI_EINVAL;
2053 }
2054 if (FLAG_SET_CMDLINE(bool, ResizeTLAB, false) != Flag::SUCCESS) {
2055 return JNI_EINVAL;
2056 }
2057 if (FLAG_SET_CMDLINE(size_t, TLABSize, 256 * K) != Flag::SUCCESS) {
2058 return JNI_EINVAL;
2059 }
2060
2061 // See the OldPLABSize comment below, but replace 'after promotion'
2062 // with 'after copying'. YoungPLABSize is the size of the survivor
2063 // space per-gc-thread buffers. The default is 4kw.
2064 if (FLAG_SET_CMDLINE(size_t, YoungPLABSize, 256 * K) != Flag::SUCCESS) { // Note: this is in words
2065 return JNI_EINVAL;
2066 }
2067
2068 // OldPLABSize is the size of the buffers in the old gen that
2069 // UseParallelGC uses to promote live data that doesn't fit in the
2070 // survivor spaces. At any given time, there's one for each gc thread.
2071 // The default size is 1kw. These buffers are rarely used, since the
2072 // survivor spaces are usually big enough. For specjbb, however, there
2073 // are occasions when there's lots of live data in the young gen
2074 // and we end up promoting some of it. We don't have a definite
2075 // explanation for why bumping OldPLABSize helps, but the theory
2076 // is that a bigger PLAB results in retaining something like the
2077 // original allocation order after promotion, which improves mutator
2078 // locality. A minor effect may be that larger PLABs reduce the
2079 // number of PLAB allocation events during gc. The value of 8kw
2080 // was arrived at by experimenting with specjbb.
2081 if (FLAG_SET_CMDLINE(size_t, OldPLABSize, 8 * K) != Flag::SUCCESS) { // Note: this is in words
2082 return JNI_EINVAL;
2083 }
2084
2085 // Enable parallel GC and adaptive generation sizing
2086 if (FLAG_SET_CMDLINE(bool, UseParallelGC, true) != Flag::SUCCESS) {
2087 return JNI_EINVAL;
2088 }
2089 FLAG_SET_DEFAULT(ParallelGCThreads,
2090 Abstract_VM_Version::parallel_worker_threads());
2091
2092 // Encourage steady state memory management
2093 if (FLAG_SET_CMDLINE(uintx, ThresholdTolerance, 100) != Flag::SUCCESS) {
2094 return JNI_EINVAL;
2095 }
2096
2097 // This appears to improve mutator locality
2098 if (FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false) != Flag::SUCCESS) {
2099 return JNI_EINVAL;
2100 }
2101
2102 // Get around early Solaris scheduling bug
2103 // (affinity vs other jobs on system)
2104 // but disallow DR and offlining (5008695).
2105 if (FLAG_SET_CMDLINE(bool, BindGCTaskThreadsToCPUs, true) != Flag::SUCCESS) {
2106 return JNI_EINVAL;
2107 }
2108
2109 return JNI_OK;
2110 }
2111
2112 // Set up runtime image flags
2113 void Arguments::set_runtime_image_flags() {
2114 #ifdef _LP64
2115 // Memory map image file by default on 64 bit machines.
2116 if (FLAG_IS_DEFAULT(MemoryMapImage)) {
2117 FLAG_SET_ERGO(bool, MemoryMapImage, true);
2118 }
2119 #endif
2120 }
2121
2122 // This must be called after ergonomics.
2123 void Arguments::set_bytecode_flags() {
2124 if (!RewriteBytecodes) {
2125 FLAG_SET_DEFAULT(RewriteFrequentPairs, false);
2126 }
2127 }
2128
2129 // Aggressive optimization flags -XX:+AggressiveOpts
2130 void Arguments::set_aggressive_opts_flags() {
2131 #ifdef COMPILER2
2132 if (AggressiveUnboxing) {
2281 "please refer to the release notes for the combinations "
2282 "allowed\n");
2283 return false;
2284 }
2285
2286 if (UseConcMarkSweepGC && !UseParNewGC) {
2287 jio_fprintf(defaultStream::error_stream(),
2288 "It is not possible to combine the DefNew young collector with the CMS collector.\n");
2289 return false;
2290 }
2291
2292 if (UseParNewGC && !UseConcMarkSweepGC) {
2293 jio_fprintf(defaultStream::error_stream(),
2294 "It is not possible to combine the ParNew young collector with any collector other than CMS.\n");
2295 return false;
2296 }
2297
2298 return true;
2299 }
2300
2301 // Check the consistency of vm_init_args
2302 bool Arguments::check_vm_args_consistency() {
2303 // Method for adding checks for flag consistency.
2304 // The intent is to warn the user of all possible conflicts,
2305 // before returning an error.
2306 // Note: Needs platform-dependent factoring.
2307 bool status = true;
2308
2309 if (TLABRefillWasteFraction == 0) {
2310 jio_fprintf(defaultStream::error_stream(),
2311 "TLABRefillWasteFraction should be a denominator, "
2312 "not " SIZE_FORMAT "\n",
2313 TLABRefillWasteFraction);
2314 status = false;
2315 }
2316
2317 if (FullGCALot && FLAG_IS_DEFAULT(MarkSweepAlwaysCompactCount)) {
2318 MarkSweepAlwaysCompactCount = 1; // Move objects every gc.
2319 }
2320
2820 ArgsRange errcode = parse_memory_size(tail, &long_ThreadStackSize, 1000);
2821 if (errcode != arg_in_range) {
2822 jio_fprintf(defaultStream::error_stream(),
2823 "Invalid thread stack size: %s\n", option->optionString);
2824 describe_range_error(errcode);
2825 return JNI_EINVAL;
2826 }
2827 // Internally track ThreadStackSize in units of 1024 bytes.
2828 if (FLAG_SET_CMDLINE(intx, ThreadStackSize,
2829 round_to((int)long_ThreadStackSize, K) / K) != Flag::SUCCESS) {
2830 return JNI_EINVAL;
2831 }
2832 // -Xoss, -Xsqnopause, -Xoptimize, -Xboundthreads
2833 } else if (match_option(option, "-Xoss", &tail) ||
2834 match_option(option, "-Xsqnopause") ||
2835 match_option(option, "-Xoptimize") ||
2836 match_option(option, "-Xboundthreads")) {
2837 // All these options are deprecated in JDK 9 and will be removed in a future release
2838 char version[256];
2839 JDK_Version::jdk(9).to_string(version, sizeof(version));
2840 warning("Ignoring option %s; support was removed in %s", option->optionString, version);
2841 } else if (match_option(option, "-XX:CodeCacheExpansionSize=", &tail)) {
2842 julong long_CodeCacheExpansionSize = 0;
2843 ArgsRange errcode = parse_memory_size(tail, &long_CodeCacheExpansionSize, os::vm_page_size());
2844 if (errcode != arg_in_range) {
2845 jio_fprintf(defaultStream::error_stream(),
2846 "Invalid argument: %s. Must be at least %luK.\n", option->optionString,
2847 os::vm_page_size()/K);
2848 return JNI_EINVAL;
2849 }
2850 if (FLAG_SET_CMDLINE(uintx, CodeCacheExpansionSize, (uintx)long_CodeCacheExpansionSize) != Flag::SUCCESS) {
2851 return JNI_EINVAL;
2852 }
2853 } else if (match_option(option, "-Xmaxjitcodesize", &tail) ||
2854 match_option(option, "-XX:ReservedCodeCacheSize=", &tail)) {
2855 julong long_ReservedCodeCacheSize = 0;
2856
2857 ArgsRange errcode = parse_memory_size(tail, &long_ReservedCodeCacheSize, 1);
2858 if (errcode != arg_in_range) {
2859 jio_fprintf(defaultStream::error_stream(),
2860 "Invalid maximum code cache size: %s.\n", option->optionString);
3087 // JNI hooks
3088 } else if (match_option(option, "-Xcheck", &tail)) {
3089 if (!strcmp(tail, ":jni")) {
3090 #if !INCLUDE_JNI_CHECK
3091 warning("JNI CHECKING is not supported in this VM");
3092 #else
3093 CheckJNICalls = true;
3094 #endif // INCLUDE_JNI_CHECK
3095 } else if (is_bad_option(option, args->ignoreUnrecognized,
3096 "check")) {
3097 return JNI_EINVAL;
3098 }
3099 } else if (match_option(option, "vfprintf")) {
3100 _vfprintf_hook = CAST_TO_FN_PTR(vfprintf_hook_t, option->extraInfo);
3101 } else if (match_option(option, "exit")) {
3102 _exit_hook = CAST_TO_FN_PTR(exit_hook_t, option->extraInfo);
3103 } else if (match_option(option, "abort")) {
3104 _abort_hook = CAST_TO_FN_PTR(abort_hook_t, option->extraInfo);
3105 // -XX:+AggressiveHeap
3106 } else if (match_option(option, "-XX:+AggressiveHeap")) {
3107 jint result = set_aggressive_heap_flags();
3108 if (result != JNI_OK) {
3109 return result;
3110 }
3111 // Need to keep consistency of MaxTenuringThreshold and AlwaysTenure/NeverTenure;
3112 // and the last option wins.
3113 } else if (match_option(option, "-XX:+NeverTenure")) {
3114 if (FLAG_SET_CMDLINE(bool, NeverTenure, true) != Flag::SUCCESS) {
3115 return JNI_EINVAL;
3116 }
3117 if (FLAG_SET_CMDLINE(bool, AlwaysTenure, false) != Flag::SUCCESS) {
3118 return JNI_EINVAL;
3119 }
3120 if (FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, markOopDesc::max_age + 1) != Flag::SUCCESS) {
3121 return JNI_EINVAL;
3122 }
3123 } else if (match_option(option, "-XX:+AlwaysTenure")) {
3124 if (FLAG_SET_CMDLINE(bool, NeverTenure, false) != Flag::SUCCESS) {
3125 return JNI_EINVAL;
3126 }
3127 if (FLAG_SET_CMDLINE(bool, AlwaysTenure, true) != Flag::SUCCESS) {
3128 return JNI_EINVAL;
3129 }
3130 if (FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, 0) != Flag::SUCCESS) {
3183 return JNI_EINVAL;
3184 }
3185 if (FLAG_SET_CMDLINE(bool, DTraceMonitorProbes, true) != Flag::SUCCESS) {
3186 return JNI_EINVAL;
3187 }
3188 #else // defined(DTRACE_ENABLED)
3189 jio_fprintf(defaultStream::error_stream(),
3190 "ExtendedDTraceProbes flag is not applicable for this configuration\n");
3191 return JNI_EINVAL;
3192 #endif // defined(DTRACE_ENABLED)
3193 #ifdef ASSERT
3194 } else if (match_option(option, "-XX:+FullGCALot")) {
3195 if (FLAG_SET_CMDLINE(bool, FullGCALot, true) != Flag::SUCCESS) {
3196 return JNI_EINVAL;
3197 }
3198 // disable scavenge before parallel mark-compact
3199 if (FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false) != Flag::SUCCESS) {
3200 return JNI_EINVAL;
3201 }
3202 #endif
3203 } else if (match_option(option, "-XX:MaxDirectMemorySize=", &tail)) {
3204 julong max_direct_memory_size = 0;
3205 ArgsRange errcode = parse_memory_size(tail, &max_direct_memory_size, 0);
3206 if (errcode != arg_in_range) {
3207 jio_fprintf(defaultStream::error_stream(),
3208 "Invalid maximum direct memory size: %s\n",
3209 option->optionString);
3210 describe_range_error(errcode);
3211 return JNI_EINVAL;
3212 }
3213 if (FLAG_SET_CMDLINE(size_t, MaxDirectMemorySize, max_direct_memory_size) != Flag::SUCCESS) {
3214 return JNI_EINVAL;
3215 }
3216 #if !INCLUDE_MANAGEMENT
3217 } else if (match_option(option, "-XX:+ManagementServer")) {
3218 jio_fprintf(defaultStream::error_stream(),
3219 "ManagementServer is not supported in this VM.\n");
3220 return JNI_ERR;
3221 #endif // INCLUDE_MANAGEMENT
3222 } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx
3223 // Skip -XX:Flags= since that case has already been handled
3224 if (strncmp(tail, "Flags=", strlen("Flags=")) != 0) {
3225 if (!process_argument(tail, args->ignoreUnrecognized, origin)) {
3226 return JNI_EINVAL;
3227 }
3228 }
3229 // Unknown option
3230 } else if (is_bad_option(option, args->ignoreUnrecognized)) {
3231 return JNI_ERR;
3232 }
3233 }
3234
3235 // PrintSharedArchiveAndExit will turn on
3236 // -Xshare:on
3237 // -XX:+TraceClassPaths
3238 if (PrintSharedArchiveAndExit) {
3239 if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != Flag::SUCCESS) {
3240 return JNI_EINVAL;
3241 }
3578 }
3579 if (*rd != 0) {
3580 // In this case, the assignment to wrt below will make *rd nul,
3581 // which will interfere with the next loop iteration.
3582 rd++;
3583 }
3584 *wrt = 0; // Zero terminate option
3585 }
3586
3587 // Fill out JavaVMInitArgs structure.
3588 jint status = vm_args->set_args(options);
3589
3590 delete options;
3591 os::free(buffer);
3592 return status;
3593 }
3594
3595 void Arguments::set_shared_spaces_flags() {
3596 if (DumpSharedSpaces) {
3597 if (RequireSharedSpaces) {
3598 warning("Cannot dump shared archive while using shared archive");
3599 }
3600 UseSharedSpaces = false;
3601 #ifdef _LP64
3602 if (!UseCompressedOops || !UseCompressedClassPointers) {
3603 vm_exit_during_initialization(
3604 "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL);
3605 }
3606 } else {
3607 if (!UseCompressedOops || !UseCompressedClassPointers) {
3608 no_shared_spaces("UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces.");
3609 }
3610 #endif
3611 }
3612 }
3613
3614 #if !INCLUDE_ALL_GCS
3615 static void force_serial_gc() {
3616 FLAG_SET_DEFAULT(UseSerialGC, true);
3617 UNSUPPORTED_GC_OPTION(UseG1GC);
3618 UNSUPPORTED_GC_OPTION(UseParallelGC);
3857 #if defined(_ALLBSD_SOURCE) || defined(AIX) // UseLargePages is not yet supported on BSD and AIX.
3858 UNSUPPORTED_OPTION(UseLargePages, "-XX:+UseLargePages");
3859 #endif
3860
3861 ArgumentsExt::report_unsupported_options();
3862
3863 #ifndef PRODUCT
3864 if (TraceBytecodesAt != 0) {
3865 TraceBytecodes = true;
3866 }
3867 if (CountCompiledCalls) {
3868 if (UseCounterDecay) {
3869 warning("UseCounterDecay disabled because CountCalls is set");
3870 UseCounterDecay = false;
3871 }
3872 }
3873 #endif // PRODUCT
3874
3875 if (ScavengeRootsInCode == 0) {
3876 if (!FLAG_IS_DEFAULT(ScavengeRootsInCode)) {
3877 warning("Forcing ScavengeRootsInCode non-zero");
3878 }
3879 ScavengeRootsInCode = 1;
3880 }
3881
3882 if (PrintGCDetails) {
3883 // Turn on -verbose:gc options as well
3884 PrintGC = true;
3885 }
3886
3887 // Set object alignment values.
3888 set_object_alignment();
3889
3890 #if !INCLUDE_ALL_GCS
3891 force_serial_gc();
3892 #endif // INCLUDE_ALL_GCS
3893 #if !INCLUDE_CDS
3894 if (DumpSharedSpaces || RequireSharedSpaces) {
3895 jio_fprintf(defaultStream::error_stream(),
3896 "Shared spaces are not supported in this VM\n");
3897 return JNI_ERR;
|