< prev index next >

src/share/vm/runtime/arguments.cpp

Print this page




  34 #include "gc/shared/taskqueue.hpp"
  35 #include "memory/allocation.inline.hpp"
  36 #include "memory/universe.inline.hpp"
  37 #include "oops/oop.inline.hpp"
  38 #include "prims/jvmtiExport.hpp"
  39 #include "runtime/arguments.hpp"
  40 #include "runtime/arguments_ext.hpp"
  41 #include "runtime/commandLineFlagConstraintList.hpp"
  42 #include "runtime/commandLineFlagRangeList.hpp"
  43 #include "runtime/globals.hpp"
  44 #include "runtime/globals_extension.hpp"
  45 #include "runtime/java.hpp"
  46 #include "runtime/os.hpp"
  47 #include "runtime/vm_version.hpp"
  48 #include "services/management.hpp"
  49 #include "services/memTracker.hpp"
  50 #include "utilities/defaultStream.hpp"
  51 #include "utilities/macros.hpp"
  52 #include "utilities/stringUtils.hpp"
  53 #if INCLUDE_ALL_GCS

  54 #include "gc/cms/compactibleFreeListSpace.hpp"
  55 #include "gc/g1/g1CollectedHeap.inline.hpp"
  56 #include "gc/parallel/parallelScavengeHeap.hpp"
  57 #endif // INCLUDE_ALL_GCS
  58 
  59 // Note: This is a special bug reporting site for the JVM
  60 #define DEFAULT_VENDOR_URL_BUG "http://bugreport.java.com/bugreport/crash.jsp"
  61 #define DEFAULT_JAVA_LAUNCHER  "generic"
  62 
  63 #define UNSUPPORTED_GC_OPTION(gc)                                     \
  64 do {                                                                  \
  65   if (gc) {                                                           \
  66     if (FLAG_IS_CMDLINE(gc)) {                                        \
  67       warning(#gc " is not supported in this VM.  Using Serial GC."); \
  68     }                                                                 \
  69     FLAG_SET_DEFAULT(gc, false);                                      \
  70   }                                                                   \
  71 } while(0)
  72 
  73 char** Arguments::_jvm_flags_array              = NULL;


1454   if (UseAutoGCSelectPolicy &&
1455       !FLAG_IS_DEFAULT(MaxGCPauseMillis) &&
1456       (MaxGCPauseMillis <= AutoGCSelectPauseMillis)) {
1457     if (PrintGCDetails) {
1458       // Cannot use gclog_or_tty yet.
1459       tty->print_cr("Automatic selection of the low pause collector"
1460        " based on pause goal of %d (ms)", (int) MaxGCPauseMillis);
1461     }
1462     return true;
1463   }
1464   return false;
1465 }
1466 
1467 void Arguments::set_use_compressed_oops() {
1468 #ifndef ZERO
1469 #ifdef _LP64
1470   // MaxHeapSize is not set up properly at this point, but
1471   // the only value that can override MaxHeapSize if we are
1472   // to use UseCompressedOops is InitialHeapSize.
1473   size_t max_heap_size = MAX2(MaxHeapSize, InitialHeapSize);





1474 
1475   if (max_heap_size <= max_heap_for_compressed_oops()) {
1476 #if !defined(COMPILER1) || defined(TIERED)
1477     if (FLAG_IS_DEFAULT(UseCompressedOops)) {
1478       FLAG_SET_ERGO(bool, UseCompressedOops, true);
1479     }
1480 #endif
1481   } else {
1482     if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) {
1483       warning("Max heap size too large for Compressed Oops");
1484       FLAG_SET_DEFAULT(UseCompressedOops, false);
1485       FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1486     }
1487   }
1488 #endif // _LP64
1489 #endif // ZERO
1490 }
1491 
1492 
1493 // NOTE: set_use_compressed_klass_ptrs() must be called after calling


