< prev index next >

src/hotspot/share/runtime/arguments.cpp

Print this page




  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/classLoader.hpp"
  27 #include "classfile/javaAssertions.hpp"
  28 #include "classfile/moduleEntry.hpp"
  29 #include "classfile/stringTable.hpp"
  30 #include "classfile/symbolTable.hpp"
  31 #include "gc/shared/gc.hpp"

  32 #include "gc/shared/genCollectedHeap.hpp"
  33 #include "gc/shared/referenceProcessor.hpp"
  34 #include "gc/shared/taskqueue.hpp"
  35 #include "logging/log.hpp"
  36 #include "logging/logConfiguration.hpp"
  37 #include "logging/logStream.hpp"
  38 #include "logging/logTag.hpp"
  39 #include "memory/allocation.inline.hpp"
  40 #include "memory/universe.inline.hpp"
  41 #include "oops/oop.inline.hpp"
  42 #include "prims/jvm.h"
  43 #include "prims/jvmtiExport.hpp"
  44 #include "runtime/arguments.hpp"
  45 #include "runtime/arguments_ext.hpp"
  46 #include "runtime/commandLineFlagConstraintList.hpp"
  47 #include "runtime/commandLineFlagWriteableList.hpp"
  48 #include "runtime/commandLineFlagRangeList.hpp"
  49 #include "runtime/globals.hpp"
  50 #include "runtime/globals_extension.hpp"
  51 #include "runtime/java.hpp"


