< prev index next >

src/hotspot/share/runtime/arguments.cpp

Print this page




 520 // version is incremented, but the source code needs to be cleanup up manually:
 521 // - As "deprecated" options age into "obsolete" or "expired" options, the associated "globals"
 522 //   variable should be removed, as well as users of the variable.
 523 // - As "deprecated" options age into "obsolete" options, move the entry into the
 524 //   "Obsolete Flags" section of the table.
 525 // - All expired options should be removed from the table.
 526 static SpecialFlag const special_jvm_flags[] = {
 527   // -------------- Deprecated Flags --------------
 528   // --- Non-alias flags - sorted by obsolete_in then expired_in:
 529   { "MaxGCMinorPauseMillis",        JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() },
 530   { "UseConcMarkSweepGC",           JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() },
 531   { "MaxRAMFraction",               JDK_Version::jdk(10),  JDK_Version::undefined(), JDK_Version::undefined() },
 532   { "MinRAMFraction",               JDK_Version::jdk(10),  JDK_Version::undefined(), JDK_Version::undefined() },
 533   { "InitialRAMFraction",           JDK_Version::jdk(10),  JDK_Version::undefined(), JDK_Version::undefined() },
 534   { "UseMembar",                    JDK_Version::jdk(10), JDK_Version::jdk(12), JDK_Version::undefined() },
 535   { "CompilationPolicyChoice",      JDK_Version::jdk(13), JDK_Version::jdk(14), JDK_Version::undefined() },
 536   { "FailOverToOldVerifier",        JDK_Version::jdk(13), JDK_Version::jdk(14), JDK_Version::undefined() },
 537   { "AllowJNIEnvProxy",             JDK_Version::jdk(13), JDK_Version::jdk(14), JDK_Version::jdk(15) },
 538   { "ThreadLocalHandshakes",        JDK_Version::jdk(13), JDK_Version::jdk(14), JDK_Version::jdk(15) },
 539   { "AllowRedefinitionToAddDeleteMethods", JDK_Version::jdk(13), JDK_Version::undefined(), JDK_Version::undefined() },
 540   { "FlightRecorder",               JDK_Version::jdk(13), JDK_Version::undefined(), JDK_Version::undefined() },
 541 
 542   // --- Deprecated alias flags (see also aliased_jvm_flags) - sorted by obsolete_in then expired_in:
 543   { "DefaultMaxRAMFraction",        JDK_Version::jdk(8),  JDK_Version::undefined(), JDK_Version::undefined() },
 544   { "CreateMinidumpOnCrash",        JDK_Version::jdk(9),  JDK_Version::undefined(), JDK_Version::undefined() },
 545   { "TLABStats",                    JDK_Version::jdk(12), JDK_Version::undefined(), JDK_Version::undefined() },
 546 
 547   // -------------- Obsolete Flags - sorted by expired_in --------------
 548   { "PermSize",                      JDK_Version::undefined(), JDK_Version::jdk(8),  JDK_Version::undefined() },
 549   { "MaxPermSize",                   JDK_Version::undefined(), JDK_Version::jdk(8),  JDK_Version::undefined() },
 550   { "SharedReadWriteSize",           JDK_Version::undefined(), JDK_Version::jdk(10), JDK_Version::undefined() },
 551   { "SharedReadOnlySize",            JDK_Version::undefined(), JDK_Version::jdk(10), JDK_Version::undefined() },
 552   { "SharedMiscDataSize",            JDK_Version::undefined(), JDK_Version::jdk(10), JDK_Version::undefined() },
 553   { "SharedMiscCodeSize",            JDK_Version::undefined(), JDK_Version::jdk(10), JDK_Version::undefined() },
 554   { "ProfilerPrintByteCodeStatistics", JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) },
 555   { "ProfilerRecordPC",              JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) },
 556   { "ProfileVM",                     JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) },
 557   { "ProfileIntervals",              JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) },
 558   { "ProfileIntervalsTicks",         JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) },
 559   { "ProfilerCheckIntervals",        JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) },
 560   { "ProfilerNumberOfInterpretedMethods", JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) },


 588   { "CreateMinidumpOnCrash",    "CreateCoredumpOnCrash" },
 589   { NULL, NULL}
 590 };
 591 
 592 // NOTE: A compatibility request will be necessary for each alias to be removed.
 593 static AliasedLoggingFlag const aliased_logging_flags[] = {
 594   { "PrintCompressedOopsMode",   LogLevel::Info,  true,  LOG_TAGS(gc, heap, coops) },
 595   { "PrintSharedSpaces",         LogLevel::Info,  true,  LOG_TAGS(cds) },
 596   { "TraceBiasedLocking",        LogLevel::Info,  true,  LOG_TAGS(biasedlocking) },
 597   { "TraceClassLoading",         LogLevel::Info,  true,  LOG_TAGS(class, load) },
 598   { "TraceClassLoadingPreorder", LogLevel::Debug, true,  LOG_TAGS(class, preorder) },
 599   { "TraceClassPaths",           LogLevel::Info,  true,  LOG_TAGS(class, path) },
 600   { "TraceClassResolution",      LogLevel::Debug, true,  LOG_TAGS(class, resolve) },
 601   { "TraceClassUnloading",       LogLevel::Info,  true,  LOG_TAGS(class, unload) },
 602   { "TraceExceptions",           LogLevel::Info,  true,  LOG_TAGS(exceptions) },
 603   { "TraceLoaderConstraints",    LogLevel::Info,  true,  LOG_TAGS(class, loader, constraints) },
 604   { "TraceMonitorInflation",     LogLevel::Trace, true,  LOG_TAGS(monitorinflation) },
 605   { "TraceSafepointCleanupTime", LogLevel::Info,  true,  LOG_TAGS(safepoint, cleanup) },
 606   { "TraceJVMTIObjectTagging",   LogLevel::Debug, true,  LOG_TAGS(jvmti, objecttagging) },
 607   { "TraceRedefineClasses",      LogLevel::Info,  false, LOG_TAGS(redefine, class) },
 608   { "TraceNMethodInstalls",      LogLevel::Info,  true,  LOG_TAGS(nmethod, install) },
 609   { NULL,                        LogLevel::Off,   false, LOG_TAGS(_NO_TAG) }
 610 };
 611 
 612 #ifndef PRODUCT
 613 // These options are removed in jdk9. Remove this code for jdk10.
 614 static AliasedFlag const removed_develop_logging_flags[] = {
 615   { "TraceClassInitialization",   "-Xlog:class+init" },
 616   { "TraceClassLoaderData",       "-Xlog:class+loader+data" },
 617   { "TraceDefaultMethods",        "-Xlog:defaultmethods=debug" },
 618   { "TraceItables",               "-Xlog:itables=debug" },
 619   { "TraceMonitorMismatch",       "-Xlog:monitormismatch=info" },
 620   { "TraceSafepoint",             "-Xlog:safepoint=debug" },
 621   { "TraceStartupTime",           "-Xlog:startuptime" },
 622   { "TraceVMOperation",           "-Xlog:vmoperation=debug" },
 623   { "PrintVtables",               "-Xlog:vtables=debug" },
 624   { "VerboseVerification",        "-Xlog:verification" },
 625   { NULL, NULL }
 626 };
 627 #endif //PRODUCT
 628 


