< prev index next >

src/share/vm/runtime/arguments.cpp

Print this page




  46 #include "utilities/taskqueue.hpp"
  47 #ifdef TARGET_OS_FAMILY_linux
  48 # include "os_linux.inline.hpp"
  49 #endif
  50 #ifdef TARGET_OS_FAMILY_solaris
  51 # include "os_solaris.inline.hpp"
  52 #endif
  53 #ifdef TARGET_OS_FAMILY_windows
  54 # include "os_windows.inline.hpp"
  55 #endif
  56 #ifdef TARGET_OS_FAMILY_aix
  57 # include "os_aix.inline.hpp"
  58 #endif
  59 #ifdef TARGET_OS_FAMILY_bsd
  60 # include "os_bsd.inline.hpp"
  61 #endif
  62 #if INCLUDE_ALL_GCS
  63 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
  64 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
  65 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"



  66 #endif // INCLUDE_ALL_GCS
  67 
  68 // Note: This is a special bug reporting site for the JVM
  69 #ifdef VENDOR_URL_VM_BUG
  70 # define DEFAULT_VENDOR_URL_BUG VENDOR_URL_VM_BUG
  71 #else
  72 # define DEFAULT_VENDOR_URL_BUG "http://bugreport.java.com/bugreport/crash.jsp"
  73 #endif
  74 #define DEFAULT_JAVA_LAUNCHER  "generic"
  75 
  76 // Disable options not supported in this release, with a warning if they
  77 // were explicitly requested on the command-line
  78 #define UNSUPPORTED_OPTION(opt, description)                    \
  79 do {                                                            \
  80   if (opt) {                                                    \
  81     if (FLAG_IS_CMDLINE(opt)) {                                 \
  82       warning(description " is disabled in this release.");     \
  83     }                                                           \
  84     FLAG_SET_DEFAULT(opt, false);                               \
  85   }                                                             \


1127     jio_fprintf(defaultStream::error_stream(),
1128       "Class data sharing is inconsistent with other specified options.\n");
1129     vm_exit_during_initialization("Unable to use shared archive.", message);
1130   } else {
1131     FLAG_SET_DEFAULT(UseSharedSpaces, false);
1132   }
1133 }
1134 #endif
1135 
1136 void Arguments::set_tiered_flags() {
1137   // With tiered, set default policy to AdvancedThresholdPolicy, which is 3.
1138   if (FLAG_IS_DEFAULT(CompilationPolicyChoice)) {
1139     FLAG_SET_DEFAULT(CompilationPolicyChoice, 3);
1140   }
1141   if (CompilationPolicyChoice < 2) {
1142     vm_exit_during_initialization(
1143       "Incompatible compilation policy selected", NULL);
1144   }
1145   // Increase the code cache size - tiered compiles a lot more.
1146   if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)) {
1147     FLAG_SET_DEFAULT(ReservedCodeCacheSize, ReservedCodeCacheSize * 5);


1148   }
1149   if (!UseInterpreter) { // -Xcomp
1150     Tier3InvokeNotifyFreqLog = 0;
1151     Tier4InvocationThreshold = 0;
1152   }
1153 }
1154 
1155 /**
1156  * Returns the minimum number of compiler threads needed to run the JVM. The following
1157  * configurations are possible.
1158  *
1159  * 1) The JVM is build using an interpreter only. As a result, the minimum number of
1160  *    compiler threads is 0.
1161  * 2) The JVM is build using the compiler(s) and tiered compilation is disabled. As
1162  *    a result, either C1 or C2 is used, so the minimum number of compiler threads is 1.
1163  * 3) The JVM is build using the compiler(s) and tiered compilation is enabled. However,
1164  *    the option "TieredStopAtLevel < CompLevel_full_optimization". As a result, only
1165  *    C1 can be used, so the minimum number of compiler threads is 1.
1166  * 4) The JVM is build using the compilers and tiered compilation is enabled. The option
1167  *    'TieredStopAtLevel = CompLevel_full_optimization' (the default value). As a result,


1503 #ifdef _WIN64
1504     if (UseLargePages && UseCompressedOops) {
1505       // Cannot allocate guard pages for implicit checks in indexed addressing
1506       // mode, when large pages are specified on windows.
1507       // This flag could be switched ON if narrow oop base address is set to 0,
1508       // see code in Universe::initialize_heap().
1509       Universe::set_narrow_oop_use_implicit_null_checks(false);
1510     }
1511 #endif //  _WIN64
1512   } else {
1513     if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) {
1514       warning("Max heap size too large for Compressed Oops");
1515       FLAG_SET_DEFAULT(UseCompressedOops, false);
1516       FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1517     }
1518   }
1519 #endif // _LP64
1520 #endif // ZERO
1521 }
1522 
1523 
1524 // NOTE: set_use_compressed_klass_ptrs() must be called after calling
1525 // set_use_compressed_oops().
1526 void Arguments::set_use_compressed_klass_ptrs() {
1527 #ifndef ZERO
1528 #ifdef _LP64
1529   // UseCompressedOops must be on for UseCompressedClassPointers to be on.
1530   if (!UseCompressedOops) {
1531     if (UseCompressedClassPointers) {
1532       warning("UseCompressedClassPointers requires UseCompressedOops");
1533     }
1534     FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1535   } else {
1536     // Turn on UseCompressedClassPointers too
1537     if (FLAG_IS_DEFAULT(UseCompressedClassPointers)) {
1538       FLAG_SET_ERGO(bool, UseCompressedClassPointers, true);
1539     }
1540     // Check the CompressedClassSpaceSize to make sure we use compressed klass ptrs.
1541     if (UseCompressedClassPointers) {
1542       if (CompressedClassSpaceSize > KlassEncodingMetaspaceMax) {
1543         warning("CompressedClassSpaceSize is too large for UseCompressedClassPointers");
1544         FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1545       }
1546     }
1547   }
1548 #endif // _LP64
1549 #endif // !ZERO
1550 }
1551 
1552 void Arguments::set_conservative_max_heap_alignment() {
1553   // The conservative maximum required alignment for the heap is the maximum of
1554   // the alignments imposed by several sources: any requirements from the heap
1555   // itself, the collector policy and the maximum page size we may run the VM
1556   // with.
1557   size_t heap_alignment = GenCollectedHeap::conservative_max_heap_alignment();
1558 #if INCLUDE_ALL_GCS
1559   if (UseParallelGC) {
1560     heap_alignment = ParallelScavengeHeap::conservative_max_heap_alignment();
1561   } else if (UseG1GC) {
1562     heap_alignment = G1CollectedHeap::conservative_max_heap_alignment();


1563   }
1564 #endif // INCLUDE_ALL_GCS
1565   _conservative_max_heap_alignment = MAX4(heap_alignment,
1566                                           (size_t)os::vm_allocation_granularity(),
1567                                           os::max_page_size(),
1568                                           CollectorPolicy::compute_heap_alignment());
1569 }
1570 
1571 void Arguments::select_gc_ergonomically() {
1572   if (os::is_server_class_machine()) {
1573     if (should_auto_select_low_pause_collector()) {
1574       FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
1575     } else {
1576       FLAG_SET_ERGO(bool, UseParallelGC, true);
1577     }
1578   }
1579 }
1580 
1581 void Arguments::select_gc() {
1582   if (!gc_selected()) {


1694     FLAG_SET_DEFAULT(MarkStackSizeMax, 128 * TASKQUEUE_SIZE);
1695   }
1696 
1697   if (FLAG_IS_DEFAULT(GCTimeRatio) || GCTimeRatio == 0) {
1698     // In G1, we want the default GC overhead goal to be higher than
1699     // say in PS. So we set it here to 10%. Otherwise the heap might
1700     // be expanded more aggressively than we would like it to. In
1701     // fact, even 10% seems to not be high enough in some cases
1702     // (especially small GC stress tests that the main thing they do
1703     // is allocation). We might consider increase it further.
1704     FLAG_SET_DEFAULT(GCTimeRatio, 9);
1705   }
1706 
1707   if (PrintGCDetails && Verbose) {
1708     tty->print_cr("MarkStackSize: %uk  MarkStackSizeMax: %uk",
1709       (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
1710     tty->print_cr("ConcGCThreads: %u", (uint) ConcGCThreads);
1711   }
1712 }
1713 














































































































































































































1714 #if !INCLUDE_ALL_GCS
1715 #ifdef ASSERT
1716 static bool verify_serial_gc_flags() {
1717   return (UseSerialGC &&
1718         !(UseParNewGC || (UseConcMarkSweepGC || CMSIncrementalMode) || UseG1GC ||
1719           UseParallelGC || UseParallelOldGC));
1720 }
1721 #endif // ASSERT
1722 #endif // INCLUDE_ALL_GCS
1723 
1724 void Arguments::set_gc_specific_flags() {
1725 #if INCLUDE_ALL_GCS
1726   // Set per-collector flags
1727   if (UseParallelGC || UseParallelOldGC) {
1728     set_parallel_gc_flags();
1729   } else if (UseConcMarkSweepGC) { // Should be done before ParNew check below
1730     set_cms_and_parnew_gc_flags();
1731   } else if (UseParNewGC) {  // Skipped if CMS is set above
1732     set_parnew_gc_flags();
1733   } else if (UseG1GC) {
1734     set_g1_gc_flags();


1735   }
1736   check_deprecated_gcs();
1737   check_deprecated_gc_flags();
1738   if (AssumeMP && !UseSerialGC) {
1739     if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) {
1740       warning("If the number of processors is expected to increase from one, then"
1741               " you should configure the number of parallel GC threads appropriately"
1742               " using -XX:ParallelGCThreads=N");
1743     }
1744   }
1745   if (MinHeapFreeRatio == 100) {
1746     // Keeping the heap 100% free is hard ;-) so limit it to 99%.
1747     FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99);
1748   }
1749 
1750   // If class unloading is disabled, also disable concurrent class unloading.
1751   if (!ClassUnloading) {
1752     FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false);
1753     FLAG_SET_CMDLINE(bool, ClassUnloadingWithConcurrentMark, false);
1754     FLAG_SET_CMDLINE(bool, ExplicitGCInvokesConcurrentAndUnloadsClasses, false);

1755   }
1756 #else // INCLUDE_ALL_GCS
1757   assert(verify_serial_gc_flags(), "SerialGC unset");
1758 #endif // INCLUDE_ALL_GCS
1759 }
1760 
1761 julong Arguments::limit_by_allocatable_memory(julong limit) {
1762   julong max_allocatable;
1763   julong result = limit;
1764   if (os::has_allocatable_memory_limit(&max_allocatable)) {
1765     result = MIN2(result, max_allocatable / MaxVirtMemFraction);
1766   }
1767   return result;
1768 }
1769 
1770 void Arguments::set_heap_size() {
1771   if (!FLAG_IS_DEFAULT(DefaultMaxRAMFraction)) {
1772     // Deprecated flag
1773     FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction);
1774   }


2115 // check if do gclog rotation
2116 // +UseGCLogFileRotation is a must,
2117 // no gc log rotation when log file not supplied or
2118 // NumberOfGCLogFiles is 0
2119 void check_gclog_consistency() {
2120   if (UseGCLogFileRotation) {
2121     if ((Arguments::gc_log_filename() == NULL) || (NumberOfGCLogFiles == 0)) {
2122       jio_fprintf(defaultStream::output_stream(),
2123                   "To enable GC log rotation, use -Xloggc:<filename> -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=<num_of_files>\n"
2124                   "where num_of_file > 0\n"
2125                   "GC log rotation is turned off\n");
2126       UseGCLogFileRotation = false;
2127     }
2128   }
2129 
2130   if (UseGCLogFileRotation && (GCLogFileSize != 0) && (GCLogFileSize < 8*K)) {
2131     FLAG_SET_CMDLINE(uintx, GCLogFileSize, 8*K);
2132     jio_fprintf(defaultStream::output_stream(),
2133                 "GCLogFileSize changed to minimum 8K\n");
2134   }














2135 }
2136 
2137 // This function is called for -Xloggc:<filename>, it can be used
2138 // to check if a given file name(or string) conforms to the following
2139 // specification:
2140 // A valid string only contains "[A-Z][a-z][0-9].-_%[p|t]"
2141 // %p and %t only allowed once. We only limit usage of filename not path
2142 bool is_filename_valid(const char *file_name) {
2143   const char* p = file_name;
2144   char file_sep = os::file_separator()[0];
2145   const char* cp;
2146   // skip prefix path
2147   for (cp = file_name; *cp != '\0'; cp++) {
2148     if (*cp == '/' || *cp == file_sep) {
2149       p = cp + 1;
2150     }
2151   }
2152 
2153   int count_p = 0;
2154   int count_t = 0;


2210   _max_heap_free_ratio = max_heap_free_ratio;
2211   return true;
2212 }
2213 
2214 // Check consistency of GC selection
2215 bool Arguments::check_gc_consistency() {
2216   check_gclog_consistency();
2217   bool status = true;
2218   // Ensure that the user has not selected conflicting sets
2219   // of collectors. [Note: this check is merely a user convenience;
2220   // collectors over-ride each other so that only a non-conflicting
2221   // set is selected; however what the user gets is not what they
2222   // may have expected from the combination they asked for. It's
2223   // better to reduce user confusion by not allowing them to
2224   // select conflicting combinations.
2225   uint i = 0;
2226   if (UseSerialGC)                       i++;
2227   if (UseConcMarkSweepGC || UseParNewGC) i++;
2228   if (UseParallelGC || UseParallelOldGC) i++;
2229   if (UseG1GC)                           i++;

2230   if (i > 1) {
2231     jio_fprintf(defaultStream::error_stream(),
2232                 "Conflicting collector combinations in option list; "
2233                 "please refer to the release notes for the combinations "
2234                 "allowed\n");
2235     status = false;
2236   }
2237   return status;
2238 }
2239 
2240 void Arguments::check_deprecated_gcs() {
2241   if (UseConcMarkSweepGC && !UseParNewGC) {
2242     warning("Using the DefNew young collector with the CMS collector is deprecated "
2243         "and will likely be removed in a future release");
2244   }
2245 
2246   if (UseParNewGC && !UseConcMarkSweepGC) {
2247     // !UseConcMarkSweepGC means that we are using serial old gc. Unfortunately we don't
2248     // set up UseSerialGC properly, so that can't be used in the check here.
2249     warning("Using the ParNew young collector with the Serial old collector is deprecated "


2597   }
2598 
2599   // Check lower bounds of the code cache
2600   // Template Interpreter code is approximately 3X larger in debug builds.
2601   uint min_code_cache_size = (CodeCacheMinimumUseSpace DEBUG_ONLY(* 3)) + CodeCacheMinimumFreeSpace;
2602   if (InitialCodeCacheSize < (uintx)os::vm_page_size()) {
2603     jio_fprintf(defaultStream::error_stream(),
2604                 "Invalid InitialCodeCacheSize=%dK. Must be at least %dK.\n", InitialCodeCacheSize/K,
2605                 os::vm_page_size()/K);
2606     status = false;
2607   } else if (ReservedCodeCacheSize < InitialCodeCacheSize) {
2608     jio_fprintf(defaultStream::error_stream(),
2609                 "Invalid ReservedCodeCacheSize: %dK. Must be at least InitialCodeCacheSize=%dK.\n",
2610                 ReservedCodeCacheSize/K, InitialCodeCacheSize/K);
2611     status = false;
2612   } else if (ReservedCodeCacheSize < min_code_cache_size) {
2613     jio_fprintf(defaultStream::error_stream(),
2614                 "Invalid ReservedCodeCacheSize=%dK. Must be at least %uK.\n", ReservedCodeCacheSize/K,
2615                 min_code_cache_size/K);
2616     status = false;
2617   } else if (ReservedCodeCacheSize > 2*G) {
2618     // Code cache size larger than MAXINT is not supported.
2619     jio_fprintf(defaultStream::error_stream(),
2620                 "Invalid ReservedCodeCacheSize=%dM. Must be at most %uM.\n", ReservedCodeCacheSize/M,
2621                 (2*G)/M);
2622     status = false;
2623   }
2624 
2625   status &= verify_interval(NmethodSweepFraction, 1, ReservedCodeCacheSize/K, "NmethodSweepFraction");
2626   status &= verify_interval(NmethodSweepActivity, 0, 2000, "NmethodSweepActivity");
2627 
2628   if (!FLAG_IS_DEFAULT(CICompilerCount) && !FLAG_IS_DEFAULT(CICompilerCountPerCPU) && CICompilerCountPerCPU) {
2629     warning("The VM option CICompilerCountPerCPU overrides CICompilerCount.");
2630   }
2631 
2632 #ifdef COMPILER1
2633   status &= verify_interval(SafepointPollOffset, 0, os::vm_page_size() - BytesPerWord, "SafepointPollOffset");
2634 #endif
2635 
2636   int min_number_of_compiler_threads = get_min_number_of_compiler_threads();
2637   // The default CICompilerCount's value is CI_COMPILER_COUNT.
2638   assert(min_number_of_compiler_threads <= CI_COMPILER_COUNT, "minimum should be less or equal default number");
2639   // Check the minimum number of compiler threads
2640   status &=verify_min_value(CICompilerCount, min_number_of_compiler_threads, "CICompilerCount");
2641 




  46 #include "utilities/taskqueue.hpp"
  47 #ifdef TARGET_OS_FAMILY_linux
  48 # include "os_linux.inline.hpp"
  49 #endif
  50 #ifdef TARGET_OS_FAMILY_solaris
  51 # include "os_solaris.inline.hpp"
  52 #endif
  53 #ifdef TARGET_OS_FAMILY_windows
  54 # include "os_windows.inline.hpp"
  55 #endif
  56 #ifdef TARGET_OS_FAMILY_aix
  57 # include "os_aix.inline.hpp"
  58 #endif
  59 #ifdef TARGET_OS_FAMILY_bsd
  60 # include "os_bsd.inline.hpp"
  61 #endif
  62 #if INCLUDE_ALL_GCS
  63 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
  64 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
  65 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
  66 #include "gc_implementation/shenandoah/shenandoahHeap.hpp"
  67 #include "gc_implementation/shenandoah/shenandoahLogging.hpp"
  68 #include "gc_implementation/shenandoah/shenandoahHeapRegion.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   }                                                             \


1130     jio_fprintf(defaultStream::error_stream(),
1131       "Class data sharing is inconsistent with other specified options.\n");
1132     vm_exit_during_initialization("Unable to use shared archive.", message);
1133   } else {
1134     FLAG_SET_DEFAULT(UseSharedSpaces, false);
1135   }
1136 }
1137 #endif
1138 
1139 void Arguments::set_tiered_flags() {
1140   // With tiered, set default policy to AdvancedThresholdPolicy, which is 3.
1141   if (FLAG_IS_DEFAULT(CompilationPolicyChoice)) {
1142     FLAG_SET_DEFAULT(CompilationPolicyChoice, 3);
1143   }
1144   if (CompilationPolicyChoice < 2) {
1145     vm_exit_during_initialization(
1146       "Incompatible compilation policy selected", NULL);
1147   }
1148   // Increase the code cache size - tiered compiles a lot more.
1149   if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)) {
1150     NOT_AARCH64(FLAG_SET_DEFAULT(ReservedCodeCacheSize, ReservedCodeCacheSize * 5));
1151     AARCH64_ONLY(FLAG_SET_DEFAULT(ReservedCodeCacheSize,
1152                                   MIN2(CODE_CACHE_DEFAULT_LIMIT, ReservedCodeCacheSize * 5)));
1153   }
1154   if (!UseInterpreter) { // -Xcomp
1155     Tier3InvokeNotifyFreqLog = 0;
1156     Tier4InvocationThreshold = 0;
1157   }
1158 }
1159 
1160 /**
1161  * Returns the minimum number of compiler threads needed to run the JVM. The following
1162  * configurations are possible.
1163  *
1164  * 1) The JVM is build using an interpreter only. As a result, the minimum number of
1165  *    compiler threads is 0.
1166  * 2) The JVM is build using the compiler(s) and tiered compilation is disabled. As
1167  *    a result, either C1 or C2 is used, so the minimum number of compiler threads is 1.
1168  * 3) The JVM is build using the compiler(s) and tiered compilation is enabled. However,
1169  *    the option "TieredStopAtLevel < CompLevel_full_optimization". As a result, only
1170  *    C1 can be used, so the minimum number of compiler threads is 1.
1171  * 4) The JVM is build using the compilers and tiered compilation is enabled. The option
1172  *    'TieredStopAtLevel = CompLevel_full_optimization' (the default value). As a result,


1508 #ifdef _WIN64
1509     if (UseLargePages && UseCompressedOops) {
1510       // Cannot allocate guard pages for implicit checks in indexed addressing
1511       // mode, when large pages are specified on windows.
1512       // This flag could be switched ON if narrow oop base address is set to 0,
1513       // see code in Universe::initialize_heap().
1514       Universe::set_narrow_oop_use_implicit_null_checks(false);
1515     }
1516 #endif //  _WIN64
1517   } else {
1518     if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) {
1519       warning("Max heap size too large for Compressed Oops");
1520       FLAG_SET_DEFAULT(UseCompressedOops, false);
1521       FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1522     }
1523   }
1524 #endif // _LP64
1525 #endif // ZERO
1526 }
1527 

1528 // NOTE: set_use_compressed_klass_ptrs() must be called after calling
1529 // set_use_compressed_oops().
1530 void Arguments::set_use_compressed_klass_ptrs() {
1531 #ifndef ZERO
1532 #ifdef _LP64
1533   // UseCompressedOops must be on for UseCompressedClassPointers to be on.
1534   if (!UseCompressedOops) {
1535     if (UseCompressedClassPointers) {
1536       warning("UseCompressedClassPointers requires UseCompressedOops");
1537     }
1538     FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1539   } else {
1540     // Turn on UseCompressedClassPointers too
1541     if (FLAG_IS_DEFAULT(UseCompressedClassPointers)) {
1542       FLAG_SET_ERGO(bool, UseCompressedClassPointers, true);
1543     }
1544     // Check the CompressedClassSpaceSize to make sure we use compressed klass ptrs.
1545     if (UseCompressedClassPointers) {
1546       if (CompressedClassSpaceSize > KlassEncodingMetaspaceMax) {
1547         warning("CompressedClassSpaceSize is too large for UseCompressedClassPointers");
1548         FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1549       }
1550     }
1551   }
1552 #endif // _LP64
1553 #endif // !ZERO
1554 }
1555 
1556 void Arguments::set_conservative_max_heap_alignment() {
1557   // The conservative maximum required alignment for the heap is the maximum of
1558   // the alignments imposed by several sources: any requirements from the heap
1559   // itself, the collector policy and the maximum page size we may run the VM
1560   // with.
1561   size_t heap_alignment = GenCollectedHeap::conservative_max_heap_alignment();
1562 #if INCLUDE_ALL_GCS
1563   if (UseParallelGC) {
1564     heap_alignment = ParallelScavengeHeap::conservative_max_heap_alignment();
1565   } else if (UseG1GC) {
1566     heap_alignment = G1CollectedHeap::conservative_max_heap_alignment();
1567   } else if (UseShenandoahGC) {
1568     heap_alignment = ShenandoahHeap::conservative_max_heap_alignment();
1569   }
1570 #endif // INCLUDE_ALL_GCS
1571   _conservative_max_heap_alignment = MAX4(heap_alignment,
1572                                           (size_t)os::vm_allocation_granularity(),
1573                                           os::max_page_size(),
1574                                           CollectorPolicy::compute_heap_alignment());
1575 }
1576 
1577 void Arguments::select_gc_ergonomically() {
1578   if (os::is_server_class_machine()) {
1579     if (should_auto_select_low_pause_collector()) {
1580       FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
1581     } else {
1582       FLAG_SET_ERGO(bool, UseParallelGC, true);
1583     }
1584   }
1585 }
1586 
1587 void Arguments::select_gc() {
1588   if (!gc_selected()) {


1700     FLAG_SET_DEFAULT(MarkStackSizeMax, 128 * TASKQUEUE_SIZE);
1701   }
1702 
1703   if (FLAG_IS_DEFAULT(GCTimeRatio) || GCTimeRatio == 0) {
1704     // In G1, we want the default GC overhead goal to be higher than
1705     // say in PS. So we set it here to 10%. Otherwise the heap might
1706     // be expanded more aggressively than we would like it to. In
1707     // fact, even 10% seems to not be high enough in some cases
1708     // (especially small GC stress tests that the main thing they do
1709     // is allocation). We might consider increase it further.
1710     FLAG_SET_DEFAULT(GCTimeRatio, 9);
1711   }
1712 
1713   if (PrintGCDetails && Verbose) {
1714     tty->print_cr("MarkStackSize: %uk  MarkStackSizeMax: %uk",
1715       (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
1716     tty->print_cr("ConcGCThreads: %u", (uint) ConcGCThreads);
1717   }
1718 }
1719 
1720 void Arguments::set_shenandoah_gc_flags() {
1721 
1722 #if !(defined AARCH64 || defined AMD64 || defined IA32)
1723   UNSUPPORTED_GC_OPTION(UseShenandoahGC);
1724 #endif
1725 
1726 #if 0 // leave this block as stepping stone for future platforms
1727   warning("Shenandoah GC is not fully supported on this platform:");
1728   warning("  concurrent modes are not supported, only STW cycles are enabled;");
1729   warning("  arch-specific barrier code is not implemented, disabling barriers;");
1730 
1731 #if INCLUDE_ALL_GCS
1732   FLAG_SET_DEFAULT(ShenandoahGCHeuristics,           "passive");
1733 
1734   FLAG_SET_DEFAULT(ShenandoahSATBBarrier,            false);
1735   FLAG_SET_DEFAULT(ShenandoahLoadRefBarrier,         false);
1736   FLAG_SET_DEFAULT(ShenandoahKeepAliveBarrier,       false);
1737   FLAG_SET_DEFAULT(ShenandoahStoreValEnqueueBarrier, false);
1738   FLAG_SET_DEFAULT(ShenandoahCASBarrier,             false);
1739   FLAG_SET_DEFAULT(ShenandoahCloneBarrier,           false);
1740 
1741   FLAG_SET_DEFAULT(ShenandoahVerifyOptoBarriers,     false);
1742 #endif
1743 #endif
1744 
1745 #if INCLUDE_ALL_GCS
1746   if (!FLAG_IS_DEFAULT(ShenandoahGarbageThreshold)) {
1747     if (0 > ShenandoahGarbageThreshold || ShenandoahGarbageThreshold > 100) {
1748       vm_exit_during_initialization("The flag -XX:ShenandoahGarbageThreshold is out of range", NULL);
1749     }
1750   }
1751 
1752   if (!FLAG_IS_DEFAULT(ShenandoahAllocationThreshold)) {
1753     if (0 > ShenandoahAllocationThreshold || ShenandoahAllocationThreshold > 100) {
1754       vm_exit_during_initialization("The flag -XX:ShenandoahAllocationThreshold is out of range", NULL);
1755     }
1756   }
1757 
1758   if (!FLAG_IS_DEFAULT(ShenandoahFreeThreshold)) {
1759     if (0 > ShenandoahFreeThreshold || ShenandoahFreeThreshold > 100) {
1760       vm_exit_during_initialization("The flag -XX:ShenandoahFreeThreshold is out of range", NULL);
1761     }
1762   }
1763 #endif
1764 
1765 #if INCLUDE_ALL_GCS
1766   if (UseLargePages && (MaxHeapSize / os::large_page_size()) < ShenandoahHeapRegion::MIN_NUM_REGIONS) {
1767     warning("Large pages size (" SIZE_FORMAT "K) is too large to afford page-sized regions, disabling uncommit",
1768             os::large_page_size() / K);
1769     FLAG_SET_DEFAULT(ShenandoahUncommit, false);
1770   }
1771 #endif
1772 
1773   // Enable NUMA by default. While Shenandoah is not NUMA-aware, enabling NUMA makes
1774   // storage allocation code NUMA-aware.
1775   if (FLAG_IS_DEFAULT(UseNUMA)) {
1776     FLAG_SET_DEFAULT(UseNUMA, true);
1777   }
1778 
1779   // Set up default number of concurrent threads. We want to have cycles complete fast
1780   // enough, but we also do not want to steal too much CPU from the concurrently running
1781   // application. Using 1/4 of available threads for concurrent GC seems a good
1782   // compromise here.
1783   bool ergo_conc = FLAG_IS_DEFAULT(ConcGCThreads);
1784   if (ergo_conc) {
1785     FLAG_SET_DEFAULT(ConcGCThreads, MAX2(1, os::processor_count() / 4));
1786   }
1787 
1788   if (ConcGCThreads == 0) {
1789     vm_exit_during_initialization("Shenandoah expects ConcGCThreads > 0, check -XX:ConcGCThreads=#");
1790   }
1791 
1792   // Set up default number of parallel threads. We want to have decent pauses performance
1793   // which would use parallel threads, but we also do not want to do too many threads
1794   // that will overwhelm the OS scheduler. Using 1/2 of available threads seems to be a fair
1795   // compromise here. Due to implementation constraints, it should not be lower than
1796   // the number of concurrent threads.
1797   bool ergo_parallel = FLAG_IS_DEFAULT(ParallelGCThreads);
1798   if (ergo_parallel) {
1799     FLAG_SET_DEFAULT(ParallelGCThreads, MAX2(1, os::processor_count() / 2));
1800   }
1801 
1802   if (ParallelGCThreads == 0) {
1803     vm_exit_during_initialization("Shenandoah expects ParallelGCThreads > 0, check -XX:ParallelGCThreads=#");
1804   }
1805 
1806   // Make sure ergonomic decisions do not break the thread count invariants.
1807   // This may happen when user overrides one of the flags, but not the other.
1808   // When that happens, we want to adjust the setting that was set ergonomically.
1809   if (ParallelGCThreads < ConcGCThreads) {
1810     if (ergo_conc && !ergo_parallel) {
1811       FLAG_SET_DEFAULT(ConcGCThreads, ParallelGCThreads);
1812     } else if (!ergo_conc && ergo_parallel) {
1813       FLAG_SET_DEFAULT(ParallelGCThreads, ConcGCThreads);
1814     } else if (ergo_conc && ergo_parallel) {
1815       // Should not happen, check the ergonomic computation above. Fail with relevant error.
1816       vm_exit_during_initialization("Shenandoah thread count ergonomic error");
1817     } else {
1818       // User settings error, report and ask user to rectify.
1819       vm_exit_during_initialization("Shenandoah expects ConcGCThreads <= ParallelGCThreads, check -XX:ParallelGCThreads, -XX:ConcGCThreads");
1820     }
1821   }
1822 
1823   if (FLAG_IS_DEFAULT(ParallelRefProcEnabled)) {
1824     FLAG_SET_DEFAULT(ParallelRefProcEnabled, true);
1825   }
1826 
1827 #if INCLUDE_ALL_GCS
1828   if (ShenandoahRegionSampling && FLAG_IS_DEFAULT(PerfDataMemorySize)) {
1829     // When sampling is enabled, max out the PerfData memory to get more
1830     // Shenandoah data in, including Matrix.
1831     FLAG_SET_DEFAULT(PerfDataMemorySize, 2048*K);
1832   }
1833 #endif
1834 
1835 #ifdef COMPILER2
1836   // Shenandoah cares more about pause times, rather than raw throughput.
1837   // Enabling safepoints in counted loops makes it more responsive with
1838   // long loops. However, it is risky in 8u, due to bugs it brings, for
1839   // example JDK-8176506. Warn user about this, and proceed.
1840   if (UseCountedLoopSafepoints) {
1841     warning("Enabling -XX:UseCountedLoopSafepoints is known to cause JVM bugs. Use at your own risk.");
1842   }
1843 
1844 #ifdef ASSERT
1845   // C2 barrier verification is only reliable when all default barriers are enabled
1846   if (ShenandoahVerifyOptoBarriers &&
1847           (!FLAG_IS_DEFAULT(ShenandoahSATBBarrier)    ||
1848            !FLAG_IS_DEFAULT(ShenandoahLoadRefBarrier) ||
1849            !FLAG_IS_DEFAULT(ShenandoahKeepAliveBarrier)       ||
1850            !FLAG_IS_DEFAULT(ShenandoahStoreValEnqueueBarrier) ||
1851            !FLAG_IS_DEFAULT(ShenandoahCASBarrier)     ||
1852            !FLAG_IS_DEFAULT(ShenandoahCloneBarrier)
1853           )) {
1854     warning("Unusual barrier configuration, disabling C2 barrier verification");
1855     FLAG_SET_DEFAULT(ShenandoahVerifyOptoBarriers, false);
1856   }
1857 #else
1858   guarantee(!ShenandoahVerifyOptoBarriers, "Should be disabled");
1859 #endif // ASSERT
1860 #endif // COMPILER2
1861 
1862 #if INCLUDE_ALL_GCS
1863   if (AlwaysPreTouch) {
1864     // Shenandoah handles pre-touch on its own. It does not let the
1865     // generic storage code to do the pre-touch before Shenandoah has
1866     // a chance to do it on its own.
1867     FLAG_SET_DEFAULT(AlwaysPreTouch, false);
1868     FLAG_SET_DEFAULT(ShenandoahAlwaysPreTouch, true);
1869   }
1870 
1871   if (ShenandoahAlwaysPreTouch) {
1872     if (!FLAG_IS_DEFAULT(ShenandoahUncommit)) {
1873       warning("AlwaysPreTouch is enabled, disabling ShenandoahUncommit");
1874     }
1875     FLAG_SET_DEFAULT(ShenandoahUncommit, false);
1876   }
1877 
1878   if ((InitialHeapSize == MaxHeapSize) && ShenandoahUncommit) {
1879     if (PrintGC) {
1880       tty->print_cr("Min heap equals to max heap, disabling ShenandoahUncommit");
1881     }
1882     FLAG_SET_DEFAULT(ShenandoahUncommit, false);
1883   }
1884 
1885   // If class unloading is disabled, no unloading for concurrent cycles as well.
1886   // If class unloading is enabled, users should opt-in for unloading during
1887   // concurrent cycles.
1888   if (!ClassUnloading || !FLAG_IS_CMDLINE(ClassUnloadingWithConcurrentMark)) {
1889     if (PrintGC) {
1890       tty->print_cr("Consider -XX:+ClassUnloadingWithConcurrentMark if large pause times "
1891                     "are observed on class-unloading sensitive workloads");
1892     }
1893     FLAG_SET_DEFAULT(ClassUnloadingWithConcurrentMark, false);
1894   }
1895 
1896   // TLAB sizing policy makes resizing decisions before each GC cycle. It averages
1897   // historical data, assigning more recent data the weight according to TLABAllocationWeight.
1898   // Current default is good for generational collectors that run frequent young GCs.
1899   // With Shenandoah, GC cycles are much less frequent, so we need we need sizing policy
1900   // to converge faster over smaller number of resizing decisions.
1901   if (FLAG_IS_DEFAULT(TLABAllocationWeight)) {
1902     FLAG_SET_DEFAULT(TLABAllocationWeight, 90);
1903   }
1904 
1905   // Shenandoah needs more C2 nodes to compile some methods with lots of barriers.
1906   // NodeLimitFudgeFactor needs to stay the same relative to MaxNodeLimit.
1907 #ifdef COMPILER2
1908   if (FLAG_IS_DEFAULT(MaxNodeLimit)) {
1909     FLAG_SET_DEFAULT(MaxNodeLimit, MaxNodeLimit * 3);
1910     FLAG_SET_DEFAULT(NodeLimitFudgeFactor, NodeLimitFudgeFactor * 3);
1911   }
1912 #endif
1913 #endif
1914 
1915   // Make sure safepoint deadlocks are failing predictably. This sets up VM to report
1916   // fatal error after 10 seconds of wait for safepoint syncronization (not the VM
1917   // operation itself). There is no good reason why Shenandoah would spend that
1918   // much time synchronizing.
1919 #ifdef ASSERT
1920   FLAG_SET_DEFAULT(SafepointTimeout, true);
1921   FLAG_SET_DEFAULT(SafepointTimeoutDelay, 10000);
1922   FLAG_SET_DEFAULT(AbortVMOnSafepointTimeout, true);
1923 #endif
1924 }
1925 
1926 #if !INCLUDE_ALL_GCS
1927 #ifdef ASSERT
1928 static bool verify_serial_gc_flags() {
1929   return (UseSerialGC &&
1930         !(UseParNewGC || (UseConcMarkSweepGC || CMSIncrementalMode) || UseG1GC ||
1931           UseParallelGC || UseParallelOldGC));
1932 }
1933 #endif // ASSERT
1934 #endif // INCLUDE_ALL_GCS
1935 
1936 void Arguments::set_gc_specific_flags() {
1937 #if INCLUDE_ALL_GCS
1938   // Set per-collector flags
1939   if (UseParallelGC || UseParallelOldGC) {
1940     set_parallel_gc_flags();
1941   } else if (UseConcMarkSweepGC) { // Should be done before ParNew check below
1942     set_cms_and_parnew_gc_flags();
1943   } else if (UseParNewGC) {  // Skipped if CMS is set above
1944     set_parnew_gc_flags();
1945   } else if (UseG1GC) {
1946     set_g1_gc_flags();
1947   } else if (UseShenandoahGC) {
1948     set_shenandoah_gc_flags();
1949   }
1950   check_deprecated_gcs();
1951   check_deprecated_gc_flags();
1952   if (AssumeMP && !UseSerialGC) {
1953     if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) {
1954       warning("If the number of processors is expected to increase from one, then"
1955               " you should configure the number of parallel GC threads appropriately"
1956               " using -XX:ParallelGCThreads=N");
1957     }
1958   }
1959   if (MinHeapFreeRatio == 100) {
1960     // Keeping the heap 100% free is hard ;-) so limit it to 99%.
1961     FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99);
1962   }
1963 
1964   // If class unloading is disabled, also disable concurrent class unloading.
1965   if (!ClassUnloading) {
1966     FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false);
1967     FLAG_SET_CMDLINE(bool, ClassUnloadingWithConcurrentMark, false);
1968     FLAG_SET_CMDLINE(bool, ExplicitGCInvokesConcurrentAndUnloadsClasses, false);
1969     FLAG_SET_CMDLINE(uintx, ShenandoahUnloadClassesFrequency, 0);
1970   }
1971 #else // INCLUDE_ALL_GCS
1972   assert(verify_serial_gc_flags(), "SerialGC unset");
1973 #endif // INCLUDE_ALL_GCS
1974 }
1975 
1976 julong Arguments::limit_by_allocatable_memory(julong limit) {
1977   julong max_allocatable;
1978   julong result = limit;
1979   if (os::has_allocatable_memory_limit(&max_allocatable)) {
1980     result = MIN2(result, max_allocatable / MaxVirtMemFraction);
1981   }
1982   return result;
1983 }
1984 
1985 void Arguments::set_heap_size() {
1986   if (!FLAG_IS_DEFAULT(DefaultMaxRAMFraction)) {
1987     // Deprecated flag
1988     FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction);
1989   }


2330 // check if do gclog rotation
2331 // +UseGCLogFileRotation is a must,
2332 // no gc log rotation when log file not supplied or
2333 // NumberOfGCLogFiles is 0
2334 void check_gclog_consistency() {
2335   if (UseGCLogFileRotation) {
2336     if ((Arguments::gc_log_filename() == NULL) || (NumberOfGCLogFiles == 0)) {
2337       jio_fprintf(defaultStream::output_stream(),
2338                   "To enable GC log rotation, use -Xloggc:<filename> -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=<num_of_files>\n"
2339                   "where num_of_file > 0\n"
2340                   "GC log rotation is turned off\n");
2341       UseGCLogFileRotation = false;
2342     }
2343   }
2344 
2345   if (UseGCLogFileRotation && (GCLogFileSize != 0) && (GCLogFileSize < 8*K)) {
2346     FLAG_SET_CMDLINE(uintx, GCLogFileSize, 8*K);
2347     jio_fprintf(defaultStream::output_stream(),
2348                 "GCLogFileSize changed to minimum 8K\n");
2349   }
2350 
2351   // Record more information about previous cycles for improved debugging pleasure
2352   if (FLAG_IS_DEFAULT(LogEventsBufferEntries)) {
2353     FLAG_SET_DEFAULT(LogEventsBufferEntries, 250);
2354   }
2355 
2356 #if INCLUDE_ALL_GCS
2357   if (AlwaysPreTouch || ShenandoahAlwaysPreTouch) {
2358     if (!FLAG_IS_DEFAULT(ShenandoahUncommitDelay)) {
2359       warning("AlwaysPreTouch is enabled, disabling ShenandoahUncommitDelay");
2360     }
2361     FLAG_SET_DEFAULT(ShenandoahUncommitDelay, max_uintx);
2362   }
2363 #endif
2364 }
2365 
2366 // This function is called for -Xloggc:<filename>, it can be used
2367 // to check if a given file name(or string) conforms to the following
2368 // specification:
2369 // A valid string only contains "[A-Z][a-z][0-9].-_%[p|t]"
2370 // %p and %t only allowed once. We only limit usage of filename not path
2371 bool is_filename_valid(const char *file_name) {
2372   const char* p = file_name;
2373   char file_sep = os::file_separator()[0];
2374   const char* cp;
2375   // skip prefix path
2376   for (cp = file_name; *cp != '\0'; cp++) {
2377     if (*cp == '/' || *cp == file_sep) {
2378       p = cp + 1;
2379     }
2380   }
2381 
2382   int count_p = 0;
2383   int count_t = 0;


2439   _max_heap_free_ratio = max_heap_free_ratio;
2440   return true;
2441 }
2442 
2443 // Check consistency of GC selection
2444 bool Arguments::check_gc_consistency() {
2445   check_gclog_consistency();
2446   bool status = true;
2447   // Ensure that the user has not selected conflicting sets
2448   // of collectors. [Note: this check is merely a user convenience;
2449   // collectors over-ride each other so that only a non-conflicting
2450   // set is selected; however what the user gets is not what they
2451   // may have expected from the combination they asked for. It's
2452   // better to reduce user confusion by not allowing them to
2453   // select conflicting combinations.
2454   uint i = 0;
2455   if (UseSerialGC)                       i++;
2456   if (UseConcMarkSweepGC || UseParNewGC) i++;
2457   if (UseParallelGC || UseParallelOldGC) i++;
2458   if (UseG1GC)                           i++;
2459   if (UseShenandoahGC)                   i++;
2460   if (i > 1) {
2461     jio_fprintf(defaultStream::error_stream(),
2462                 "Conflicting collector combinations in option list; "
2463                 "please refer to the release notes for the combinations "
2464                 "allowed\n");
2465     status = false;
2466   }
2467   return status;
2468 }
2469 
2470 void Arguments::check_deprecated_gcs() {
2471   if (UseConcMarkSweepGC && !UseParNewGC) {
2472     warning("Using the DefNew young collector with the CMS collector is deprecated "
2473         "and will likely be removed in a future release");
2474   }
2475 
2476   if (UseParNewGC && !UseConcMarkSweepGC) {
2477     // !UseConcMarkSweepGC means that we are using serial old gc. Unfortunately we don't
2478     // set up UseSerialGC properly, so that can't be used in the check here.
2479     warning("Using the ParNew young collector with the Serial old collector is deprecated "


2827   }
2828 
2829   // Check lower bounds of the code cache
2830   // Template Interpreter code is approximately 3X larger in debug builds.
2831   uint min_code_cache_size = (CodeCacheMinimumUseSpace DEBUG_ONLY(* 3)) + CodeCacheMinimumFreeSpace;
2832   if (InitialCodeCacheSize < (uintx)os::vm_page_size()) {
2833     jio_fprintf(defaultStream::error_stream(),
2834                 "Invalid InitialCodeCacheSize=%dK. Must be at least %dK.\n", InitialCodeCacheSize/K,
2835                 os::vm_page_size()/K);
2836     status = false;
2837   } else if (ReservedCodeCacheSize < InitialCodeCacheSize) {
2838     jio_fprintf(defaultStream::error_stream(),
2839                 "Invalid ReservedCodeCacheSize: %dK. Must be at least InitialCodeCacheSize=%dK.\n",
2840                 ReservedCodeCacheSize/K, InitialCodeCacheSize/K);
2841     status = false;
2842   } else if (ReservedCodeCacheSize < min_code_cache_size) {
2843     jio_fprintf(defaultStream::error_stream(),
2844                 "Invalid ReservedCodeCacheSize=%dK. Must be at least %uK.\n", ReservedCodeCacheSize/K,
2845                 min_code_cache_size/K);
2846     status = false;
2847   } else if (ReservedCodeCacheSize > CODE_CACHE_SIZE_LIMIT) {
2848     // Code cache size larger than CODE_CACHE_SIZE_LIMIT is not supported.
2849     jio_fprintf(defaultStream::error_stream(),
2850                 "Invalid ReservedCodeCacheSize=%dM. Must be at most %uM.\n", ReservedCodeCacheSize/M,
2851                 CODE_CACHE_SIZE_LIMIT/M);
2852     status = false;
2853   }
2854 
2855   status &= verify_interval(NmethodSweepFraction, 1, ReservedCodeCacheSize/K, "NmethodSweepFraction");
2856   status &= verify_interval(NmethodSweepActivity, 0, 2000, "NmethodSweepActivity");
2857 
2858   if (!FLAG_IS_DEFAULT(CICompilerCount) && !FLAG_IS_DEFAULT(CICompilerCountPerCPU) && CICompilerCountPerCPU) {
2859     warning("The VM option CICompilerCountPerCPU overrides CICompilerCount.");
2860   }
2861 
2862 #ifdef COMPILER1
2863   status &= verify_interval(SafepointPollOffset, 0, os::vm_page_size() - BytesPerWord, "SafepointPollOffset");
2864 #endif
2865 
2866   int min_number_of_compiler_threads = get_min_number_of_compiler_threads();
2867   // The default CICompilerCount's value is CI_COMPILER_COUNT.
2868   assert(min_number_of_compiler_threads <= CI_COMPILER_COUNT, "minimum should be less or equal default number");
2869   // Check the minimum number of compiler threads
2870   status &=verify_min_value(CICompilerCount, min_number_of_compiler_threads, "CICompilerCount");
2871 


< prev index next >