1512         warning("CompressedClassSpaceSize is too large for UseCompressedClassPointers");
1513         FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1514       }
1515     }
1516   }
1517 #endif // _LP64
1518 #endif // !ZERO
1519 }
1520 
1521 void Arguments::set_conservative_max_heap_alignment() {
1522   // The conservative maximum required alignment for the heap is the maximum of
1523   // the alignments imposed by several sources: any requirements from the heap
1524   // itself, the collector policy and the maximum page size we may run the VM
1525   // with.
1526   size_t heap_alignment = GenCollectedHeap::conservative_max_heap_alignment();
1527 #if INCLUDE_ALL_GCS
1528   if (UseParallelGC) {
1529     heap_alignment = ParallelScavengeHeap::conservative_max_heap_alignment();
1530   } else if (UseG1GC) {
1531     heap_alignment = G1CollectedHeap::conservative_max_heap_alignment();




1532   }
1533 #endif // INCLUDE_ALL_GCS
1534   _conservative_max_heap_alignment = MAX4(heap_alignment,
1535                                           (size_t)os::vm_allocation_granularity(),
1536                                           os::max_page_size(),
1537                                           CollectorPolicy::compute_heap_alignment());
1538 }
1539 
1540 void Arguments::select_gc_ergonomically() {
1541   if (os::is_server_class_machine()) {
1542     if (should_auto_select_low_pause_collector()) {
1543       FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
1544     } else {
1545 #if defined(JAVASE_EMBEDDED)
1546       FLAG_SET_ERGO(bool, UseParallelGC, true);
1547 #else
1548       FLAG_SET_ERGO(bool, UseG1GC, true);
1549 #endif
1550     }
1551   } else {


1670     FLAG_SET_DEFAULT(MarkStackSizeMax, 128 * TASKQUEUE_SIZE);
1671   }
1672 
1673   if (FLAG_IS_DEFAULT(GCTimeRatio) || GCTimeRatio == 0) {
1674     // In G1, we want the default GC overhead goal to be higher than
1675     // say in PS. So we set it here to 10%. Otherwise the heap might
1676     // be expanded more aggressively than we would like it to. In
1677     // fact, even 10% seems to not be high enough in some cases
1678     // (especially small GC stress tests that the main thing they do
1679     // is allocation). We might consider increase it further.
1680     FLAG_SET_DEFAULT(GCTimeRatio, 9);
1681   }
1682 
1683   if (PrintGCDetails && Verbose) {
1684     tty->print_cr("MarkStackSize: %uk  MarkStackSizeMax: %uk",
1685       (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
1686     tty->print_cr("ConcGCThreads: %u", ConcGCThreads);
1687   }
1688 }
1689 















1690 #if !INCLUDE_ALL_GCS
1691 #ifdef ASSERT
1692 static bool verify_serial_gc_flags() {
1693   return (UseSerialGC &&
1694         !(UseParNewGC || (UseConcMarkSweepGC) || UseG1GC ||
1695           UseParallelGC || UseParallelOldGC));
1696 }
1697 #endif // ASSERT
1698 #endif // INCLUDE_ALL_GCS
1699 
1700 void Arguments::set_gc_specific_flags() {
1701 #if INCLUDE_ALL_GCS
1702   // Set per-collector flags
1703   if (UseParallelGC || UseParallelOldGC) {
1704     set_parallel_gc_flags();
1705   } else if (UseConcMarkSweepGC) {
1706     set_cms_and_parnew_gc_flags();
1707   } else if (UseG1GC) {
1708     set_g1_gc_flags();


1709   }
1710   check_deprecated_gc_flags();
1711   if (AssumeMP && !UseSerialGC) {
1712     if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) {
1713       warning("If the number of processors is expected to increase from one, then"
1714               " you should configure the number of parallel GC threads appropriately"
1715               " using -XX:ParallelGCThreads=N");
1716     }
1717   }
1718   if (MinHeapFreeRatio == 100) {
1719     // Keeping the heap 100% free is hard ;-) so limit it to 99%.
1720     FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99);
1721   }
1722 #else // INCLUDE_ALL_GCS
1723   assert(verify_serial_gc_flags(), "SerialGC unset");
1724 #endif // INCLUDE_ALL_GCS
1725 }
1726 
1727 julong Arguments::limit_by_allocatable_memory(julong limit) {
1728   julong max_allocatable;




  34 #include "gc/shared/taskqueue.hpp"
  35 #include "memory/allocation.inline.hpp"
  36 #include "memory/universe.inline.hpp"
  37 #include "oops/oop.inline.hpp"
  38 #include "prims/jvmtiExport.hpp"
  39 #include "runtime/arguments.hpp"
  40 #include "runtime/arguments_ext.hpp"
  41 #include "runtime/commandLineFlagConstraintList.hpp"
  42 #include "runtime/commandLineFlagRangeList.hpp"
  43 #include "runtime/globals.hpp"
  44 #include "runtime/globals_extension.hpp"
  45 #include "runtime/java.hpp"
  46 #include "runtime/os.hpp"
  47 #include "runtime/vm_version.hpp"
  48 #include "services/management.hpp"
  49 #include "services/memTracker.hpp"
  50 #include "utilities/defaultStream.hpp"
  51 #include "utilities/macros.hpp"
  52 #include "utilities/stringUtils.hpp"
  53 #if INCLUDE_ALL_GCS
  54 #include "gc/shenandoah/shenandoahHeap.hpp"
  55 #include "gc/cms/compactibleFreeListSpace.hpp"
  56 #include "gc/g1/g1CollectedHeap.inline.hpp"
  57 #include "gc/parallel/parallelScavengeHeap.hpp"
  58 #endif // INCLUDE_ALL_GCS
  59 
  60 // Note: This is a special bug reporting site for the JVM
  61 #define DEFAULT_VENDOR_URL_BUG "http://bugreport.java.com/bugreport/crash.jsp"
  62 #define DEFAULT_JAVA_LAUNCHER  "generic"
  63 
  64 #define UNSUPPORTED_GC_OPTION(gc)                                     \
  65 do {                                                                  \
  66   if (gc) {                                                           \
  67     if (FLAG_IS_CMDLINE(gc)) {                                        \
  68       warning(#gc " is not supported in this VM.  Using Serial GC."); \
  69     }                                                                 \
  70     FLAG_SET_DEFAULT(gc, false);                                      \
  71   }                                                                   \
  72 } while(0)
  73 
  74 char** Arguments::_jvm_flags_array              = NULL;


1455   if (UseAutoGCSelectPolicy &&
1456       !FLAG_IS_DEFAULT(MaxGCPauseMillis) &&
1457       (MaxGCPauseMillis <= AutoGCSelectPauseMillis)) {
1458     if (PrintGCDetails) {
1459       // Cannot use gclog_or_tty yet.
1460       tty->print_cr("Automatic selection of the low pause collector"
1461        " based on pause goal of %d (ms)", (int) MaxGCPauseMillis);
1462     }
1463     return true;
1464   }
1465   return false;
1466 }
1467 
1468 void Arguments::set_use_compressed_oops() {
1469 #ifndef ZERO
1470 #ifdef _LP64
1471   // MaxHeapSize is not set up properly at this point, but
1472   // the only value that can override MaxHeapSize if we are
1473   // to use UseCompressedOops is InitialHeapSize.
1474   size_t max_heap_size = MAX2(MaxHeapSize, InitialHeapSize);
1475   if (UseShenandoahGC && FLAG_IS_DEFAULT(UseCompressedOops)) {
1476     warning("Compressed Oops not supported with ShenandoahGC");
1477     FLAG_SET_ERGO(bool, UseCompressedOops, false);
1478     FLAG_SET_ERGO(bool, UseCompressedClassPointers, false);
1479   }
1480 
1481   if (max_heap_size <= max_heap_for_compressed_oops()) {
1482 #if !defined(COMPILER1) || defined(TIERED)
1483     if (FLAG_IS_DEFAULT(UseCompressedOops)) {
1484       FLAG_SET_ERGO(bool, UseCompressedOops, true);
1485     }
1486 #endif
1487   } else {
1488     if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) {
1489       warning("Max heap size too large for Compressed Oops");
1490       FLAG_SET_DEFAULT(UseCompressedOops, false);
1491       FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1492     }
1493   }
1494 #endif // _LP64
1495 #endif // ZERO
1496 }
1497 
1498 
1499 // NOTE: set_use_compressed_klass_ptrs() must be called after calling