1613 
1614 size_t Arguments::max_heap_for_compressed_oops() {
1615   // Avoid sign flip.
1616   assert(OopEncodingHeapMax > (uint64_t)os::vm_page_size(), "Unusual page size");
1617   // We need to fit both the NULL page and the heap into the memory budget, while
1618   // keeping alignment constraints of the heap. To guarantee the latter, as the
1619   // NULL page is located before the heap, we pad the NULL page to the conservative
1620   // maximum alignment that the GC may ever impose upon the heap.
1621   size_t displacement_due_to_null_page = align_up((size_t)os::vm_page_size(),
1622                                                   _conservative_max_heap_alignment);
1623 
1624   LP64_ONLY(return OopEncodingHeapMax - displacement_due_to_null_page);
1625   NOT_LP64(ShouldNotReachHere(); return 0);
1626 }
1627 
1628 void Arguments::set_use_compressed_oops() {
1629 #ifndef ZERO
1630 #ifdef _LP64
1631   // MaxHeapSize is not set up properly at this point, but
1632   // the only value that can override MaxHeapSize if we are
1633   // to use UseCompressedOops are InitialHeapSize and MinHeapSize.
1634   size_t max_heap_size = MAX3(MaxHeapSize, InitialHeapSize, MinHeapSize);
1635 
1636   if (max_heap_size <= max_heap_for_compressed_oops()) {
1637 #if !defined(COMPILER1) || defined(TIERED)
1638     if (FLAG_IS_DEFAULT(UseCompressedOops)) {
1639       FLAG_SET_ERGO(UseCompressedOops, true);
1640     }
1641 #endif
1642   } else {
1643     if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) {
1644       warning("Max heap size too large for Compressed Oops");
1645       FLAG_SET_DEFAULT(UseCompressedOops, false);
1646       FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1647     }
1648   }
1649 #endif // _LP64
1650 #endif // ZERO
1651 }
1652 
1653 
1654 // NOTE: set_use_compressed_klass_ptrs() must be called after calling


