< prev index next >

src/hotspot/share/runtime/arguments.cpp

Print this page

1500     if (FLAG_IS_DEFAULT(UseCompressedOops)) {
1501       FLAG_SET_ERGO(UseCompressedOops, true);
1502     }
1503   } else {
1504     if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) {
1505       warning("Max heap size too large for Compressed Oops");
1506       FLAG_SET_DEFAULT(UseCompressedOops, false);
1507       if (COMPRESSED_CLASS_POINTERS_DEPENDS_ON_COMPRESSED_OOPS) {
1508         FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1509       }
1510     }
1511   }
1512 #endif // _LP64
1513 }
1514 
1515 
1516 // NOTE: set_use_compressed_klass_ptrs() must be called after calling
1517 // set_use_compressed_oops().
1518 void Arguments::set_use_compressed_klass_ptrs() {
1519 #ifdef _LP64















1520   // On some architectures, the use of UseCompressedClassPointers implies the use of
1521   // UseCompressedOops. The reason is that the rheap_base register of said platforms
1522   // is reused to perform some optimized spilling, in order to use rheap_base as a
1523   // temp register. But by treating it as any other temp register, spilling can typically
1524   // be completely avoided instead. So it is better not to perform this trick. And by
1525   // not having that reliance, large heaps, or heaps not supporting compressed oops,
1526   // can still use compressed class pointers.
1527   if (COMPRESSED_CLASS_POINTERS_DEPENDS_ON_COMPRESSED_OOPS && !UseCompressedOops) {
1528     if (UseCompressedClassPointers) {
1529       warning("UseCompressedClassPointers requires UseCompressedOops");
1530     }
1531     FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1532   } else {
1533     // Turn on UseCompressedClassPointers too
1534     if (FLAG_IS_DEFAULT(UseCompressedClassPointers)) {
1535       FLAG_SET_ERGO(UseCompressedClassPointers, true);
1536     }
1537     // Check the CompressedClassSpaceSize to make sure we use compressed klass ptrs.
1538     if (UseCompressedClassPointers) {
1539       if (CompressedClassSpaceSize > KlassEncodingMetaspaceMax) {
1540         warning("CompressedClassSpaceSize is too large for UseCompressedClassPointers");
1541         FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1542       }
1543     }
1544   }
1545 #endif // _LP64









1546 }
1547 
1548 void Arguments::set_conservative_max_heap_alignment() {
1549   // The conservative maximum required alignment for the heap is the maximum of
1550   // the alignments imposed by several sources: any requirements from the heap
1551   // itself and the maximum page size we may run the VM with.
1552   size_t heap_alignment = GCConfig::arguments()->conservative_max_heap_alignment();
1553   _conservative_max_heap_alignment = MAX4(heap_alignment,
1554                                           os::vm_allocation_granularity(),
1555                                           os::max_page_size(),
1556                                           GCArguments::compute_heap_alignment());
1557 }
1558 
1559 jint Arguments::set_ergonomics_flags() {
1560   GCConfig::initialize();
1561 
1562   set_conservative_max_heap_alignment();
1563 
1564 #ifdef _LP64
1565   set_use_compressed_oops();

3108   if (UseSharedSpaces && patch_mod_javabase) {
3109     no_shared_spaces("CDS is disabled when " JAVA_BASE_NAME " module is patched.");
3110   }
3111   if (UseSharedSpaces && !DumpSharedSpaces && check_unsupported_cds_runtime_properties()) {
3112     UseSharedSpaces = false;
3113   }
3114 
3115   if (DumpSharedSpaces || DynamicDumpSharedSpaces) {
3116     // Always verify non-system classes during CDS dump
3117     if (!BytecodeVerificationRemote) {
3118       BytecodeVerificationRemote = true;
3119       log_info(cds)("All non-system classes will be verified (-Xverify:remote) during CDS dump time.");
3120     }
3121   }
3122 #endif
3123 
3124 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
3125   UNSUPPORTED_OPTION(ShowRegistersOnAssert);
3126 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
3127 
















3128   return JNI_OK;
3129 }
3130 
3131 // Helper class for controlling the lifetime of JavaVMInitArgs
3132 // objects.  The contents of the JavaVMInitArgs are guaranteed to be
3133 // deleted on the destruction of the ScopedVMInitArgs object.
3134 class ScopedVMInitArgs : public StackObj {
3135  private:
3136   JavaVMInitArgs _args;
3137   char*          _container_name;
3138   bool           _is_set;
3139   char*          _vm_options_file_arg;
3140 
3141  public:
3142   ScopedVMInitArgs(const char *container_name) {
3143     _args.version = JNI_VERSION_1_2;
3144     _args.nOptions = 0;
3145     _args.options = nullptr;
3146     _args.ignoreUnrecognized = false;
3147     _container_name = (char *)container_name;

1500     if (FLAG_IS_DEFAULT(UseCompressedOops)) {
1501       FLAG_SET_ERGO(UseCompressedOops, true);
1502     }
1503   } else {
1504     if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) {
1505       warning("Max heap size too large for Compressed Oops");
1506       FLAG_SET_DEFAULT(UseCompressedOops, false);
1507       if (COMPRESSED_CLASS_POINTERS_DEPENDS_ON_COMPRESSED_OOPS) {
1508         FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1509       }
1510     }
1511   }
1512 #endif // _LP64
1513 }
1514 
1515 
1516 // NOTE: set_use_compressed_klass_ptrs() must be called after calling
1517 // set_use_compressed_oops().
1518 void Arguments::set_use_compressed_klass_ptrs() {
1519 #ifdef _LP64
1520 
1521   if (UseCompactObjectHeaders) {
1522     // 512 byte alignment, 22-bit values (Lilliput)
1523     LogKlassAlignmentInBytes = 9;
1524     MaxNarrowKlassPointerBits = 22;
1525   } else {
1526     // Traditional: 8 byte alignment, 32-bit values
1527     LogKlassAlignmentInBytes = 3;
1528     MaxNarrowKlassPointerBits = 32;
1529   }
1530 
1531   KlassAlignmentInBytes = 1 << LogKlassAlignmentInBytes;
1532   NarrowKlassPointerBitMask = ((((uint64_t)1) << MaxNarrowKlassPointerBits) - 1);
1533   KlassEncodingMetaspaceMax = UCONST64(1) << (MaxNarrowKlassPointerBits + LogKlassAlignmentInBytes);
1534 
1535   // On some architectures, the use of UseCompressedClassPointers implies the use of
1536   // UseCompressedOops. The reason is that the rheap_base register of said platforms
1537   // is reused to perform some optimized spilling, in order to use rheap_base as a
1538   // temp register. But by treating it as any other temp register, spilling can typically
1539   // be completely avoided instead. So it is better not to perform this trick. And by
1540   // not having that reliance, large heaps, or heaps not supporting compressed oops,
1541   // can still use compressed class pointers.
1542   if (COMPRESSED_CLASS_POINTERS_DEPENDS_ON_COMPRESSED_OOPS && !UseCompressedOops) {
1543     if (UseCompressedClassPointers) {
1544       warning("UseCompressedClassPointers requires UseCompressedOops");
1545     }
1546     FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1547   } else {
1548     // Turn on UseCompressedClassPointers too
1549     if (FLAG_IS_DEFAULT(UseCompressedClassPointers)) {
1550       FLAG_SET_ERGO(UseCompressedClassPointers, true);
1551     }
1552     // Check the CompressedClassSpaceSize to make sure we use compressed klass ptrs.
1553     if (UseCompressedClassPointers) {
1554       if (CompressedClassSpaceSize > KlassEncodingMetaspaceMax) {
1555         warning("CompressedClassSpaceSize is too large for UseCompressedClassPointers");
1556         FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1557       }
1558     }
1559   }
1560 
1561   // Assert validity of compressed class space size. User arg should have been checked at this point
1562   // (see CompressedClassSpaceSizeConstraintFunc()), so no need to be nice about it, this fires in
1563   // case the default is wrong.
1564   // TODO: This is placed wrong. The CompressedClassSpaceSizeFunc is done after ergo, but this
1565   // assert is during ergo.
1566   // assert(CompressedClassSpaceSize <= Metaspace::max_class_space_size(),
1567   //        "CompressedClassSpaceSize " SIZE_FORMAT " too large (max: " SIZE_FORMAT ")",
1568   //        CompressedClassSpaceSize, Metaspace::max_class_space_size());
1569 #endif
1570 }
1571 
1572 void Arguments::set_conservative_max_heap_alignment() {
1573   // The conservative maximum required alignment for the heap is the maximum of
1574   // the alignments imposed by several sources: any requirements from the heap
1575   // itself and the maximum page size we may run the VM with.
1576   size_t heap_alignment = GCConfig::arguments()->conservative_max_heap_alignment();
1577   _conservative_max_heap_alignment = MAX4(heap_alignment,
1578                                           os::vm_allocation_granularity(),
1579                                           os::max_page_size(),
1580                                           GCArguments::compute_heap_alignment());
1581 }
1582 
1583 jint Arguments::set_ergonomics_flags() {
1584   GCConfig::initialize();
1585 
1586   set_conservative_max_heap_alignment();
1587 
1588 #ifdef _LP64
1589   set_use_compressed_oops();

3132   if (UseSharedSpaces && patch_mod_javabase) {
3133     no_shared_spaces("CDS is disabled when " JAVA_BASE_NAME " module is patched.");
3134   }
3135   if (UseSharedSpaces && !DumpSharedSpaces && check_unsupported_cds_runtime_properties()) {
3136     UseSharedSpaces = false;
3137   }
3138 
3139   if (DumpSharedSpaces || DynamicDumpSharedSpaces) {
3140     // Always verify non-system classes during CDS dump
3141     if (!BytecodeVerificationRemote) {
3142       BytecodeVerificationRemote = true;
3143       log_info(cds)("All non-system classes will be verified (-Xverify:remote) during CDS dump time.");
3144     }
3145   }
3146 #endif
3147 
3148 #ifndef CAN_SHOW_REGISTERS_ON_ASSERT
3149   UNSUPPORTED_OPTION(ShowRegistersOnAssert);
3150 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
3151 
3152 #ifdef _LP64
3153   if (UseCompactObjectHeaders && FLAG_IS_CMDLINE(UseCompressedClassPointers) && !UseCompressedClassPointers) {
3154     // If user specifies -UseCompressedClassPointers, disable compact headers with a warning.
3155     warning("Compact object headers require compressed class pointers. Disabling compact object headers.");
3156     FLAG_SET_DEFAULT(UseCompactObjectHeaders, false);
3157   }
3158 
3159   if (UseCompactObjectHeaders && !UseFastLocking) {
3160     FLAG_SET_DEFAULT(UseFastLocking, true);
3161   }
3162 
3163   if (!UseCompactObjectHeaders) {
3164     FLAG_SET_DEFAULT(UseSharedSpaces, false);
3165   }
3166 #endif
3167 
3168   return JNI_OK;
3169 }
3170 
3171 // Helper class for controlling the lifetime of JavaVMInitArgs
3172 // objects.  The contents of the JavaVMInitArgs are guaranteed to be
3173 // deleted on the destruction of the ScopedVMInitArgs object.
3174 class ScopedVMInitArgs : public StackObj {
3175  private:
3176   JavaVMInitArgs _args;
3177   char*          _container_name;
3178   bool           _is_set;
3179   char*          _vm_options_file_arg;
3180 
3181  public:
3182   ScopedVMInitArgs(const char *container_name) {
3183     _args.version = JNI_VERSION_1_2;
3184     _args.nOptions = 0;
3185     _args.options = nullptr;
3186     _args.ignoreUnrecognized = false;
3187     _container_name = (char *)container_name;
< prev index next >