21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "classfile/classLoader.hpp" 27 #include "classfile/javaAssertions.hpp" 28 #include "classfile/stringTable.hpp" 29 #include "classfile/symbolTable.hpp" 30 #include "compiler/compilerOracle.hpp" 31 #include "gc/shared/cardTableRS.hpp" 32 #include "gc/shared/genCollectedHeap.hpp" 33 #include "gc/shared/referenceProcessor.hpp" 34 #include "gc/shared/taskqueue.hpp" 35 #include "memory/allocation.inline.hpp" 36 #include "memory/universe.inline.hpp" 37 #include "oops/oop.inline.hpp" 38 #include "prims/jvmtiExport.hpp" 39 #include "runtime/arguments.hpp" 40 #include "runtime/arguments_ext.hpp" 41 #include "runtime/globals_extension.hpp" 42 #include "runtime/java.hpp" 43 #include "runtime/os.hpp" 44 #include "runtime/vm_version.hpp" 45 #include "services/management.hpp" 46 #include "services/memTracker.hpp" 47 #include "utilities/defaultStream.hpp" 48 #include "utilities/macros.hpp" 49 #include "utilities/stringUtils.hpp" 50 #if INCLUDE_ALL_GCS 51 #include "gc/cms/compactibleFreeListSpace.hpp" 52 #include "gc/g1/g1CollectedHeap.inline.hpp" 53 #include "gc/parallel/parallelScavengeHeap.hpp" 54 #endif // INCLUDE_ALL_GCS 55 56 // Note: This is a special bug reporting site for the JVM 57 #define DEFAULT_VENDOR_URL_BUG "http://bugreport.java.com/bugreport/crash.jsp" 58 #define DEFAULT_JAVA_LAUNCHER "generic" 59 60 #define UNSUPPORTED_GC_OPTION(gc) \ 170 171 if (match_option(option, "-Dsun.java.launcher=", &tail)) { 172 process_java_launcher_argument(tail, option->extraInfo); 173 continue; 174 } 175 if (match_option(option, "-Dsun.java.launcher.is_altjvm=", &tail)) { 176 if (strcmp(tail, "true") == 0) { 177 _sun_java_launcher_is_altjvm = true; 178 } 179 continue; 180 } 181 if (match_option(option, "-Dsun.java.launcher.pid=", &tail)) { 182 _sun_java_launcher_pid = atoi(tail); 183 continue; 184 } 185 } 186 } 187 188 // Initialize system properties key and value. 189 void Arguments::init_system_properties() { 190 191 PropertyList_add(&_system_properties, new SystemProperty("java.vm.specification.name", 192 "Java Virtual Machine Specification", false)); 193 PropertyList_add(&_system_properties, new SystemProperty("java.vm.version", VM_Version::vm_release(), false)); 194 PropertyList_add(&_system_properties, new SystemProperty("java.vm.name", VM_Version::vm_name(), false)); 195 PropertyList_add(&_system_properties, new SystemProperty("java.vm.info", VM_Version::vm_info_string(), true)); 196 197 // Following are JVMTI agent writable properties. 198 // Properties values are set to NULL and they are 199 // os specific they are initialized in os::init_system_properties_values(). 200 _sun_boot_library_path = new SystemProperty("sun.boot.library.path", NULL, true); 201 _java_library_path = new SystemProperty("java.library.path", NULL, true); 202 _java_home = new SystemProperty("java.home", NULL, true); 203 _sun_boot_class_path = new SystemProperty("sun.boot.class.path", NULL, true); 204 205 _java_class_path = new SystemProperty("java.class.path", "", true); 206 207 // Add to System Property list. 208 PropertyList_add(&_system_properties, _sun_boot_library_path); 209 PropertyList_add(&_system_properties, _java_library_path); 210 PropertyList_add(&_system_properties, _java_home); 211 PropertyList_add(&_system_properties, _java_class_path); 212 PropertyList_add(&_system_properties, _sun_boot_class_path); 213 214 // Set OS specific system properties values 215 os::init_system_properties_values(); 216 } 217 218 219 // Update/Initialize System properties after JDK version number is known 220 void Arguments::init_version_specific_system_properties() { 221 enum { bufsz = 16 }; 222 char buffer[bufsz]; 223 const char* spec_vendor = "Sun Microsystems Inc."; 224 uint32_t spec_version = 0; 225 226 spec_vendor = "Oracle Corporation"; 227 spec_version = JDK_Version::current().major_version(); 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 * Provide a slightly more user-friendly way of eliminating -XX flags. 552 553 // Describe an argument out of range error 554 void Arguments::describe_range_error(ArgsRange errcode) { 555 switch(errcode) { 556 case arg_too_big: 557 jio_fprintf(defaultStream::error_stream(), 558 "The specified size exceeds the maximum " 559 "representable size.\n"); 560 break; 561 case arg_too_small: 562 case arg_unreadable: 563 case arg_in_range: 564 // do nothing for now 565 break; 566 default: 567 ShouldNotReachHere(); 568 } 569 } 570 571 static bool set_bool_flag(char* name, bool value, Flag::Flags origin) { 572 return CommandLineFlags::boolAtPut(name, &value, origin); 573 } 574 575 static bool set_fp_numeric_flag(char* name, char* value, Flag::Flags origin) { 576 double v; 577 if (sscanf(value, "%lf", &v) != 1) { 578 return false; 579 } 580 581 if (CommandLineFlags::doubleAtPut(name, &v, origin)) { 582 return true; 583 } 584 return false; 585 } 586 587 static bool set_numeric_flag(char* name, char* value, Flag::Flags origin) { 588 julong v; 589 int int_v; 590 intx intx_v; 591 bool is_neg = false; 592 // Check the sign first since atomull() parses only unsigned values. 593 if (*value == '-') { 594 if (!CommandLineFlags::intxAt(name, &intx_v) && !CommandLineFlags::intAt(name, &int_v)) { 595 return false; 596 } 597 value++; 598 is_neg = true; 599 } 600 if (!atomull(value, &v)) { 601 return false; 602 } 603 int_v = (int) v; 604 if (is_neg) { 605 int_v = -int_v; 606 } 607 if (CommandLineFlags::intAtPut(name, &int_v, origin)) { 608 return true; 609 } 610 uint uint_v = (uint) v; 611 if (!is_neg && CommandLineFlags::uintAtPut(name, &uint_v, origin)) { 612 return true; 613 } 614 intx_v = (intx) v; 615 if (is_neg) { 616 intx_v = -intx_v; 617 } 618 if (CommandLineFlags::intxAtPut(name, &intx_v, origin)) { 619 return true; 620 } 621 uintx uintx_v = (uintx) v; 622 if (!is_neg && CommandLineFlags::uintxAtPut(name, &uintx_v, origin)) { 623 return true; 624 } 625 uint64_t uint64_t_v = (uint64_t) v; 626 if (!is_neg && CommandLineFlags::uint64_tAtPut(name, &uint64_t_v, origin)) { 627 return true; 628 } 629 size_t size_t_v = (size_t) v; 630 if (!is_neg && CommandLineFlags::size_tAtPut(name, &size_t_v, origin)) { 631 return true; 632 } 633 return false; 634 } 635 636 static bool set_string_flag(char* name, const char* value, Flag::Flags origin) { 637 if (!CommandLineFlags::ccstrAtPut(name, &value, origin)) return false; 638 // Contract: CommandLineFlags always returns a pointer that needs freeing. 639 FREE_C_HEAP_ARRAY(char, value); 640 return true; 641 } 642 643 static bool append_to_string_flag(char* name, const char* new_value, Flag::Flags origin) { 644 const char* old_value = ""; 645 if (!CommandLineFlags::ccstrAt(name, &old_value)) return false; 646 size_t old_len = old_value != NULL ? strlen(old_value) : 0; 647 size_t new_len = strlen(new_value); 648 const char* value; 649 char* free_this_too = NULL; 650 if (old_len == 0) { 651 value = new_value; 652 } else if (new_len == 0) { 653 value = old_value; 654 } else { 655 char* buf = NEW_C_HEAP_ARRAY(char, old_len + 1 + new_len + 1, mtInternal); 656 // each new setting adds another LINE to the switch: 657 sprintf(buf, "%s\n%s", old_value, new_value); 658 value = buf; 659 free_this_too = buf; 660 } 661 (void) CommandLineFlags::ccstrAtPut(name, &value, origin); 662 // CommandLineFlags always returns a pointer that needs freeing. 663 FREE_C_HEAP_ARRAY(char, value); 664 if (free_this_too != NULL) { 665 // CommandLineFlags made its own copy, so I must delete my own temp. buffer. 1390 tty->print_cr("ConcGCThreads: %u", ConcGCThreads); 1391 } 1392 } 1393 #endif // INCLUDE_ALL_GCS 1394 1395 void set_object_alignment() { 1396 // Object alignment. 1397 assert(is_power_of_2(ObjectAlignmentInBytes), "ObjectAlignmentInBytes must be power of 2"); 1398 MinObjAlignmentInBytes = ObjectAlignmentInBytes; 1399 assert(MinObjAlignmentInBytes >= HeapWordsPerLong * HeapWordSize, "ObjectAlignmentInBytes value is too small"); 1400 MinObjAlignment = MinObjAlignmentInBytes / HeapWordSize; 1401 assert(MinObjAlignmentInBytes == MinObjAlignment * HeapWordSize, "ObjectAlignmentInBytes value is incorrect"); 1402 MinObjAlignmentInBytesMask = MinObjAlignmentInBytes - 1; 1403 1404 LogMinObjAlignmentInBytes = exact_log2(ObjectAlignmentInBytes); 1405 LogMinObjAlignment = LogMinObjAlignmentInBytes - LogHeapWordSize; 1406 1407 // Oop encoding heap max 1408 OopEncodingHeapMax = (uint64_t(max_juint) + 1) << LogMinObjAlignmentInBytes; 1409 1410 #if INCLUDE_ALL_GCS 1411 // Set CMS global values 1412 CompactibleFreeListSpace::set_cms_values(); 1413 #endif // INCLUDE_ALL_GCS 1414 } 1415 1416 bool verify_object_alignment() { 1417 // Object alignment. 1418 if (!is_power_of_2(ObjectAlignmentInBytes)) { 1419 jio_fprintf(defaultStream::error_stream(), 1420 "error: ObjectAlignmentInBytes=%d must be power of 2\n", 1421 (int)ObjectAlignmentInBytes); 1422 return false; 1423 } 1424 if ((int)ObjectAlignmentInBytes < BytesPerLong) { 1425 jio_fprintf(defaultStream::error_stream(), 1426 "error: ObjectAlignmentInBytes=%d must be greater or equal %d\n", 1427 (int)ObjectAlignmentInBytes, BytesPerLong); 1428 return false; 1429 } 1430 // It does not make sense to have big object alignment 1431 // since a space lost due to alignment will be greater 1432 // then a saved space from compressed oops. 1433 if ((int)ObjectAlignmentInBytes > 256) { 1434 jio_fprintf(defaultStream::error_stream(), 1435 "error: ObjectAlignmentInBytes=%d must not be greater than 256\n", 1436 (int)ObjectAlignmentInBytes); 1437 return false; 1438 } 1439 // In case page size is very small. 1440 if ((int)ObjectAlignmentInBytes >= os::vm_page_size()) { 1441 jio_fprintf(defaultStream::error_stream(), 1442 "error: ObjectAlignmentInBytes=%d must be less than page size %d\n", 1443 (int)ObjectAlignmentInBytes, os::vm_page_size()); 1444 return false; 1445 } 1446 if(SurvivorAlignmentInBytes == 0) { 1447 SurvivorAlignmentInBytes = ObjectAlignmentInBytes; 1448 } else { 1449 if (!is_power_of_2(SurvivorAlignmentInBytes)) { 1450 jio_fprintf(defaultStream::error_stream(), 1451 "error: SurvivorAlignmentInBytes=%d must be power of 2\n", 1452 (int)SurvivorAlignmentInBytes); 1453 return false; 1454 } 1455 if (SurvivorAlignmentInBytes < ObjectAlignmentInBytes) { 1456 jio_fprintf(defaultStream::error_stream(), 1457 "error: SurvivorAlignmentInBytes=%d must be greater than ObjectAlignmentInBytes=%d \n", 1458 (int)SurvivorAlignmentInBytes, (int)ObjectAlignmentInBytes); 1459 return false; 1460 } 1461 } 1462 return true; 1463 } 1464 1465 size_t Arguments::max_heap_for_compressed_oops() { 1466 // Avoid sign flip. 1467 assert(OopEncodingHeapMax > (uint64_t)os::vm_page_size(), "Unusual page size"); 1468 // We need to fit both the NULL page and the heap into the memory budget, while 1469 // keeping alignment constraints of the heap. To guarantee the latter, as the 1470 // NULL page is located before the heap, we pad the NULL page to the conservative 1471 // maximum alignment that the GC may ever impose upon the heap. 1472 size_t displacement_due_to_null_page = align_size_up_(os::vm_page_size(), 1473 _conservative_max_heap_alignment); 1474 1475 LP64_ONLY(return OopEncodingHeapMax - displacement_due_to_null_page); 1476 NOT_LP64(ShouldNotReachHere(); return 0); 1477 } 1478 1479 bool Arguments::should_auto_select_low_pause_collector() { 1480 if (UseAutoGCSelectPolicy && 1481 !FLAG_IS_DEFAULT(MaxGCPauseMillis) && 1482 (MaxGCPauseMillis <= AutoGCSelectPauseMillis)) { 1483 if (PrintGCDetails) { 1484 // Cannot use gclog_or_tty yet. 1927 set_java_compiler(true); // "-Djava.compiler[=...]" most recently seen. 1928 } 1929 } 1930 1931 void Arguments::process_java_launcher_argument(const char* launcher, void* extra_info) { 1932 _sun_java_launcher = os::strdup_check_oom(launcher); 1933 } 1934 1935 bool Arguments::created_by_java_launcher() { 1936 assert(_sun_java_launcher != NULL, "property must have value"); 1937 return strcmp(DEFAULT_JAVA_LAUNCHER, _sun_java_launcher) != 0; 1938 } 1939 1940 bool Arguments::sun_java_launcher_is_altjvm() { 1941 return _sun_java_launcher_is_altjvm; 1942 } 1943 1944 //=========================================================================================================== 1945 // Parsing of main arguments 1946 1947 bool Arguments::verify_interval(uintx val, uintx min, 1948 uintx max, const char* name) { 1949 // Returns true iff value is in the inclusive interval [min..max] 1950 // false, otherwise. 1951 if (val >= min && val <= max) { 1952 return true; 1953 } 1954 jio_fprintf(defaultStream::error_stream(), 1955 "%s of " UINTX_FORMAT " is invalid; must be between " UINTX_FORMAT 1956 " and " UINTX_FORMAT "\n", 1957 name, val, min, max); 1958 return false; 1959 } 1960 1961 bool Arguments::verify_min_value(intx val, intx min, const char* name) { 1962 // Returns true if given value is at least specified min threshold 1963 // false, otherwise. 1964 if (val >= min ) { 1965 return true; 1966 } 1967 jio_fprintf(defaultStream::error_stream(), 1968 "%s of " INTX_FORMAT " is invalid; must be at least " INTX_FORMAT "\n", 1969 name, val, min); 1970 return false; 1971 } 1972 1973 bool Arguments::verify_percentage(uintx value, const char* name) { 1974 if (is_percentage(value)) { 1975 return true; 1976 } 1977 jio_fprintf(defaultStream::error_stream(), 1978 "%s of " UINTX_FORMAT " is invalid; must be between 0 and 100\n", 1979 name, value); 1980 return false; 1981 } 1982 1983 // check if do gclog rotation 1984 // +UseGCLogFileRotation is a must, 1985 // no gc log rotation when log file not supplied or 1986 // NumberOfGCLogFiles is 0 1987 void check_gclog_consistency() { 1988 if (UseGCLogFileRotation) { 1989 if ((Arguments::gc_log_filename() == NULL) || (NumberOfGCLogFiles == 0)) { 1990 jio_fprintf(defaultStream::output_stream(), 1991 "To enable GC log rotation, use -Xloggc:<filename> -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=<num_of_files>\n" 1992 "where num_of_file > 0\n" 1993 "GC log rotation is turned off\n"); 1994 UseGCLogFileRotation = false; 1995 } 1996 } 1997 1998 if (UseGCLogFileRotation && (GCLogFileSize != 0) && (GCLogFileSize < 8*K)) { 1999 FLAG_SET_CMDLINE(size_t, GCLogFileSize, 8*K); 2000 jio_fprintf(defaultStream::output_stream(), 2001 "GCLogFileSize changed to minimum 8K\n"); 2002 } 2003 } 2004 2005 // This function is called for -Xloggc:<filename>, it can be used 2006 // to check if a given file name(or string) conforms to the following 2007 // specification: 2008 // A valid string only contains "[A-Z][a-z][0-9].-_%[p|t]" 2009 // %p and %t only allowed once. We only limit usage of filename not path 2010 bool is_filename_valid(const char *file_name) { 2011 const char* p = file_name; 2012 char file_sep = os::file_separator()[0]; 2013 const char* cp; 2014 // skip prefix path 2015 for (cp = file_name; *cp != '\0'; cp++) { 2016 if (*cp == '/' || *cp == file_sep) { 2017 p = cp + 1; 2018 } 2019 } 2020 2021 int count_p = 0; 2022 int count_t = 0; 2030 p++; 2031 continue; 2032 } 2033 if (*p == '%') { 2034 if(*(p + 1) == 'p') { 2035 p += 2; 2036 count_p ++; 2037 continue; 2038 } 2039 if (*(p + 1) == 't') { 2040 p += 2; 2041 count_t ++; 2042 continue; 2043 } 2044 } 2045 return false; 2046 } 2047 return count_p < 2 && count_t < 2; 2048 } 2049 2050 bool Arguments::verify_MinHeapFreeRatio(FormatBuffer<80>& err_msg, uintx min_heap_free_ratio) { 2051 if (!is_percentage(min_heap_free_ratio)) { 2052 err_msg.print("MinHeapFreeRatio must have a value between 0 and 100"); 2053 return false; 2054 } 2055 if (min_heap_free_ratio > MaxHeapFreeRatio) { 2056 err_msg.print("MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or " 2057 "equal to MaxHeapFreeRatio (" UINTX_FORMAT ")", min_heap_free_ratio, 2058 MaxHeapFreeRatio); 2059 return false; 2060 } 2061 // This does not set the flag itself, but stores the value in a safe place for later usage. 2062 _min_heap_free_ratio = min_heap_free_ratio; 2063 return true; 2064 } 2065 2066 bool Arguments::verify_MaxHeapFreeRatio(FormatBuffer<80>& err_msg, uintx max_heap_free_ratio) { 2067 if (!is_percentage(max_heap_free_ratio)) { 2068 err_msg.print("MaxHeapFreeRatio must have a value between 0 and 100"); 2069 return false; 2070 } 2071 if (max_heap_free_ratio < MinHeapFreeRatio) { 2072 err_msg.print("MaxHeapFreeRatio (" UINTX_FORMAT ") must be greater than or " 2073 "equal to MinHeapFreeRatio (" UINTX_FORMAT ")", max_heap_free_ratio, 2074 MinHeapFreeRatio); 2075 return false; 2076 } 2077 // This does not set the flag itself, but stores the value in a safe place for later usage. 2078 _max_heap_free_ratio = max_heap_free_ratio; 2079 return true; 2080 } 2081 2082 // Check consistency of GC selection 2083 bool Arguments::check_gc_consistency() { 2084 check_gclog_consistency(); 2085 // Ensure that the user has not selected conflicting sets 2086 // of collectors. 2087 uint i = 0; 2088 if (UseSerialGC) i++; 2089 if (UseConcMarkSweepGC) i++; 2090 if (UseParallelGC || UseParallelOldGC) i++; 2091 if (UseG1GC) i++; 2092 if (i > 1) { 2093 jio_fprintf(defaultStream::error_stream(), 2094 "Conflicting collector combinations in option list; " 2095 "please refer to the release notes for the combinations " 2096 "allowed\n"); 2097 return false; 2098 } 2099 2100 if (UseConcMarkSweepGC && !UseParNewGC) { 2101 jio_fprintf(defaultStream::error_stream(), 2109 return false; 2110 } 2111 2112 return true; 2113 } 2114 2115 void Arguments::check_deprecated_gc_flags() { 2116 if (FLAG_IS_CMDLINE(UseParNewGC)) { 2117 warning("The UseParNewGC flag is deprecated and will likely be removed in a future release"); 2118 } 2119 if (FLAG_IS_CMDLINE(MaxGCMinorPauseMillis)) { 2120 warning("Using MaxGCMinorPauseMillis as minor pause goal is deprecated" 2121 "and will likely be removed in future release"); 2122 } 2123 if (FLAG_IS_CMDLINE(DefaultMaxRAMFraction)) { 2124 warning("DefaultMaxRAMFraction is deprecated and will likely be removed in a future release. " 2125 "Use MaxRAMFraction instead."); 2126 } 2127 } 2128 2129 // Check stack pages settings 2130 bool Arguments::check_stack_pages() 2131 { 2132 bool status = true; 2133 status = status && verify_min_value(StackYellowPages, 1, "StackYellowPages"); 2134 status = status && verify_min_value(StackRedPages, 1, "StackRedPages"); 2135 // greater stack shadow pages can't generate instruction to bang stack 2136 status = status && verify_interval(StackShadowPages, 1, 50, "StackShadowPages"); 2137 return status; 2138 } 2139 2140 // Check the consistency of vm_init_args 2141 bool Arguments::check_vm_args_consistency() { 2142 // Method for adding checks for flag consistency. 2143 // The intent is to warn the user of all possible conflicts, 2144 // before returning an error. 2145 // Note: Needs platform-dependent factoring. 2146 bool status = true; 2147 2148 if (TLABRefillWasteFraction == 0) { 2149 jio_fprintf(defaultStream::error_stream(), 2150 "TLABRefillWasteFraction should be a denominator, " 2151 "not " SIZE_FORMAT "\n", 2152 TLABRefillWasteFraction); 2153 status = false; 2154 } 2155 2156 status = status && verify_interval(AdaptiveSizePolicyWeight, 0, 100, 2157 "AdaptiveSizePolicyWeight"); 2158 status = status && verify_percentage(ThresholdTolerance, "ThresholdTolerance"); 2159 2160 // Divide by bucket size to prevent a large size from causing rollover when 2161 // calculating amount of memory needed to be allocated for the String table. 2162 status = status && verify_interval(StringTableSize, minimumStringTableSize, 2163 (max_uintx / StringTable::bucket_size()), "StringTable size"); 2164 2165 status = status && verify_interval(SymbolTableSize, minimumSymbolTableSize, 2166 (max_uintx / SymbolTable::bucket_size()), "SymbolTable size"); 2167 2168 { 2169 // Using "else if" below to avoid printing two error messages if min > max. 2170 // This will also prevent us from reporting both min>100 and max>100 at the 2171 // same time, but that is less annoying than printing two identical errors IMHO. 2172 FormatBuffer<80> err_msg("%s",""); 2173 if (!verify_MinHeapFreeRatio(err_msg, MinHeapFreeRatio)) { 2174 jio_fprintf(defaultStream::error_stream(), "%s\n", err_msg.buffer()); 2175 status = false; 2176 } else if (!verify_MaxHeapFreeRatio(err_msg, MaxHeapFreeRatio)) { 2177 jio_fprintf(defaultStream::error_stream(), "%s\n", err_msg.buffer()); 2178 status = false; 2179 } 2180 } 2181 2182 // Min/MaxMetaspaceFreeRatio 2183 status = status && verify_percentage(MinMetaspaceFreeRatio, "MinMetaspaceFreeRatio"); 2184 status = status && verify_percentage(MaxMetaspaceFreeRatio, "MaxMetaspaceFreeRatio"); 2185 2186 if (MinMetaspaceFreeRatio > MaxMetaspaceFreeRatio) { 2187 jio_fprintf(defaultStream::error_stream(), 2188 "MinMetaspaceFreeRatio (%s" UINTX_FORMAT ") must be less than or " 2189 "equal to MaxMetaspaceFreeRatio (%s" UINTX_FORMAT ")\n", 2190 FLAG_IS_DEFAULT(MinMetaspaceFreeRatio) ? "Default: " : "", 2191 MinMetaspaceFreeRatio, 2192 FLAG_IS_DEFAULT(MaxMetaspaceFreeRatio) ? "Default: " : "", 2193 MaxMetaspaceFreeRatio); 2194 status = false; 2195 } 2196 2197 // Trying to keep 100% free is not practical 2198 MinMetaspaceFreeRatio = MIN2(MinMetaspaceFreeRatio, (uintx) 99); 2199 2200 if (FullGCALot && FLAG_IS_DEFAULT(MarkSweepAlwaysCompactCount)) { 2201 MarkSweepAlwaysCompactCount = 1; // Move objects every gc. 2202 } 2203 2204 if (UseParallelOldGC && ParallelOldGCSplitALot) { 2205 // Settings to encourage splitting. 2206 if (!FLAG_IS_CMDLINE(NewRatio)) { 2207 FLAG_SET_CMDLINE(uintx, NewRatio, 2); 2208 } 2209 if (!FLAG_IS_CMDLINE(ScavengeBeforeFullGC)) { 2210 FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false); 2211 } 2212 } 2213 2214 if (!(UseParallelGC || UseParallelOldGC) && FLAG_IS_DEFAULT(ScavengeBeforeFullGC)) { 2215 FLAG_SET_DEFAULT(ScavengeBeforeFullGC, false); 2216 } 2217 2218 status = status && verify_percentage(GCHeapFreeLimit, "GCHeapFreeLimit"); 2219 status = status && verify_percentage(GCTimeLimit, "GCTimeLimit"); 2220 if (GCTimeLimit == 100) { 2221 // Turn off gc-overhead-limit-exceeded checks 2222 FLAG_SET_DEFAULT(UseGCOverheadLimit, false); 2223 } 2224 2225 status = status && check_gc_consistency(); 2226 status = status && check_stack_pages(); 2227 2228 status = status && verify_percentage(CMSIncrementalSafetyFactor, 2229 "CMSIncrementalSafetyFactor"); 2230 2231 // CMS space iteration, which FLSVerifyAllHeapreferences entails, 2232 // insists that we hold the requisite locks so that the iteration is 2233 // MT-safe. For the verification at start-up and shut-down, we don't 2234 // yet have a good way of acquiring and releasing these locks, 2235 // which are not visible at the CollectedHeap level. We want to 2236 // be able to acquire these locks and then do the iteration rather 2237 // than just disable the lock verification. This will be fixed under 2238 // bug 4788986. 2239 if (UseConcMarkSweepGC && FLSVerifyAllHeapReferences) { 2240 if (VerifyDuringStartup) { 2241 warning("Heap verification at start-up disabled " 2242 "(due to current incompatibility with FLSVerifyAllHeapReferences)"); 2243 VerifyDuringStartup = false; // Disable verification at start-up 2244 } 2245 2246 if (VerifyBeforeExit) { 2247 warning("Heap verification at shutdown disabled " 2248 "(due to current incompatibility with FLSVerifyAllHeapReferences)"); 2249 VerifyBeforeExit = false; // Disable verification at shutdown 2250 } 2251 } 2252 2253 // Note: only executed in non-PRODUCT mode 2254 if (!UseAsyncConcMarkSweepGC && 2255 (ExplicitGCInvokesConcurrent || 2256 ExplicitGCInvokesConcurrentAndUnloadsClasses)) { 2257 jio_fprintf(defaultStream::error_stream(), 2258 "error: +ExplicitGCInvokesConcurrent[AndUnloadsClasses] conflicts" 2259 " with -UseAsyncConcMarkSweepGC"); 2260 status = false; 2261 } 2262 2263 status = status && verify_min_value(ParGCArrayScanChunk, 1, "ParGCArrayScanChunk"); 2264 2265 #if INCLUDE_ALL_GCS 2266 if (UseG1GC) { 2267 status = status && verify_percentage(G1NewSizePercent, "G1NewSizePercent"); 2268 status = status && verify_percentage(G1MaxNewSizePercent, "G1MaxNewSizePercent"); 2269 status = status && verify_interval(G1NewSizePercent, 0, G1MaxNewSizePercent, "G1NewSizePercent"); 2270 2271 status = status && verify_percentage(G1ConfidencePercent, "G1ConfidencePercent"); 2272 status = status && verify_percentage(InitiatingHeapOccupancyPercent, 2273 "InitiatingHeapOccupancyPercent"); 2274 status = status && verify_min_value(G1RefProcDrainInterval, 1, 2275 "G1RefProcDrainInterval"); 2276 status = status && verify_min_value((intx)G1ConcMarkStepDurationMillis, 1, 2277 "G1ConcMarkStepDurationMillis"); 2278 status = status && verify_interval(G1ConcRSHotCardLimit, 0, max_jubyte, 2279 "G1ConcRSHotCardLimit"); 2280 status = status && verify_interval(G1ConcRSLogCacheSize, 0, 27, 2281 "G1ConcRSLogCacheSize"); 2282 status = status && verify_interval(StringDeduplicationAgeThreshold, 1, markOopDesc::max_age, 2283 "StringDeduplicationAgeThreshold"); 2284 } 2285 if (UseConcMarkSweepGC) { 2286 status = status && verify_min_value(CMSOldPLABNumRefills, 1, "CMSOldPLABNumRefills"); 2287 status = status && verify_min_value(CMSOldPLABToleranceFactor, 1, "CMSOldPLABToleranceFactor"); 2288 status = status && verify_min_value(CMSOldPLABMax, 1, "CMSOldPLABMax"); 2289 status = status && verify_interval(CMSOldPLABMin, 1, CMSOldPLABMax, "CMSOldPLABMin"); 2290 2291 status = status && verify_min_value(CMSYoungGenPerWorker, 1, "CMSYoungGenPerWorker"); 2292 2293 status = status && verify_min_value(CMSSamplingGrain, 1, "CMSSamplingGrain"); 2294 status = status && verify_interval(CMS_SweepWeight, 0, 100, "CMS_SweepWeight"); 2295 status = status && verify_interval(CMS_FLSWeight, 0, 100, "CMS_FLSWeight"); 2296 2297 status = status && verify_interval(FLSCoalescePolicy, 0, 4, "FLSCoalescePolicy"); 2298 2299 status = status && verify_min_value(CMSRescanMultiple, 1, "CMSRescanMultiple"); 2300 status = status && verify_min_value(CMSConcMarkMultiple, 1, "CMSConcMarkMultiple"); 2301 2302 status = status && verify_interval(CMSPrecleanIter, 0, 9, "CMSPrecleanIter"); 2303 status = status && verify_min_value(CMSPrecleanDenominator, 1, "CMSPrecleanDenominator"); 2304 status = status && verify_interval(CMSPrecleanNumerator, 0, CMSPrecleanDenominator - 1, "CMSPrecleanNumerator"); 2305 2306 status = status && verify_percentage(CMSBootstrapOccupancy, "CMSBootstrapOccupancy"); 2307 2308 status = status && verify_min_value(CMSPrecleanThreshold, 100, "CMSPrecleanThreshold"); 2309 2310 status = status && verify_percentage(CMSScheduleRemarkEdenPenetration, "CMSScheduleRemarkEdenPenetration"); 2311 status = status && verify_min_value(CMSScheduleRemarkSamplingRatio, 1, "CMSScheduleRemarkSamplingRatio"); 2312 status = status && verify_min_value(CMSBitMapYieldQuantum, 1, "CMSBitMapYieldQuantum"); 2313 status = status && verify_percentage(CMSTriggerRatio, "CMSTriggerRatio"); 2314 status = status && verify_percentage(CMSIsTooFullPercentage, "CMSIsTooFullPercentage"); 2315 } 2316 2317 if (UseParallelGC || UseParallelOldGC) { 2318 status = status && verify_interval(ParallelOldDeadWoodLimiterMean, 0, 100, "ParallelOldDeadWoodLimiterMean"); 2319 status = status && verify_interval(ParallelOldDeadWoodLimiterStdDev, 0, 100, "ParallelOldDeadWoodLimiterStdDev"); 2320 2321 status = status && verify_percentage(YoungGenerationSizeIncrement, "YoungGenerationSizeIncrement"); 2322 status = status && verify_percentage(TenuredGenerationSizeIncrement, "TenuredGenerationSizeIncrement"); 2323 2324 status = status && verify_min_value(YoungGenerationSizeSupplementDecay, 1, "YoungGenerationSizeSupplementDecay"); 2325 status = status && verify_min_value(TenuredGenerationSizeSupplementDecay, 1, "TenuredGenerationSizeSupplementDecay"); 2326 2327 status = status && verify_min_value(ParGCCardsPerStrideChunk, 1, "ParGCCardsPerStrideChunk"); 2328 2329 status = status && verify_min_value(ParallelOldGCSplitInterval, 0, "ParallelOldGCSplitInterval"); 2330 } 2331 #endif // INCLUDE_ALL_GCS 2332 2333 status = status && verify_interval(RefDiscoveryPolicy, 2334 ReferenceProcessor::DiscoveryPolicyMin, 2335 ReferenceProcessor::DiscoveryPolicyMax, 2336 "RefDiscoveryPolicy"); 2337 2338 // Limit the lower bound of this flag to 1 as it is used in a division 2339 // expression. 2340 status = status && verify_interval(TLABWasteTargetPercent, 2341 1, 100, "TLABWasteTargetPercent"); 2342 2343 status = status && verify_object_alignment(); 2344 2345 status = status && verify_interval(CompressedClassSpaceSize, 1*M, 3*G, 2346 "CompressedClassSpaceSize"); 2347 2348 status = status && verify_interval(MarkStackSizeMax, 2349 1, (max_jint - 1), "MarkStackSizeMax"); 2350 status = status && verify_interval(NUMAChunkResizeWeight, 0, 100, "NUMAChunkResizeWeight"); 2351 2352 status = status && verify_min_value(LogEventsBufferEntries, 1, "LogEventsBufferEntries"); 2353 2354 status = status && verify_min_value(HeapSizePerGCThread, (size_t) os::vm_page_size(), "HeapSizePerGCThread"); 2355 2356 status = status && verify_min_value(GCTaskTimeStampEntries, 1, "GCTaskTimeStampEntries"); 2357 2358 status = status && verify_percentage(ParallelGCBufferWastePct, "ParallelGCBufferWastePct"); 2359 status = status && verify_interval(TargetPLABWastePct, 1, 100, "TargetPLABWastePct"); 2360 2361 status = status && verify_min_value(ParGCStridesPerThread, 1, "ParGCStridesPerThread"); 2362 2363 status = status && verify_min_value(MinRAMFraction, 1, "MinRAMFraction"); 2364 status = status && verify_min_value(InitialRAMFraction, 1, "InitialRAMFraction"); 2365 status = status && verify_min_value(MaxRAMFraction, 1, "MaxRAMFraction"); 2366 status = status && verify_min_value(DefaultMaxRAMFraction, 1, "DefaultMaxRAMFraction"); 2367 2368 status = status && verify_interval(AdaptiveTimeWeight, 0, 100, "AdaptiveTimeWeight"); 2369 status = status && verify_min_value(AdaptiveSizeDecrementScaleFactor, 1, "AdaptiveSizeDecrementScaleFactor"); 2370 2371 status = status && verify_interval(TLABAllocationWeight, 0, 100, "TLABAllocationWeight"); 2372 status = status && verify_min_value(MinTLABSize, 1, "MinTLABSize"); 2373 status = status && verify_min_value(TLABRefillWasteFraction, 1, "TLABRefillWasteFraction"); 2374 2375 status = status && verify_percentage(YoungGenerationSizeSupplement, "YoungGenerationSizeSupplement"); 2376 status = status && verify_percentage(TenuredGenerationSizeSupplement, "TenuredGenerationSizeSupplement"); 2377 2378 status = status && verify_interval(MaxTenuringThreshold, 0, markOopDesc::max_age + 1, "MaxTenuringThreshold"); 2379 status = status && verify_interval(InitialTenuringThreshold, 0, MaxTenuringThreshold, "InitialTenuringThreshold"); 2380 status = status && verify_percentage(TargetSurvivorRatio, "TargetSurvivorRatio"); 2381 status = status && verify_percentage(MarkSweepDeadRatio, "MarkSweepDeadRatio"); 2382 2383 status = status && verify_min_value(MarkSweepAlwaysCompactCount, 1, "MarkSweepAlwaysCompactCount"); 2384 #ifdef COMPILER1 2385 status = status && verify_min_value(ValueMapInitialSize, 1, "ValueMapInitialSize"); 2386 #endif 2387 status = status && verify_min_value(HeapSearchSteps, 1, "HeapSearchSteps"); 2388 2389 if (PrintNMTStatistics) { 2390 #if INCLUDE_NMT 2391 if (MemTracker::tracking_level() == NMT_off) { 2392 #endif // INCLUDE_NMT 2393 warning("PrintNMTStatistics is disabled, because native memory tracking is not enabled"); 2394 PrintNMTStatistics = false; 2395 #if INCLUDE_NMT 2396 } 2397 #endif 2398 } 2399 2400 // Need to limit the extent of the padding to reasonable size. 2401 // 8K is well beyond the reasonable HW cache line size, even with the 2402 // aggressive prefetching, while still leaving the room for segregating 2403 // among the distinct pages. 2404 if (ContendedPaddingWidth < 0 || ContendedPaddingWidth > 8192) { 2405 jio_fprintf(defaultStream::error_stream(), 2406 "ContendedPaddingWidth=" INTX_FORMAT " must be in between %d and %d\n", 2407 ContendedPaddingWidth, 0, 8192); 2408 status = false; 2409 } 2410 2411 // Need to enforce the padding not to break the existing field alignments. 2412 // It is sufficient to check against the largest type size. 2413 if ((ContendedPaddingWidth % BytesPerLong) != 0) { 2414 jio_fprintf(defaultStream::error_stream(), 2415 "ContendedPaddingWidth=" INTX_FORMAT " must be a multiple of %d\n", 2416 ContendedPaddingWidth, BytesPerLong); 2417 status = false; 2418 } 2419 2420 // Check lower bounds of the code cache 2421 // Template Interpreter code is approximately 3X larger in debug builds. 2422 uint min_code_cache_size = CodeCacheMinimumUseSpace DEBUG_ONLY(* 3); 2423 if (InitialCodeCacheSize < (uintx)os::vm_page_size()) { 2424 jio_fprintf(defaultStream::error_stream(), 2425 "Invalid InitialCodeCacheSize=%dK. Must be at least %dK.\n", InitialCodeCacheSize/K, 2426 os::vm_page_size()/K); 2427 status = false; 2428 } else if (ReservedCodeCacheSize < InitialCodeCacheSize) { 2429 jio_fprintf(defaultStream::error_stream(), 2430 "Invalid ReservedCodeCacheSize: %dK. Must be at least InitialCodeCacheSize=%dK.\n", 2431 ReservedCodeCacheSize/K, InitialCodeCacheSize/K); 2432 status = false; 2433 } else if (ReservedCodeCacheSize < min_code_cache_size) { 2434 jio_fprintf(defaultStream::error_stream(), 2435 "Invalid ReservedCodeCacheSize=%dK. Must be at least %uK.\n", ReservedCodeCacheSize/K, 2436 min_code_cache_size/K); 2437 status = false; 2438 } else if (ReservedCodeCacheSize > CODE_CACHE_SIZE_LIMIT) { 2439 // Code cache size larger than CODE_CACHE_SIZE_LIMIT is not supported. 2440 jio_fprintf(defaultStream::error_stream(), 2441 "Invalid ReservedCodeCacheSize=%dM. Must be at most %uM.\n", ReservedCodeCacheSize/M, 2442 CODE_CACHE_SIZE_LIMIT/M); 2443 status = false; 2444 } else if (NonNMethodCodeHeapSize < min_code_cache_size){ 2445 jio_fprintf(defaultStream::error_stream(), 2446 "Invalid NonNMethodCodeHeapSize=%dK. Must be at least %uK.\n", NonNMethodCodeHeapSize/K, 2447 min_code_cache_size/K); 2448 status = false; 2449 } else if ((!FLAG_IS_DEFAULT(NonNMethodCodeHeapSize) || !FLAG_IS_DEFAULT(ProfiledCodeHeapSize) || !FLAG_IS_DEFAULT(NonProfiledCodeHeapSize)) 2450 && (NonNMethodCodeHeapSize + NonProfiledCodeHeapSize + ProfiledCodeHeapSize) != ReservedCodeCacheSize) { 2451 jio_fprintf(defaultStream::error_stream(), 2452 "Invalid code heap sizes: NonNMethodCodeHeapSize(%dK) + ProfiledCodeHeapSize(%dK) + NonProfiledCodeHeapSize(%dK) = %dK. Must be equal to ReservedCodeCacheSize = %uK.\n", 2453 NonNMethodCodeHeapSize/K, ProfiledCodeHeapSize/K, NonProfiledCodeHeapSize/K, 2454 (NonNMethodCodeHeapSize + ProfiledCodeHeapSize + NonProfiledCodeHeapSize)/K, ReservedCodeCacheSize/K); 2455 status = false; 2456 } 2457 2458 status &= verify_interval(NmethodSweepActivity, 0, 2000, "NmethodSweepActivity"); 2459 status &= verify_interval(CodeCacheMinBlockLength, 1, 100, "CodeCacheMinBlockLength"); 2460 status &= verify_interval(CodeCacheSegmentSize, 1, 1024, "CodeCacheSegmentSize"); 2461 status &= verify_interval(StartAggressiveSweepingAt, 0, 100, "StartAggressiveSweepingAt"); 2462 2463 2464 int min_number_of_compiler_threads = get_min_number_of_compiler_threads(); 2465 // The default CICompilerCount's value is CI_COMPILER_COUNT. 2466 assert(min_number_of_compiler_threads <= CI_COMPILER_COUNT, "minimum should be less or equal default number"); 2467 // Check the minimum number of compiler threads 2468 status &=verify_min_value(CICompilerCount, min_number_of_compiler_threads, "CICompilerCount"); 2469 2470 if (!FLAG_IS_DEFAULT(CICompilerCount) && !FLAG_IS_DEFAULT(CICompilerCountPerCPU) && CICompilerCountPerCPU) { 2471 warning("The VM option CICompilerCountPerCPU overrides CICompilerCount."); 2472 } 2473 2474 return status; 2475 } 2476 2477 bool Arguments::is_bad_option(const JavaVMOption* option, jboolean ignore, 2478 const char* option_type) { 2479 if (ignore) return false; 2480 2481 const char* spacer = " "; 2482 if (option_type == NULL) { 2483 option_type = ++spacer; // Set both to the empty string. 2484 } 2485 2486 if (os::obsolete_option(option)) { 2487 jio_fprintf(defaultStream::error_stream(), 2488 "Obsolete %s%soption: %s\n", option_type, spacer, 2641 for (int index = 0; index < args->nOptions; index++) { 2642 bool is_absolute_path = false; // for -agentpath vs -agentlib 2643 2644 const JavaVMOption* option = args->options + index; 2645 2646 if (!match_option(option, "-Djava.class.path", &tail) && 2647 !match_option(option, "-Dsun.java.command", &tail) && 2648 !match_option(option, "-Dsun.java.launcher", &tail)) { 2649 2650 // add all jvm options to the jvm_args string. This string 2651 // is used later to set the java.vm.args PerfData string constant. 2652 // the -Djava.class.path and the -Dsun.java.command options are 2653 // omitted from jvm_args string as each have their own PerfData 2654 // string constant object. 2655 build_jvm_args(option->optionString); 2656 } 2657 2658 // -verbose:[class/gc/jni] 2659 if (match_option(option, "-verbose", &tail)) { 2660 if (!strcmp(tail, ":class") || !strcmp(tail, "")) { 2661 FLAG_SET_CMDLINE(bool, TraceClassLoading, true); 2662 FLAG_SET_CMDLINE(bool, TraceClassUnloading, true); 2663 } else if (!strcmp(tail, ":gc")) { 2664 FLAG_SET_CMDLINE(bool, PrintGC, true); 2665 } else if (!strcmp(tail, ":jni")) { 2666 FLAG_SET_CMDLINE(bool, PrintJNIResolving, true); 2667 } 2668 // -da / -ea / -disableassertions / -enableassertions 2669 // These accept an optional class/package name separated by a colon, e.g., 2670 // -da:java.lang.Thread. 2671 } else if (match_option(option, user_assertion_options, &tail, true)) { 2672 bool enable = option->optionString[1] == 'e'; // char after '-' is 'e' 2673 if (*tail == '\0') { 2674 JavaAssertions::setUserClassDefault(enable); 2675 } else { 2676 assert(*tail == ':', "bogus match by match_option()"); 2677 JavaAssertions::addOption(tail + 1, enable); 2678 } 2679 // -dsa / -esa / -disablesystemassertions / -enablesystemassertions 2680 } else if (match_option(option, system_assertion_options, &tail, false)) { 2681 bool enable = option->optionString[1] == 'e'; // char after '-' is 'e' 2682 JavaAssertions::setSystemClassDefault(enable); 2683 // -bootclasspath: 2684 } else if (match_option(option, "-Xbootclasspath:", &tail)) { 2685 scp_p->reset_path(tail); 2686 *scp_assembly_required_p = true; 2733 "Profiling and debugging agents are not supported in this VM\n"); 2734 return JNI_ERR; 2735 } 2736 #endif // !INCLUDE_JVMTI 2737 add_init_agent(name, options, is_absolute_path); 2738 } 2739 // -javaagent 2740 } else if (match_option(option, "-javaagent:", &tail)) { 2741 #if !INCLUDE_JVMTI 2742 jio_fprintf(defaultStream::error_stream(), 2743 "Instrumentation agents are not supported in this VM\n"); 2744 return JNI_ERR; 2745 #else 2746 if(tail != NULL) { 2747 char *options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(tail) + 1, mtInternal), tail); 2748 add_init_agent("instrument", options, false); 2749 } 2750 #endif // !INCLUDE_JVMTI 2751 // -Xnoclassgc 2752 } else if (match_option(option, "-Xnoclassgc")) { 2753 FLAG_SET_CMDLINE(bool, ClassUnloading, false); 2754 // -Xconcgc 2755 } else if (match_option(option, "-Xconcgc")) { 2756 FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, true); 2757 // -Xnoconcgc 2758 } else if (match_option(option, "-Xnoconcgc")) { 2759 FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, false); 2760 // -Xbatch 2761 } else if (match_option(option, "-Xbatch")) { 2762 FLAG_SET_CMDLINE(bool, BackgroundCompilation, false); 2763 // -Xmn for compatibility with other JVM vendors 2764 } else if (match_option(option, "-Xmn", &tail)) { 2765 julong long_initial_young_size = 0; 2766 ArgsRange errcode = parse_memory_size(tail, &long_initial_young_size, 1); 2767 if (errcode != arg_in_range) { 2768 jio_fprintf(defaultStream::error_stream(), 2769 "Invalid initial young generation size: %s\n", option->optionString); 2770 describe_range_error(errcode); 2771 return JNI_EINVAL; 2772 } 2773 FLAG_SET_CMDLINE(size_t, MaxNewSize, (size_t)long_initial_young_size); 2774 FLAG_SET_CMDLINE(size_t, NewSize, (size_t)long_initial_young_size); 2775 // -Xms 2776 } else if (match_option(option, "-Xms", &tail)) { 2777 julong long_initial_heap_size = 0; 2778 // an initial heap size of 0 means automatically determine 2779 ArgsRange errcode = parse_memory_size(tail, &long_initial_heap_size, 0); 2780 if (errcode != arg_in_range) { 2781 jio_fprintf(defaultStream::error_stream(), 2782 "Invalid initial heap size: %s\n", option->optionString); 2783 describe_range_error(errcode); 2784 return JNI_EINVAL; 2785 } 2786 set_min_heap_size((size_t)long_initial_heap_size); 2787 // Currently the minimum size and the initial heap sizes are the same. 2788 // Can be overridden with -XX:InitialHeapSize. 2789 FLAG_SET_CMDLINE(size_t, InitialHeapSize, (size_t)long_initial_heap_size); 2790 // -Xmx 2791 } else if (match_option(option, "-Xmx", &tail) || match_option(option, "-XX:MaxHeapSize=", &tail)) { 2792 julong long_max_heap_size = 0; 2793 ArgsRange errcode = parse_memory_size(tail, &long_max_heap_size, 1); 2794 if (errcode != arg_in_range) { 2795 jio_fprintf(defaultStream::error_stream(), 2796 "Invalid maximum heap size: %s\n", option->optionString); 2797 describe_range_error(errcode); 2798 return JNI_EINVAL; 2799 } 2800 FLAG_SET_CMDLINE(size_t, MaxHeapSize, (size_t)long_max_heap_size); 2801 // Xmaxf 2802 } else if (match_option(option, "-Xmaxf", &tail)) { 2803 char* err; 2804 int maxf = (int)(strtod(tail, &err) * 100); 2805 if (*err != '\0' || *tail == '\0' || maxf < 0 || maxf > 100) { 2806 jio_fprintf(defaultStream::error_stream(), 2807 "Bad max heap free percentage size: %s\n", 2808 option->optionString); 2809 return JNI_EINVAL; 2810 } else { 2811 FLAG_SET_CMDLINE(uintx, MaxHeapFreeRatio, maxf); 2812 } 2813 // Xminf 2814 } else if (match_option(option, "-Xminf", &tail)) { 2815 char* err; 2816 int minf = (int)(strtod(tail, &err) * 100); 2817 if (*err != '\0' || *tail == '\0' || minf < 0 || minf > 100) { 2818 jio_fprintf(defaultStream::error_stream(), 2819 "Bad min heap free percentage size: %s\n", 2820 option->optionString); 2821 return JNI_EINVAL; 2822 } else { 2823 FLAG_SET_CMDLINE(uintx, MinHeapFreeRatio, minf); 2824 } 2825 // -Xss 2826 } else if (match_option(option, "-Xss", &tail)) { 2827 julong long_ThreadStackSize = 0; 2828 ArgsRange errcode = parse_memory_size(tail, &long_ThreadStackSize, 1000); 2829 if (errcode != arg_in_range) { 2830 jio_fprintf(defaultStream::error_stream(), 2831 "Invalid thread stack size: %s\n", option->optionString); 2832 describe_range_error(errcode); 2833 return JNI_EINVAL; 2834 } 2835 // Internally track ThreadStackSize in units of 1024 bytes. 2836 FLAG_SET_CMDLINE(intx, ThreadStackSize, 2837 round_to((int)long_ThreadStackSize, K) / K); 2838 // -Xoss 2839 } else if (match_option(option, "-Xoss", &tail)) { 2840 // HotSpot does not have separate native and Java stacks, ignore silently for compatibility 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 FLAG_SET_CMDLINE(uintx, CodeCacheExpansionSize, (uintx)long_CodeCacheExpansionSize); 2851 } else if (match_option(option, "-Xmaxjitcodesize", &tail) || 2852 match_option(option, "-XX:ReservedCodeCacheSize=", &tail)) { 2853 julong long_ReservedCodeCacheSize = 0; 2854 2855 ArgsRange errcode = parse_memory_size(tail, &long_ReservedCodeCacheSize, 1); 2856 if (errcode != arg_in_range) { 2857 jio_fprintf(defaultStream::error_stream(), 2858 "Invalid maximum code cache size: %s.\n", option->optionString); 2859 return JNI_EINVAL; 2860 } 2861 FLAG_SET_CMDLINE(uintx, ReservedCodeCacheSize, (uintx)long_ReservedCodeCacheSize); 2862 // -XX:NonNMethodCodeHeapSize= 2863 } else if (match_option(option, "-XX:NonNMethodCodeHeapSize=", &tail)) { 2864 julong long_NonNMethodCodeHeapSize = 0; 2865 2866 ArgsRange errcode = parse_memory_size(tail, &long_NonNMethodCodeHeapSize, 1); 2867 if (errcode != arg_in_range) { 2868 jio_fprintf(defaultStream::error_stream(), 2869 "Invalid maximum non-nmethod code heap size: %s.\n", option->optionString); 2870 return JNI_EINVAL; 2871 } 2872 FLAG_SET_CMDLINE(uintx, NonNMethodCodeHeapSize, (uintx)long_NonNMethodCodeHeapSize); 2873 // -XX:ProfiledCodeHeapSize= 2874 } else if (match_option(option, "-XX:ProfiledCodeHeapSize=", &tail)) { 2875 julong long_ProfiledCodeHeapSize = 0; 2876 2877 ArgsRange errcode = parse_memory_size(tail, &long_ProfiledCodeHeapSize, 1); 2878 if (errcode != arg_in_range) { 2879 jio_fprintf(defaultStream::error_stream(), 2880 "Invalid maximum profiled code heap size: %s.\n", option->optionString); 2881 return JNI_EINVAL; 2882 } 2883 FLAG_SET_CMDLINE(uintx, ProfiledCodeHeapSize, (uintx)long_ProfiledCodeHeapSize); 2884 // -XX:NonProfiledCodeHeapSizee= 2885 } else if (match_option(option, "-XX:NonProfiledCodeHeapSize=", &tail)) { 2886 julong long_NonProfiledCodeHeapSize = 0; 2887 2888 ArgsRange errcode = parse_memory_size(tail, &long_NonProfiledCodeHeapSize, 1); 2889 if (errcode != arg_in_range) { 2890 jio_fprintf(defaultStream::error_stream(), 2891 "Invalid maximum non-profiled code heap size: %s.\n", option->optionString); 2892 return JNI_EINVAL; 2893 } 2894 FLAG_SET_CMDLINE(uintx, NonProfiledCodeHeapSize, (uintx)long_NonProfiledCodeHeapSize); 2895 //-XX:IncreaseFirstTierCompileThresholdAt= 2896 } else if (match_option(option, "-XX:IncreaseFirstTierCompileThresholdAt=", &tail)) { 2897 uintx uint_IncreaseFirstTierCompileThresholdAt = 0; 2898 if (!parse_uintx(tail, &uint_IncreaseFirstTierCompileThresholdAt, 0) || uint_IncreaseFirstTierCompileThresholdAt > 99) { 2899 jio_fprintf(defaultStream::error_stream(), 2900 "Invalid value for IncreaseFirstTierCompileThresholdAt: %s. Should be between 0 and 99.\n", 2901 option->optionString); 2902 return JNI_EINVAL; 2903 } 2904 FLAG_SET_CMDLINE(uintx, IncreaseFirstTierCompileThresholdAt, (uintx)uint_IncreaseFirstTierCompileThresholdAt); 2905 // -green 2906 } else if (match_option(option, "-green")) { 2907 jio_fprintf(defaultStream::error_stream(), 2908 "Green threads support not available\n"); 2909 return JNI_EINVAL; 2910 // -native 2911 } else if (match_option(option, "-native")) { 2912 // HotSpot always uses native threads, ignore silently for compatibility 2913 // -Xsqnopause 2914 } else if (match_option(option, "-Xsqnopause")) { 2915 // EVM option, ignore silently for compatibility 2916 // -Xrs 2917 } else if (match_option(option, "-Xrs")) { 2918 // Classic/EVM option, new functionality 2919 FLAG_SET_CMDLINE(bool, ReduceSignalUsage, true); 2920 } else if (match_option(option, "-Xusealtsigs")) { 2921 // change default internal VM signals used - lower case for back compat 2922 FLAG_SET_CMDLINE(bool, UseAltSigs, true); 2923 // -Xoptimize 2924 } else if (match_option(option, "-Xoptimize")) { 2925 // EVM option, ignore silently for compatibility 2926 // -Xprof 2927 } else if (match_option(option, "-Xprof")) { 2928 #if INCLUDE_FPROF 2929 _has_profile = true; 2930 #else // INCLUDE_FPROF 2931 jio_fprintf(defaultStream::error_stream(), 2932 "Flat profiling is not supported in this VM.\n"); 2933 return JNI_ERR; 2934 #endif // INCLUDE_FPROF 2935 // -Xconcurrentio 2936 } else if (match_option(option, "-Xconcurrentio")) { 2937 FLAG_SET_CMDLINE(bool, UseLWPSynchronization, true); 2938 FLAG_SET_CMDLINE(bool, BackgroundCompilation, false); 2939 FLAG_SET_CMDLINE(intx, DeferThrSuspendLoopCount, 1); 2940 FLAG_SET_CMDLINE(bool, UseTLAB, false); 2941 FLAG_SET_CMDLINE(size_t, NewSizeThreadIncrease, 16 * K); // 20Kb per thread added to new generation 2942 2943 // -Xinternalversion 2944 } else if (match_option(option, "-Xinternalversion")) { 2945 jio_fprintf(defaultStream::output_stream(), "%s\n", 2946 VM_Version::internal_vm_info_string()); 2947 vm_exit(0); 2948 #ifndef PRODUCT 2949 // -Xprintflags 2950 } else if (match_option(option, "-Xprintflags")) { 2951 CommandLineFlags::printFlags(tty, false); 2952 vm_exit(0); 2953 #endif 2954 // -D 2955 } else if (match_option(option, "-D", &tail)) { 2956 const char* value; 2957 if (match_option(option, "-Djava.endorsed.dirs=", &value) && 2958 *value!= '\0' && strcmp(value, "\"\"") != 0) { 2959 // abort if -Djava.endorsed.dirs is set 2960 jio_fprintf(defaultStream::output_stream(), 2961 "-Djava.endorsed.dirs=%s is not supported. Endorsed standards and standalone APIs\n" 2962 "in modular form will be supported via the concept of upgradeable modules.\n", value); 2963 return JNI_EINVAL; 2964 } 2965 if (match_option(option, "-Djava.ext.dirs=", &value) && 2966 *value != '\0' && strcmp(value, "\"\"") != 0) { 2967 // abort if -Djava.ext.dirs is set 2968 jio_fprintf(defaultStream::output_stream(), 2969 "-Djava.ext.dirs=%s is not supported. Use -classpath instead.\n", value); 2970 return JNI_EINVAL; 2971 } 2972 2973 if (!add_property(tail)) { 2974 return JNI_ENOMEM; 2975 } 2976 // Out of the box management support 2977 if (match_option(option, "-Dcom.sun.management", &tail)) { 2978 #if INCLUDE_MANAGEMENT 2979 FLAG_SET_CMDLINE(bool, ManagementServer, true); 2980 #else 2981 jio_fprintf(defaultStream::output_stream(), 2982 "-Dcom.sun.management is not supported in this VM.\n"); 2983 return JNI_ERR; 2984 #endif 2985 } 2986 // -Xint 2987 } else if (match_option(option, "-Xint")) { 2988 set_mode_flags(_int); 2989 // -Xmixed 2990 } else if (match_option(option, "-Xmixed")) { 2991 set_mode_flags(_mixed); 2992 // -Xcomp 2993 } else if (match_option(option, "-Xcomp")) { 2994 // for testing the compiler; turn off all flags that inhibit compilation 2995 set_mode_flags(_comp); 2996 // -Xshare:dump 2997 } else if (match_option(option, "-Xshare:dump")) { 2998 FLAG_SET_CMDLINE(bool, DumpSharedSpaces, true); 2999 set_mode_flags(_int); // Prevent compilation, which creates objects 3000 // -Xshare:on 3001 } else if (match_option(option, "-Xshare:on")) { 3002 FLAG_SET_CMDLINE(bool, UseSharedSpaces, true); 3003 FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true); 3004 // -Xshare:auto 3005 } else if (match_option(option, "-Xshare:auto")) { 3006 FLAG_SET_CMDLINE(bool, UseSharedSpaces, true); 3007 FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false); 3008 // -Xshare:off 3009 } else if (match_option(option, "-Xshare:off")) { 3010 FLAG_SET_CMDLINE(bool, UseSharedSpaces, false); 3011 FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false); 3012 // -Xverify 3013 } else if (match_option(option, "-Xverify", &tail)) { 3014 if (strcmp(tail, ":all") == 0 || strcmp(tail, "") == 0) { 3015 FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, true); 3016 FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true); 3017 } else if (strcmp(tail, ":remote") == 0) { 3018 FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false); 3019 FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true); 3020 } else if (strcmp(tail, ":none") == 0) { 3021 FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false); 3022 FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, false); 3023 } else if (is_bad_option(option, args->ignoreUnrecognized, "verification")) { 3024 return JNI_EINVAL; 3025 } 3026 // -Xdebug 3027 } else if (match_option(option, "-Xdebug")) { 3028 // note this flag has been used, then ignore 3029 set_xdebug_mode(true); 3030 // -Xnoagent 3031 } else if (match_option(option, "-Xnoagent")) { 3032 // For compatibility with classic. HotSpot refuses to load the old style agent.dll. 3033 } else if (match_option(option, "-Xboundthreads")) { 3034 // Ignore silently for compatibility 3035 } else if (match_option(option, "-Xloggc:", &tail)) { 3036 // Redirect GC output to the file. -Xloggc:<filename> 3037 // ostream_init_log(), when called will use this filename 3038 // to initialize a fileStream. 3039 _gc_log_filename = os::strdup_check_oom(tail); 3040 if (!is_filename_valid(_gc_log_filename)) { 3041 jio_fprintf(defaultStream::output_stream(), 3042 "Invalid file name for use with -Xloggc: Filename can only contain the " 3043 "characters [A-Z][a-z][0-9]-_.%%[p|t] but it has been %s\n" 3044 "Note %%p or %%t can only be used once\n", _gc_log_filename); 3045 return JNI_EINVAL; 3046 } 3047 FLAG_SET_CMDLINE(bool, PrintGC, true); 3048 FLAG_SET_CMDLINE(bool, PrintGCTimeStamps, true); 3049 3050 // JNI hooks 3051 } else if (match_option(option, "-Xcheck", &tail)) { 3052 if (!strcmp(tail, ":jni")) { 3053 #if !INCLUDE_JNI_CHECK 3054 warning("JNI CHECKING is not supported in this VM"); 3055 #else 3056 CheckJNICalls = true; 3057 #endif // INCLUDE_JNI_CHECK 3058 } else if (is_bad_option(option, args->ignoreUnrecognized, 3059 "check")) { 3060 return JNI_EINVAL; 3061 } 3062 } else if (match_option(option, "vfprintf")) { 3063 _vfprintf_hook = CAST_TO_FN_PTR(vfprintf_hook_t, option->extraInfo); 3064 } else if (match_option(option, "exit")) { 3065 _exit_hook = CAST_TO_FN_PTR(exit_hook_t, option->extraInfo); 3066 } else if (match_option(option, "abort")) { 3067 _abort_hook = CAST_TO_FN_PTR(abort_hook_t, option->extraInfo); 3068 // -XX:+AggressiveHeap 3069 } else if (match_option(option, "-XX:+AggressiveHeap")) { 3081 julong initHeapSize; 3082 julong total_memory = os::physical_memory(); 3083 3084 if (total_memory < (julong)256*M) { 3085 jio_fprintf(defaultStream::error_stream(), 3086 "You need at least 256mb of memory to use -XX:+AggressiveHeap\n"); 3087 vm_exit(1); 3088 } 3089 3090 // The heap size is half of available memory, or (at most) 3091 // all of possible memory less 160mb (leaving room for the OS 3092 // when using ISM). This is the maximum; because adaptive sizing 3093 // is turned on below, the actual space used may be smaller. 3094 3095 initHeapSize = MIN2(total_memory / (julong)2, 3096 total_memory - (julong)160*M); 3097 3098 initHeapSize = limit_by_allocatable_memory(initHeapSize); 3099 3100 if (FLAG_IS_DEFAULT(MaxHeapSize)) { 3101 FLAG_SET_CMDLINE(size_t, MaxHeapSize, initHeapSize); 3102 FLAG_SET_CMDLINE(size_t, InitialHeapSize, initHeapSize); 3103 // Currently the minimum size and the initial heap sizes are the same. 3104 set_min_heap_size(initHeapSize); 3105 } 3106 if (FLAG_IS_DEFAULT(NewSize)) { 3107 // Make the young generation 3/8ths of the total heap. 3108 FLAG_SET_CMDLINE(size_t, NewSize, 3109 ((julong)MaxHeapSize / (julong)8) * (julong)3); 3110 FLAG_SET_CMDLINE(size_t, MaxNewSize, NewSize); 3111 } 3112 3113 #if !defined(_ALLBSD_SOURCE) && !defined(AIX) // UseLargePages is not yet supported on BSD and AIX. 3114 FLAG_SET_DEFAULT(UseLargePages, true); 3115 #endif 3116 3117 // Increase some data structure sizes for efficiency 3118 FLAG_SET_CMDLINE(size_t, BaseFootPrintEstimate, MaxHeapSize); 3119 FLAG_SET_CMDLINE(bool, ResizeTLAB, false); 3120 FLAG_SET_CMDLINE(size_t, TLABSize, 256*K); 3121 3122 // See the OldPLABSize comment below, but replace 'after promotion' 3123 // with 'after copying'. YoungPLABSize is the size of the survivor 3124 // space per-gc-thread buffers. The default is 4kw. 3125 FLAG_SET_CMDLINE(size_t, YoungPLABSize, 256*K); // Note: this is in words 3126 3127 // OldPLABSize is the size of the buffers in the old gen that 3128 // UseParallelGC uses to promote live data that doesn't fit in the 3129 // survivor spaces. At any given time, there's one for each gc thread. 3130 // The default size is 1kw. These buffers are rarely used, since the 3131 // survivor spaces are usually big enough. For specjbb, however, there 3132 // are occasions when there's lots of live data in the young gen 3133 // and we end up promoting some of it. We don't have a definite 3134 // explanation for why bumping OldPLABSize helps, but the theory 3135 // is that a bigger PLAB results in retaining something like the 3136 // original allocation order after promotion, which improves mutator 3137 // locality. A minor effect may be that larger PLABs reduce the 3138 // number of PLAB allocation events during gc. The value of 8kw 3139 // was arrived at by experimenting with specjbb. 3140 FLAG_SET_CMDLINE(size_t, OldPLABSize, 8*K); // Note: this is in words 3141 3142 // Enable parallel GC and adaptive generation sizing 3143 FLAG_SET_CMDLINE(bool, UseParallelGC, true); 3144 FLAG_SET_DEFAULT(ParallelGCThreads, 3145 Abstract_VM_Version::parallel_worker_threads()); 3146 3147 // Encourage steady state memory management 3148 FLAG_SET_CMDLINE(uintx, ThresholdTolerance, 100); 3149 3150 // This appears to improve mutator locality 3151 FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false); 3152 3153 // Get around early Solaris scheduling bug 3154 // (affinity vs other jobs on system) 3155 // but disallow DR and offlining (5008695). 3156 FLAG_SET_CMDLINE(bool, BindGCTaskThreadsToCPUs, true); 3157 3158 // Need to keep consistency of MaxTenuringThreshold and AlwaysTenure/NeverTenure; 3159 // and the last option wins. 3160 } else if (match_option(option, "-XX:+NeverTenure")) { 3161 FLAG_SET_CMDLINE(bool, NeverTenure, true); 3162 FLAG_SET_CMDLINE(bool, AlwaysTenure, false); 3163 FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, markOopDesc::max_age + 1); 3164 } else if (match_option(option, "-XX:+AlwaysTenure")) { 3165 FLAG_SET_CMDLINE(bool, NeverTenure, false); 3166 FLAG_SET_CMDLINE(bool, AlwaysTenure, true); 3167 FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, 0); 3168 } else if (match_option(option, "-XX:MaxTenuringThreshold=", &tail)) { 3169 uintx max_tenuring_thresh = 0; 3170 if(!parse_uintx(tail, &max_tenuring_thresh, 0)) { 3171 jio_fprintf(defaultStream::error_stream(), 3172 "Improperly specified VM option 'MaxTenuringThreshold=%s'\n", tail); 3173 return JNI_EINVAL; 3174 } 3175 FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, max_tenuring_thresh); 3176 3177 if (MaxTenuringThreshold == 0) { 3178 FLAG_SET_CMDLINE(bool, NeverTenure, false); 3179 FLAG_SET_CMDLINE(bool, AlwaysTenure, true); 3180 } else { 3181 FLAG_SET_CMDLINE(bool, NeverTenure, false); 3182 FLAG_SET_CMDLINE(bool, AlwaysTenure, false); 3183 } 3184 } else if (match_option(option, "-XX:+DisplayVMOutputToStderr")) { 3185 FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, false); 3186 FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, true); 3187 } else if (match_option(option, "-XX:+DisplayVMOutputToStdout")) { 3188 FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, false); 3189 FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, true); 3190 } else if (match_option(option, "-XX:+ExtendedDTraceProbes")) { 3191 #if defined(DTRACE_ENABLED) 3192 FLAG_SET_CMDLINE(bool, ExtendedDTraceProbes, true); 3193 FLAG_SET_CMDLINE(bool, DTraceMethodProbes, true); 3194 FLAG_SET_CMDLINE(bool, DTraceAllocProbes, true); 3195 FLAG_SET_CMDLINE(bool, DTraceMonitorProbes, true); 3196 #else // defined(DTRACE_ENABLED) 3197 jio_fprintf(defaultStream::error_stream(), 3198 "ExtendedDTraceProbes flag is not applicable for this configuration\n"); 3199 return JNI_EINVAL; 3200 #endif // defined(DTRACE_ENABLED) 3201 #ifdef ASSERT 3202 } else if (match_option(option, "-XX:+FullGCALot")) { 3203 FLAG_SET_CMDLINE(bool, FullGCALot, true); 3204 // disable scavenge before parallel mark-compact 3205 FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false); 3206 #endif 3207 } else if (match_option(option, "-XX:CMSMarkStackSize=", &tail) || 3208 match_option(option, "-XX:G1MarkStackSize=", &tail)) { 3209 julong stack_size = 0; 3210 ArgsRange errcode = parse_memory_size(tail, &stack_size, 1); 3211 if (errcode != arg_in_range) { 3212 jio_fprintf(defaultStream::error_stream(), 3213 "Invalid mark stack size: %s\n", option->optionString); 3214 describe_range_error(errcode); 3215 return JNI_EINVAL; 3216 } 3217 jio_fprintf(defaultStream::error_stream(), 3218 "Please use -XX:MarkStackSize in place of " 3219 "-XX:CMSMarkStackSize or -XX:G1MarkStackSize in the future\n"); 3220 FLAG_SET_CMDLINE(size_t, MarkStackSize, stack_size); 3221 } else if (match_option(option, "-XX:CMSMarkStackSizeMax=", &tail)) { 3222 julong max_stack_size = 0; 3223 ArgsRange errcode = parse_memory_size(tail, &max_stack_size, 1); 3224 if (errcode != arg_in_range) { 3225 jio_fprintf(defaultStream::error_stream(), 3226 "Invalid maximum mark stack size: %s\n", 3227 option->optionString); 3228 describe_range_error(errcode); 3229 return JNI_EINVAL; 3230 } 3231 jio_fprintf(defaultStream::error_stream(), 3232 "Please use -XX:MarkStackSizeMax in place of " 3233 "-XX:CMSMarkStackSizeMax in the future\n"); 3234 FLAG_SET_CMDLINE(size_t, MarkStackSizeMax, max_stack_size); 3235 } else if (match_option(option, "-XX:ParallelMarkingThreads=", &tail) || 3236 match_option(option, "-XX:ParallelCMSThreads=", &tail)) { 3237 uintx conc_threads = 0; 3238 if (!parse_uintx(tail, &conc_threads, 1)) { 3239 jio_fprintf(defaultStream::error_stream(), 3240 "Invalid concurrent threads: %s\n", option->optionString); 3241 return JNI_EINVAL; 3242 } 3243 jio_fprintf(defaultStream::error_stream(), 3244 "Please use -XX:ConcGCThreads in place of " 3245 "-XX:ParallelMarkingThreads or -XX:ParallelCMSThreads in the future\n"); 3246 FLAG_SET_CMDLINE(uint, ConcGCThreads, conc_threads); 3247 } else if (match_option(option, "-XX:MaxDirectMemorySize=", &tail)) { 3248 julong max_direct_memory_size = 0; 3249 ArgsRange errcode = parse_memory_size(tail, &max_direct_memory_size, 0); 3250 if (errcode != arg_in_range) { 3251 jio_fprintf(defaultStream::error_stream(), 3252 "Invalid maximum direct memory size: %s\n", 3253 option->optionString); 3254 describe_range_error(errcode); 3255 return JNI_EINVAL; 3256 } 3257 FLAG_SET_CMDLINE(size_t, MaxDirectMemorySize, max_direct_memory_size); 3258 #if !INCLUDE_MANAGEMENT 3259 } else if (match_option(option, "-XX:+ManagementServer")) { 3260 jio_fprintf(defaultStream::error_stream(), 3261 "ManagementServer is not supported in this VM.\n"); 3262 return JNI_ERR; 3263 #endif // INCLUDE_MANAGEMENT 3264 // CreateMinidumpOnCrash is removed, and replaced by CreateCoredumpOnCrash 3265 } else if (match_option(option, "-XX:+CreateMinidumpOnCrash")) { 3266 FLAG_SET_CMDLINE(bool, CreateCoredumpOnCrash, true); 3267 jio_fprintf(defaultStream::output_stream(), 3268 "CreateMinidumpOnCrash is replaced by CreateCoredumpOnCrash: CreateCoredumpOnCrash is on\n"); 3269 } else if (match_option(option, "-XX:-CreateMinidumpOnCrash")) { 3270 FLAG_SET_CMDLINE(bool, CreateCoredumpOnCrash, false); 3271 jio_fprintf(defaultStream::output_stream(), 3272 "CreateMinidumpOnCrash is replaced by CreateCoredumpOnCrash: CreateCoredumpOnCrash is off\n"); 3273 } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx 3274 // Skip -XX:Flags= since that case has already been handled 3275 if (strncmp(tail, "Flags=", strlen("Flags=")) != 0) { 3276 if (!process_argument(tail, args->ignoreUnrecognized, origin)) { 3277 return JNI_EINVAL; 3278 } 3279 } 3280 // Unknown option 3281 } else if (is_bad_option(option, args->ignoreUnrecognized)) { 3282 return JNI_ERR; 3283 } 3284 } 3285 3286 // PrintSharedArchiveAndExit will turn on 3287 // -Xshare:on 3288 // -XX:+TraceClassPaths 3289 if (PrintSharedArchiveAndExit) { 3290 FLAG_SET_CMDLINE(bool, UseSharedSpaces, true); 3291 FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true); 3292 FLAG_SET_CMDLINE(bool, TraceClassPaths, true); 3293 } 3294 3295 // Change the default value for flags which have different default values 3296 // when working with older JDKs. 3297 #ifdef LINUX 3298 if (JDK_Version::current().compare_major(6) <= 0 && 3299 FLAG_IS_DEFAULT(UseLinuxPosixThreadCPUClocks)) { 3300 FLAG_SET_DEFAULT(UseLinuxPosixThreadCPUClocks, false); 3301 } 3302 #endif // LINUX 3303 fix_appclasspath(); 3304 return JNI_OK; 3305 } 3306 3307 // Remove all empty paths from the app classpath (if IgnoreEmptyClassPaths is enabled) 3308 // 3309 // This is necessary because some apps like to specify classpath like -cp foo.jar:${XYZ}:bar.jar 3310 // in their start-up scripts. If XYZ is empty, the classpath will look like "-cp foo.jar::bar.jar". 3311 // Java treats such empty paths as if the user specified "-cp foo.jar:.:bar.jar". I.e., an empty 3312 // path is treated as the current directory. 3679 #ifdef COMPILER1 3680 if (PrintC1Statistics) { 3681 return true; 3682 } 3683 #endif // COMPILER1 3684 3685 #ifdef COMPILER2 3686 if (PrintOptoAssembly || PrintOptoStatistics) { 3687 return true; 3688 } 3689 #endif // COMPILER2 3690 3691 return false; 3692 } 3693 #endif // PRODUCT 3694 3695 // Parse entry point called from JNI_CreateJavaVM 3696 3697 jint Arguments::parse(const JavaVMInitArgs* args) { 3698 3699 // Remaining part of option string 3700 const char* tail; 3701 3702 // If flag "-XX:Flags=flags-file" is used it will be the first option to be processed. 3703 const char* hotspotrc = ".hotspotrc"; 3704 bool settings_file_specified = false; 3705 bool needs_hotspotrc_warning = false; 3706 3707 const char* flags_file; 3708 int index; 3709 for (index = 0; index < args->nOptions; index++) { 3710 const JavaVMOption *option = args->options + index; 3711 if (ArgumentsExt::process_options(option)) { 3712 continue; 3713 } 3714 if (match_option(option, "-XX:Flags=", &tail)) { 3715 flags_file = tail; 3716 settings_file_specified = true; 3717 continue; 3718 } 4013 if (UseParallelGC || UseParallelOldGC) { 4014 if (FLAG_IS_DEFAULT(MinHeapDeltaBytes)) { 4015 FLAG_SET_DEFAULT(MinHeapDeltaBytes, 64*M); 4016 } 4017 } 4018 // UseNUMAInterleaving is set to ON for all collectors and 4019 // platforms when UseNUMA is set to ON. NUMA-aware collectors 4020 // such as the parallel collector for Linux and Solaris will 4021 // interleave old gen and survivor spaces on top of NUMA 4022 // allocation policy for the eden space. 4023 // Non NUMA-aware collectors such as CMS, G1 and Serial-GC on 4024 // all platforms and ParallelGC on Windows will interleave all 4025 // of the heap spaces across NUMA nodes. 4026 if (FLAG_IS_DEFAULT(UseNUMAInterleaving)) { 4027 FLAG_SET_ERGO(bool, UseNUMAInterleaving, true); 4028 } 4029 } 4030 return JNI_OK; 4031 } 4032 4033 int Arguments::PropertyList_count(SystemProperty* pl) { 4034 int count = 0; 4035 while(pl != NULL) { 4036 count++; 4037 pl = pl->next(); 4038 } 4039 return count; 4040 } 4041 4042 const char* Arguments::PropertyList_get_value(SystemProperty *pl, const char* key) { 4043 assert(key != NULL, "just checking"); 4044 SystemProperty* prop; 4045 for (prop = pl; prop != NULL; prop = prop->next()) { 4046 if (strcmp(key, prop->key()) == 0) return prop->value(); 4047 } 4048 return NULL; 4049 } 4050 4051 const char* Arguments::PropertyList_get_key_at(SystemProperty *pl, int index) { 4052 int count = 0; |