1767 
1768   // If the maximum heap size has not been set with -Xmx,
1769   // then set it as fraction of the size of physical memory,
1770   // respecting the maximum and minimum sizes of the heap.
1771   if (FLAG_IS_DEFAULT(MaxHeapSize)) {
1772     julong reasonable_max = (julong)((phys_mem * MaxRAMPercentage) / 100);
1773     const julong reasonable_min = (julong)((phys_mem * MinRAMPercentage) / 100);
1774     if (reasonable_min < MaxHeapSize) {
1775       // Small physical memory, so use a minimum fraction of it for the heap
1776       reasonable_max = reasonable_min;
1777     } else {
1778       // Not-small physical memory, so require a heap at least
1779       // as large as MaxHeapSize
1780       reasonable_max = MAX2(reasonable_max, (julong)MaxHeapSize);
1781     }
1782 
1783     if (!FLAG_IS_DEFAULT(ErgoHeapSizeLimit) && ErgoHeapSizeLimit != 0) {
1784       // Limit the heap size to ErgoHeapSizeLimit
1785       reasonable_max = MIN2(reasonable_max, (julong)ErgoHeapSizeLimit);
1786     }
1787 
1788 #ifdef _LP64
1789     if (UseCompressedOops) {
1790       // Limit the heap size to the maximum possible when using compressed oops
1791       julong max_coop_heap = (julong)max_heap_for_compressed_oops();
1792 
1793       // HeapBaseMinAddress can be greater than default but not less than.
1794       if (!FLAG_IS_DEFAULT(HeapBaseMinAddress)) {
1795         if (HeapBaseMinAddress < DefaultHeapBaseMinAddress) {
1796           // matches compressed oops printing flags
1797           log_debug(gc, heap, coops)("HeapBaseMinAddress must be at least " SIZE_FORMAT
1798                                      " (" SIZE_FORMAT "G) which is greater than value given " SIZE_FORMAT,
1799                                      DefaultHeapBaseMinAddress,
1800                                      DefaultHeapBaseMinAddress/G,
1801                                      HeapBaseMinAddress);
1802           FLAG_SET_ERGO(HeapBaseMinAddress, DefaultHeapBaseMinAddress);
1803         }
1804       }
1805 
1806       if (HeapBaseMinAddress + MaxHeapSize < max_coop_heap) {
1807         // Heap should be above HeapBaseMinAddress to get zero based compressed oops
1808         // but it should be not less than default MaxHeapSize.
1809         max_coop_heap -= HeapBaseMinAddress;
1810       }
1811 
1812       // If user specified flags prioritizing os physical
1813       // memory limits, then disable compressed oops if
1814       // limits exceed max_coop_heap and UseCompressedOops
1815       // was not specified.
1816       if (reasonable_max > max_coop_heap) {
1817         if (FLAG_IS_ERGO(UseCompressedOops) && override_coop_limit) {
1818           FLAG_SET_ERGO(UseCompressedOops, false);
1819           FLAG_SET_ERGO(UseCompressedClassPointers, false);
1820         } else {
1821           reasonable_max = MIN2(reasonable_max, max_coop_heap);
1822         }
1823       }
1824     }
1825 #endif // _LP64
1826 
1827     reasonable_max = limit_by_allocatable_memory(reasonable_max);
1828 
1829     if (!FLAG_IS_DEFAULT(InitialHeapSize)) {
1830       // An initial heap size was specified on the command line,
1831       // so be sure that the maximum size is consistent.  Done
1832       // after call to limit_by_allocatable_memory because that
1833       // method might reduce the allocation size.
1834       reasonable_max = MAX2(reasonable_max, (julong)InitialHeapSize);
1835     } else if (!FLAG_IS_DEFAULT(MinHeapSize)) {
1836       reasonable_max = MAX2(reasonable_max, (julong)MinHeapSize);
1837     }
1838 
1839     log_trace(gc, heap)("  Maximum heap size " SIZE_FORMAT, (size_t) reasonable_max);
1840     FLAG_SET_ERGO(MaxHeapSize, (size_t)reasonable_max);
1841   }
1842 
1843   // If the minimum or initial heap_size have not been set or requested to be set
1844   // ergonomically, set them accordingly.
1845   if (InitialHeapSize == 0 || MinHeapSize == 0) {
1846     julong reasonable_minimum = (julong)(OldSize + NewSize);
1847 
1848     reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize);
1849 
1850     reasonable_minimum = limit_by_allocatable_memory(reasonable_minimum);
1851 
1852     if (InitialHeapSize == 0) {
1853       julong reasonable_initial = (julong)((phys_mem * InitialRAMPercentage) / 100);
1854 
1855       reasonable_initial = MAX3(reasonable_initial, reasonable_minimum, (julong)MinHeapSize);
1856       reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize);
1857 
1858       reasonable_initial = limit_by_allocatable_memory(reasonable_initial);
1859 

