49 #endif
50 #ifdef TARGET_OS_FAMILY_linux
51 # include "os_linux.inline.hpp"
52 #endif
53 #ifdef TARGET_OS_FAMILY_solaris
54 # include "os_solaris.inline.hpp"
55 #endif
56 #ifdef TARGET_OS_FAMILY_windows
57 # include "os_windows.inline.hpp"
58 #endif
59 #ifdef TARGET_OS_FAMILY_aix
60 # include "os_aix.inline.hpp"
61 #endif
62 #ifdef TARGET_OS_FAMILY_bsd
63 # include "os_bsd.inline.hpp"
64 #endif
65 #if INCLUDE_ALL_GCS
66 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
67 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
68 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
69 #endif // INCLUDE_ALL_GCS
70
71 // Note: This is a special bug reporting site for the JVM
72 #ifdef VENDOR_URL_VM_BUG
73 # define DEFAULT_VENDOR_URL_BUG VENDOR_URL_VM_BUG
74 #else
75 # define DEFAULT_VENDOR_URL_BUG "http://bugreport.java.com/bugreport/crash.jsp"
76 #endif
77 #define DEFAULT_JAVA_LAUNCHER "generic"
78
79 // Disable options not supported in this release, with a warning if they
80 // were explicitly requested on the command-line
81 #define UNSUPPORTED_OPTION(opt, description) \
82 do { \
83 if (opt) { \
84 if (FLAG_IS_CMDLINE(opt)) { \
85 warning(description " is disabled in this release."); \
86 } \
87 FLAG_SET_DEFAULT(opt, false); \
88 } \
1525 #ifdef _WIN64
1526 if (UseLargePages && UseCompressedOops) {
1527 // Cannot allocate guard pages for implicit checks in indexed addressing
1528 // mode, when large pages are specified on windows.
1529 // This flag could be switched ON if narrow oop base address is set to 0,
1530 // see code in Universe::initialize_heap().
1531 Universe::set_narrow_oop_use_implicit_null_checks(false);
1532 }
1533 #endif // _WIN64
1534 } else {
1535 if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) {
1536 warning("Max heap size too large for Compressed Oops");
1537 FLAG_SET_DEFAULT(UseCompressedOops, false);
1538 FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1539 }
1540 }
1541 #endif // _LP64
1542 #endif // ZERO
1543 }
1544
1545
1546 // NOTE: set_use_compressed_klass_ptrs() must be called after calling
1547 // set_use_compressed_oops().
1548 void Arguments::set_use_compressed_klass_ptrs() {
1549 #ifndef ZERO
1550 #ifdef _LP64
1551 // UseCompressedOops must be on for UseCompressedClassPointers to be on.
1552 if (!UseCompressedOops) {
1553 if (UseCompressedClassPointers) {
1554 warning("UseCompressedClassPointers requires UseCompressedOops");
1555 }
1556 FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1557 } else {
1558 // Turn on UseCompressedClassPointers too
1559 if (FLAG_IS_DEFAULT(UseCompressedClassPointers)) {
1560 FLAG_SET_ERGO(bool, UseCompressedClassPointers, true);
1561 }
1562 // Check the CompressedClassSpaceSize to make sure we use compressed klass ptrs.
1563 if (UseCompressedClassPointers) {
1564 if (CompressedClassSpaceSize > KlassEncodingMetaspaceMax) {
1565 warning("CompressedClassSpaceSize is too large for UseCompressedClassPointers");
1566 FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1567 }
1568 }
1569 }
1570 #endif // _LP64
1571 #endif // !ZERO
1572 }
1573
1574 void Arguments::set_conservative_max_heap_alignment() {
1575 // The conservative maximum required alignment for the heap is the maximum of
1576 // the alignments imposed by several sources: any requirements from the heap
1577 // itself, the collector policy and the maximum page size we may run the VM
1578 // with.
1579 size_t heap_alignment = GenCollectedHeap::conservative_max_heap_alignment();
1580 #if INCLUDE_ALL_GCS
1581 if (UseParallelGC) {
1582 heap_alignment = ParallelScavengeHeap::conservative_max_heap_alignment();
1583 } else if (UseG1GC) {
1584 heap_alignment = G1CollectedHeap::conservative_max_heap_alignment();
1585 }
1586 #endif // INCLUDE_ALL_GCS
1587 _conservative_max_heap_alignment = MAX4(heap_alignment,
1588 (size_t)os::vm_allocation_granularity(),
1589 os::max_page_size(),
1590 CollectorPolicy::compute_heap_alignment());
1591 }
1592
1593 void Arguments::select_gc_ergonomically() {
1594 if (os::is_server_class_machine()) {
1595 if (should_auto_select_low_pause_collector()) {
1596 FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
1597 } else {
1598 FLAG_SET_ERGO(bool, UseParallelGC, true);
1599 }
1600 }
1601 }
1602
1603 void Arguments::select_gc() {
1604 if (!gc_selected()) {
1716 FLAG_SET_DEFAULT(MarkStackSizeMax, 128 * TASKQUEUE_SIZE);
1717 }
1718
1719 if (FLAG_IS_DEFAULT(GCTimeRatio) || GCTimeRatio == 0) {
1720 // In G1, we want the default GC overhead goal to be higher than
1721 // say in PS. So we set it here to 10%. Otherwise the heap might
1722 // be expanded more aggressively than we would like it to. In
1723 // fact, even 10% seems to not be high enough in some cases
1724 // (especially small GC stress tests that the main thing they do
1725 // is allocation). We might consider increase it further.
1726 FLAG_SET_DEFAULT(GCTimeRatio, 9);
1727 }
1728
1729 if (PrintGCDetails && Verbose) {
1730 tty->print_cr("MarkStackSize: %uk MarkStackSizeMax: %uk",
1731 (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
1732 tty->print_cr("ConcGCThreads: %u", (uint) ConcGCThreads);
1733 }
1734 }
1735
1736 #if !INCLUDE_ALL_GCS
1737 #ifdef ASSERT
1738 static bool verify_serial_gc_flags() {
1739 return (UseSerialGC &&
1740 !(UseParNewGC || (UseConcMarkSweepGC || CMSIncrementalMode) || UseG1GC ||
1741 UseParallelGC || UseParallelOldGC));
1742 }
1743 #endif // ASSERT
1744 #endif // INCLUDE_ALL_GCS
1745
1746 void Arguments::set_gc_specific_flags() {
1747 #if INCLUDE_ALL_GCS
1748 // Set per-collector flags
1749 if (UseParallelGC || UseParallelOldGC) {
1750 set_parallel_gc_flags();
1751 } else if (UseConcMarkSweepGC) { // Should be done before ParNew check below
1752 set_cms_and_parnew_gc_flags();
1753 } else if (UseParNewGC) { // Skipped if CMS is set above
1754 set_parnew_gc_flags();
1755 } else if (UseG1GC) {
1756 set_g1_gc_flags();
1757 }
1758 check_deprecated_gcs();
1759 check_deprecated_gc_flags();
1760 if (AssumeMP && !UseSerialGC) {
1761 if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) {
1762 warning("If the number of processors is expected to increase from one, then"
1763 " you should configure the number of parallel GC threads appropriately"
1764 " using -XX:ParallelGCThreads=N");
1765 }
1766 }
1767 if (MinHeapFreeRatio == 100) {
1768 // Keeping the heap 100% free is hard ;-) so limit it to 99%.
1769 FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99);
1770 }
1771
1772 // If class unloading is disabled, also disable concurrent class unloading.
1773 if (!ClassUnloading) {
1774 FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false);
1775 FLAG_SET_CMDLINE(bool, ClassUnloadingWithConcurrentMark, false);
1776 FLAG_SET_CMDLINE(bool, ExplicitGCInvokesConcurrentAndUnloadsClasses, false);
1777 }
1778 #else // INCLUDE_ALL_GCS
1779 assert(verify_serial_gc_flags(), "SerialGC unset");
1780 #endif // INCLUDE_ALL_GCS
1781 }
1782
1783 julong Arguments::limit_by_allocatable_memory(julong limit) {
1784 julong max_allocatable;
1785 julong result = limit;
1786 if (os::has_allocatable_memory_limit(&max_allocatable)) {
1787 result = MIN2(result, max_allocatable / MaxVirtMemFraction);
1788 }
1789 return result;
1790 }
1791
1792 void Arguments::set_heap_size() {
1793 if (!FLAG_IS_DEFAULT(DefaultMaxRAMFraction)) {
1794 // Deprecated flag
1795 FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction);
1796 }
2137 // check if do gclog rotation
2138 // +UseGCLogFileRotation is a must,
2139 // no gc log rotation when log file not supplied or
2140 // NumberOfGCLogFiles is 0
2141 void check_gclog_consistency() {
2142 if (UseGCLogFileRotation) {
2143 if ((Arguments::gc_log_filename() == NULL) || (NumberOfGCLogFiles == 0)) {
2144 jio_fprintf(defaultStream::output_stream(),
2145 "To enable GC log rotation, use -Xloggc:<filename> -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=<num_of_files>\n"
2146 "where num_of_file > 0\n"
2147 "GC log rotation is turned off\n");
2148 UseGCLogFileRotation = false;
2149 }
2150 }
2151
2152 if (UseGCLogFileRotation && (GCLogFileSize != 0) && (GCLogFileSize < 8*K)) {
2153 FLAG_SET_CMDLINE(uintx, GCLogFileSize, 8*K);
2154 jio_fprintf(defaultStream::output_stream(),
2155 "GCLogFileSize changed to minimum 8K\n");
2156 }
2157 }
2158
2159 // This function is called for -Xloggc:<filename>, it can be used
2160 // to check if a given file name(or string) conforms to the following
2161 // specification:
2162 // A valid string only contains "[A-Z][a-z][0-9].-_%[p|t]"
2163 // %p and %t only allowed once. We only limit usage of filename not path
2164 bool is_filename_valid(const char *file_name) {
2165 const char* p = file_name;
2166 char file_sep = os::file_separator()[0];
2167 const char* cp;
2168 // skip prefix path
2169 for (cp = file_name; *cp != '\0'; cp++) {
2170 if (*cp == '/' || *cp == file_sep) {
2171 p = cp + 1;
2172 }
2173 }
2174
2175 int count_p = 0;
2176 int count_t = 0;
2232 _max_heap_free_ratio = max_heap_free_ratio;
2233 return true;
2234 }
2235
2236 // Check consistency of GC selection
2237 bool Arguments::check_gc_consistency() {
2238 check_gclog_consistency();
2239 bool status = true;
2240 // Ensure that the user has not selected conflicting sets
2241 // of collectors. [Note: this check is merely a user convenience;
2242 // collectors over-ride each other so that only a non-conflicting
2243 // set is selected; however what the user gets is not what they
2244 // may have expected from the combination they asked for. It's
2245 // better to reduce user confusion by not allowing them to
2246 // select conflicting combinations.
2247 uint i = 0;
2248 if (UseSerialGC) i++;
2249 if (UseConcMarkSweepGC || UseParNewGC) i++;
2250 if (UseParallelGC || UseParallelOldGC) i++;
2251 if (UseG1GC) i++;
2252 if (i > 1) {
2253 jio_fprintf(defaultStream::error_stream(),
2254 "Conflicting collector combinations in option list; "
2255 "please refer to the release notes for the combinations "
2256 "allowed\n");
2257 status = false;
2258 }
2259 return status;
2260 }
2261
2262 void Arguments::check_deprecated_gcs() {
2263 if (UseConcMarkSweepGC && !UseParNewGC) {
2264 warning("Using the DefNew young collector with the CMS collector is deprecated "
2265 "and will likely be removed in a future release");
2266 }
2267
2268 if (UseParNewGC && !UseConcMarkSweepGC) {
2269 // !UseConcMarkSweepGC means that we are using serial old gc. Unfortunately we don't
2270 // set up UseSerialGC properly, so that can't be used in the check here.
2271 warning("Using the ParNew young collector with the Serial old collector is deprecated "
2619 }
2620
2621 // Check lower bounds of the code cache
2622 // Template Interpreter code is approximately 3X larger in debug builds.
2623 uint min_code_cache_size = (CodeCacheMinimumUseSpace DEBUG_ONLY(* 3)) + CodeCacheMinimumFreeSpace;
2624 if (InitialCodeCacheSize < (uintx)os::vm_page_size()) {
2625 jio_fprintf(defaultStream::error_stream(),
2626 "Invalid InitialCodeCacheSize=%dK. Must be at least %dK.\n", InitialCodeCacheSize/K,
2627 os::vm_page_size()/K);
2628 status = false;
2629 } else if (ReservedCodeCacheSize < InitialCodeCacheSize) {
2630 jio_fprintf(defaultStream::error_stream(),
2631 "Invalid ReservedCodeCacheSize: %dK. Must be at least InitialCodeCacheSize=%dK.\n",
2632 ReservedCodeCacheSize/K, InitialCodeCacheSize/K);
2633 status = false;
2634 } else if (ReservedCodeCacheSize < min_code_cache_size) {
2635 jio_fprintf(defaultStream::error_stream(),
2636 "Invalid ReservedCodeCacheSize=%dK. Must be at least %uK.\n", ReservedCodeCacheSize/K,
2637 min_code_cache_size/K);
2638 status = false;
2639 } else if (ReservedCodeCacheSize > 2*G) {
2640 // Code cache size larger than MAXINT is not supported.
2641 jio_fprintf(defaultStream::error_stream(),
2642 "Invalid ReservedCodeCacheSize=%dM. Must be at most %uM.\n", ReservedCodeCacheSize/M,
2643 (2*G)/M);
2644 status = false;
2645 }
2646
2647 status &= verify_interval(NmethodSweepFraction, 1, ReservedCodeCacheSize/K, "NmethodSweepFraction");
2648 status &= verify_interval(NmethodSweepActivity, 0, 2000, "NmethodSweepActivity");
2649
2650 if (!FLAG_IS_DEFAULT(CICompilerCount) && !FLAG_IS_DEFAULT(CICompilerCountPerCPU) && CICompilerCountPerCPU) {
2651 warning("The VM option CICompilerCountPerCPU overrides CICompilerCount.");
2652 }
2653
2654 #ifdef COMPILER1
2655 status &= verify_interval(SafepointPollOffset, 0, os::vm_page_size() - BytesPerWord, "SafepointPollOffset");
2656 #endif
2657
2658 int min_number_of_compiler_threads = get_min_number_of_compiler_threads();
2659 // The default CICompilerCount's value is CI_COMPILER_COUNT.
2660 assert(min_number_of_compiler_threads <= CI_COMPILER_COUNT, "minimum should be less or equal default number");
2661 // Check the minimum number of compiler threads
2662 status &=verify_min_value(CICompilerCount, min_number_of_compiler_threads, "CICompilerCount");
2663
|
49 #endif
50 #ifdef TARGET_OS_FAMILY_linux
51 # include "os_linux.inline.hpp"
52 #endif
53 #ifdef TARGET_OS_FAMILY_solaris
54 # include "os_solaris.inline.hpp"
55 #endif
56 #ifdef TARGET_OS_FAMILY_windows
57 # include "os_windows.inline.hpp"
58 #endif
59 #ifdef TARGET_OS_FAMILY_aix
60 # include "os_aix.inline.hpp"
61 #endif
62 #ifdef TARGET_OS_FAMILY_bsd
63 # include "os_bsd.inline.hpp"
64 #endif
65 #if INCLUDE_ALL_GCS
66 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
67 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
68 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
69 #include "gc_implementation/shenandoah/shenandoahHeap.hpp"
70 #include "gc_implementation/shenandoah/shenandoahLogging.hpp"
71 #include "gc_implementation/shenandoah/shenandoahHeapRegion.hpp"
72 #endif // INCLUDE_ALL_GCS
73
74 // Note: This is a special bug reporting site for the JVM
75 #ifdef VENDOR_URL_VM_BUG
76 # define DEFAULT_VENDOR_URL_BUG VENDOR_URL_VM_BUG
77 #else
78 # define DEFAULT_VENDOR_URL_BUG "http://bugreport.java.com/bugreport/crash.jsp"
79 #endif
80 #define DEFAULT_JAVA_LAUNCHER "generic"
81
82 // Disable options not supported in this release, with a warning if they
83 // were explicitly requested on the command-line
84 #define UNSUPPORTED_OPTION(opt, description) \
85 do { \
86 if (opt) { \
87 if (FLAG_IS_CMDLINE(opt)) { \
88 warning(description " is disabled in this release."); \
89 } \
90 FLAG_SET_DEFAULT(opt, false); \
91 } \
1528 #ifdef _WIN64
1529 if (UseLargePages && UseCompressedOops) {
1530 // Cannot allocate guard pages for implicit checks in indexed addressing
1531 // mode, when large pages are specified on windows.
1532 // This flag could be switched ON if narrow oop base address is set to 0,
1533 // see code in Universe::initialize_heap().
1534 Universe::set_narrow_oop_use_implicit_null_checks(false);
1535 }
1536 #endif // _WIN64
1537 } else {
1538 if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) {
1539 warning("Max heap size too large for Compressed Oops");
1540 FLAG_SET_DEFAULT(UseCompressedOops, false);
1541 FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1542 }
1543 }
1544 #endif // _LP64
1545 #endif // ZERO
1546 }
1547
1548 // NOTE: set_use_compressed_klass_ptrs() must be called after calling
1549 // set_use_compressed_oops().
1550 void Arguments::set_use_compressed_klass_ptrs() {
1551 #ifndef ZERO
1552 #ifdef _LP64
1553 // UseCompressedOops must be on for UseCompressedClassPointers to be on.
1554 if (!UseCompressedOops) {
1555 if (UseCompressedClassPointers) {
1556 warning("UseCompressedClassPointers requires UseCompressedOops");
1557 }
1558 FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1559 } else {
1560 // Turn on UseCompressedClassPointers too
1561 if (FLAG_IS_DEFAULT(UseCompressedClassPointers)) {
1562 FLAG_SET_ERGO(bool, UseCompressedClassPointers, true);
1563 }
1564 // Check the CompressedClassSpaceSize to make sure we use compressed klass ptrs.
1565 if (UseCompressedClassPointers) {
1566 if (CompressedClassSpaceSize > KlassEncodingMetaspaceMax) {
1567 warning("CompressedClassSpaceSize is too large for UseCompressedClassPointers");
1568 FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1569 }
1570 }
1571 }
1572 #endif // _LP64
1573 #endif // !ZERO
1574 }
1575
1576 void Arguments::set_conservative_max_heap_alignment() {
1577 // The conservative maximum required alignment for the heap is the maximum of
1578 // the alignments imposed by several sources: any requirements from the heap
1579 // itself, the collector policy and the maximum page size we may run the VM
1580 // with.
1581 size_t heap_alignment = GenCollectedHeap::conservative_max_heap_alignment();
1582 #if INCLUDE_ALL_GCS
1583 if (UseParallelGC) {
1584 heap_alignment = ParallelScavengeHeap::conservative_max_heap_alignment();
1585 } else if (UseG1GC) {
1586 heap_alignment = G1CollectedHeap::conservative_max_heap_alignment();
1587 } else if (UseShenandoahGC) {
1588 heap_alignment = ShenandoahHeap::conservative_max_heap_alignment();
1589 }
1590 #endif // INCLUDE_ALL_GCS
1591 _conservative_max_heap_alignment = MAX4(heap_alignment,
1592 (size_t)os::vm_allocation_granularity(),
1593 os::max_page_size(),
1594 CollectorPolicy::compute_heap_alignment());
1595 }
1596
1597 void Arguments::select_gc_ergonomically() {
1598 if (os::is_server_class_machine()) {
1599 if (should_auto_select_low_pause_collector()) {
1600 FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
1601 } else {
1602 FLAG_SET_ERGO(bool, UseParallelGC, true);
1603 }
1604 }
1605 }
1606
1607 void Arguments::select_gc() {
1608 if (!gc_selected()) {
1720 FLAG_SET_DEFAULT(MarkStackSizeMax, 128 * TASKQUEUE_SIZE);
1721 }
1722
1723 if (FLAG_IS_DEFAULT(GCTimeRatio) || GCTimeRatio == 0) {
1724 // In G1, we want the default GC overhead goal to be higher than
1725 // say in PS. So we set it here to 10%. Otherwise the heap might
1726 // be expanded more aggressively than we would like it to. In
1727 // fact, even 10% seems to not be high enough in some cases
1728 // (especially small GC stress tests that the main thing they do
1729 // is allocation). We might consider increase it further.
1730 FLAG_SET_DEFAULT(GCTimeRatio, 9);
1731 }
1732
1733 if (PrintGCDetails && Verbose) {
1734 tty->print_cr("MarkStackSize: %uk MarkStackSizeMax: %uk",
1735 (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
1736 tty->print_cr("ConcGCThreads: %u", (uint) ConcGCThreads);
1737 }
1738 }
1739
1740 void Arguments::set_shenandoah_gc_flags() {
1741
1742 #if !(defined AARCH64 || defined AMD64 || defined IA32)
1743 UNSUPPORTED_GC_OPTION(UseShenandoahGC);
1744 #endif
1745
1746 #if 0 // leave this block as stepping stone for future platforms
1747 warning("Shenandoah GC is not fully supported on this platform:");
1748 warning(" concurrent modes are not supported, only STW cycles are enabled;");
1749 warning(" arch-specific barrier code is not implemented, disabling barriers;");
1750
1751 #if INCLUDE_ALL_GCS
1752 FLAG_SET_DEFAULT(ShenandoahGCHeuristics, "passive");
1753
1754 FLAG_SET_DEFAULT(ShenandoahSATBBarrier, false);
1755 FLAG_SET_DEFAULT(ShenandoahLoadRefBarrier, false);
1756 FLAG_SET_DEFAULT(ShenandoahStoreValEnqueueBarrier, false);
1757 FLAG_SET_DEFAULT(ShenandoahCASBarrier, false);
1758 FLAG_SET_DEFAULT(ShenandoahCloneBarrier, false);
1759
1760 FLAG_SET_DEFAULT(ShenandoahVerifyOptoBarriers, false);
1761 #endif
1762 #endif
1763
1764 #if INCLUDE_ALL_GCS
1765 if (!FLAG_IS_DEFAULT(ShenandoahGarbageThreshold)) {
1766 if (0 > ShenandoahGarbageThreshold || ShenandoahGarbageThreshold > 100) {
1767 vm_exit_during_initialization("The flag -XX:ShenandoahGarbageThreshold is out of range", NULL);
1768 }
1769 }
1770
1771 if (!FLAG_IS_DEFAULT(ShenandoahAllocationThreshold)) {
1772 if (0 > ShenandoahAllocationThreshold || ShenandoahAllocationThreshold > 100) {
1773 vm_exit_during_initialization("The flag -XX:ShenandoahAllocationThreshold is out of range", NULL);
1774 }
1775 }
1776
1777 if (!FLAG_IS_DEFAULT(ShenandoahMinFreeThreshold)) {
1778 if (0 > ShenandoahMinFreeThreshold || ShenandoahMinFreeThreshold > 100) {
1779 vm_exit_during_initialization("The flag -XX:ShenandoahMinFreeThreshold is out of range", NULL);
1780 }
1781 }
1782 #endif
1783
1784 #if INCLUDE_ALL_GCS
1785 if (UseLargePages && (MaxHeapSize / os::large_page_size()) < ShenandoahHeapRegion::MIN_NUM_REGIONS) {
1786 warning("Large pages size (" SIZE_FORMAT "K) is too large to afford page-sized regions, disabling uncommit",
1787 os::large_page_size() / K);
1788 FLAG_SET_DEFAULT(ShenandoahUncommit, false);
1789 }
1790 #endif
1791
1792 // Enable NUMA by default. While Shenandoah is not NUMA-aware, enabling NUMA makes
1793 // storage allocation code NUMA-aware.
1794 if (FLAG_IS_DEFAULT(UseNUMA)) {
1795 FLAG_SET_DEFAULT(UseNUMA, true);
1796 }
1797
1798 // Set up default number of concurrent threads. We want to have cycles complete fast
1799 // enough, but we also do not want to steal too much CPU from the concurrently running
1800 // application. Using 1/4 of available threads for concurrent GC seems a good
1801 // compromise here.
1802 bool ergo_conc = FLAG_IS_DEFAULT(ConcGCThreads);
1803 if (ergo_conc) {
1804 FLAG_SET_DEFAULT(ConcGCThreads, MAX2(1, os::initial_active_processor_count() / 4));
1805 }
1806
1807 if (ConcGCThreads == 0) {
1808 vm_exit_during_initialization("Shenandoah expects ConcGCThreads > 0, check -XX:ConcGCThreads=#");
1809 }
1810
1811 // Set up default number of parallel threads. We want to have decent pauses performance
1812 // which would use parallel threads, but we also do not want to do too many threads
1813 // that will overwhelm the OS scheduler. Using 1/2 of available threads seems to be a fair
1814 // compromise here. Due to implementation constraints, it should not be lower than
1815 // the number of concurrent threads.
1816 bool ergo_parallel = FLAG_IS_DEFAULT(ParallelGCThreads);
1817 if (ergo_parallel) {
1818 FLAG_SET_DEFAULT(ParallelGCThreads, MAX2(1, os::initial_active_processor_count() / 2));
1819 }
1820
1821 if (ParallelGCThreads == 0) {
1822 vm_exit_during_initialization("Shenandoah expects ParallelGCThreads > 0, check -XX:ParallelGCThreads=#");
1823 }
1824
1825 // Make sure ergonomic decisions do not break the thread count invariants.
1826 // This may happen when user overrides one of the flags, but not the other.
1827 // When that happens, we want to adjust the setting that was set ergonomically.
1828 if (ParallelGCThreads < ConcGCThreads) {
1829 if (ergo_conc && !ergo_parallel) {
1830 FLAG_SET_DEFAULT(ConcGCThreads, ParallelGCThreads);
1831 } else if (!ergo_conc && ergo_parallel) {
1832 FLAG_SET_DEFAULT(ParallelGCThreads, ConcGCThreads);
1833 } else if (ergo_conc && ergo_parallel) {
1834 // Should not happen, check the ergonomic computation above. Fail with relevant error.
1835 vm_exit_during_initialization("Shenandoah thread count ergonomic error");
1836 } else {
1837 // User settings error, report and ask user to rectify.
1838 vm_exit_during_initialization("Shenandoah expects ConcGCThreads <= ParallelGCThreads, check -XX:ParallelGCThreads, -XX:ConcGCThreads");
1839 }
1840 }
1841
1842 if (FLAG_IS_DEFAULT(ParallelRefProcEnabled)) {
1843 FLAG_SET_DEFAULT(ParallelRefProcEnabled, true);
1844 }
1845
1846 #if INCLUDE_ALL_GCS
1847 if (ShenandoahRegionSampling && FLAG_IS_DEFAULT(PerfDataMemorySize)) {
1848 // When sampling is enabled, max out the PerfData memory to get more
1849 // Shenandoah data in, including Matrix.
1850 FLAG_SET_DEFAULT(PerfDataMemorySize, 2048*K);
1851 }
1852 #endif
1853
1854 #ifdef COMPILER2
1855 // Shenandoah cares more about pause times, rather than raw throughput.
1856 // Enabling safepoints in counted loops makes it more responsive with
1857 // long loops. However, it is risky in 8u, due to bugs it brings, for
1858 // example JDK-8176506. Warn user about this, and proceed.
1859 if (UseCountedLoopSafepoints) {
1860 warning("Enabling -XX:UseCountedLoopSafepoints is known to cause JVM bugs. Use at your own risk.");
1861 }
1862
1863 #ifdef ASSERT
1864 // C2 barrier verification is only reliable when all default barriers are enabled
1865 if (ShenandoahVerifyOptoBarriers &&
1866 (!FLAG_IS_DEFAULT(ShenandoahSATBBarrier) ||
1867 !FLAG_IS_DEFAULT(ShenandoahLoadRefBarrier) ||
1868 !FLAG_IS_DEFAULT(ShenandoahStoreValEnqueueBarrier) ||
1869 !FLAG_IS_DEFAULT(ShenandoahCASBarrier) ||
1870 !FLAG_IS_DEFAULT(ShenandoahCloneBarrier)
1871 )) {
1872 warning("Unusual barrier configuration, disabling C2 barrier verification");
1873 FLAG_SET_DEFAULT(ShenandoahVerifyOptoBarriers, false);
1874 }
1875 #else
1876 guarantee(!ShenandoahVerifyOptoBarriers, "Should be disabled");
1877 #endif // ASSERT
1878 #endif // COMPILER2
1879
1880 #if INCLUDE_ALL_GCS
1881 if ((InitialHeapSize == MaxHeapSize) && ShenandoahUncommit) {
1882 if (PrintGC) {
1883 tty->print_cr("Min heap equals to max heap, disabling ShenandoahUncommit");
1884 }
1885 FLAG_SET_DEFAULT(ShenandoahUncommit, false);
1886 }
1887
1888 // If class unloading is disabled, no unloading for concurrent cycles as well.
1889 if (!ClassUnloading) {
1890 FLAG_SET_DEFAULT(ClassUnloadingWithConcurrentMark, false);
1891 }
1892
1893 // TLAB sizing policy makes resizing decisions before each GC cycle. It averages
1894 // historical data, assigning more recent data the weight according to TLABAllocationWeight.
1895 // Current default is good for generational collectors that run frequent young GCs.
1896 // With Shenandoah, GC cycles are much less frequent, so we need we need sizing policy
1897 // to converge faster over smaller number of resizing decisions.
1898 if (FLAG_IS_DEFAULT(TLABAllocationWeight)) {
1899 FLAG_SET_DEFAULT(TLABAllocationWeight, 90);
1900 }
1901
1902 if (FLAG_IS_DEFAULT(ShenandoahSoftMaxHeapSize)) {
1903 FLAG_SET_DEFAULT(ShenandoahSoftMaxHeapSize, MaxHeapSize);
1904 } else {
1905 if (ShenandoahSoftMaxHeapSize > MaxHeapSize) {
1906 vm_exit_during_initialization("ShenandoahSoftMaxHeapSize must be less than or equal to the maximum heap size\n");
1907 }
1908 }
1909 #endif
1910 }
1911
1912 #if !INCLUDE_ALL_GCS
1913 #ifdef ASSERT
1914 static bool verify_serial_gc_flags() {
1915 return (UseSerialGC &&
1916 !(UseParNewGC || (UseConcMarkSweepGC || CMSIncrementalMode) || UseG1GC ||
1917 UseParallelGC || UseParallelOldGC));
1918 }
1919 #endif // ASSERT
1920 #endif // INCLUDE_ALL_GCS
1921
1922 void Arguments::set_gc_specific_flags() {
1923 #if INCLUDE_ALL_GCS
1924 // Set per-collector flags
1925 if (UseParallelGC || UseParallelOldGC) {
1926 set_parallel_gc_flags();
1927 } else if (UseConcMarkSweepGC) { // Should be done before ParNew check below
1928 set_cms_and_parnew_gc_flags();
1929 } else if (UseParNewGC) { // Skipped if CMS is set above
1930 set_parnew_gc_flags();
1931 } else if (UseG1GC) {
1932 set_g1_gc_flags();
1933 } else if (UseShenandoahGC) {
1934 set_shenandoah_gc_flags();
1935 }
1936 check_deprecated_gcs();
1937 check_deprecated_gc_flags();
1938 if (AssumeMP && !UseSerialGC) {
1939 if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) {
1940 warning("If the number of processors is expected to increase from one, then"
1941 " you should configure the number of parallel GC threads appropriately"
1942 " using -XX:ParallelGCThreads=N");
1943 }
1944 }
1945 if (MinHeapFreeRatio == 100) {
1946 // Keeping the heap 100% free is hard ;-) so limit it to 99%.
1947 FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99);
1948 }
1949
1950 // If class unloading is disabled, also disable concurrent class unloading.
1951 if (!ClassUnloading) {
1952 FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false);
1953 FLAG_SET_CMDLINE(bool, ClassUnloadingWithConcurrentMark, false);
1954 FLAG_SET_CMDLINE(bool, ExplicitGCInvokesConcurrentAndUnloadsClasses, false);
1955 FLAG_SET_CMDLINE(uintx, ShenandoahUnloadClassesFrequency, 0);
1956 }
1957 #else // INCLUDE_ALL_GCS
1958 assert(verify_serial_gc_flags(), "SerialGC unset");
1959 #endif // INCLUDE_ALL_GCS
1960 }
1961
1962 julong Arguments::limit_by_allocatable_memory(julong limit) {
1963 julong max_allocatable;
1964 julong result = limit;
1965 if (os::has_allocatable_memory_limit(&max_allocatable)) {
1966 result = MIN2(result, max_allocatable / MaxVirtMemFraction);
1967 }
1968 return result;
1969 }
1970
1971 void Arguments::set_heap_size() {
1972 if (!FLAG_IS_DEFAULT(DefaultMaxRAMFraction)) {
1973 // Deprecated flag
1974 FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction);
1975 }
2316 // check if do gclog rotation
2317 // +UseGCLogFileRotation is a must,
2318 // no gc log rotation when log file not supplied or
2319 // NumberOfGCLogFiles is 0
2320 void check_gclog_consistency() {
2321 if (UseGCLogFileRotation) {
2322 if ((Arguments::gc_log_filename() == NULL) || (NumberOfGCLogFiles == 0)) {
2323 jio_fprintf(defaultStream::output_stream(),
2324 "To enable GC log rotation, use -Xloggc:<filename> -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=<num_of_files>\n"
2325 "where num_of_file > 0\n"
2326 "GC log rotation is turned off\n");
2327 UseGCLogFileRotation = false;
2328 }
2329 }
2330
2331 if (UseGCLogFileRotation && (GCLogFileSize != 0) && (GCLogFileSize < 8*K)) {
2332 FLAG_SET_CMDLINE(uintx, GCLogFileSize, 8*K);
2333 jio_fprintf(defaultStream::output_stream(),
2334 "GCLogFileSize changed to minimum 8K\n");
2335 }
2336
2337 // Record more information about previous cycles for improved debugging pleasure
2338 if (FLAG_IS_DEFAULT(LogEventsBufferEntries)) {
2339 FLAG_SET_DEFAULT(LogEventsBufferEntries, 250);
2340 }
2341 }
2342
2343 // This function is called for -Xloggc:<filename>, it can be used
2344 // to check if a given file name(or string) conforms to the following
2345 // specification:
2346 // A valid string only contains "[A-Z][a-z][0-9].-_%[p|t]"
2347 // %p and %t only allowed once. We only limit usage of filename not path
2348 bool is_filename_valid(const char *file_name) {
2349 const char* p = file_name;
2350 char file_sep = os::file_separator()[0];
2351 const char* cp;
2352 // skip prefix path
2353 for (cp = file_name; *cp != '\0'; cp++) {
2354 if (*cp == '/' || *cp == file_sep) {
2355 p = cp + 1;
2356 }
2357 }
2358
2359 int count_p = 0;
2360 int count_t = 0;
2416 _max_heap_free_ratio = max_heap_free_ratio;
2417 return true;
2418 }
2419
2420 // Check consistency of GC selection
2421 bool Arguments::check_gc_consistency() {
2422 check_gclog_consistency();
2423 bool status = true;
2424 // Ensure that the user has not selected conflicting sets
2425 // of collectors. [Note: this check is merely a user convenience;
2426 // collectors over-ride each other so that only a non-conflicting
2427 // set is selected; however what the user gets is not what they
2428 // may have expected from the combination they asked for. It's
2429 // better to reduce user confusion by not allowing them to
2430 // select conflicting combinations.
2431 uint i = 0;
2432 if (UseSerialGC) i++;
2433 if (UseConcMarkSweepGC || UseParNewGC) i++;
2434 if (UseParallelGC || UseParallelOldGC) i++;
2435 if (UseG1GC) i++;
2436 if (UseShenandoahGC) i++;
2437 if (i > 1) {
2438 jio_fprintf(defaultStream::error_stream(),
2439 "Conflicting collector combinations in option list; "
2440 "please refer to the release notes for the combinations "
2441 "allowed\n");
2442 status = false;
2443 }
2444 return status;
2445 }
2446
2447 void Arguments::check_deprecated_gcs() {
2448 if (UseConcMarkSweepGC && !UseParNewGC) {
2449 warning("Using the DefNew young collector with the CMS collector is deprecated "
2450 "and will likely be removed in a future release");
2451 }
2452
2453 if (UseParNewGC && !UseConcMarkSweepGC) {
2454 // !UseConcMarkSweepGC means that we are using serial old gc. Unfortunately we don't
2455 // set up UseSerialGC properly, so that can't be used in the check here.
2456 warning("Using the ParNew young collector with the Serial old collector is deprecated "
2804 }
2805
2806 // Check lower bounds of the code cache
2807 // Template Interpreter code is approximately 3X larger in debug builds.
2808 uint min_code_cache_size = (CodeCacheMinimumUseSpace DEBUG_ONLY(* 3)) + CodeCacheMinimumFreeSpace;
2809 if (InitialCodeCacheSize < (uintx)os::vm_page_size()) {
2810 jio_fprintf(defaultStream::error_stream(),
2811 "Invalid InitialCodeCacheSize=%dK. Must be at least %dK.\n", InitialCodeCacheSize/K,
2812 os::vm_page_size()/K);
2813 status = false;
2814 } else if (ReservedCodeCacheSize < InitialCodeCacheSize) {
2815 jio_fprintf(defaultStream::error_stream(),
2816 "Invalid ReservedCodeCacheSize: %dK. Must be at least InitialCodeCacheSize=%dK.\n",
2817 ReservedCodeCacheSize/K, InitialCodeCacheSize/K);
2818 status = false;
2819 } else if (ReservedCodeCacheSize < min_code_cache_size) {
2820 jio_fprintf(defaultStream::error_stream(),
2821 "Invalid ReservedCodeCacheSize=%dK. Must be at least %uK.\n", ReservedCodeCacheSize/K,
2822 min_code_cache_size/K);
2823 status = false;
2824 } else if (ReservedCodeCacheSize > CODE_CACHE_SIZE_LIMIT) {
2825 // Code cache size larger than CODE_CACHE_SIZE_LIMIT is not supported.
2826 jio_fprintf(defaultStream::error_stream(),
2827 "Invalid ReservedCodeCacheSize=%dM. Must be at most %uM.\n", ReservedCodeCacheSize/M,
2828 CODE_CACHE_SIZE_LIMIT/M);
2829 status = false;
2830 }
2831
2832 status &= verify_interval(NmethodSweepFraction, 1, ReservedCodeCacheSize/K, "NmethodSweepFraction");
2833 status &= verify_interval(NmethodSweepActivity, 0, 2000, "NmethodSweepActivity");
2834
2835 if (!FLAG_IS_DEFAULT(CICompilerCount) && !FLAG_IS_DEFAULT(CICompilerCountPerCPU) && CICompilerCountPerCPU) {
2836 warning("The VM option CICompilerCountPerCPU overrides CICompilerCount.");
2837 }
2838
2839 #ifdef COMPILER1
2840 status &= verify_interval(SafepointPollOffset, 0, os::vm_page_size() - BytesPerWord, "SafepointPollOffset");
2841 #endif
2842
2843 int min_number_of_compiler_threads = get_min_number_of_compiler_threads();
2844 // The default CICompilerCount's value is CI_COMPILER_COUNT.
2845 assert(min_number_of_compiler_threads <= CI_COMPILER_COUNT, "minimum should be less or equal default number");
2846 // Check the minimum number of compiler threads
2847 status &=verify_min_value(CICompilerCount, min_number_of_compiler_threads, "CICompilerCount");
2848
|