1552 }
1553
1554 void Arguments::set_parallel_gc_flags() {
1555 assert(UseParallelGC || UseParallelOldGC, "Error");
1556 // Enable ParallelOld unless it was explicitly disabled (cmd line or rc file).
1557 if (FLAG_IS_DEFAULT(UseParallelOldGC)) {
1558 FLAG_SET_DEFAULT(UseParallelOldGC, true);
1559 }
1560 FLAG_SET_DEFAULT(UseParallelGC, true);
1561
1562 // If no heap maximum was requested explicitly, use some reasonable fraction
1563 // of the physical memory, up to a maximum of 1GB.
1564 FLAG_SET_DEFAULT(ParallelGCThreads,
1565 Abstract_VM_Version::parallel_worker_threads());
1566 if (ParallelGCThreads == 0) {
1567 jio_fprintf(defaultStream::error_stream(),
1568 "The Parallel GC can not be combined with -XX:ParallelGCThreads=0\n");
1569 vm_exit(1);
1570 }
1571
1572
1573 // If InitialSurvivorRatio or MinSurvivorRatio were not specified, but the
1574 // SurvivorRatio has been set, reset their default values to SurvivorRatio +
1575 // 2. By doing this we make SurvivorRatio also work for Parallel Scavenger.
1576 // See CR 6362902 for details.
1577 if (!FLAG_IS_DEFAULT(SurvivorRatio)) {
1578 if (FLAG_IS_DEFAULT(InitialSurvivorRatio)) {
1579 FLAG_SET_DEFAULT(InitialSurvivorRatio, SurvivorRatio + 2);
1580 }
1581 if (FLAG_IS_DEFAULT(MinSurvivorRatio)) {
1582 FLAG_SET_DEFAULT(MinSurvivorRatio, SurvivorRatio + 2);
1583 }
1584 }
1585
1586 if (UseParallelOldGC) {
1587 // Par compact uses lower default values since they are treated as
1588 // minimums. These are different defaults because of the different
1589 // interpretation and are not ergonomically set.
1590 if (FLAG_IS_DEFAULT(MarkSweepDeadRatio)) {
1591 FLAG_SET_DEFAULT(MarkSweepDeadRatio, 1);
1827 jio_fprintf(defaultStream::error_stream(),
1828 "%s of " UINTX_FORMAT " is invalid; must be between " UINTX_FORMAT
1829 " and " UINTX_FORMAT "\n",
1830 name, val, min, max);
1831 return false;
1832 }
1833
1834 bool Arguments::verify_min_value(intx val, intx min, const char* name) {
1835 // Returns true if given value is at least specified min threshold
1836 // false, otherwise.
1837 if (val >= min ) {
1838 return true;
1839 }
1840 jio_fprintf(defaultStream::error_stream(),
1841 "%s of " INTX_FORMAT " is invalid; must be at least " INTX_FORMAT "\n",
1842 name, val, min);
1843 return false;
1844 }
1845
1846 bool Arguments::verify_percentage(uintx value, const char* name) {
1847 if (value <= 100) {
1848 return true;
1849 }
1850 jio_fprintf(defaultStream::error_stream(),
1851 "%s of " UINTX_FORMAT " is invalid; must be between 0 and 100\n",
1852 name, value);
1853 return false;
1854 }
1855
1856 #if !INCLUDE_ALL_GCS
1857 #ifdef ASSERT
1858 static bool verify_serial_gc_flags() {
1859 return (UseSerialGC &&
1860 !(UseParNewGC || (UseConcMarkSweepGC || CMSIncrementalMode) || UseG1GC ||
1861 UseParallelGC || UseParallelOldGC));
1862 }
1863 #endif // ASSERT
1864 #endif // INCLUDE_ALL_GCS
1865
1866 // check if do gclog rotation
1867 // +UseGCLogFileRotation is a must,
1915 p++;
1916 continue;
1917 }
1918 if (*p == '%') {
1919 if(*(p + 1) == 'p') {
1920 p += 2;
1921 count_p ++;
1922 continue;
1923 }
1924 if (*(p + 1) == 't') {
1925 p += 2;
1926 count_t ++;
1927 continue;
1928 }
1929 }
1930 return false;
1931 }
1932 return count_p < 2 && count_t < 2;
1933 }
1934
1935 // Check consistency of GC selection
1936 bool Arguments::check_gc_consistency() {
1937 check_gclog_consistency();
1938 bool status = true;
1939 // Ensure that the user has not selected conflicting sets
1940 // of collectors. [Note: this check is merely a user convenience;
1941 // collectors over-ride each other so that only a non-conflicting
1942 // set is selected; however what the user gets is not what they
1943 // may have expected from the combination they asked for. It's
1944 // better to reduce user confusion by not allowing them to
1945 // select conflicting combinations.
1946 uint i = 0;
1947 if (UseSerialGC) i++;
1948 if (UseConcMarkSweepGC || UseParNewGC) i++;
1949 if (UseParallelGC || UseParallelOldGC) i++;
1950 if (UseG1GC) i++;
1951 if (i > 1) {
1952 jio_fprintf(defaultStream::error_stream(),
1953 "Conflicting collector combinations in option list; "
1954 "please refer to the release notes for the combinations "
2020 #if (defined(PRODUCT) && defined(SOLARIS))
2021 if (!UseBoundThreads && !UseStackBanging) {
2022 jio_fprintf(defaultStream::error_stream(),
2023 "-UseStackBanging conflicts with -UseBoundThreads\n");
2024
2025 status = false;
2026 }
2027 #endif
2028
2029 if (TLABRefillWasteFraction == 0) {
2030 jio_fprintf(defaultStream::error_stream(),
2031 "TLABRefillWasteFraction should be a denominator, "
2032 "not " SIZE_FORMAT "\n",
2033 TLABRefillWasteFraction);
2034 status = false;
2035 }
2036
2037 status = status && verify_interval(AdaptiveSizePolicyWeight, 0, 100,
2038 "AdaptiveSizePolicyWeight");
2039 status = status && verify_percentage(ThresholdTolerance, "ThresholdTolerance");
2040 status = status && verify_percentage(MinHeapFreeRatio, "MinHeapFreeRatio");
2041 status = status && verify_percentage(MaxHeapFreeRatio, "MaxHeapFreeRatio");
2042
2043 // Divide by bucket size to prevent a large size from causing rollover when
2044 // calculating amount of memory needed to be allocated for the String table.
2045 status = status && verify_interval(StringTableSize, minimumStringTableSize,
2046 (max_uintx / StringTable::bucket_size()), "StringTable size");
2047
2048 status = status && verify_interval(SymbolTableSize, minimumSymbolTableSize,
2049 (max_uintx / SymbolTable::bucket_size()), "SymbolTable size");
2050
2051 if (MinHeapFreeRatio > MaxHeapFreeRatio) {
2052 jio_fprintf(defaultStream::error_stream(),
2053 "MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or "
2054 "equal to MaxHeapFreeRatio (" UINTX_FORMAT ")\n",
2055 MinHeapFreeRatio, MaxHeapFreeRatio);
2056 status = false;
2057 }
2058 // Keeping the heap 100% free is hard ;-) so limit it to 99%.
2059 MinHeapFreeRatio = MIN2(MinHeapFreeRatio, (uintx) 99);
2060
2061 // Min/MaxMetaspaceFreeRatio
2062 status = status && verify_percentage(MinMetaspaceFreeRatio, "MinMetaspaceFreeRatio");
2063 status = status && verify_percentage(MaxMetaspaceFreeRatio, "MaxMetaspaceFreeRatio");
2064
2065 if (MinMetaspaceFreeRatio > MaxMetaspaceFreeRatio) {
2066 jio_fprintf(defaultStream::error_stream(),
2067 "MinMetaspaceFreeRatio (%s" UINTX_FORMAT ") must be less than or "
2068 "equal to MaxMetaspaceFreeRatio (%s" UINTX_FORMAT ")\n",
2069 FLAG_IS_DEFAULT(MinMetaspaceFreeRatio) ? "Default: " : "",
2070 MinMetaspaceFreeRatio,
2071 FLAG_IS_DEFAULT(MaxMetaspaceFreeRatio) ? "Default: " : "",
2072 MaxMetaspaceFreeRatio);
2073 status = false;
2074 }
2075
2076 // Trying to keep 100% free is not practical
2077 MinMetaspaceFreeRatio = MIN2(MinMetaspaceFreeRatio, (uintx) 99);
2078
2079 if (FullGCALot && FLAG_IS_DEFAULT(MarkSweepAlwaysCompactCount)) {
2672 }
2673 set_min_heap_size((uintx)long_initial_heap_size);
2674 // Currently the minimum size and the initial heap sizes are the same.
2675 // Can be overridden with -XX:InitialHeapSize.
2676 FLAG_SET_CMDLINE(uintx, InitialHeapSize, (uintx)long_initial_heap_size);
2677 // -Xmx
2678 } else if (match_option(option, "-Xmx", &tail) || match_option(option, "-XX:MaxHeapSize=", &tail)) {
2679 julong long_max_heap_size = 0;
2680 ArgsRange errcode = parse_memory_size(tail, &long_max_heap_size, 1);
2681 if (errcode != arg_in_range) {
2682 jio_fprintf(defaultStream::error_stream(),
2683 "Invalid maximum heap size: %s\n", option->optionString);
2684 describe_range_error(errcode);
2685 return JNI_EINVAL;
2686 }
2687 FLAG_SET_CMDLINE(uintx, MaxHeapSize, (uintx)long_max_heap_size);
2688 // Xmaxf
2689 } else if (match_option(option, "-Xmaxf", &tail)) {
2690 char* err;
2691 int maxf = (int)(strtod(tail, &err) * 100);
2692 if (*err != '\0' || maxf < 0 || maxf > 100) {
2693 jio_fprintf(defaultStream::error_stream(),
2694 "Bad max heap free percentage size: %s\n",
2695 option->optionString);
2696 return JNI_EINVAL;
2697 } else {
2698 FLAG_SET_CMDLINE(uintx, MaxHeapFreeRatio, maxf);
2699 }
2700 // Xminf
2701 } else if (match_option(option, "-Xminf", &tail)) {
2702 char* err;
2703 int minf = (int)(strtod(tail, &err) * 100);
2704 if (*err != '\0' || minf < 0 || minf > 100) {
2705 jio_fprintf(defaultStream::error_stream(),
2706 "Bad min heap free percentage size: %s\n",
2707 option->optionString);
2708 return JNI_EINVAL;
2709 } else {
2710 FLAG_SET_CMDLINE(uintx, MinHeapFreeRatio, minf);
2711 }
2712 // -Xss
2713 } else if (match_option(option, "-Xss", &tail)) {
2714 julong long_ThreadStackSize = 0;
2715 ArgsRange errcode = parse_memory_size(tail, &long_ThreadStackSize, 1000);
2716 if (errcode != arg_in_range) {
2717 jio_fprintf(defaultStream::error_stream(),
2718 "Invalid thread stack size: %s\n", option->optionString);
2719 describe_range_error(errcode);
2720 return JNI_EINVAL;
2721 }
2722 // Internally track ThreadStackSize in units of 1024 bytes.
2723 FLAG_SET_CMDLINE(intx, ThreadStackSize,
2724 round_to((int)long_ThreadStackSize, K) / K);
3629 } else {
3630 // Check if the policy is valid. Policies 0 and 1 are valid for non-tiered setup.
3631 if (CompilationPolicyChoice >= 2) {
3632 vm_exit_during_initialization(
3633 "Incompatible compilation policy selected", NULL);
3634 }
3635 }
3636 // Set NmethodSweepFraction after the size of the code cache is adapted (in case of tiered)
3637 if (FLAG_IS_DEFAULT(NmethodSweepFraction)) {
3638 FLAG_SET_DEFAULT(NmethodSweepFraction, 1 + ReservedCodeCacheSize / (16 * M));
3639 }
3640
3641
3642 // Set heap size based on available physical memory
3643 set_heap_size();
3644
3645 #if INCLUDE_ALL_GCS
3646 // Set per-collector flags
3647 if (UseParallelGC || UseParallelOldGC) {
3648 set_parallel_gc_flags();
3649 } else if (UseConcMarkSweepGC) { // should be done before ParNew check below
3650 set_cms_and_parnew_gc_flags();
3651 } else if (UseParNewGC) { // skipped if CMS is set above
3652 set_parnew_gc_flags();
3653 } else if (UseG1GC) {
3654 set_g1_gc_flags();
3655 }
3656 check_deprecated_gcs();
3657 check_deprecated_gc_flags();
3658 if (AssumeMP && !UseSerialGC) {
3659 if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) {
3660 warning("If the number of processors is expected to increase from one, then"
3661 " you should configure the number of parallel GC threads appropriately"
3662 " using -XX:ParallelGCThreads=N");
3663 }
3664 }
3665 #else // INCLUDE_ALL_GCS
3666 assert(verify_serial_gc_flags(), "SerialGC unset");
3667 #endif // INCLUDE_ALL_GCS
3668
3669 // Initialize Metaspace flags and alignments.
3670 Metaspace::ergo_initialize();
3671
3672 // Set bytecode rewriting flags
3673 set_bytecode_flags();
3674
3675 // Set flags if Aggressive optimization flags (-XX:+AggressiveOpts) enabled.
3676 set_aggressive_opts_flags();
3677
3678 // Turn off biased locking for locking debug mode flags,
3679 // which are subtlely different from each other but neither works with
3680 // biased locking.
3681 if (UseHeavyMonitors
3682 #ifdef COMPILER1
3683 || !UseFastLocking
3684 #endif // COMPILER1
|
1552 }
1553
1554 void Arguments::set_parallel_gc_flags() {
1555 assert(UseParallelGC || UseParallelOldGC, "Error");
1556 // Enable ParallelOld unless it was explicitly disabled (cmd line or rc file).
1557 if (FLAG_IS_DEFAULT(UseParallelOldGC)) {
1558 FLAG_SET_DEFAULT(UseParallelOldGC, true);
1559 }
1560 FLAG_SET_DEFAULT(UseParallelGC, true);
1561
1562 // If no heap maximum was requested explicitly, use some reasonable fraction
1563 // of the physical memory, up to a maximum of 1GB.
1564 FLAG_SET_DEFAULT(ParallelGCThreads,
1565 Abstract_VM_Version::parallel_worker_threads());
1566 if (ParallelGCThreads == 0) {
1567 jio_fprintf(defaultStream::error_stream(),
1568 "The Parallel GC can not be combined with -XX:ParallelGCThreads=0\n");
1569 vm_exit(1);
1570 }
1571
1572 if (UseAdaptiveSizePolicy) {
1573 // We don't want to limit adaptive heap sizing's freedom to adjust the heap
1574 // unless the user actually sets these flags.
1575 if (FLAG_IS_DEFAULT(MinHeapFreeRatio)) {
1576 FLAG_SET_DEFAULT(MinHeapFreeRatio, 0);
1577 }
1578 if (FLAG_IS_DEFAULT(MaxHeapFreeRatio)) {
1579 FLAG_SET_DEFAULT(MaxHeapFreeRatio, 100);
1580 }
1581 }
1582
1583 // If InitialSurvivorRatio or MinSurvivorRatio were not specified, but the
1584 // SurvivorRatio has been set, reset their default values to SurvivorRatio +
1585 // 2. By doing this we make SurvivorRatio also work for Parallel Scavenger.
1586 // See CR 6362902 for details.
1587 if (!FLAG_IS_DEFAULT(SurvivorRatio)) {
1588 if (FLAG_IS_DEFAULT(InitialSurvivorRatio)) {
1589 FLAG_SET_DEFAULT(InitialSurvivorRatio, SurvivorRatio + 2);
1590 }
1591 if (FLAG_IS_DEFAULT(MinSurvivorRatio)) {
1592 FLAG_SET_DEFAULT(MinSurvivorRatio, SurvivorRatio + 2);
1593 }
1594 }
1595
1596 if (UseParallelOldGC) {
1597 // Par compact uses lower default values since they are treated as
1598 // minimums. These are different defaults because of the different
1599 // interpretation and are not ergonomically set.
1600 if (FLAG_IS_DEFAULT(MarkSweepDeadRatio)) {
1601 FLAG_SET_DEFAULT(MarkSweepDeadRatio, 1);
1837 jio_fprintf(defaultStream::error_stream(),
1838 "%s of " UINTX_FORMAT " is invalid; must be between " UINTX_FORMAT
1839 " and " UINTX_FORMAT "\n",
1840 name, val, min, max);
1841 return false;
1842 }
1843
1844 bool Arguments::verify_min_value(intx val, intx min, const char* name) {
1845 // Returns true if given value is at least specified min threshold
1846 // false, otherwise.
1847 if (val >= min ) {
1848 return true;
1849 }
1850 jio_fprintf(defaultStream::error_stream(),
1851 "%s of " INTX_FORMAT " is invalid; must be at least " INTX_FORMAT "\n",
1852 name, val, min);
1853 return false;
1854 }
1855
1856 bool Arguments::verify_percentage(uintx value, const char* name) {
1857 if (is_percentage(value)) {
1858 return true;
1859 }
1860 jio_fprintf(defaultStream::error_stream(),
1861 "%s of " UINTX_FORMAT " is invalid; must be between 0 and 100\n",
1862 name, value);
1863 return false;
1864 }
1865
1866 #if !INCLUDE_ALL_GCS
1867 #ifdef ASSERT
1868 static bool verify_serial_gc_flags() {
1869 return (UseSerialGC &&
1870 !(UseParNewGC || (UseConcMarkSweepGC || CMSIncrementalMode) || UseG1GC ||
1871 UseParallelGC || UseParallelOldGC));
1872 }
1873 #endif // ASSERT
1874 #endif // INCLUDE_ALL_GCS
1875
1876 // check if do gclog rotation
1877 // +UseGCLogFileRotation is a must,
1925 p++;
1926 continue;
1927 }
1928 if (*p == '%') {
1929 if(*(p + 1) == 'p') {
1930 p += 2;
1931 count_p ++;
1932 continue;
1933 }
1934 if (*(p + 1) == 't') {
1935 p += 2;
1936 count_t ++;
1937 continue;
1938 }
1939 }
1940 return false;
1941 }
1942 return count_p < 2 && count_t < 2;
1943 }
1944
1945 bool Arguments::verify_MinHeapFreeRatio(FormatBuffer<80>& err_msg, uintx min_heap_free_ratio) {
1946 if (!is_percentage(min_heap_free_ratio)) {
1947 err_msg.print("MinHeapFreeRatio must have a value between 0 and 100");
1948 return false;
1949 }
1950 if (min_heap_free_ratio > MaxHeapFreeRatio) {
1951 err_msg.print("MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or "
1952 "equal to MaxHeapFreeRatio (" UINTX_FORMAT ")", min_heap_free_ratio,
1953 MaxHeapFreeRatio);
1954 return false;
1955 }
1956 return true;
1957 }
1958
1959 bool Arguments::verify_MaxHeapFreeRatio(FormatBuffer<80>& err_msg, uintx max_heap_free_ratio) {
1960 if (!is_percentage(max_heap_free_ratio)) {
1961 err_msg.print("MaxHeapFreeRatio must have a value between 0 and 100");
1962 return false;
1963 }
1964 if (max_heap_free_ratio < MinHeapFreeRatio) {
1965 err_msg.print("MaxHeapFreeRatio (" UINTX_FORMAT ") must be greater than or "
1966 "equal to MinHeapFreeRatio (" UINTX_FORMAT ")", max_heap_free_ratio,
1967 MinHeapFreeRatio);
1968 return false;
1969 }
1970 return true;
1971 }
1972
1973 // Check consistency of GC selection
1974 bool Arguments::check_gc_consistency() {
1975 check_gclog_consistency();
1976 bool status = true;
1977 // Ensure that the user has not selected conflicting sets
1978 // of collectors. [Note: this check is merely a user convenience;
1979 // collectors over-ride each other so that only a non-conflicting
1980 // set is selected; however what the user gets is not what they
1981 // may have expected from the combination they asked for. It's
1982 // better to reduce user confusion by not allowing them to
1983 // select conflicting combinations.
1984 uint i = 0;
1985 if (UseSerialGC) i++;
1986 if (UseConcMarkSweepGC || UseParNewGC) i++;
1987 if (UseParallelGC || UseParallelOldGC) i++;
1988 if (UseG1GC) i++;
1989 if (i > 1) {
1990 jio_fprintf(defaultStream::error_stream(),
1991 "Conflicting collector combinations in option list; "
1992 "please refer to the release notes for the combinations "
2058 #if (defined(PRODUCT) && defined(SOLARIS))
2059 if (!UseBoundThreads && !UseStackBanging) {
2060 jio_fprintf(defaultStream::error_stream(),
2061 "-UseStackBanging conflicts with -UseBoundThreads\n");
2062
2063 status = false;
2064 }
2065 #endif
2066
2067 if (TLABRefillWasteFraction == 0) {
2068 jio_fprintf(defaultStream::error_stream(),
2069 "TLABRefillWasteFraction should be a denominator, "
2070 "not " SIZE_FORMAT "\n",
2071 TLABRefillWasteFraction);
2072 status = false;
2073 }
2074
2075 status = status && verify_interval(AdaptiveSizePolicyWeight, 0, 100,
2076 "AdaptiveSizePolicyWeight");
2077 status = status && verify_percentage(ThresholdTolerance, "ThresholdTolerance");
2078
2079 // Divide by bucket size to prevent a large size from causing rollover when
2080 // calculating amount of memory needed to be allocated for the String table.
2081 status = status && verify_interval(StringTableSize, minimumStringTableSize,
2082 (max_uintx / StringTable::bucket_size()), "StringTable size");
2083
2084 status = status && verify_interval(SymbolTableSize, minimumSymbolTableSize,
2085 (max_uintx / SymbolTable::bucket_size()), "SymbolTable size");
2086
2087 {
2088 // Using "else if" below to avoid printing two error messages if min > max.
2089 // This will also prevent us from reporting both min>100 and max>100 at the
2090 // same time, but that is less annoying than printing two identical errors IMHO.
2091 FormatBuffer<80> err_msg("");
2092 if (!verify_MinHeapFreeRatio(err_msg, MinHeapFreeRatio)) {
2093 jio_fprintf(defaultStream::error_stream(), "%s\n", err_msg.buffer());
2094 status = false;
2095 } else if (!verify_MaxHeapFreeRatio(err_msg, MaxHeapFreeRatio)) {
2096 jio_fprintf(defaultStream::error_stream(), "%s\n", err_msg.buffer());
2097 status = false;
2098 }
2099 }
2100
2101 // Min/MaxMetaspaceFreeRatio
2102 status = status && verify_percentage(MinMetaspaceFreeRatio, "MinMetaspaceFreeRatio");
2103 status = status && verify_percentage(MaxMetaspaceFreeRatio, "MaxMetaspaceFreeRatio");
2104
2105 if (MinMetaspaceFreeRatio > MaxMetaspaceFreeRatio) {
2106 jio_fprintf(defaultStream::error_stream(),
2107 "MinMetaspaceFreeRatio (%s" UINTX_FORMAT ") must be less than or "
2108 "equal to MaxMetaspaceFreeRatio (%s" UINTX_FORMAT ")\n",
2109 FLAG_IS_DEFAULT(MinMetaspaceFreeRatio) ? "Default: " : "",
2110 MinMetaspaceFreeRatio,
2111 FLAG_IS_DEFAULT(MaxMetaspaceFreeRatio) ? "Default: " : "",
2112 MaxMetaspaceFreeRatio);
2113 status = false;
2114 }
2115
2116 // Trying to keep 100% free is not practical
2117 MinMetaspaceFreeRatio = MIN2(MinMetaspaceFreeRatio, (uintx) 99);
2118
2119 if (FullGCALot && FLAG_IS_DEFAULT(MarkSweepAlwaysCompactCount)) {
2712 }
2713 set_min_heap_size((uintx)long_initial_heap_size);
2714 // Currently the minimum size and the initial heap sizes are the same.
2715 // Can be overridden with -XX:InitialHeapSize.
2716 FLAG_SET_CMDLINE(uintx, InitialHeapSize, (uintx)long_initial_heap_size);
2717 // -Xmx
2718 } else if (match_option(option, "-Xmx", &tail) || match_option(option, "-XX:MaxHeapSize=", &tail)) {
2719 julong long_max_heap_size = 0;
2720 ArgsRange errcode = parse_memory_size(tail, &long_max_heap_size, 1);
2721 if (errcode != arg_in_range) {
2722 jio_fprintf(defaultStream::error_stream(),
2723 "Invalid maximum heap size: %s\n", option->optionString);
2724 describe_range_error(errcode);
2725 return JNI_EINVAL;
2726 }
2727 FLAG_SET_CMDLINE(uintx, MaxHeapSize, (uintx)long_max_heap_size);
2728 // Xmaxf
2729 } else if (match_option(option, "-Xmaxf", &tail)) {
2730 char* err;
2731 int maxf = (int)(strtod(tail, &err) * 100);
2732 if (*err != '\0' || *tail == '\0' || maxf < 0 || maxf > 100) {
2733 jio_fprintf(defaultStream::error_stream(),
2734 "Bad max heap free percentage size: %s\n",
2735 option->optionString);
2736 return JNI_EINVAL;
2737 } else {
2738 FLAG_SET_CMDLINE(uintx, MaxHeapFreeRatio, maxf);
2739 }
2740 // Xminf
2741 } else if (match_option(option, "-Xminf", &tail)) {
2742 char* err;
2743 int minf = (int)(strtod(tail, &err) * 100);
2744 if (*err != '\0' || *tail == '\0' || minf < 0 || minf > 100) {
2745 jio_fprintf(defaultStream::error_stream(),
2746 "Bad min heap free percentage size: %s\n",
2747 option->optionString);
2748 return JNI_EINVAL;
2749 } else {
2750 FLAG_SET_CMDLINE(uintx, MinHeapFreeRatio, minf);
2751 }
2752 // -Xss
2753 } else if (match_option(option, "-Xss", &tail)) {
2754 julong long_ThreadStackSize = 0;
2755 ArgsRange errcode = parse_memory_size(tail, &long_ThreadStackSize, 1000);
2756 if (errcode != arg_in_range) {
2757 jio_fprintf(defaultStream::error_stream(),
2758 "Invalid thread stack size: %s\n", option->optionString);
2759 describe_range_error(errcode);
2760 return JNI_EINVAL;
2761 }
2762 // Internally track ThreadStackSize in units of 1024 bytes.
2763 FLAG_SET_CMDLINE(intx, ThreadStackSize,
2764 round_to((int)long_ThreadStackSize, K) / K);
3669 } else {
3670 // Check if the policy is valid. Policies 0 and 1 are valid for non-tiered setup.
3671 if (CompilationPolicyChoice >= 2) {
3672 vm_exit_during_initialization(
3673 "Incompatible compilation policy selected", NULL);
3674 }
3675 }
3676 // Set NmethodSweepFraction after the size of the code cache is adapted (in case of tiered)
3677 if (FLAG_IS_DEFAULT(NmethodSweepFraction)) {
3678 FLAG_SET_DEFAULT(NmethodSweepFraction, 1 + ReservedCodeCacheSize / (16 * M));
3679 }
3680
3681
3682 // Set heap size based on available physical memory
3683 set_heap_size();
3684
3685 #if INCLUDE_ALL_GCS
3686 // Set per-collector flags
3687 if (UseParallelGC || UseParallelOldGC) {
3688 set_parallel_gc_flags();
3689 } else if (UseConcMarkSweepGC) { // Should be done before ParNew check below
3690 set_cms_and_parnew_gc_flags();
3691 } else if (UseParNewGC) { // Skipped if CMS is set above
3692 set_parnew_gc_flags();
3693 } else if (UseG1GC) {
3694 set_g1_gc_flags();
3695 }
3696 check_deprecated_gcs();
3697 check_deprecated_gc_flags();
3698 if (AssumeMP && !UseSerialGC) {
3699 if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) {
3700 warning("If the number of processors is expected to increase from one, then"
3701 " you should configure the number of parallel GC threads appropriately"
3702 " using -XX:ParallelGCThreads=N");
3703 }
3704 }
3705 if (MinHeapFreeRatio == 100) {
3706 // Keeping the heap 100% free is hard ;-) so limit it to 99%.
3707 FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99);
3708 }
3709 #else // INCLUDE_ALL_GCS
3710 assert(verify_serial_gc_flags(), "SerialGC unset");
3711 #endif // INCLUDE_ALL_GCS
3712
3713 // Initialize Metaspace flags and alignments.
3714 Metaspace::ergo_initialize();
3715
3716 // Set bytecode rewriting flags
3717 set_bytecode_flags();
3718
3719 // Set flags if Aggressive optimization flags (-XX:+AggressiveOpts) enabled.
3720 set_aggressive_opts_flags();
3721
3722 // Turn off biased locking for locking debug mode flags,
3723 // which are subtlely different from each other but neither works with
3724 // biased locking.
3725 if (UseHeavyMonitors
3726 #ifdef COMPILER1
3727 || !UseFastLocking
3728 #endif // COMPILER1
|