1860       FLAG_SET_ERGO(InitialHeapSize, (size_t)reasonable_initial);
1861       log_trace(gc, heap)("  Initial heap size " SIZE_FORMAT, InitialHeapSize);
1862     }
1863     // If the minimum heap size has not been set (via -Xms or -XX:MinHeapSize),
1864     // synchronize with InitialHeapSize to avoid errors with the default value.
1865     if (MinHeapSize == 0) {
1866       FLAG_SET_ERGO(MinHeapSize, MIN2((size_t)reasonable_minimum, InitialHeapSize));
1867       log_trace(gc, heap)("  Minimum heap size " SIZE_FORMAT, MinHeapSize);
1868     }
1869   }
1870 }
1871 
1872 // This option inspects the machine and attempts to set various
1873 // parameters to be optimal for long-running, memory allocation
1874 // intensive jobs.  It is intended for machines with large
1875 // amounts of cpu and memory.
1876 jint Arguments::set_aggressive_heap_flags() {
1877   // initHeapSize is needed since _initial_heap_size is 4 bytes on a 32 bit
1878   // VM, but we may not be able to represent the total physical memory
1879   // available (like having 8gb of memory on a box but using a 32bit VM).
1880   // Thus, we need to make sure we're using a julong for intermediate
1881   // calculations.
1882   julong initHeapSize;
1883   julong total_memory = os::physical_memory();
1884 
1885   if (total_memory < (julong) 256 * M) {
1886     jio_fprintf(defaultStream::error_stream(),


1888     vm_exit(1);
1889   }
1890 
1891   // The heap size is half of available memory, or (at most)
1892   // all of possible memory less 160mb (leaving room for the OS
1893   // when using ISM).  This is the maximum; because adaptive sizing
1894   // is turned on below, the actual space used may be smaller.
1895 
1896   initHeapSize = MIN2(total_memory / (julong) 2,
1897           total_memory - (julong) 160 * M);
1898 
1899   initHeapSize = limit_by_allocatable_memory(initHeapSize);
1900 
1901   if (FLAG_IS_DEFAULT(MaxHeapSize)) {
1902     if (FLAG_SET_CMDLINE(MaxHeapSize, initHeapSize) != JVMFlag::SUCCESS) {
1903       return JNI_EINVAL;
1904     }
1905     if (FLAG_SET_CMDLINE(InitialHeapSize, initHeapSize) != JVMFlag::SUCCESS) {
1906       return JNI_EINVAL;
1907     }
1908     if (FLAG_SET_CMDLINE(MinHeapSize, initHeapSize) != JVMFlag::SUCCESS) {
1909       return JNI_EINVAL;
1910     }
1911   }
1912   if (FLAG_IS_DEFAULT(NewSize)) {
1913     // Make the young generation 3/8ths of the total heap.
1914     if (FLAG_SET_CMDLINE(NewSize,
1915             ((julong) MaxHeapSize / (julong) 8) * (julong) 3) != JVMFlag::SUCCESS) {
1916       return JNI_EINVAL;
1917     }
1918     if (FLAG_SET_CMDLINE(MaxNewSize, NewSize) != JVMFlag::SUCCESS) {
1919       return JNI_EINVAL;
1920     }
1921   }
1922 
1923 #if !defined(_ALLBSD_SOURCE) && !defined(AIX)  // UseLargePages is not yet supported on BSD and AIX.
1924   FLAG_SET_DEFAULT(UseLargePages, true);
1925 #endif
1926 
1927   // Increase some data structure sizes for efficiency
1928   if (FLAG_SET_CMDLINE(BaseFootPrintEstimate, MaxHeapSize) != JVMFlag::SUCCESS) {
1929     return JNI_EINVAL;
1930   }


2581         return JNI_EINVAL;
2582       }
2583     // -Xmn for compatibility with other JVM vendors
2584     } else if (match_option(option, "-Xmn", &tail)) {
2585       julong long_initial_young_size = 0;
2586       ArgsRange errcode = parse_memory_size(tail, &long_initial_young_size, 1);
2587       if (errcode != arg_in_range) {
2588         jio_fprintf(defaultStream::error_stream(),
2589                     "Invalid initial young generation size: %s\n", option->optionString);
2590         describe_range_error(errcode);
2591         return JNI_EINVAL;
2592       }
2593       if (FLAG_SET_CMDLINE(MaxNewSize, (size_t)long_initial_young_size) != JVMFlag::SUCCESS) {
2594         return JNI_EINVAL;
2595       }
2596       if (FLAG_SET_CMDLINE(NewSize, (size_t)long_initial_young_size) != JVMFlag::SUCCESS) {
2597         return JNI_EINVAL;
2598       }
2599     // -Xms
2600     } else if (match_option(option, "-Xms", &tail)) {
2601       julong size = 0;
2602       // an initial heap size of 0 means automatically determine
2603       ArgsRange errcode = parse_memory_size(tail, &size, 0);
2604       if (errcode != arg_in_range) {
2605         jio_fprintf(defaultStream::error_stream(),
2606                     "Invalid initial heap size: %s\n", option->optionString);
2607         describe_range_error(errcode);
2608         return JNI_EINVAL;
2609       }
2610       if (FLAG_SET_CMDLINE(MinHeapSize, (size_t)size) != JVMFlag::SUCCESS) {
2611         return JNI_EINVAL;
2612       }
2613       if (FLAG_SET_CMDLINE(InitialHeapSize, (size_t)size) != JVMFlag::SUCCESS) {
2614         return JNI_EINVAL;
2615       }
2616     // -Xmx
2617     } else if (match_option(option, "-Xmx", &tail) || match_option(option, "-XX:MaxHeapSize=", &tail)) {
2618       julong long_max_heap_size = 0;
2619       ArgsRange errcode = parse_memory_size(tail, &long_max_heap_size, 1);
2620       if (errcode != arg_in_range) {
2621         jio_fprintf(defaultStream::error_stream(),
2622                     "Invalid maximum heap size: %s\n", option->optionString);
2623         describe_range_error(errcode);
2624         return JNI_EINVAL;
2625       }
2626       if (FLAG_SET_CMDLINE(MaxHeapSize, (size_t)long_max_heap_size) != JVMFlag::SUCCESS) {
2627         return JNI_EINVAL;
2628       }
2629     // Xmaxf
2630     } else if (match_option(option, "-Xmaxf", &tail)) {
2631       char* err;
2632       int maxf = (int)(strtod(tail, &err) * 100);
2633       if (*err != '\0' || *tail == '\0') {




 520 // version is incremented, but the source code needs to be cleanup up manually:
 521 // - As "deprecated" options age into "obsolete" or "expired" options, the associated "globals"
 522 //   variable should be removed, as well as users of the variable.
 523 // - As "deprecated" options age into "obsolete" options, move the entry into the
 524 //   "Obsolete Flags" section of the table.
 525 // - All expired options should be removed from the table.
 526 static SpecialFlag const special_jvm_flags[] = {
 527   // -------------- Deprecated Flags --------------
 528   // --- Non-alias flags - sorted by obsolete_in then expired_in:
 529   { "MaxGCMinorPauseMillis",        JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() },
 530   { "UseConcMarkSweepGC",           JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() },
 531   { "MaxRAMFraction",               JDK_Version::jdk(10),  JDK_Version::undefined(), JDK_Version::undefined() },
 532   { "MinRAMFraction",               JDK_Version::jdk(10),  JDK_Version::undefined(), JDK_Version::undefined() },
 533   { "InitialRAMFraction",           JDK_Version::jdk(10),  JDK_Version::undefined(), JDK_Version::undefined() },
 534   { "UseMembar",                    JDK_Version::jdk(10), JDK_Version::jdk(12), JDK_Version::undefined() },
 535   { "CompilationPolicyChoice",      JDK_Version::jdk(13), JDK_Version::jdk(14), JDK_Version::undefined() },
 536   { "FailOverToOldVerifier",        JDK_Version::jdk(13), JDK_Version::jdk(14), JDK_Version::undefined() },
 537   { "AllowJNIEnvProxy",             JDK_Version::jdk(13), JDK_Version::jdk(14), JDK_Version::jdk(15) },
 538   { "ThreadLocalHandshakes",        JDK_Version::jdk(13), JDK_Version::jdk(14), JDK_Version::jdk(15) },
 539   { "AllowRedefinitionToAddDeleteMethods", JDK_Version::jdk(13), JDK_Version::undefined(), JDK_Version::undefined() },

 540 
 541   // --- Deprecated alias flags (see also aliased_jvm_flags) - sorted by obsolete_in then expired_in:
 542   { "DefaultMaxRAMFraction",        JDK_Version::jdk(8),  JDK_Version::undefined(), JDK_Version::undefined() },
 543   { "CreateMinidumpOnCrash",        JDK_Version::jdk(9),  JDK_Version::undefined(), JDK_Version::undefined() },
 544   { "TLABStats",                    JDK_Version::jdk(12), JDK_Version::undefined(), JDK_Version::undefined() },
 545 
 546   // -------------- Obsolete Flags - sorted by expired_in --------------
 547   { "PermSize",                      JDK_Version::undefined(), JDK_Version::jdk(8),  JDK_Version::undefined() },
 548   { "MaxPermSize",                   JDK_Version::undefined(), JDK_Version::jdk(8),  JDK_Version::undefined() },
 549   { "SharedReadWriteSize",           JDK_Version::undefined(), JDK_Version::jdk(10), JDK_Version::undefined() },
 550   { "SharedReadOnlySize",            JDK_Version::undefined(), JDK_Version::jdk(10), JDK_Version::undefined() },
 551   { "SharedMiscDataSize",            JDK_Version::undefined(), JDK_Version::jdk(10), JDK_Version::undefined() },
 552   { "SharedMiscCodeSize",            JDK_Version::undefined(), JDK_Version::jdk(10), JDK_Version::undefined() },
 553   { "ProfilerPrintByteCodeStatistics", JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) },
 554   { "ProfilerRecordPC",              JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) },
 555   { "ProfileVM",                     JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) },
 556   { "ProfileIntervals",              JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) },
 557   { "ProfileIntervalsTicks",         JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) },
 558   { "ProfilerCheckIntervals",        JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) },
 559   { "ProfilerNumberOfInterpretedMethods", JDK_Version::undefined(), JDK_Version::jdk(13), JDK_Version::jdk(14) },


 587   { "CreateMinidumpOnCrash",    "CreateCoredumpOnCrash" },
 588   { NULL, NULL}
 589 };
 590 
 591 // NOTE: A compatibility request will be necessary for each alias to be removed.
 592 static AliasedLoggingFlag const aliased_logging_flags[] = {
 593   { "PrintCompressedOopsMode",   LogLevel::Info,  true,  LOG_TAGS(gc, heap, coops) },
 594   { "PrintSharedSpaces",         LogLevel::Info,  true,  LOG_TAGS(cds) },
 595   { "TraceBiasedLocking",        LogLevel::Info,  true,  LOG_TAGS(biasedlocking) },
 596   { "TraceClassLoading",         LogLevel::Info,  true,  LOG_TAGS(class, load) },
 597   { "TraceClassLoadingPreorder", LogLevel::Debug, true,  LOG_TAGS(class, preorder) },
 598   { "TraceClassPaths",           LogLevel::Info,  true,  LOG_TAGS(class, path) },
 599   { "TraceClassResolution",      LogLevel::Debug, true,  LOG_TAGS(class, resolve) },
 600   { "TraceClassUnloading",       LogLevel::Info,  true,  LOG_TAGS(class, unload) },
 601   { "TraceExceptions",           LogLevel::Info,  true,  LOG_TAGS(exceptions) },
 602   { "TraceLoaderConstraints",    LogLevel::Info,  true,  LOG_TAGS(class, loader, constraints) },
 603   { "TraceMonitorInflation",     LogLevel::Trace, true,  LOG_TAGS(monitorinflation) },
 604   { "TraceSafepointCleanupTime", LogLevel::Info,  true,  LOG_TAGS(safepoint, cleanup) },
 605   { "TraceJVMTIObjectTagging",   LogLevel::Debug, true,  LOG_TAGS(jvmti, objecttagging) },
 606   { "TraceRedefineClasses",      LogLevel::Info,  false, LOG_TAGS(redefine, class) },

 607   { NULL,                        LogLevel::Off,   false, LOG_TAGS(_NO_TAG) }
 608 };
 609 
 610 #ifndef PRODUCT
 611 // These options are removed in jdk9. Remove this code for jdk10.
 612 static AliasedFlag const removed_develop_logging_flags[] = {
 613   { "TraceClassInitialization",   "-Xlog:class+init" },
 614   { "TraceClassLoaderData",       "-Xlog:class+loader+data" },
 615   { "TraceDefaultMethods",        "-Xlog:defaultmethods=debug" },
 616   { "TraceItables",               "-Xlog:itables=debug" },
 617   { "TraceMonitorMismatch",       "-Xlog:monitormismatch=info" },
 618   { "TraceSafepoint",             "-Xlog:safepoint=debug" },
 619   { "TraceStartupTime",           "-Xlog:startuptime" },
 620   { "TraceVMOperation",           "-Xlog:vmoperation=debug" },
 621   { "PrintVtables",               "-Xlog:vtables=debug" },
 622   { "VerboseVerification",        "-Xlog:verification" },
 623   { NULL, NULL }
 624 };
 625 #endif //PRODUCT
 626 


