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 = GCArguments::instance()->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 = GCArguments::create_instance();
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 GC flags
1694 GCArguments::instance()->initialize_flags();
1695 }
1696
1697 julong Arguments::limit_by_allocatable_memory(julong limit) {
1698 julong max_allocatable;
1699 julong result = limit;
1700 if (os::has_allocatable_memory_limit(&max_allocatable)) {
1701 result = MIN2(result, max_allocatable / MaxVirtMemFraction);
1702 }
1703 return result;
1704 }
1705
1706 // Use static initialization to get the default before parsing
1707 static const size_t DefaultHeapBaseMinAddress = HeapBaseMinAddress;
1708
1709 void Arguments::set_heap_size() {
1710 julong phys_mem =
1711 FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
1712 : (julong)MaxRAM;
1713
1714 // Experimental support for CGroup memory limits
|
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 = GCArguments::arguments()->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 = GCArguments::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 GC flags
1694 GCArguments::arguments()->initialize_flags();
1695 }
1696
1697 julong Arguments::limit_by_allocatable_memory(julong limit) {
1698 julong max_allocatable;
1699 julong result = limit;
1700 if (os::has_allocatable_memory_limit(&max_allocatable)) {
1701 result = MIN2(result, max_allocatable / MaxVirtMemFraction);
1702 }
1703 return result;
1704 }
1705
1706 // Use static initialization to get the default before parsing
1707 static const size_t DefaultHeapBaseMinAddress = HeapBaseMinAddress;
1708
1709 void Arguments::set_heap_size() {
1710 julong phys_mem =
1711 FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
1712 : (julong)MaxRAM;
1713
1714 // Experimental support for CGroup memory limits
|