15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/classLoader.hpp"
27 #include "classfile/javaAssertions.hpp"
28 #include "classfile/stringTable.hpp"
29 #include "classfile/symbolTable.hpp"
30 #include "code/codeCacheExtensions.hpp"
31 #include "gc/shared/cardTableRS.hpp"
32 #include "gc/shared/genCollectedHeap.hpp"
33 #include "gc/shared/referenceProcessor.hpp"
34 #include "gc/shared/taskqueue.hpp"
35 #include "logging/logConfiguration.hpp"
36 #include "memory/allocation.inline.hpp"
37 #include "memory/universe.inline.hpp"
38 #include "oops/oop.inline.hpp"
39 #include "prims/jvmtiExport.hpp"
40 #include "runtime/arguments.hpp"
41 #include "runtime/arguments_ext.hpp"
42 #include "runtime/commandLineFlagConstraintList.hpp"
43 #include "runtime/commandLineFlagRangeList.hpp"
44 #include "runtime/globals.hpp"
45 #include "runtime/globals_extension.hpp"
46 #include "runtime/java.hpp"
47 #include "runtime/os.hpp"
48 #include "runtime/vm_version.hpp"
49 #include "services/management.hpp"
50 #include "services/memTracker.hpp"
51 #include "utilities/defaultStream.hpp"
52 #include "utilities/macros.hpp"
53 #include "utilities/stringUtils.hpp"
54 #if INCLUDE_JVMCI
1598 const size_t preferred_max_new_size_unaligned =
1599 MIN2(max_heap/(NewRatio+1), ScaleForWordSize(young_gen_per_worker * ParallelGCThreads));
1600 size_t preferred_max_new_size =
1601 align_size_up(preferred_max_new_size_unaligned, os::vm_page_size());
1602
1603 // Unless explicitly requested otherwise, size young gen
1604 // for "short" pauses ~ CMSYoungGenPerWorker*ParallelGCThreads
1605
1606 // If either MaxNewSize or NewRatio is set on the command line,
1607 // assume the user is trying to set the size of the young gen.
1608 if (FLAG_IS_DEFAULT(MaxNewSize) && FLAG_IS_DEFAULT(NewRatio)) {
1609
1610 // Set MaxNewSize to our calculated preferred_max_new_size unless
1611 // NewSize was set on the command line and it is larger than
1612 // preferred_max_new_size.
1613 if (!FLAG_IS_DEFAULT(NewSize)) { // NewSize explicitly set at command-line
1614 FLAG_SET_ERGO(size_t, MaxNewSize, MAX2(NewSize, preferred_max_new_size));
1615 } else {
1616 FLAG_SET_ERGO(size_t, MaxNewSize, preferred_max_new_size);
1617 }
1618 if (PrintGCDetails && Verbose) {
1619 // Too early to use gclog_or_tty
1620 tty->print_cr("CMS ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize);
1621 }
1622
1623 // Code along this path potentially sets NewSize and OldSize
1624 if (PrintGCDetails && Verbose) {
1625 // Too early to use gclog_or_tty
1626 tty->print_cr("CMS set min_heap_size: " SIZE_FORMAT
1627 " initial_heap_size: " SIZE_FORMAT
1628 " max_heap: " SIZE_FORMAT,
1629 min_heap_size(), InitialHeapSize, max_heap);
1630 }
1631 size_t min_new = preferred_max_new_size;
1632 if (FLAG_IS_CMDLINE(NewSize)) {
1633 min_new = NewSize;
1634 }
1635 if (max_heap > min_new && min_heap_size() > min_new) {
1636 // Unless explicitly requested otherwise, make young gen
1637 // at least min_new, and at most preferred_max_new_size.
1638 if (FLAG_IS_DEFAULT(NewSize)) {
1639 FLAG_SET_ERGO(size_t, NewSize, MAX2(NewSize, min_new));
1640 FLAG_SET_ERGO(size_t, NewSize, MIN2(preferred_max_new_size, NewSize));
1641 if (PrintGCDetails && Verbose) {
1642 // Too early to use gclog_or_tty
1643 tty->print_cr("CMS ergo set NewSize: " SIZE_FORMAT, NewSize);
1644 }
1645 }
1646 // Unless explicitly requested otherwise, size old gen
1647 // so it's NewRatio x of NewSize.
1648 if (FLAG_IS_DEFAULT(OldSize)) {
1649 if (max_heap > NewSize) {
1650 FLAG_SET_ERGO(size_t, OldSize, MIN2(NewRatio*NewSize, max_heap - NewSize));
1651 if (PrintGCDetails && Verbose) {
1652 // Too early to use gclog_or_tty
1653 tty->print_cr("CMS ergo set OldSize: " SIZE_FORMAT, OldSize);
1654 }
1655 }
1656 }
1657 }
1658 }
1659 // Unless explicitly requested otherwise, definitely
1660 // promote all objects surviving "tenuring_default" scavenges.
1661 if (FLAG_IS_DEFAULT(MaxTenuringThreshold) &&
1662 FLAG_IS_DEFAULT(SurvivorRatio)) {
1663 FLAG_SET_ERGO(uintx, MaxTenuringThreshold, tenuring_default);
1664 }
1665 // If we decided above (or user explicitly requested)
1666 // `promote all' (via MaxTenuringThreshold := 0),
1667 // prefer minuscule survivor spaces so as not to waste
1668 // space for (non-existent) survivors
1669 if (FLAG_IS_DEFAULT(SurvivorRatio) && MaxTenuringThreshold == 0) {
1670 FLAG_SET_ERGO(uintx, SurvivorRatio, MAX2((uintx)1024, SurvivorRatio));
1671 }
1672
1673 // OldPLABSize is interpreted in CMS as not the size of the PLAB in words,
1674 // but rather the number of free blocks of a given size that are used when
1678 // OldPLAB sizing manually turned off: Use a larger default setting,
1679 // unless it was manually specified. This is because a too-low value
1680 // will slow down scavenges.
1681 FLAG_SET_ERGO(size_t, OldPLABSize, CFLS_LAB::_default_static_old_plab_size); // default value before 6631166
1682 } else {
1683 FLAG_SET_DEFAULT(OldPLABSize, CFLS_LAB::_default_dynamic_old_plab_size); // old CMSParPromoteBlocksToClaim default
1684 }
1685 }
1686
1687 // If either of the static initialization defaults have changed, note this
1688 // modification.
1689 if (!FLAG_IS_DEFAULT(OldPLABSize) || !FLAG_IS_DEFAULT(OldPLABWeight)) {
1690 CFLS_LAB::modify_initialization(OldPLABSize, OldPLABWeight);
1691 }
1692
1693 if (!ClassUnloading) {
1694 FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false);
1695 FLAG_SET_CMDLINE(bool, ExplicitGCInvokesConcurrentAndUnloadsClasses, false);
1696 }
1697
1698 if (PrintGCDetails && Verbose) {
1699 tty->print_cr("MarkStackSize: %uk MarkStackSizeMax: %uk",
1700 (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
1701 tty->print_cr("ConcGCThreads: %u", ConcGCThreads);
1702 }
1703 }
1704 #endif // INCLUDE_ALL_GCS
1705
1706 void set_object_alignment() {
1707 // Object alignment.
1708 assert(is_power_of_2(ObjectAlignmentInBytes), "ObjectAlignmentInBytes must be power of 2");
1709 MinObjAlignmentInBytes = ObjectAlignmentInBytes;
1710 assert(MinObjAlignmentInBytes >= HeapWordsPerLong * HeapWordSize, "ObjectAlignmentInBytes value is too small");
1711 MinObjAlignment = MinObjAlignmentInBytes / HeapWordSize;
1712 assert(MinObjAlignmentInBytes == MinObjAlignment * HeapWordSize, "ObjectAlignmentInBytes value is incorrect");
1713 MinObjAlignmentInBytesMask = MinObjAlignmentInBytes - 1;
1714
1715 LogMinObjAlignmentInBytes = exact_log2(ObjectAlignmentInBytes);
1716 LogMinObjAlignment = LogMinObjAlignmentInBytes - LogHeapWordSize;
1717
1718 // Oop encoding heap max
1719 OopEncodingHeapMax = (uint64_t(max_juint) + 1) << LogMinObjAlignmentInBytes;
1720
1721 if (SurvivorAlignmentInBytes == 0) {
1722 SurvivorAlignmentInBytes = ObjectAlignmentInBytes;
1729 }
1730
1731 size_t Arguments::max_heap_for_compressed_oops() {
1732 // Avoid sign flip.
1733 assert(OopEncodingHeapMax > (uint64_t)os::vm_page_size(), "Unusual page size");
1734 // We need to fit both the NULL page and the heap into the memory budget, while
1735 // keeping alignment constraints of the heap. To guarantee the latter, as the
1736 // NULL page is located before the heap, we pad the NULL page to the conservative
1737 // maximum alignment that the GC may ever impose upon the heap.
1738 size_t displacement_due_to_null_page = align_size_up_(os::vm_page_size(),
1739 _conservative_max_heap_alignment);
1740
1741 LP64_ONLY(return OopEncodingHeapMax - displacement_due_to_null_page);
1742 NOT_LP64(ShouldNotReachHere(); return 0);
1743 }
1744
1745 bool Arguments::should_auto_select_low_pause_collector() {
1746 if (UseAutoGCSelectPolicy &&
1747 !FLAG_IS_DEFAULT(MaxGCPauseMillis) &&
1748 (MaxGCPauseMillis <= AutoGCSelectPauseMillis)) {
1749 if (PrintGCDetails) {
1750 // Cannot use gclog_or_tty yet.
1751 tty->print_cr("Automatic selection of the low pause collector"
1752 " based on pause goal of %d (ms)", (int) MaxGCPauseMillis);
1753 }
1754 return true;
1755 }
1756 return false;
1757 }
1758
1759 void Arguments::set_use_compressed_oops() {
1760 #ifndef ZERO
1761 #ifdef _LP64
1762 // MaxHeapSize is not set up properly at this point, but
1763 // the only value that can override MaxHeapSize if we are
1764 // to use UseCompressedOops is InitialHeapSize.
1765 size_t max_heap_size = MAX2(MaxHeapSize, InitialHeapSize);
1766
1767 if (max_heap_size <= max_heap_for_compressed_oops()) {
1768 #if !defined(COMPILER1) || defined(TIERED)
1769 if (FLAG_IS_DEFAULT(UseCompressedOops)) {
1770 FLAG_SET_ERGO(bool, UseCompressedOops, true);
1771 }
1772 #endif
1773 } else {
2071 }
2072 }
2073
2074 if (HeapBaseMinAddress + MaxHeapSize < max_coop_heap) {
2075 // Heap should be above HeapBaseMinAddress to get zero based compressed oops
2076 // but it should be not less than default MaxHeapSize.
2077 max_coop_heap -= HeapBaseMinAddress;
2078 }
2079 reasonable_max = MIN2(reasonable_max, max_coop_heap);
2080 }
2081 reasonable_max = limit_by_allocatable_memory(reasonable_max);
2082
2083 if (!FLAG_IS_DEFAULT(InitialHeapSize)) {
2084 // An initial heap size was specified on the command line,
2085 // so be sure that the maximum size is consistent. Done
2086 // after call to limit_by_allocatable_memory because that
2087 // method might reduce the allocation size.
2088 reasonable_max = MAX2(reasonable_max, (julong)InitialHeapSize);
2089 }
2090
2091 if (PrintGCDetails && Verbose) {
2092 // Cannot use gclog_or_tty yet.
2093 tty->print_cr(" Maximum heap size " SIZE_FORMAT, (size_t) reasonable_max);
2094 }
2095 FLAG_SET_ERGO(size_t, MaxHeapSize, (size_t)reasonable_max);
2096 }
2097
2098 // If the minimum or initial heap_size have not been set or requested to be set
2099 // ergonomically, set them accordingly.
2100 if (InitialHeapSize == 0 || min_heap_size() == 0) {
2101 julong reasonable_minimum = (julong)(OldSize + NewSize);
2102
2103 reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize);
2104
2105 reasonable_minimum = limit_by_allocatable_memory(reasonable_minimum);
2106
2107 if (InitialHeapSize == 0) {
2108 julong reasonable_initial = phys_mem / InitialRAMFraction;
2109
2110 reasonable_initial = MAX3(reasonable_initial, reasonable_minimum, (julong)min_heap_size());
2111 reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize);
2112
2113 reasonable_initial = limit_by_allocatable_memory(reasonable_initial);
2114
2115 if (PrintGCDetails && Verbose) {
2116 // Cannot use gclog_or_tty yet.
2117 tty->print_cr(" Initial heap size " SIZE_FORMAT, (size_t)reasonable_initial);
2118 }
2119 FLAG_SET_ERGO(size_t, InitialHeapSize, (size_t)reasonable_initial);
2120 }
2121 // If the minimum heap size has not been set (via -Xms),
2122 // synchronize with InitialHeapSize to avoid errors with the default value.
2123 if (min_heap_size() == 0) {
2124 set_min_heap_size(MIN2((size_t)reasonable_minimum, InitialHeapSize));
2125 if (PrintGCDetails && Verbose) {
2126 // Cannot use gclog_or_tty yet.
2127 tty->print_cr(" Minimum heap size " SIZE_FORMAT, min_heap_size());
2128 }
2129 }
2130 }
2131 }
2132
2133 // This option inspects the machine and attempts to set various
2134 // parameters to be optimal for long-running, memory allocation
2135 // intensive jobs. It is intended for machines with large
2136 // amounts of cpu and memory.
2137 jint Arguments::set_aggressive_heap_flags() {
2138 // initHeapSize is needed since _initial_heap_size is 4 bytes on a 32 bit
2139 // VM, but we may not be able to represent the total physical memory
2140 // available (like having 8gb of memory on a box but using a 32bit VM).
2141 // Thus, we need to make sure we're using a julong for intermediate
2142 // calculations.
2143 julong initHeapSize;
2144 julong total_memory = os::physical_memory();
2145
2146 if (total_memory < (julong) 256 * M) {
2147 jio_fprintf(defaultStream::error_stream(),
2148 "You need at least 256mb of memory to use -XX:+AggressiveHeap\n");
3183 // note this flag has been used, then ignore
3184 set_xdebug_mode(true);
3185 // -Xnoagent
3186 } else if (match_option(option, "-Xnoagent")) {
3187 // For compatibility with classic. HotSpot refuses to load the old style agent.dll.
3188 } else if (match_option(option, "-Xloggc:", &tail)) {
3189 // Redirect GC output to the file. -Xloggc:<filename>
3190 // ostream_init_log(), when called will use this filename
3191 // to initialize a fileStream.
3192 _gc_log_filename = os::strdup_check_oom(tail);
3193 if (!is_filename_valid(_gc_log_filename)) {
3194 jio_fprintf(defaultStream::output_stream(),
3195 "Invalid file name for use with -Xloggc: Filename can only contain the "
3196 "characters [A-Z][a-z][0-9]-_.%%[p|t] but it has been %s\n"
3197 "Note %%p or %%t can only be used once\n", _gc_log_filename);
3198 return JNI_EINVAL;
3199 }
3200 if (FLAG_SET_CMDLINE(bool, PrintGC, true) != Flag::SUCCESS) {
3201 return JNI_EINVAL;
3202 }
3203 if (FLAG_SET_CMDLINE(bool, PrintGCTimeStamps, true) != Flag::SUCCESS) {
3204 return JNI_EINVAL;
3205 }
3206 } else if (match_option(option, "-Xlog", &tail)) {
3207 bool ret = false;
3208 if (strcmp(tail, ":help") == 0) {
3209 LogConfiguration::print_command_line_help(defaultStream::output_stream());
3210 vm_exit(0);
3211 } else if (strcmp(tail, ":disable") == 0) {
3212 LogConfiguration::disable_logging();
3213 ret = true;
3214 } else if (*tail == '\0') {
3215 ret = LogConfiguration::parse_command_line_arguments();
3216 assert(ret, "-Xlog without arguments should never fail to parse");
3217 } else if (*tail == ':') {
3218 ret = LogConfiguration::parse_command_line_arguments(tail + 1);
3219 }
3220 if (ret == false) {
3221 jio_fprintf(defaultStream::error_stream(),
3222 "Invalid -Xlog option '-Xlog%s'\n",
3223 tail);
3224 return JNI_EINVAL;
3225 }
4226
4227 #ifndef PRODUCT
4228 if (TraceBytecodesAt != 0) {
4229 TraceBytecodes = true;
4230 }
4231 if (CountCompiledCalls) {
4232 if (UseCounterDecay) {
4233 warning("UseCounterDecay disabled because CountCalls is set");
4234 UseCounterDecay = false;
4235 }
4236 }
4237 #endif // PRODUCT
4238
4239 if (ScavengeRootsInCode == 0) {
4240 if (!FLAG_IS_DEFAULT(ScavengeRootsInCode)) {
4241 warning("Forcing ScavengeRootsInCode non-zero");
4242 }
4243 ScavengeRootsInCode = 1;
4244 }
4245
4246 if (PrintGCDetails) {
4247 // Turn on -verbose:gc options as well
4248 PrintGC = true;
4249 }
4250
4251 // Set object alignment values.
4252 set_object_alignment();
4253
4254 #if !INCLUDE_ALL_GCS
4255 force_serial_gc();
4256 #endif // INCLUDE_ALL_GCS
4257 #if !INCLUDE_CDS
4258 if (DumpSharedSpaces || RequireSharedSpaces) {
4259 jio_fprintf(defaultStream::error_stream(),
4260 "Shared spaces are not supported in this VM\n");
4261 return JNI_ERR;
4262 }
4263 if ((UseSharedSpaces && FLAG_IS_CMDLINE(UseSharedSpaces)) || PrintSharedSpaces) {
4264 warning("Shared spaces are not supported in this VM");
4265 FLAG_SET_DEFAULT(UseSharedSpaces, false);
4266 FLAG_SET_DEFAULT(PrintSharedSpaces, false);
4267 }
4268 no_shared_spaces("CDS Disabled");
|
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/classLoader.hpp"
27 #include "classfile/javaAssertions.hpp"
28 #include "classfile/stringTable.hpp"
29 #include "classfile/symbolTable.hpp"
30 #include "code/codeCacheExtensions.hpp"
31 #include "gc/shared/cardTableRS.hpp"
32 #include "gc/shared/genCollectedHeap.hpp"
33 #include "gc/shared/referenceProcessor.hpp"
34 #include "gc/shared/taskqueue.hpp"
35 #include "logging/log.hpp"
36 #include "logging/logConfiguration.hpp"
37 #include "memory/allocation.inline.hpp"
38 #include "memory/universe.inline.hpp"
39 #include "oops/oop.inline.hpp"
40 #include "prims/jvmtiExport.hpp"
41 #include "runtime/arguments.hpp"
42 #include "runtime/arguments_ext.hpp"
43 #include "runtime/commandLineFlagConstraintList.hpp"
44 #include "runtime/commandLineFlagRangeList.hpp"
45 #include "runtime/globals.hpp"
46 #include "runtime/globals_extension.hpp"
47 #include "runtime/java.hpp"
48 #include "runtime/os.hpp"
49 #include "runtime/vm_version.hpp"
50 #include "services/management.hpp"
51 #include "services/memTracker.hpp"
52 #include "utilities/defaultStream.hpp"
53 #include "utilities/macros.hpp"
54 #include "utilities/stringUtils.hpp"
55 #if INCLUDE_JVMCI
1599 const size_t preferred_max_new_size_unaligned =
1600 MIN2(max_heap/(NewRatio+1), ScaleForWordSize(young_gen_per_worker * ParallelGCThreads));
1601 size_t preferred_max_new_size =
1602 align_size_up(preferred_max_new_size_unaligned, os::vm_page_size());
1603
1604 // Unless explicitly requested otherwise, size young gen
1605 // for "short" pauses ~ CMSYoungGenPerWorker*ParallelGCThreads
1606
1607 // If either MaxNewSize or NewRatio is set on the command line,
1608 // assume the user is trying to set the size of the young gen.
1609 if (FLAG_IS_DEFAULT(MaxNewSize) && FLAG_IS_DEFAULT(NewRatio)) {
1610
1611 // Set MaxNewSize to our calculated preferred_max_new_size unless
1612 // NewSize was set on the command line and it is larger than
1613 // preferred_max_new_size.
1614 if (!FLAG_IS_DEFAULT(NewSize)) { // NewSize explicitly set at command-line
1615 FLAG_SET_ERGO(size_t, MaxNewSize, MAX2(NewSize, preferred_max_new_size));
1616 } else {
1617 FLAG_SET_ERGO(size_t, MaxNewSize, preferred_max_new_size);
1618 }
1619 log_trace(gc, init)("CMS ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize);
1620
1621 // Code along this path potentially sets NewSize and OldSize
1622 log_trace(gc, init)("CMS set min_heap_size: " SIZE_FORMAT " initial_heap_size: " SIZE_FORMAT " max_heap: " SIZE_FORMAT,
1623 min_heap_size(), InitialHeapSize, max_heap);
1624 size_t min_new = preferred_max_new_size;
1625 if (FLAG_IS_CMDLINE(NewSize)) {
1626 min_new = NewSize;
1627 }
1628 if (max_heap > min_new && min_heap_size() > min_new) {
1629 // Unless explicitly requested otherwise, make young gen
1630 // at least min_new, and at most preferred_max_new_size.
1631 if (FLAG_IS_DEFAULT(NewSize)) {
1632 FLAG_SET_ERGO(size_t, NewSize, MAX2(NewSize, min_new));
1633 FLAG_SET_ERGO(size_t, NewSize, MIN2(preferred_max_new_size, NewSize));
1634 log_trace(gc, init)("CMS ergo set NewSize: " SIZE_FORMAT, NewSize);
1635 }
1636 // Unless explicitly requested otherwise, size old gen
1637 // so it's NewRatio x of NewSize.
1638 if (FLAG_IS_DEFAULT(OldSize)) {
1639 if (max_heap > NewSize) {
1640 FLAG_SET_ERGO(size_t, OldSize, MIN2(NewRatio*NewSize, max_heap - NewSize));
1641 log_trace(gc, init)("CMS ergo set OldSize: " SIZE_FORMAT, OldSize);
1642 }
1643 }
1644 }
1645 }
1646 // Unless explicitly requested otherwise, definitely
1647 // promote all objects surviving "tenuring_default" scavenges.
1648 if (FLAG_IS_DEFAULT(MaxTenuringThreshold) &&
1649 FLAG_IS_DEFAULT(SurvivorRatio)) {
1650 FLAG_SET_ERGO(uintx, MaxTenuringThreshold, tenuring_default);
1651 }
1652 // If we decided above (or user explicitly requested)
1653 // `promote all' (via MaxTenuringThreshold := 0),
1654 // prefer minuscule survivor spaces so as not to waste
1655 // space for (non-existent) survivors
1656 if (FLAG_IS_DEFAULT(SurvivorRatio) && MaxTenuringThreshold == 0) {
1657 FLAG_SET_ERGO(uintx, SurvivorRatio, MAX2((uintx)1024, SurvivorRatio));
1658 }
1659
1660 // OldPLABSize is interpreted in CMS as not the size of the PLAB in words,
1661 // but rather the number of free blocks of a given size that are used when
1665 // OldPLAB sizing manually turned off: Use a larger default setting,
1666 // unless it was manually specified. This is because a too-low value
1667 // will slow down scavenges.
1668 FLAG_SET_ERGO(size_t, OldPLABSize, CFLS_LAB::_default_static_old_plab_size); // default value before 6631166
1669 } else {
1670 FLAG_SET_DEFAULT(OldPLABSize, CFLS_LAB::_default_dynamic_old_plab_size); // old CMSParPromoteBlocksToClaim default
1671 }
1672 }
1673
1674 // If either of the static initialization defaults have changed, note this
1675 // modification.
1676 if (!FLAG_IS_DEFAULT(OldPLABSize) || !FLAG_IS_DEFAULT(OldPLABWeight)) {
1677 CFLS_LAB::modify_initialization(OldPLABSize, OldPLABWeight);
1678 }
1679
1680 if (!ClassUnloading) {
1681 FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false);
1682 FLAG_SET_CMDLINE(bool, ExplicitGCInvokesConcurrentAndUnloadsClasses, false);
1683 }
1684
1685 log_trace(gc, init)("MarkStackSize: %uk MarkStackSizeMax: %uk", (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
1686 log_trace(gc, init)("ConcGCThreads: %u", ConcGCThreads);
1687 }
1688 #endif // INCLUDE_ALL_GCS
1689
1690 void set_object_alignment() {
1691 // Object alignment.
1692 assert(is_power_of_2(ObjectAlignmentInBytes), "ObjectAlignmentInBytes must be power of 2");
1693 MinObjAlignmentInBytes = ObjectAlignmentInBytes;
1694 assert(MinObjAlignmentInBytes >= HeapWordsPerLong * HeapWordSize, "ObjectAlignmentInBytes value is too small");
1695 MinObjAlignment = MinObjAlignmentInBytes / HeapWordSize;
1696 assert(MinObjAlignmentInBytes == MinObjAlignment * HeapWordSize, "ObjectAlignmentInBytes value is incorrect");
1697 MinObjAlignmentInBytesMask = MinObjAlignmentInBytes - 1;
1698
1699 LogMinObjAlignmentInBytes = exact_log2(ObjectAlignmentInBytes);
1700 LogMinObjAlignment = LogMinObjAlignmentInBytes - LogHeapWordSize;
1701
1702 // Oop encoding heap max
1703 OopEncodingHeapMax = (uint64_t(max_juint) + 1) << LogMinObjAlignmentInBytes;
1704
1705 if (SurvivorAlignmentInBytes == 0) {
1706 SurvivorAlignmentInBytes = ObjectAlignmentInBytes;
1713 }
1714
1715 size_t Arguments::max_heap_for_compressed_oops() {
1716 // Avoid sign flip.
1717 assert(OopEncodingHeapMax > (uint64_t)os::vm_page_size(), "Unusual page size");
1718 // We need to fit both the NULL page and the heap into the memory budget, while
1719 // keeping alignment constraints of the heap. To guarantee the latter, as the
1720 // NULL page is located before the heap, we pad the NULL page to the conservative
1721 // maximum alignment that the GC may ever impose upon the heap.
1722 size_t displacement_due_to_null_page = align_size_up_(os::vm_page_size(),
1723 _conservative_max_heap_alignment);
1724
1725 LP64_ONLY(return OopEncodingHeapMax - displacement_due_to_null_page);
1726 NOT_LP64(ShouldNotReachHere(); return 0);
1727 }
1728
1729 bool Arguments::should_auto_select_low_pause_collector() {
1730 if (UseAutoGCSelectPolicy &&
1731 !FLAG_IS_DEFAULT(MaxGCPauseMillis) &&
1732 (MaxGCPauseMillis <= AutoGCSelectPauseMillis)) {
1733 log_trace(gc, init)("Automatic selection of the low pause collector based on pause goal of %d (ms)", (int) MaxGCPauseMillis);
1734 return true;
1735 }
1736 return false;
1737 }
1738
1739 void Arguments::set_use_compressed_oops() {
1740 #ifndef ZERO
1741 #ifdef _LP64
1742 // MaxHeapSize is not set up properly at this point, but
1743 // the only value that can override MaxHeapSize if we are
1744 // to use UseCompressedOops is InitialHeapSize.
1745 size_t max_heap_size = MAX2(MaxHeapSize, InitialHeapSize);
1746
1747 if (max_heap_size <= max_heap_for_compressed_oops()) {
1748 #if !defined(COMPILER1) || defined(TIERED)
1749 if (FLAG_IS_DEFAULT(UseCompressedOops)) {
1750 FLAG_SET_ERGO(bool, UseCompressedOops, true);
1751 }
1752 #endif
1753 } else {
2051 }
2052 }
2053
2054 if (HeapBaseMinAddress + MaxHeapSize < max_coop_heap) {
2055 // Heap should be above HeapBaseMinAddress to get zero based compressed oops
2056 // but it should be not less than default MaxHeapSize.
2057 max_coop_heap -= HeapBaseMinAddress;
2058 }
2059 reasonable_max = MIN2(reasonable_max, max_coop_heap);
2060 }
2061 reasonable_max = limit_by_allocatable_memory(reasonable_max);
2062
2063 if (!FLAG_IS_DEFAULT(InitialHeapSize)) {
2064 // An initial heap size was specified on the command line,
2065 // so be sure that the maximum size is consistent. Done
2066 // after call to limit_by_allocatable_memory because that
2067 // method might reduce the allocation size.
2068 reasonable_max = MAX2(reasonable_max, (julong)InitialHeapSize);
2069 }
2070
2071 log_trace(gc, init)(" Maximum heap size " SIZE_FORMAT, (size_t) reasonable_max);
2072 FLAG_SET_ERGO(size_t, MaxHeapSize, (size_t)reasonable_max);
2073 }
2074
2075 // If the minimum or initial heap_size have not been set or requested to be set
2076 // ergonomically, set them accordingly.
2077 if (InitialHeapSize == 0 || min_heap_size() == 0) {
2078 julong reasonable_minimum = (julong)(OldSize + NewSize);
2079
2080 reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize);
2081
2082 reasonable_minimum = limit_by_allocatable_memory(reasonable_minimum);
2083
2084 if (InitialHeapSize == 0) {
2085 julong reasonable_initial = phys_mem / InitialRAMFraction;
2086
2087 reasonable_initial = MAX3(reasonable_initial, reasonable_minimum, (julong)min_heap_size());
2088 reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize);
2089
2090 reasonable_initial = limit_by_allocatable_memory(reasonable_initial);
2091
2092 log_trace(gc, init)(" Initial heap size " SIZE_FORMAT, (size_t)reasonable_initial);
2093 FLAG_SET_ERGO(size_t, InitialHeapSize, (size_t)reasonable_initial);
2094 }
2095 // If the minimum heap size has not been set (via -Xms),
2096 // synchronize with InitialHeapSize to avoid errors with the default value.
2097 if (min_heap_size() == 0) {
2098 set_min_heap_size(MIN2((size_t)reasonable_minimum, InitialHeapSize));
2099 log_trace(gc, init)(" Minimum heap size " SIZE_FORMAT, min_heap_size());
2100 }
2101 }
2102 }
2103
2104 // This option inspects the machine and attempts to set various
2105 // parameters to be optimal for long-running, memory allocation
2106 // intensive jobs. It is intended for machines with large
2107 // amounts of cpu and memory.
2108 jint Arguments::set_aggressive_heap_flags() {
2109 // initHeapSize is needed since _initial_heap_size is 4 bytes on a 32 bit
2110 // VM, but we may not be able to represent the total physical memory
2111 // available (like having 8gb of memory on a box but using a 32bit VM).
2112 // Thus, we need to make sure we're using a julong for intermediate
2113 // calculations.
2114 julong initHeapSize;
2115 julong total_memory = os::physical_memory();
2116
2117 if (total_memory < (julong) 256 * M) {
2118 jio_fprintf(defaultStream::error_stream(),
2119 "You need at least 256mb of memory to use -XX:+AggressiveHeap\n");
3154 // note this flag has been used, then ignore
3155 set_xdebug_mode(true);
3156 // -Xnoagent
3157 } else if (match_option(option, "-Xnoagent")) {
3158 // For compatibility with classic. HotSpot refuses to load the old style agent.dll.
3159 } else if (match_option(option, "-Xloggc:", &tail)) {
3160 // Redirect GC output to the file. -Xloggc:<filename>
3161 // ostream_init_log(), when called will use this filename
3162 // to initialize a fileStream.
3163 _gc_log_filename = os::strdup_check_oom(tail);
3164 if (!is_filename_valid(_gc_log_filename)) {
3165 jio_fprintf(defaultStream::output_stream(),
3166 "Invalid file name for use with -Xloggc: Filename can only contain the "
3167 "characters [A-Z][a-z][0-9]-_.%%[p|t] but it has been %s\n"
3168 "Note %%p or %%t can only be used once\n", _gc_log_filename);
3169 return JNI_EINVAL;
3170 }
3171 if (FLAG_SET_CMDLINE(bool, PrintGC, true) != Flag::SUCCESS) {
3172 return JNI_EINVAL;
3173 }
3174 } else if (match_option(option, "-Xlog", &tail)) {
3175 bool ret = false;
3176 if (strcmp(tail, ":help") == 0) {
3177 LogConfiguration::print_command_line_help(defaultStream::output_stream());
3178 vm_exit(0);
3179 } else if (strcmp(tail, ":disable") == 0) {
3180 LogConfiguration::disable_logging();
3181 ret = true;
3182 } else if (*tail == '\0') {
3183 ret = LogConfiguration::parse_command_line_arguments();
3184 assert(ret, "-Xlog without arguments should never fail to parse");
3185 } else if (*tail == ':') {
3186 ret = LogConfiguration::parse_command_line_arguments(tail + 1);
3187 }
3188 if (ret == false) {
3189 jio_fprintf(defaultStream::error_stream(),
3190 "Invalid -Xlog option '-Xlog%s'\n",
3191 tail);
3192 return JNI_EINVAL;
3193 }
4194
4195 #ifndef PRODUCT
4196 if (TraceBytecodesAt != 0) {
4197 TraceBytecodes = true;
4198 }
4199 if (CountCompiledCalls) {
4200 if (UseCounterDecay) {
4201 warning("UseCounterDecay disabled because CountCalls is set");
4202 UseCounterDecay = false;
4203 }
4204 }
4205 #endif // PRODUCT
4206
4207 if (ScavengeRootsInCode == 0) {
4208 if (!FLAG_IS_DEFAULT(ScavengeRootsInCode)) {
4209 warning("Forcing ScavengeRootsInCode non-zero");
4210 }
4211 ScavengeRootsInCode = 1;
4212 }
4213
4214 if (PrintGC) {
4215 warning("-XX:+PrintGC not supported in this build. Will turn it off.");
4216 PrintGC = false;
4217 }
4218 if (PrintGCDetails) {
4219 warning("-XX:+PrintGCDetails not supported in this build. Will turn it off.");
4220 PrintGCDetails = false;
4221 }
4222
4223 // Set object alignment values.
4224 set_object_alignment();
4225
4226 #if !INCLUDE_ALL_GCS
4227 force_serial_gc();
4228 #endif // INCLUDE_ALL_GCS
4229 #if !INCLUDE_CDS
4230 if (DumpSharedSpaces || RequireSharedSpaces) {
4231 jio_fprintf(defaultStream::error_stream(),
4232 "Shared spaces are not supported in this VM\n");
4233 return JNI_ERR;
4234 }
4235 if ((UseSharedSpaces && FLAG_IS_CMDLINE(UseSharedSpaces)) || PrintSharedSpaces) {
4236 warning("Shared spaces are not supported in this VM");
4237 FLAG_SET_DEFAULT(UseSharedSpaces, false);
4238 FLAG_SET_DEFAULT(PrintSharedSpaces, false);
4239 }
4240 no_shared_spaces("CDS Disabled");
|