1611 
1612 size_t Arguments::max_heap_for_compressed_oops() {
1613   // Avoid sign flip.
1614   assert(OopEncodingHeapMax > (uint64_t)os::vm_page_size(), "Unusual page size");
1615   // We need to fit both the NULL page and the heap into the memory budget, while
1616   // keeping alignment constraints of the heap. To guarantee the latter, as the
1617   // NULL page is located before the heap, we pad the NULL page to the conservative
1618   // maximum alignment that the GC may ever impose upon the heap.
1619   size_t displacement_due_to_null_page = align_up((size_t)os::vm_page_size(),
1620                                                   _conservative_max_heap_alignment);
1621 
1622   LP64_ONLY(return OopEncodingHeapMax - displacement_due_to_null_page);
1623   NOT_LP64(ShouldNotReachHere(); return 0);
1624 }
1625 
1626 void Arguments::set_use_compressed_oops() {
1627 #ifndef ZERO
1628 #ifdef _LP64
1629   // MaxHeapSize is not set up properly at this point, but
1630   // the only value that can override MaxHeapSize if we are
1631   // to use UseCompressedOops is InitialHeapSize.
1632   size_t max_heap_size = MAX2(MaxHeapSize, InitialHeapSize);
1633 
1634   if (max_heap_size <= max_heap_for_compressed_oops()) {
1635 #if !defined(COMPILER1) || defined(TIERED)
1636     if (FLAG_IS_DEFAULT(UseCompressedOops)) {
1637       FLAG_SET_ERGO(UseCompressedOops, true);
1638     }
1639 #endif
1640   } else {
1641     if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) {
1642       warning("Max heap size too large for Compressed Oops");
1643       FLAG_SET_DEFAULT(UseCompressedOops, false);
1644       FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1645     }
1646   }
1647 #endif // _LP64
1648 #endif // ZERO
1649 }
1650 
1651 
1652 // NOTE: set_use_compressed_klass_ptrs() must be called after calling