1518         warning("CompressedClassSpaceSize is too large for UseCompressedClassPointers");
1519         FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1520       }
1521     }
1522   }
1523 #endif // _LP64
1524 #endif // !ZERO
1525 }
1526 
1527 void Arguments::set_conservative_max_heap_alignment() {
1528   // The conservative maximum required alignment for the heap is the maximum of
1529   // the alignments imposed by several sources: any requirements from the heap
1530   // itself, the collector policy and the maximum page size we may run the VM
1531   // with.
1532   size_t heap_alignment = GenCollectedHeap::conservative_max_heap_alignment();
1533 #if INCLUDE_ALL_GCS
1534   if (UseParallelGC) {
1535     heap_alignment = ParallelScavengeHeap::conservative_max_heap_alignment();
1536   } else if (UseG1GC) {
1537     heap_alignment = G1CollectedHeap::conservative_max_heap_alignment();
1538   } else if (UseShenandoahGC) {
1539     // TODO: This sucks. Can't we have a clean interface to call the GC's collector
1540     // policy for this?
1541     heap_alignment = ShenandoahHeap::conservative_max_heap_alignment();
1542   }
1543 #endif // INCLUDE_ALL_GCS
1544   _conservative_max_heap_alignment = MAX4(heap_alignment,
1545                                           (size_t)os::vm_allocation_granularity(),
1546                                           os::max_page_size(),
1547                                           CollectorPolicy::compute_heap_alignment());
1548 }
1549 
1550 void Arguments::select_gc_ergonomically() {
1551   if (os::is_server_class_machine()) {
1552     if (should_auto_select_low_pause_collector()) {
1553       FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
1554     } else {
1555 #if defined(JAVASE_EMBEDDED)
1556       FLAG_SET_ERGO(bool, UseParallelGC, true);
1557 #else
1558       FLAG_SET_ERGO(bool, UseG1GC, true);
1559 #endif
1560     }
1561   } else {


1680     FLAG_SET_DEFAULT(MarkStackSizeMax, 128 * TASKQUEUE_SIZE);
1681   }
1682 
1683   if (FLAG_IS_DEFAULT(GCTimeRatio) || GCTimeRatio == 0) {
1684     // In G1, we want the default GC overhead goal to be higher than
1685     // say in PS. So we set it here to 10%. Otherwise the heap might
1686     // be expanded more aggressively than we would like it to. In
1687     // fact, even 10% seems to not be high enough in some cases
1688     // (especially small GC stress tests that the main thing they do
1689     // is allocation). We might consider increase it further.
1690     FLAG_SET_DEFAULT(GCTimeRatio, 9);
1691   }
1692 
1693   if (PrintGCDetails && Verbose) {
1694     tty->print_cr("MarkStackSize: %uk  MarkStackSizeMax: %uk",
1695       (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
1696     tty->print_cr("ConcGCThreads: %u", ConcGCThreads);
1697   }
1698 }
1699 
1700 void Arguments::set_shenandoah_gc_flags() {
1701   FLAG_SET_DEFAULT(UseDynamicNumberOfGCThreads, true);
1702   FLAG_SET_DEFAULT(ParallelGCThreads,
1703                    Abstract_VM_Version::parallel_worker_threads());
1704 
1705   if (FLAG_IS_DEFAULT(ConcGCThreads)) {
1706     uint conc_threads = MAX2((uint) 1, ParallelGCThreads);
1707     FLAG_SET_DEFAULT(ConcGCThreads, conc_threads);
1708   }
1709 
1710   if (FLAG_IS_DEFAULT(ParallelRefProcEnabled)) {
1711     FLAG_SET_DEFAULT(ParallelRefProcEnabled, true);
1712   }
1713 }
1714 
1715 #if !INCLUDE_ALL_GCS
1716 #ifdef ASSERT
1717 static bool verify_serial_gc_flags() {
1718   return (UseSerialGC &&
1719         !(UseParNewGC || (UseConcMarkSweepGC) || UseG1GC ||
1720           UseParallelGC || UseParallelOldGC));
1721 }
1722 #endif // ASSERT
1723 #endif // INCLUDE_ALL_GCS
1724 
1725 void Arguments::set_gc_specific_flags() {
1726 #if INCLUDE_ALL_GCS
1727   // Set per-collector flags
1728   if (UseParallelGC || UseParallelOldGC) {
1729     set_parallel_gc_flags();
1730   } else if (UseConcMarkSweepGC) {
1731     set_cms_and_parnew_gc_flags();
1732   } else if (UseG1GC) {
1733     set_g1_gc_flags();
1734   } else if (UseShenandoahGC) {
1735     set_shenandoah_gc_flags();
1736   }
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 #else // INCLUDE_ALL_GCS
1750   assert(verify_serial_gc_flags(), "SerialGC unset");
1751 #endif // INCLUDE_ALL_GCS
1752 }
1753 
1754 julong Arguments::limit_by_allocatable_memory(julong limit) {
1755   julong max_allocatable;


< prev index next >