src/share/vm/runtime/arguments.cpp

changeset 7708
12478c5eb000
parent 7704
9c5134750f1d
parent 7262
f10fe402dfb1
child 7710
b1cf34d57e78
equal deleted inserted replaced
7706:37179dcf830a 7708:12478c5eb000
21 * questions. 21 * questions.
22 * 22 *
23 */ 23 */
24 24
25 #include "precompiled.hpp" 25 #include "precompiled.hpp"
26 #include "classfile/classLoader.hpp"
26 #include "classfile/javaAssertions.hpp" 27 #include "classfile/javaAssertions.hpp"
27 #include "classfile/symbolTable.hpp" 28 #include "classfile/symbolTable.hpp"
28 #include "compiler/compilerOracle.hpp" 29 #include "compiler/compilerOracle.hpp"
29 #include "memory/allocation.inline.hpp" 30 #include "memory/allocation.inline.hpp"
30 #include "memory/cardTableRS.hpp" 31 #include "memory/cardTableRS.hpp"
32 #include "memory/referenceProcessor.hpp" 33 #include "memory/referenceProcessor.hpp"
33 #include "memory/universe.inline.hpp" 34 #include "memory/universe.inline.hpp"
34 #include "oops/oop.inline.hpp" 35 #include "oops/oop.inline.hpp"
35 #include "prims/jvmtiExport.hpp" 36 #include "prims/jvmtiExport.hpp"
36 #include "runtime/arguments.hpp" 37 #include "runtime/arguments.hpp"
38 #include "runtime/arguments_ext.hpp"
37 #include "runtime/globals_extension.hpp" 39 #include "runtime/globals_extension.hpp"
38 #include "runtime/java.hpp" 40 #include "runtime/java.hpp"
39 #include "services/management.hpp" 41 #include "services/management.hpp"
40 #include "services/memTracker.hpp" 42 #include "services/memTracker.hpp"
41 #include "utilities/defaultStream.hpp" 43 #include "utilities/defaultStream.hpp"
42 #include "utilities/macros.hpp" 44 #include "utilities/macros.hpp"
45 #include "utilities/stringUtils.hpp"
43 #include "utilities/taskqueue.hpp" 46 #include "utilities/taskqueue.hpp"
44 #ifdef TARGET_OS_FAMILY_linux 47 #ifdef TARGET_OS_FAMILY_linux
45 # include "os_linux.inline.hpp" 48 # include "os_linux.inline.hpp"
46 #endif 49 #endif
47 #ifdef TARGET_OS_FAMILY_solaris 50 #ifdef TARGET_OS_FAMILY_solaris
96 SystemProperty* Arguments::_system_properties = NULL; 99 SystemProperty* Arguments::_system_properties = NULL;
97 const char* Arguments::_gc_log_filename = NULL; 100 const char* Arguments::_gc_log_filename = NULL;
98 bool Arguments::_has_profile = false; 101 bool Arguments::_has_profile = false;
99 size_t Arguments::_conservative_max_heap_alignment = 0; 102 size_t Arguments::_conservative_max_heap_alignment = 0;
100 uintx Arguments::_min_heap_size = 0; 103 uintx Arguments::_min_heap_size = 0;
104 uintx Arguments::_min_heap_free_ratio = 0;
105 uintx Arguments::_max_heap_free_ratio = 0;
101 Arguments::Mode Arguments::_mode = _mixed; 106 Arguments::Mode Arguments::_mode = _mixed;
102 bool Arguments::_java_compiler = false; 107 bool Arguments::_java_compiler = false;
103 bool Arguments::_xdebug_mode = false; 108 bool Arguments::_xdebug_mode = false;
104 const char* Arguments::_java_vendor_url_bug = DEFAULT_VENDOR_URL_BUG; 109 const char* Arguments::_java_vendor_url_bug = DEFAULT_VENDOR_URL_BUG;
105 const char* Arguments::_sun_java_launcher = DEFAULT_JAVA_LAUNCHER; 110 const char* Arguments::_sun_java_launcher = DEFAULT_JAVA_LAUNCHER;
292 { "UseISM", JDK_Version::jdk(8), JDK_Version::jdk(9) }, 297 { "UseISM", JDK_Version::jdk(8), JDK_Version::jdk(9) },
293 { "UsePermISM", JDK_Version::jdk(8), JDK_Version::jdk(9) }, 298 { "UsePermISM", JDK_Version::jdk(8), JDK_Version::jdk(9) },
294 { "UseMPSS", JDK_Version::jdk(8), JDK_Version::jdk(9) }, 299 { "UseMPSS", JDK_Version::jdk(8), JDK_Version::jdk(9) },
295 { "UseStringCache", JDK_Version::jdk(8), JDK_Version::jdk(9) }, 300 { "UseStringCache", JDK_Version::jdk(8), JDK_Version::jdk(9) },
296 { "UseOldInlining", JDK_Version::jdk(9), JDK_Version::jdk(10) }, 301 { "UseOldInlining", JDK_Version::jdk(9), JDK_Version::jdk(10) },
302 { "AutoShutdownNMT", JDK_Version::jdk(9), JDK_Version::jdk(10) },
297 #ifdef PRODUCT 303 #ifdef PRODUCT
298 { "DesiredMethodLimit", 304 { "DesiredMethodLimit",
299 JDK_Version::jdk_update(7, 2), JDK_Version::jdk(8) }, 305 JDK_Version::jdk_update(7, 2), JDK_Version::jdk(8) },
300 #endif // PRODUCT 306 #endif // PRODUCT
301 { NULL, JDK_Version(0), JDK_Version(0) } 307 { NULL, JDK_Version(0), JDK_Version(0) }
1106 1112
1107 #if defined(COMPILER2) || defined(_LP64) || !INCLUDE_CDS 1113 #if defined(COMPILER2) || defined(_LP64) || !INCLUDE_CDS
1108 // Conflict: required to use shared spaces (-Xshare:on), but 1114 // Conflict: required to use shared spaces (-Xshare:on), but
1109 // incompatible command line options were chosen. 1115 // incompatible command line options were chosen.
1110 1116
1111 static void no_shared_spaces() { 1117 static void no_shared_spaces(const char* message) {
1112 if (RequireSharedSpaces) { 1118 if (RequireSharedSpaces) {
1113 jio_fprintf(defaultStream::error_stream(), 1119 jio_fprintf(defaultStream::error_stream(),
1114 "Class data sharing is inconsistent with other specified options.\n"); 1120 "Class data sharing is inconsistent with other specified options.\n");
1115 vm_exit_during_initialization("Unable to use shared archive.", NULL); 1121 vm_exit_during_initialization("Unable to use shared archive.", message);
1116 } else { 1122 } else {
1117 FLAG_SET_DEFAULT(UseSharedSpaces, false); 1123 FLAG_SET_DEFAULT(UseSharedSpaces, false);
1118 } 1124 }
1119 } 1125 }
1120 #endif 1126 #endif
1396 jio_fprintf(defaultStream::error_stream(), 1402 jio_fprintf(defaultStream::error_stream(),
1397 "error: ObjectAlignmentInBytes=%d must be less than page size %d\n", 1403 "error: ObjectAlignmentInBytes=%d must be less than page size %d\n",
1398 (int)ObjectAlignmentInBytes, os::vm_page_size()); 1404 (int)ObjectAlignmentInBytes, os::vm_page_size());
1399 return false; 1405 return false;
1400 } 1406 }
1407 if(SurvivorAlignmentInBytes == 0) {
1408 SurvivorAlignmentInBytes = ObjectAlignmentInBytes;
1409 } else {
1410 if (!is_power_of_2(SurvivorAlignmentInBytes)) {
1411 jio_fprintf(defaultStream::error_stream(),
1412 "error: SurvivorAlignmentInBytes=%d must be power of 2\n",
1413 (int)SurvivorAlignmentInBytes);
1414 return false;
1415 }
1416 if (SurvivorAlignmentInBytes < ObjectAlignmentInBytes) {
1417 jio_fprintf(defaultStream::error_stream(),
1418 "error: SurvivorAlignmentInBytes=%d must be greater than ObjectAlignmentInBytes=%d \n",
1419 (int)SurvivorAlignmentInBytes, (int)ObjectAlignmentInBytes);
1420 return false;
1421 }
1422 }
1401 return true; 1423 return true;
1402 } 1424 }
1403 1425
1404 uintx Arguments::max_heap_for_compressed_oops() { 1426 size_t Arguments::max_heap_for_compressed_oops() {
1405 // Avoid sign flip. 1427 // Avoid sign flip.
1406 assert(OopEncodingHeapMax > (uint64_t)os::vm_page_size(), "Unusual page size"); 1428 assert(OopEncodingHeapMax > (uint64_t)os::vm_page_size(), "Unusual page size");
1407 // We need to fit both the NULL page and the heap into the memory budget, while 1429 // We need to fit both the NULL page and the heap into the memory budget, while
1408 // keeping alignment constraints of the heap. To guarantee the latter, as the 1430 // keeping alignment constraints of the heap. To guarantee the latter, as the
1409 // NULL page is located before the heap, we pad the NULL page to the conservative 1431 // NULL page is located before the heap, we pad the NULL page to the conservative
1503 heap_alignment = ParallelScavengeHeap::conservative_max_heap_alignment(); 1525 heap_alignment = ParallelScavengeHeap::conservative_max_heap_alignment();
1504 } else if (UseG1GC) { 1526 } else if (UseG1GC) {
1505 heap_alignment = G1CollectedHeap::conservative_max_heap_alignment(); 1527 heap_alignment = G1CollectedHeap::conservative_max_heap_alignment();
1506 } 1528 }
1507 #endif // INCLUDE_ALL_GCS 1529 #endif // INCLUDE_ALL_GCS
1508 _conservative_max_heap_alignment = MAX3(heap_alignment, os::max_page_size(), 1530 _conservative_max_heap_alignment = MAX4(heap_alignment,
1509 CollectorPolicy::compute_heap_alignment()); 1531 (size_t)os::vm_allocation_granularity(),
1532 os::max_page_size(),
1533 CollectorPolicy::compute_heap_alignment());
1534 }
1535
1536 void Arguments::select_gc_ergonomically() {
1537 if (os::is_server_class_machine()) {
1538 if (should_auto_select_low_pause_collector()) {
1539 FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
1540 } else {
1541 FLAG_SET_ERGO(bool, UseParallelGC, true);
1542 }
1543 }
1544 }
1545
1546 void Arguments::select_gc() {
1547 if (!gc_selected()) {
1548 ArgumentsExt::select_gc_ergonomically();
1549 }
1510 } 1550 }
1511 1551
1512 void Arguments::set_ergonomics_flags() { 1552 void Arguments::set_ergonomics_flags() {
1513 1553 select_gc();
1514 if (os::is_server_class_machine()) { 1554
1515 // If no other collector is requested explicitly,
1516 // let the VM select the collector based on
1517 // machine class and automatic selection policy.
1518 if (!UseSerialGC &&
1519 !UseConcMarkSweepGC &&
1520 !UseG1GC &&
1521 !UseParNewGC &&
1522 FLAG_IS_DEFAULT(UseParallelGC)) {
1523 if (should_auto_select_low_pause_collector()) {
1524 FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
1525 } else {
1526 FLAG_SET_ERGO(bool, UseParallelGC, true);
1527 }
1528 }
1529 }
1530 #ifdef COMPILER2 1555 #ifdef COMPILER2
1531 // Shared spaces work fine with other GCs but causes bytecode rewriting 1556 // Shared spaces work fine with other GCs but causes bytecode rewriting
1532 // to be disabled, which hurts interpreter performance and decreases 1557 // to be disabled, which hurts interpreter performance and decreases
1533 // server performance. When -server is specified, keep the default off 1558 // server performance. When -server is specified, keep the default off
1534 // unless it is asked for. Future work: either add bytecode rewriting 1559 // unless it is asked for. Future work: either add bytecode rewriting
1535 // at link time, or rewrite bytecodes in non-shared methods. 1560 // at link time, or rewrite bytecodes in non-shared methods.
1536 if (!DumpSharedSpaces && !RequireSharedSpaces && 1561 if (!DumpSharedSpaces && !RequireSharedSpaces &&
1537 (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) { 1562 (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) {
1538 no_shared_spaces(); 1563 no_shared_spaces("COMPILER2 default: -Xshare:auto | off, have to manually setup to on.");
1539 } 1564 }
1540 #endif 1565 #endif
1541 1566
1542 set_conservative_max_heap_alignment(); 1567 set_conservative_max_heap_alignment();
1543 1568
1576 if (UseAdaptiveSizePolicy) { 1601 if (UseAdaptiveSizePolicy) {
1577 // We don't want to limit adaptive heap sizing's freedom to adjust the heap 1602 // We don't want to limit adaptive heap sizing's freedom to adjust the heap
1578 // unless the user actually sets these flags. 1603 // unless the user actually sets these flags.
1579 if (FLAG_IS_DEFAULT(MinHeapFreeRatio)) { 1604 if (FLAG_IS_DEFAULT(MinHeapFreeRatio)) {
1580 FLAG_SET_DEFAULT(MinHeapFreeRatio, 0); 1605 FLAG_SET_DEFAULT(MinHeapFreeRatio, 0);
1606 _min_heap_free_ratio = MinHeapFreeRatio;
1581 } 1607 }
1582 if (FLAG_IS_DEFAULT(MaxHeapFreeRatio)) { 1608 if (FLAG_IS_DEFAULT(MaxHeapFreeRatio)) {
1583 FLAG_SET_DEFAULT(MaxHeapFreeRatio, 100); 1609 FLAG_SET_DEFAULT(MaxHeapFreeRatio, 100);
1610 _max_heap_free_ratio = MaxHeapFreeRatio;
1584 } 1611 }
1585 } 1612 }
1586 1613
1587 // If InitialSurvivorRatio or MinSurvivorRatio were not specified, but the 1614 // If InitialSurvivorRatio or MinSurvivorRatio were not specified, but the
1588 // SurvivorRatio has been set, reset their default values to SurvivorRatio + 1615 // SurvivorRatio has been set, reset their default values to SurvivorRatio +
1617 if (ParallelGCThreads == 0) { 1644 if (ParallelGCThreads == 0) {
1618 FLAG_SET_DEFAULT(ParallelGCThreads, 1645 FLAG_SET_DEFAULT(ParallelGCThreads,
1619 Abstract_VM_Version::parallel_worker_threads()); 1646 Abstract_VM_Version::parallel_worker_threads());
1620 } 1647 }
1621 1648
1649 #if INCLUDE_ALL_GCS
1650 if (G1ConcRefinementThreads == 0) {
1651 FLAG_SET_DEFAULT(G1ConcRefinementThreads, ParallelGCThreads);
1652 }
1653 #endif
1654
1622 // MarkStackSize will be set (if it hasn't been set by the user) 1655 // MarkStackSize will be set (if it hasn't been set by the user)
1623 // when concurrent marking is initialized. 1656 // when concurrent marking is initialized.
1624 // Its value will be based upon the number of parallel marking threads. 1657 // Its value will be based upon the number of parallel marking threads.
1625 // But we do set the maximum mark stack size here. 1658 // But we do set the maximum mark stack size here.
1626 if (FLAG_IS_DEFAULT(MarkStackSizeMax)) { 1659 if (FLAG_IS_DEFAULT(MarkStackSizeMax)) {
1640 if (PrintGCDetails && Verbose) { 1673 if (PrintGCDetails && Verbose) {
1641 tty->print_cr("MarkStackSize: %uk MarkStackSizeMax: %uk", 1674 tty->print_cr("MarkStackSize: %uk MarkStackSizeMax: %uk",
1642 (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K)); 1675 (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
1643 tty->print_cr("ConcGCThreads: %u", (uint) ConcGCThreads); 1676 tty->print_cr("ConcGCThreads: %u", (uint) ConcGCThreads);
1644 } 1677 }
1678 }
1679
1680 #if !INCLUDE_ALL_GCS
1681 #ifdef ASSERT
1682 static bool verify_serial_gc_flags() {
1683 return (UseSerialGC &&
1684 !(UseParNewGC || (UseConcMarkSweepGC || CMSIncrementalMode) || UseG1GC ||
1685 UseParallelGC || UseParallelOldGC));
1686 }
1687 #endif // ASSERT
1688 #endif // INCLUDE_ALL_GCS
1689
1690 void Arguments::set_gc_specific_flags() {
1691 #if INCLUDE_ALL_GCS
1692 // Set per-collector flags
1693 if (UseParallelGC || UseParallelOldGC) {
1694 set_parallel_gc_flags();
1695 } else if (UseConcMarkSweepGC) { // Should be done before ParNew check below
1696 set_cms_and_parnew_gc_flags();
1697 } else if (UseParNewGC) { // Skipped if CMS is set above
1698 set_parnew_gc_flags();
1699 } else if (UseG1GC) {
1700 set_g1_gc_flags();
1701 }
1702 check_deprecated_gcs();
1703 check_deprecated_gc_flags();
1704 if (AssumeMP && !UseSerialGC) {
1705 if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) {
1706 warning("If the number of processors is expected to increase from one, then"
1707 " you should configure the number of parallel GC threads appropriately"
1708 " using -XX:ParallelGCThreads=N");
1709 }
1710 }
1711 if (MinHeapFreeRatio == 100) {
1712 // Keeping the heap 100% free is hard ;-) so limit it to 99%.
1713 FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99);
1714 }
1715 #else // INCLUDE_ALL_GCS
1716 assert(verify_serial_gc_flags(), "SerialGC unset");
1717 #endif // INCLUDE_ALL_GCS
1645 } 1718 }
1646 1719
1647 julong Arguments::limit_by_allocatable_memory(julong limit) { 1720 julong Arguments::limit_by_allocatable_memory(julong limit) {
1648 julong max_allocatable; 1721 julong max_allocatable;
1649 julong result = limit; 1722 julong result = limit;
1864 jio_fprintf(defaultStream::error_stream(), 1937 jio_fprintf(defaultStream::error_stream(),
1865 "%s of " UINTX_FORMAT " is invalid; must be between 0 and 100\n", 1938 "%s of " UINTX_FORMAT " is invalid; must be between 0 and 100\n",
1866 name, value); 1939 name, value);
1867 return false; 1940 return false;
1868 } 1941 }
1869
1870 #if !INCLUDE_ALL_GCS
1871 #ifdef ASSERT
1872 static bool verify_serial_gc_flags() {
1873 return (UseSerialGC &&
1874 !(UseParNewGC || (UseConcMarkSweepGC || CMSIncrementalMode) || UseG1GC ||
1875 UseParallelGC || UseParallelOldGC));
1876 }
1877 #endif // ASSERT
1878 #endif // INCLUDE_ALL_GCS
1879 1942
1880 // check if do gclog rotation 1943 // check if do gclog rotation
1881 // +UseGCLogFileRotation is a must, 1944 // +UseGCLogFileRotation is a must,
1882 // no gc log rotation when log file not supplied or 1945 // no gc log rotation when log file not supplied or
1883 // NumberOfGCLogFiles is 0 1946 // NumberOfGCLogFiles is 0
1953 err_msg.print("MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or " 2016 err_msg.print("MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or "
1954 "equal to MaxHeapFreeRatio (" UINTX_FORMAT ")", min_heap_free_ratio, 2017 "equal to MaxHeapFreeRatio (" UINTX_FORMAT ")", min_heap_free_ratio,
1955 MaxHeapFreeRatio); 2018 MaxHeapFreeRatio);
1956 return false; 2019 return false;
1957 } 2020 }
2021 // This does not set the flag itself, but stores the value in a safe place for later usage.
2022 _min_heap_free_ratio = min_heap_free_ratio;
1958 return true; 2023 return true;
1959 } 2024 }
1960 2025
1961 bool Arguments::verify_MaxHeapFreeRatio(FormatBuffer<80>& err_msg, uintx max_heap_free_ratio) { 2026 bool Arguments::verify_MaxHeapFreeRatio(FormatBuffer<80>& err_msg, uintx max_heap_free_ratio) {
1962 if (!is_percentage(max_heap_free_ratio)) { 2027 if (!is_percentage(max_heap_free_ratio)) {
1967 err_msg.print("MaxHeapFreeRatio (" UINTX_FORMAT ") must be greater than or " 2032 err_msg.print("MaxHeapFreeRatio (" UINTX_FORMAT ") must be greater than or "
1968 "equal to MinHeapFreeRatio (" UINTX_FORMAT ")", max_heap_free_ratio, 2033 "equal to MinHeapFreeRatio (" UINTX_FORMAT ")", max_heap_free_ratio,
1969 MinHeapFreeRatio); 2034 MinHeapFreeRatio);
1970 return false; 2035 return false;
1971 } 2036 }
2037 // This does not set the flag itself, but stores the value in a safe place for later usage.
2038 _max_heap_free_ratio = max_heap_free_ratio;
1972 return true; 2039 return true;
1973 } 2040 }
1974 2041
1975 // Check consistency of GC selection 2042 // Check consistency of GC selection
1976 bool Arguments::check_gc_consistency() { 2043 bool Arguments::check_gc_consistency_user() {
1977 check_gclog_consistency(); 2044 check_gclog_consistency();
1978 bool status = true; 2045 bool status = true;
1979 // Ensure that the user has not selected conflicting sets 2046 // Ensure that the user has not selected conflicting sets
1980 // of collectors. [Note: this check is merely a user convenience; 2047 // of collectors. [Note: this check is merely a user convenience;
1981 // collectors over-ride each other so that only a non-conflicting 2048 // collectors over-ride each other so that only a non-conflicting
2137 if (GCTimeLimit == 100) { 2204 if (GCTimeLimit == 100) {
2138 // Turn off gc-overhead-limit-exceeded checks 2205 // Turn off gc-overhead-limit-exceeded checks
2139 FLAG_SET_DEFAULT(UseGCOverheadLimit, false); 2206 FLAG_SET_DEFAULT(UseGCOverheadLimit, false);
2140 } 2207 }
2141 2208
2142 status = status && check_gc_consistency(); 2209 status = status && ArgumentsExt::check_gc_consistency_user();
2143 status = status && check_stack_pages(); 2210 status = status && check_stack_pages();
2144 2211
2145 if (CMSIncrementalMode) { 2212 if (CMSIncrementalMode) {
2146 if (!UseConcMarkSweepGC) { 2213 if (!UseConcMarkSweepGC) {
2147 jio_fprintf(defaultStream::error_stream(), 2214 jio_fprintf(defaultStream::error_stream(),
2320 status = status && verify_interval(InitialTenuringThreshold, 0, MaxTenuringThreshold, "MaxTenuringThreshold"); 2387 status = status && verify_interval(InitialTenuringThreshold, 0, MaxTenuringThreshold, "MaxTenuringThreshold");
2321 status = status && verify_percentage(TargetSurvivorRatio, "TargetSurvivorRatio"); 2388 status = status && verify_percentage(TargetSurvivorRatio, "TargetSurvivorRatio");
2322 status = status && verify_percentage(MarkSweepDeadRatio, "MarkSweepDeadRatio"); 2389 status = status && verify_percentage(MarkSweepDeadRatio, "MarkSweepDeadRatio");
2323 2390
2324 status = status && verify_min_value(MarkSweepAlwaysCompactCount, 1, "MarkSweepAlwaysCompactCount"); 2391 status = status && verify_min_value(MarkSweepAlwaysCompactCount, 1, "MarkSweepAlwaysCompactCount");
2392 #ifdef COMPILER1
2393 status = status && verify_min_value(ValueMapInitialSize, 1, "ValueMapInitialSize");
2394 #endif
2325 2395
2326 if (PrintNMTStatistics) { 2396 if (PrintNMTStatistics) {
2327 #if INCLUDE_NMT 2397 #if INCLUDE_NMT
2328 if (MemTracker::tracking_level() == MemTracker::NMT_off) { 2398 if (MemTracker::tracking_level() == NMT_off) {
2329 #endif // INCLUDE_NMT 2399 #endif // INCLUDE_NMT
2330 warning("PrintNMTStatistics is disabled, because native memory tracking is not enabled"); 2400 warning("PrintNMTStatistics is disabled, because native memory tracking is not enabled");
2331 PrintNMTStatistics = false; 2401 PrintNMTStatistics = false;
2332 #if INCLUDE_NMT 2402 #if INCLUDE_NMT
2333 } 2403 }
3224 } else if (is_bad_option(option, args->ignoreUnrecognized)) { 3294 } else if (is_bad_option(option, args->ignoreUnrecognized)) {
3225 return JNI_ERR; 3295 return JNI_ERR;
3226 } 3296 }
3227 } 3297 }
3228 3298
3299 // PrintSharedArchiveAndExit will turn on
3300 // -Xshare:on
3301 // -XX:+TraceClassPaths
3302 if (PrintSharedArchiveAndExit) {
3303 FLAG_SET_CMDLINE(bool, UseSharedSpaces, true);
3304 FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true);
3305 FLAG_SET_CMDLINE(bool, TraceClassPaths, true);
3306 }
3307
3229 // Change the default value for flags which have different default values 3308 // Change the default value for flags which have different default values
3230 // when working with older JDKs. 3309 // when working with older JDKs.
3231 #ifdef LINUX 3310 #ifdef LINUX
3232 if (JDK_Version::current().compare_major(6) <= 0 && 3311 if (JDK_Version::current().compare_major(6) <= 0 &&
3233 FLAG_IS_DEFAULT(UseLinuxPosixThreadCPUClocks)) { 3312 FLAG_IS_DEFAULT(UseLinuxPosixThreadCPUClocks)) {
3234 FLAG_SET_DEFAULT(UseLinuxPosixThreadCPUClocks, false); 3313 FLAG_SET_DEFAULT(UseLinuxPosixThreadCPUClocks, false);
3235 } 3314 }
3236 #endif // LINUX 3315 #endif // LINUX
3316 fix_appclasspath();
3237 return JNI_OK; 3317 return JNI_OK;
3318 }
3319
3320 // Remove all empty paths from the app classpath (if IgnoreEmptyClassPaths is enabled)
3321 //
3322 // This is necessary because some apps like to specify classpath like -cp foo.jar:${XYZ}:bar.jar
3323 // in their start-up scripts. If XYZ is empty, the classpath will look like "-cp foo.jar::bar.jar".
3324 // Java treats such empty paths as if the user specified "-cp foo.jar:.:bar.jar". I.e., an empty
3325 // path is treated as the current directory.
3326 //
3327 // This causes problems with CDS, which requires that all directories specified in the classpath
3328 // must be empty. In most cases, applications do NOT want to load classes from the current
3329 // directory anyway. Adding -XX:+IgnoreEmptyClassPaths will make these applications' start-up
3330 // scripts compatible with CDS.
3331 void Arguments::fix_appclasspath() {
3332 if (IgnoreEmptyClassPaths) {
3333 const char separator = *os::path_separator();
3334 const char* src = _java_class_path->value();
3335
3336 // skip over all the leading empty paths
3337 while (*src == separator) {
3338 src ++;
3339 }
3340
3341 char* copy = AllocateHeap(strlen(src) + 1, mtInternal);
3342 strncpy(copy, src, strlen(src) + 1);
3343
3344 // trim all trailing empty paths
3345 for (char* tail = copy + strlen(copy) - 1; tail >= copy && *tail == separator; tail--) {
3346 *tail = '\0';
3347 }
3348
3349 char from[3] = {separator, separator, '\0'};
3350 char to [2] = {separator, '\0'};
3351 while (StringUtils::replace_no_expand(copy, from, to) > 0) {
3352 // Keep replacing "::" -> ":" until we have no more "::" (non-windows)
3353 // Keep replacing ";;" -> ";" until we have no more ";;" (windows)
3354 }
3355
3356 _java_class_path->set_value(copy);
3357 FreeHeap(copy); // a copy was made by set_value, so don't need this anymore
3358 }
3359
3360 if (!PrintSharedArchiveAndExit) {
3361 ClassLoader::trace_class_path("[classpath: ", _java_class_path->value());
3362 }
3238 } 3363 }
3239 3364
3240 jint Arguments::finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_required) { 3365 jint Arguments::finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_required) {
3241 // This must be done after all -D arguments have been processed. 3366 // This must be done after all -D arguments have been processed.
3242 scp_p->expand_endorsed(); 3367 scp_p->expand_endorsed();
3304 } 3429 }
3305 } 3430 }
3306 } 3431 }
3307 } 3432 }
3308 3433
3309 if (!check_vm_args_consistency()) { 3434 if (!ArgumentsExt::check_vm_args_consistency()) {
3310 return JNI_ERR; 3435 return JNI_ERR;
3311 } 3436 }
3312 3437
3313 return JNI_OK; 3438 return JNI_OK;
3314 } 3439 }
3405 if (!UseCompressedOops || !UseCompressedClassPointers) { 3530 if (!UseCompressedOops || !UseCompressedClassPointers) {
3406 vm_exit_during_initialization( 3531 vm_exit_during_initialization(
3407 "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL); 3532 "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL);
3408 } 3533 }
3409 } else { 3534 } else {
3410 // UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces.
3411 if (!UseCompressedOops || !UseCompressedClassPointers) { 3535 if (!UseCompressedOops || !UseCompressedClassPointers) {
3412 no_shared_spaces(); 3536 no_shared_spaces("UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces.");
3413 } 3537 }
3414 #endif 3538 #endif
3415 } 3539 }
3416 } 3540 }
3417 3541
3515 } 3639 }
3516 if (match_option(option, "-XX:+PrintFlagsInitial", &tail)) { 3640 if (match_option(option, "-XX:+PrintFlagsInitial", &tail)) {
3517 CommandLineFlags::printFlags(tty, false); 3641 CommandLineFlags::printFlags(tty, false);
3518 vm_exit(0); 3642 vm_exit(0);
3519 } 3643 }
3644 #if INCLUDE_NMT
3520 if (match_option(option, "-XX:NativeMemoryTracking", &tail)) { 3645 if (match_option(option, "-XX:NativeMemoryTracking", &tail)) {
3521 #if INCLUDE_NMT 3646 // The launcher did not setup nmt environment variable properly.
3522 MemTracker::init_tracking_options(tail); 3647 if (!MemTracker::check_launcher_nmt_support(tail)) {
3523 #else 3648 warning("Native Memory Tracking did not setup properly, using wrong launcher?");
3524 jio_fprintf(defaultStream::error_stream(), 3649 }
3525 "Native Memory Tracking is not supported in this VM\n"); 3650
3526 return JNI_ERR; 3651 // Verify if nmt option is valid.
3652 if (MemTracker::verify_nmt_option()) {
3653 // Late initialization, still in single-threaded mode.
3654 if (MemTracker::tracking_level() >= NMT_summary) {
3655 MemTracker::init();
3656 }
3657 } else {
3658 vm_exit_during_initialization("Syntax error, expecting -XX:NativeMemoryTracking=[off|summary|detail]", NULL);
3659 }
3660 }
3527 #endif 3661 #endif
3528 }
3529 3662
3530 3663
3531 #ifndef PRODUCT 3664 #ifndef PRODUCT
3532 if (match_option(option, "-XX:+PrintFlagsWithComments", &tail)) { 3665 if (match_option(option, "-XX:+PrintFlagsWithComments", &tail)) {
3533 CommandLineFlags::printFlags(tty, true); 3666 CommandLineFlags::printFlags(tty, true);
3661 if ((UseSharedSpaces && FLAG_IS_CMDLINE(UseSharedSpaces)) || PrintSharedSpaces) { 3794 if ((UseSharedSpaces && FLAG_IS_CMDLINE(UseSharedSpaces)) || PrintSharedSpaces) {
3662 warning("Shared spaces are not supported in this VM"); 3795 warning("Shared spaces are not supported in this VM");
3663 FLAG_SET_DEFAULT(UseSharedSpaces, false); 3796 FLAG_SET_DEFAULT(UseSharedSpaces, false);
3664 FLAG_SET_DEFAULT(PrintSharedSpaces, false); 3797 FLAG_SET_DEFAULT(PrintSharedSpaces, false);
3665 } 3798 }
3666 no_shared_spaces(); 3799 no_shared_spaces("CDS Disabled");
3667 #endif // INCLUDE_CDS 3800 #endif // INCLUDE_CDS
3668 3801
3669 return JNI_OK; 3802 return JNI_OK;
3670 } 3803 }
3671 3804
3675 set_ergonomics_flags(); 3808 set_ergonomics_flags();
3676 3809
3677 set_shared_spaces_flags(); 3810 set_shared_spaces_flags();
3678 3811
3679 // Check the GC selections again. 3812 // Check the GC selections again.
3680 if (!check_gc_consistency()) { 3813 if (!ArgumentsExt::check_gc_consistency_ergo()) {
3681 return JNI_EINVAL; 3814 return JNI_EINVAL;
3682 } 3815 }
3683 3816
3684 if (TieredCompilation) { 3817 if (TieredCompilation) {
3685 set_tiered_flags(); 3818 set_tiered_flags();
3697 3830
3698 3831
3699 // Set heap size based on available physical memory 3832 // Set heap size based on available physical memory
3700 set_heap_size(); 3833 set_heap_size();
3701 3834
3702 #if INCLUDE_ALL_GCS 3835 set_gc_specific_flags();
3703 // Set per-collector flags
3704 if (UseParallelGC || UseParallelOldGC) {
3705 set_parallel_gc_flags();
3706 } else if (UseConcMarkSweepGC) { // Should be done before ParNew check below
3707 set_cms_and_parnew_gc_flags();
3708 } else if (UseParNewGC) { // Skipped if CMS is set above
3709 set_parnew_gc_flags();
3710 } else if (UseG1GC) {
3711 set_g1_gc_flags();
3712 }
3713 check_deprecated_gcs();
3714 check_deprecated_gc_flags();
3715 if (AssumeMP && !UseSerialGC) {
3716 if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) {
3717 warning("If the number of processors is expected to increase from one, then"
3718 " you should configure the number of parallel GC threads appropriately"
3719 " using -XX:ParallelGCThreads=N");
3720 }
3721 }
3722 if (MinHeapFreeRatio == 100) {
3723 // Keeping the heap 100% free is hard ;-) so limit it to 99%.
3724 FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99);
3725 }
3726 #else // INCLUDE_ALL_GCS
3727 assert(verify_serial_gc_flags(), "SerialGC unset");
3728 #endif // INCLUDE_ALL_GCS
3729 3836
3730 // Initialize Metaspace flags and alignments. 3837 // Initialize Metaspace flags and alignments.
3731 Metaspace::ergo_initialize(); 3838 Metaspace::ergo_initialize();
3732 3839
3733 // Set bytecode rewriting flags 3840 // Set bytecode rewriting flags
3779 } 3886 }
3780 if (!UseTypeSpeculation && FLAG_IS_DEFAULT(TypeProfileLevel)) { 3887 if (!UseTypeSpeculation && FLAG_IS_DEFAULT(TypeProfileLevel)) {
3781 // nothing to use the profiling, turn if off 3888 // nothing to use the profiling, turn if off
3782 FLAG_SET_DEFAULT(TypeProfileLevel, 0); 3889 FLAG_SET_DEFAULT(TypeProfileLevel, 0);
3783 } 3890 }
3784 if (UseTypeSpeculation && FLAG_IS_DEFAULT(ReplaceInParentMaps)) {
3785 // Doing the replace in parent maps helps speculation
3786 FLAG_SET_DEFAULT(ReplaceInParentMaps, true);
3787 }
3788 #endif 3891 #endif
3789 3892
3790 if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) { 3893 if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3791 warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output"); 3894 warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3792 DebugNonSafepoints = true; 3895 DebugNonSafepoints = true;
3840 3943
3841 return JNI_OK; 3944 return JNI_OK;
3842 } 3945 }
3843 3946
3844 jint Arguments::adjust_after_os() { 3947 jint Arguments::adjust_after_os() {
3845 #if INCLUDE_ALL_GCS 3948 if (UseNUMA) {
3846 if (UseParallelGC || UseParallelOldGC) { 3949 if (UseParallelGC || UseParallelOldGC) {
3847 if (UseNUMA) {
3848 if (FLAG_IS_DEFAULT(MinHeapDeltaBytes)) { 3950 if (FLAG_IS_DEFAULT(MinHeapDeltaBytes)) {
3849 FLAG_SET_DEFAULT(MinHeapDeltaBytes, 64*M); 3951 FLAG_SET_DEFAULT(MinHeapDeltaBytes, 64*M);
3850 } 3952 }
3851 // For those collectors or operating systems (eg, Windows) that do 3953 }
3852 // not support full UseNUMA, we will map to UseNUMAInterleaving for now 3954 // UseNUMAInterleaving is set to ON for all collectors and
3853 UseNUMAInterleaving = true; 3955 // platforms when UseNUMA is set to ON. NUMA-aware collectors
3854 } 3956 // such as the parallel collector for Linux and Solaris will
3855 } 3957 // interleave old gen and survivor spaces on top of NUMA
3856 #endif // INCLUDE_ALL_GCS 3958 // allocation policy for the eden space.
3959 // Non NUMA-aware collectors such as CMS, G1 and Serial-GC on
3960 // all platforms and ParallelGC on Windows will interleave all
3961 // of the heap spaces across NUMA nodes.
3962 if (FLAG_IS_DEFAULT(UseNUMAInterleaving)) {
3963 FLAG_SET_ERGO(bool, UseNUMAInterleaving, true);
3964 }
3965 }
3857 return JNI_OK; 3966 return JNI_OK;
3858 } 3967 }
3859 3968
3860 int Arguments::PropertyList_count(SystemProperty* pl) { 3969 int Arguments::PropertyList_count(SystemProperty* pl) {
3861 int count = 0; 3970 int count = 0;

mercurial