1765 
1766   // If the maximum heap size has not been set with -Xmx,
1767   // then set it as fraction of the size of physical memory,
1768   // respecting the maximum and minimum sizes of the heap.
1769   if (FLAG_IS_DEFAULT(MaxHeapSize)) {
1770     julong reasonable_max = (julong)((phys_mem * MaxRAMPercentage) / 100);
1771     const julong reasonable_min = (julong)((phys_mem * MinRAMPercentage) / 100);
1772     if (reasonable_min < MaxHeapSize) {
1773       // Small physical memory, so use a minimum fraction of it for the heap
1774       reasonable_max = reasonable_min;
1775     } else {
1776       // Not-small physical memory, so require a heap at least
1777       // as large as MaxHeapSize
1778       reasonable_max = MAX2(reasonable_max, (julong)MaxHeapSize);
1779     }
1780 
1781     if (!FLAG_IS_DEFAULT(ErgoHeapSizeLimit) && ErgoHeapSizeLimit != 0) {
1782       // Limit the heap size to ErgoHeapSizeLimit
1783       reasonable_max = MIN2(reasonable_max, (julong)ErgoHeapSizeLimit);
1784     }


1785     if (UseCompressedOops) {
1786       // Limit the heap size to the maximum possible when using compressed oops
1787       julong max_coop_heap = (julong)max_heap_for_compressed_oops();
1788 
1789       // HeapBaseMinAddress can be greater than default but not less than.
1790       if (!FLAG_IS_DEFAULT(HeapBaseMinAddress)) {
1791         if (HeapBaseMinAddress < DefaultHeapBaseMinAddress) {
1792           // matches compressed oops printing flags
1793           log_debug(gc, heap, coops)("HeapBaseMinAddress must be at least " SIZE_FORMAT
1794                                      " (" SIZE_FORMAT "G) which is greater than value given " SIZE_FORMAT,
1795                                      DefaultHeapBaseMinAddress,
1796                                      DefaultHeapBaseMinAddress/G,
1797                                      HeapBaseMinAddress);
1798           FLAG_SET_ERGO(HeapBaseMinAddress, DefaultHeapBaseMinAddress);
1799         }
1800       }
1801 
1802       if (HeapBaseMinAddress + MaxHeapSize < max_coop_heap) {
1803         // Heap should be above HeapBaseMinAddress to get zero based compressed oops
1804         // but it should be not less than default MaxHeapSize.
1805         max_coop_heap -= HeapBaseMinAddress;
1806       }
1807 
1808       // If user specified flags prioritizing os physical
1809       // memory limits, then disable compressed oops if
1810       // limits exceed max_coop_heap and UseCompressedOops
1811       // was not specified.
1812       if (reasonable_max > max_coop_heap) {
1813         if (FLAG_IS_ERGO(UseCompressedOops) && override_coop_limit) {
1814           FLAG_SET_ERGO(UseCompressedOops, false);
1815           FLAG_SET_ERGO(UseCompressedClassPointers, false);
1816         } else {
1817           reasonable_max = MIN2(reasonable_max, max_coop_heap);
1818         }
1819       }
1820     }


1821     reasonable_max = limit_by_allocatable_memory(reasonable_max);
1822 
1823     if (!FLAG_IS_DEFAULT(InitialHeapSize)) {
1824       // An initial heap size was specified on the command line,
1825       // so be sure that the maximum size is consistent.  Done
1826       // after call to limit_by_allocatable_memory because that
1827       // method might reduce the allocation size.
1828       reasonable_max = MAX2(reasonable_max, (julong)InitialHeapSize);


1829     }
1830 
1831     log_trace(gc, heap)("  Maximum heap size " SIZE_FORMAT, (size_t) reasonable_max);
1832     FLAG_SET_ERGO(MaxHeapSize, (size_t)reasonable_max);
1833   }
1834 
1835   // If the minimum or initial heap_size have not been set or requested to be set
1836   // ergonomically, set them accordingly.
1837   if (InitialHeapSize == 0 || MinHeapSize == 0) {
1838     julong reasonable_minimum = (julong)(OldSize + NewSize);
1839 
1840     reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize);
1841 
1842     reasonable_minimum = limit_by_allocatable_memory(reasonable_minimum);
1843 
1844     if (InitialHeapSize == 0) {
1845       julong reasonable_initial = (julong)((phys_mem * InitialRAMPercentage) / 100);
1846 
1847       reasonable_initial = MAX3(reasonable_initial, reasonable_minimum, (julong)MinHeapSize);
1848       reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize);
1849 
1850       reasonable_initial = limit_by_allocatable_memory(reasonable_initial);
1851 
1852       log_trace(gc, heap)("  Initial heap size " SIZE_FORMAT, (size_t)reasonable_initial);
1853       FLAG_SET_ERGO(InitialHeapSize, (size_t)reasonable_initial);

