6689523: max heap calculation for compressed oops is off by MaxPermSize

Tue, 29 Apr 2008 19:31:29 -0400

author
coleenp
date
Tue, 29 Apr 2008 19:31:29 -0400
changeset 570
b7268662a986
parent 569
8a79f7ec8f5d
child 571
7f3a69574470

6689523: max heap calculation for compressed oops is off by MaxPermSize
Summary: Need to subtract MaxPermSize from the total heap size when determining whether compressed oops is turned on.
Reviewed-by: jmasa, jcoomes, kvn

src/share/vm/oops/oop.hpp file | annotate | diff | comparison | revisions
src/share/vm/oops/oop.inline.hpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/arguments.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/oops/oop.hpp	Tue Apr 29 11:21:51 2008 -0400
     1.2 +++ b/src/share/vm/oops/oop.hpp	Tue Apr 29 19:31:29 2008 -0400
     1.3 @@ -138,6 +138,10 @@
     1.4    // Need this as public for garbage collection.
     1.5    template <class T> T* obj_field_addr(int offset) const;
     1.6  
     1.7 +  // Oop encoding heap max
     1.8 +  static const uint64_t OopEncodingHeapMax =
     1.9 +              (uint64_t(max_juint) + 1) << LogMinObjAlignmentInBytes;
    1.10 +
    1.11    static bool is_null(oop obj);
    1.12    static bool is_null(narrowOop obj);
    1.13  
     2.1 --- a/src/share/vm/oops/oop.inline.hpp	Tue Apr 29 11:21:51 2008 -0400
     2.2 +++ b/src/share/vm/oops/oop.inline.hpp	Tue Apr 29 19:31:29 2008 -0400
     2.3 @@ -134,8 +134,10 @@
     2.4  inline narrowOop oopDesc::encode_heap_oop_not_null(oop v) {
     2.5    assert(!is_null(v), "oop value can never be zero");
     2.6    address heap_base = Universe::heap_base();
     2.7 -  uint64_t result = (uint64_t)(pointer_delta((void*)v, (void*)heap_base, 1) >> LogMinObjAlignmentInBytes);
     2.8 -  assert((result & 0xffffffff00000000ULL) == 0, "narrow oop overflow");
     2.9 +  uint64_t pd = (uint64_t)(pointer_delta((void*)v, (void*)heap_base, 1));
    2.10 +  assert(OopEncodingHeapMax > pd, "change encoding max if new encoding");
    2.11 +  uint64_t result = pd >> LogMinObjAlignmentInBytes;
    2.12 +  assert((result & CONST64(0xffffffff00000000)) == 0, "narrow oop overflow");
    2.13    return (narrowOop)result;
    2.14  }
    2.15  
     3.1 --- a/src/share/vm/runtime/arguments.cpp	Tue Apr 29 11:21:51 2008 -0400
     3.2 +++ b/src/share/vm/runtime/arguments.cpp	Tue Apr 29 19:31:29 2008 -0400
     3.3 @@ -1125,6 +1125,11 @@
     3.4    }
     3.5  }
     3.6  
     3.7 +inline uintx max_heap_for_compressed_oops() {
     3.8 +  LP64_ONLY(return oopDesc::OopEncodingHeapMax - MaxPermSize - os::vm_page_size());
     3.9 +  NOT_LP64(return DefaultMaxRAM);
    3.10 +}
    3.11 +
    3.12  bool Arguments::should_auto_select_low_pause_collector() {
    3.13    if (UseAutoGCSelectPolicy &&
    3.14        !FLAG_IS_DEFAULT(MaxGCPauseMillis) &&
    3.15 @@ -1169,7 +1174,7 @@
    3.16    // field offset to determine free list chunk markers.
    3.17    // Check that UseCompressedOops can be set with the max heap size allocated
    3.18    // by ergonomics.
    3.19 -  if (!UseConcMarkSweepGC && MaxHeapSize <= (32*G - os::vm_page_size())) {
    3.20 +  if (!UseConcMarkSweepGC && MaxHeapSize <= max_heap_for_compressed_oops()) {
    3.21      if (FLAG_IS_DEFAULT(UseCompressedOops)) {
    3.22        FLAG_SET_ERGO(bool, UseCompressedOops, true);
    3.23      }
    3.24 @@ -1205,7 +1210,10 @@
    3.25      if (FLAG_IS_DEFAULT(MaxHeapSize)) {
    3.26        const uint64_t reasonable_fraction =
    3.27          os::physical_memory() / DefaultMaxRAMFraction;
    3.28 -      const uint64_t maximum_size = (uint64_t) DefaultMaxRAM;
    3.29 +      const uint64_t maximum_size = (uint64_t)
    3.30 +                 (FLAG_IS_DEFAULT(DefaultMaxRAM) && UseCompressedOops ?
    3.31 +                     MIN2(max_heap_for_compressed_oops(), DefaultMaxRAM) :
    3.32 +                     DefaultMaxRAM);
    3.33        size_t reasonable_max =
    3.34          (size_t) os::allocatable_physical_memory(reasonable_fraction);
    3.35        if (reasonable_max > maximum_size) {

mercurial