1570     if (FLAG_IS_DEFAULT(UseCompressedClassPointers)) {
1571       FLAG_SET_ERGO(bool, UseCompressedClassPointers, true);
1572     }
1573     // Check the CompressedClassSpaceSize to make sure we use compressed klass ptrs.
1574     if (UseCompressedClassPointers) {
1575       if (CompressedClassSpaceSize > KlassEncodingMetaspaceMax) {
1576         warning("CompressedClassSpaceSize is too large for UseCompressedClassPointers");
1577         FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1578       }
1579     }
1580   }
1581 #endif // _LP64
1582 #endif // !ZERO
1583 }
1584 
1585 void Arguments::set_conservative_max_heap_alignment() {
1586   // The conservative maximum required alignment for the heap is the maximum of
1587   // the alignments imposed by several sources: any requirements from the heap
1588   // itself, the collector policy and the maximum page size we may run the VM
1589   // with.
1590   size_t heap_alignment = GC::gc()->conservative_max_heap_alignment();
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 #ifdef TIERED
1598 bool Arguments::compilation_mode_selected() {
1599  return !FLAG_IS_DEFAULT(TieredCompilation) || !FLAG_IS_DEFAULT(TieredStopAtLevel) ||
1600         !FLAG_IS_DEFAULT(UseAOT) JVMCI_ONLY(|| !FLAG_IS_DEFAULT(EnableJVMCI) || !FLAG_IS_DEFAULT(UseJVMCICompiler));
1601 
1602 }
1603 
1604 void Arguments::select_compilation_mode_ergonomically() {
1605 #if defined(_WINDOWS) && !defined(_LP64)
1606   if (FLAG_IS_DEFAULT(NeverActAsServerClassMachine)) {
1607     FLAG_SET_ERGO(bool, NeverActAsServerClassMachine, true);
1608   }
1609 #endif
1610   if (NeverActAsServerClassMachine) {


1636     }
1637     if (TieredStopAtLevel != CompLevel_full_optimization) {
1638       // Currently JVMCI compiler can only work at the full optimization level
1639       warning("forcing TieredStopAtLevel to full optimization because JVMCI is enabled");
1640       TieredStopAtLevel = CompLevel_full_optimization;
1641     }
1642     if (FLAG_IS_DEFAULT(TypeProfileLevel)) {
1643       FLAG_SET_DEFAULT(TypeProfileLevel, 0);
1644     }
1645   }
1646 }
1647 #endif
1648 
1649 jint Arguments::set_ergonomics_flags() {
1650 #ifdef TIERED
1651   if (!compilation_mode_selected()) {
1652     select_compilation_mode_ergonomically();
1653   }
1654 #endif
1655 
1656   jint gc_result = GC::initialize();
1657   if (gc_result != JNI_OK) {
1658     return gc_result;
1659   }
1660 
1661 #if defined(COMPILER2) || INCLUDE_JVMCI
1662   // Shared spaces work fine with other GCs but causes bytecode rewriting
1663   // to be disabled, which hurts interpreter performance and decreases
1664   // server performance.  When -server is specified, keep the default off
1665   // unless it is asked for.  Future work: either add bytecode rewriting
1666   // at link time, or rewrite bytecodes in non-shared methods.
1667   if (is_server_compilation_mode_vm() && !DumpSharedSpaces && !RequireSharedSpaces &&
1668       (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) {
1669     no_shared_spaces("COMPILER2 default: -Xshare:auto | off, have to manually setup to on.");
1670   }
1671 #endif
1672 
1673   set_conservative_max_heap_alignment();
1674 
1675 #ifndef ZERO
1676 #ifdef _LP64
1677   set_use_compressed_oops();
1678 
1679   // set_use_compressed_klass_ptrs() must be called after calling
1680   // set_use_compressed_oops().
1681   set_use_compressed_klass_ptrs();
1682 
1683   // Also checks that certain machines are slower with compressed oops
1684   // in vm_version initialization code.
1685 #endif // _LP64
1686 #endif // !ZERO
1687 
1688   return JNI_OK;
1689 }
1690 
1691 void Arguments::set_gc_specific_flags() {
1692   // Set per-collector flags
1693   GC::gc()->initialize_flags();
1694   // Set flags for all collectors.
1695   GC::initialize_flags_global();
1696 }
1697 
1698 julong Arguments::limit_by_allocatable_memory(julong limit) {
1699   julong max_allocatable;
1700   julong result = limit;
1701   if (os::has_allocatable_memory_limit(&max_allocatable)) {
1702     result = MIN2(result, max_allocatable / MaxVirtMemFraction);
1703   }
1704   return result;
1705 }
1706 
1707 // Use static initialization to get the default before parsing
1708 static const size_t DefaultHeapBaseMinAddress = HeapBaseMinAddress;
1709 
1710 void Arguments::set_heap_size() {
1711   julong phys_mem =
1712     FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
1713                             : (julong)MaxRAM;
1714 
1715   // Experimental support for CGroup memory limits




  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/classLoader.hpp"
  27 #include "classfile/javaAssertions.hpp"
  28 #include "classfile/moduleEntry.hpp"
  29 #include "classfile/stringTable.hpp"
  30 #include "classfile/symbolTable.hpp"
  31 #include "gc/shared/gc.hpp"
  32 #include "gc/shared/gcFactory.hpp"
  33 #include "gc/shared/genCollectedHeap.hpp"
  34 #include "gc/shared/referenceProcessor.hpp"
  35 #include "gc/shared/taskqueue.hpp"
  36 #include "logging/log.hpp"
  37 #include "logging/logConfiguration.hpp"
  38 #include "logging/logStream.hpp"
  39 #include "logging/logTag.hpp"
  40 #include "memory/allocation.inline.hpp"
  41 #include "memory/universe.inline.hpp"
  42 #include "oops/oop.inline.hpp"
  43 #include "prims/jvm.h"
  44 #include "prims/jvmtiExport.hpp"
  45 #include "runtime/arguments.hpp"
  46 #include "runtime/arguments_ext.hpp"
  47 #include "runtime/commandLineFlagConstraintList.hpp"
  48 #include "runtime/commandLineFlagWriteableList.hpp"
  49 #include "runtime/commandLineFlagRangeList.hpp"
  50 #include "runtime/globals.hpp"
  51 #include "runtime/globals_extension.hpp"
  52 #include "runtime/java.hpp"


1571     if (FLAG_IS_DEFAULT(UseCompressedClassPointers)) {
1572       FLAG_SET_ERGO(bool, UseCompressedClassPointers, true);
1573     }
1574     // Check the CompressedClassSpaceSize to make sure we use compressed klass ptrs.
1575     if (UseCompressedClassPointers) {
1576       if (CompressedClassSpaceSize > KlassEncodingMetaspaceMax) {
1577         warning("CompressedClassSpaceSize is too large for UseCompressedClassPointers");
1578         FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1579       }
1580     }
1581   }
1582 #endif // _LP64
1583 #endif // !ZERO
1584 }
1585 
1586 void Arguments::set_conservative_max_heap_alignment() {
1587   // The conservative maximum required alignment for the heap is the maximum of
1588   // the alignments imposed by several sources: any requirements from the heap
1589   // itself, the collector policy and the maximum page size we may run the VM
1590   // with.
1591   size_t heap_alignment = GCFactory::gc()->conservative_max_heap_alignment();
1592   _conservative_max_heap_alignment = MAX4(heap_alignment,
1593                                           (size_t)os::vm_allocation_granularity(),
1594                                           os::max_page_size(),
1595                                           CollectorPolicy::compute_heap_alignment());
1596 }
1597 
1598 #ifdef TIERED
1599 bool Arguments::compilation_mode_selected() {
1600  return !FLAG_IS_DEFAULT(TieredCompilation) || !FLAG_IS_DEFAULT(TieredStopAtLevel) ||
1601         !FLAG_IS_DEFAULT(UseAOT) JVMCI_ONLY(|| !FLAG_IS_DEFAULT(EnableJVMCI) || !FLAG_IS_DEFAULT(UseJVMCICompiler));
1602 
1603 }
1604 
1605 void Arguments::select_compilation_mode_ergonomically() {
1606 #if defined(_WINDOWS) && !defined(_LP64)
1607   if (FLAG_IS_DEFAULT(NeverActAsServerClassMachine)) {
1608     FLAG_SET_ERGO(bool, NeverActAsServerClassMachine, true);
1609   }
1610 #endif
1611   if (NeverActAsServerClassMachine) {


1637     }
1638     if (TieredStopAtLevel != CompLevel_full_optimization) {
1639       // Currently JVMCI compiler can only work at the full optimization level
1640       warning("forcing TieredStopAtLevel to full optimization because JVMCI is enabled");
1641       TieredStopAtLevel = CompLevel_full_optimization;
1642     }
1643     if (FLAG_IS_DEFAULT(TypeProfileLevel)) {
1644       FLAG_SET_DEFAULT(TypeProfileLevel, 0);
1645     }
1646   }
1647 }
1648 #endif
1649 
1650 jint Arguments::set_ergonomics_flags() {
1651 #ifdef TIERED
1652   if (!compilation_mode_selected()) {
1653     select_compilation_mode_ergonomically();
1654   }
1655 #endif
1656 
1657   jint gc_result = GCFactory::initialize();
1658   if (gc_result != JNI_OK) {
1659     return gc_result;
1660   }
1661 
1662 #if defined(COMPILER2) || INCLUDE_JVMCI
1663   // Shared spaces work fine with other GCs but causes bytecode rewriting
1664   // to be disabled, which hurts interpreter performance and decreases
1665   // server performance.  When -server is specified, keep the default off
1666   // unless it is asked for.  Future work: either add bytecode rewriting
1667   // at link time, or rewrite bytecodes in non-shared methods.
1668   if (is_server_compilation_mode_vm() && !DumpSharedSpaces && !RequireSharedSpaces &&
1669       (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) {
1670     no_shared_spaces("COMPILER2 default: -Xshare:auto | off, have to manually setup to on.");
1671   }
1672 #endif
1673 
1674   set_conservative_max_heap_alignment();
1675 
1676 #ifndef ZERO
1677 #ifdef _LP64
1678   set_use_compressed_oops();
1679 
1680   // set_use_compressed_klass_ptrs() must be called after calling
1681   // set_use_compressed_oops().
1682   set_use_compressed_klass_ptrs();
1683 
1684   // Also checks that certain machines are slower with compressed oops
1685   // in vm_version initialization code.
1686 #endif // _LP64
1687 #endif // !ZERO
1688 
1689   return JNI_OK;
1690 }
1691 
1692 void Arguments::set_gc_specific_flags() {
1693   // Set per-collector flags
1694   GCFactory::gc()->initialize_flags();
1695   // Set flags for all collectors.
1696   GCFactory::initialize_flags_global();
1697 }
1698 
1699 julong Arguments::limit_by_allocatable_memory(julong limit) {
1700   julong max_allocatable;
1701   julong result = limit;
1702   if (os::has_allocatable_memory_limit(&max_allocatable)) {
1703     result = MIN2(result, max_allocatable / MaxVirtMemFraction);
1704   }
1705   return result;
1706 }
1707 
1708 // Use static initialization to get the default before parsing
1709 static const size_t DefaultHeapBaseMinAddress = HeapBaseMinAddress;
1710 
1711 void Arguments::set_heap_size() {
1712   julong phys_mem =
1713     FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
1714                             : (julong)MaxRAM;
1715 
1716   // Experimental support for CGroup memory limits


< prev index next >