1854     }
1855     // If the minimum heap size has not been set (via -Xms),
1856     // synchronize with InitialHeapSize to avoid errors with the default value.
1857     if (MinHeapSize == 0) {
1858       MinHeapSize = MIN2((size_t)reasonable_minimum, InitialHeapSize);
1859       log_trace(gc, heap)("  Minimum heap size " SIZE_FORMAT, MinHeapSize);
1860     }
1861   }
1862 }
1863 
1864 // This option inspects the machine and attempts to set various
1865 // parameters to be optimal for long-running, memory allocation
1866 // intensive jobs.  It is intended for machines with large
1867 // amounts of cpu and memory.
1868 jint Arguments::set_aggressive_heap_flags() {
1869   // initHeapSize is needed since _initial_heap_size is 4 bytes on a 32 bit
1870   // VM, but we may not be able to represent the total physical memory
1871   // available (like having 8gb of memory on a box but using a 32bit VM).
1872   // Thus, we need to make sure we're using a julong for intermediate
1873   // calculations.
1874   julong initHeapSize;
1875   julong total_memory = os::physical_memory();
1876 
1877   if (total_memory < (julong) 256 * M) {
1878     jio_fprintf(defaultStream::error_stream(),


1880     vm_exit(1);
1881   }
1882 
1883   // The heap size is half of available memory, or (at most)
1884   // all of possible memory less 160mb (leaving room for the OS
1885   // when using ISM).  This is the maximum; because adaptive sizing
1886   // is turned on below, the actual space used may be smaller.
1887 
1888   initHeapSize = MIN2(total_memory / (julong) 2,
1889           total_memory - (julong) 160 * M);
1890 
1891   initHeapSize = limit_by_allocatable_memory(initHeapSize);
1892 
1893   if (FLAG_IS_DEFAULT(MaxHeapSize)) {
1894     if (FLAG_SET_CMDLINE(MaxHeapSize, initHeapSize) != JVMFlag::SUCCESS) {
1895       return JNI_EINVAL;
1896     }
1897     if (FLAG_SET_CMDLINE(InitialHeapSize, initHeapSize) != JVMFlag::SUCCESS) {
1898       return JNI_EINVAL;
1899     }
1900     // Currently the minimum size and the initial heap sizes are the same.
1901     MinHeapSize = initHeapSize;

1902   }
1903   if (FLAG_IS_DEFAULT(NewSize)) {
1904     // Make the young generation 3/8ths of the total heap.
1905     if (FLAG_SET_CMDLINE(NewSize,
1906             ((julong) MaxHeapSize / (julong) 8) * (julong) 3) != JVMFlag::SUCCESS) {
1907       return JNI_EINVAL;
1908     }
1909     if (FLAG_SET_CMDLINE(MaxNewSize, NewSize) != JVMFlag::SUCCESS) {
1910       return JNI_EINVAL;
1911     }
1912   }
1913 
1914 #if !defined(_ALLBSD_SOURCE) && !defined(AIX)  // UseLargePages is not yet supported on BSD and AIX.
1915   FLAG_SET_DEFAULT(UseLargePages, true);
1916 #endif
1917 
1918   // Increase some data structure sizes for efficiency
1919   if (FLAG_SET_CMDLINE(BaseFootPrintEstimate, MaxHeapSize) != JVMFlag::SUCCESS) {
1920     return JNI_EINVAL;
1921   }


2572         return JNI_EINVAL;
2573       }
2574     // -Xmn for compatibility with other JVM vendors
2575     } else if (match_option(option, "-Xmn", &tail)) {
2576       julong long_initial_young_size = 0;
2577       ArgsRange errcode = parse_memory_size(tail, &long_initial_young_size, 1);
2578       if (errcode != arg_in_range) {
2579         jio_fprintf(defaultStream::error_stream(),
2580                     "Invalid initial young generation size: %s\n", option->optionString);
2581         describe_range_error(errcode);
2582         return JNI_EINVAL;
2583       }
2584       if (FLAG_SET_CMDLINE(MaxNewSize, (size_t)long_initial_young_size) != JVMFlag::SUCCESS) {
2585         return JNI_EINVAL;
2586       }
2587       if (FLAG_SET_CMDLINE(NewSize, (size_t)long_initial_young_size) != JVMFlag::SUCCESS) {
2588         return JNI_EINVAL;
2589       }
2590     // -Xms
2591     } else if (match_option(option, "-Xms", &tail)) {
2592       julong long_initial_heap_size = 0;
2593       // an initial heap size of 0 means automatically determine
2594       ArgsRange errcode = parse_memory_size(tail, &long_initial_heap_size, 0);
2595       if (errcode != arg_in_range) {
2596         jio_fprintf(defaultStream::error_stream(),
2597                     "Invalid initial heap size: %s\n", option->optionString);
2598         describe_range_error(errcode);
2599         return JNI_EINVAL;
2600       }
2601       MinHeapSize = (size_t)long_initial_heap_size;
2602       // Currently the minimum size and the initial heap sizes are the same.
2603       // Can be overridden with -XX:InitialHeapSize.
2604       if (FLAG_SET_CMDLINE(InitialHeapSize, (size_t)long_initial_heap_size) != JVMFlag::SUCCESS) {
2605         return JNI_EINVAL;
2606       }
2607     // -Xmx
2608     } else if (match_option(option, "-Xmx", &tail) || match_option(option, "-XX:MaxHeapSize=", &tail)) {
2609       julong long_max_heap_size = 0;
2610       ArgsRange errcode = parse_memory_size(tail, &long_max_heap_size, 1);
2611       if (errcode != arg_in_range) {
2612         jio_fprintf(defaultStream::error_stream(),
2613                     "Invalid maximum heap size: %s\n", option->optionString);
2614         describe_range_error(errcode);
2615         return JNI_EINVAL;
2616       }
2617       if (FLAG_SET_CMDLINE(MaxHeapSize, (size_t)long_max_heap_size) != JVMFlag::SUCCESS) {
2618         return JNI_EINVAL;
2619       }
2620     // Xmaxf
2621     } else if (match_option(option, "-Xmaxf", &tail)) {
2622       char* err;
2623       int maxf = (int)(strtod(tail, &err) * 100);
2624       if (*err != '\0' || *tail == '\0') {


< prev index next >