Mercurial > hg > truffle
changeset 135:b7268662a986
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
author | coleenp |
---|---|
date | Tue, 29 Apr 2008 19:31:29 -0400 |
parents | 8a79f7ec8f5d |
children | 7f3a69574470 |
files | src/share/vm/oops/oop.hpp src/share/vm/oops/oop.inline.hpp src/share/vm/runtime/arguments.cpp |
diffstat | 3 files changed, 18 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/vm/oops/oop.hpp Tue Apr 29 11:21:51 2008 -0400 +++ b/src/share/vm/oops/oop.hpp Tue Apr 29 19:31:29 2008 -0400 @@ -138,6 +138,10 @@ // Need this as public for garbage collection. template <class T> T* obj_field_addr(int offset) const; + // Oop encoding heap max + static const uint64_t OopEncodingHeapMax = + (uint64_t(max_juint) + 1) << LogMinObjAlignmentInBytes; + static bool is_null(oop obj); static bool is_null(narrowOop obj);
--- a/src/share/vm/oops/oop.inline.hpp Tue Apr 29 11:21:51 2008 -0400 +++ b/src/share/vm/oops/oop.inline.hpp Tue Apr 29 19:31:29 2008 -0400 @@ -134,8 +134,10 @@ inline narrowOop oopDesc::encode_heap_oop_not_null(oop v) { assert(!is_null(v), "oop value can never be zero"); address heap_base = Universe::heap_base(); - uint64_t result = (uint64_t)(pointer_delta((void*)v, (void*)heap_base, 1) >> LogMinObjAlignmentInBytes); - assert((result & 0xffffffff00000000ULL) == 0, "narrow oop overflow"); + uint64_t pd = (uint64_t)(pointer_delta((void*)v, (void*)heap_base, 1)); + assert(OopEncodingHeapMax > pd, "change encoding max if new encoding"); + uint64_t result = pd >> LogMinObjAlignmentInBytes; + assert((result & CONST64(0xffffffff00000000)) == 0, "narrow oop overflow"); return (narrowOop)result; }
--- a/src/share/vm/runtime/arguments.cpp Tue Apr 29 11:21:51 2008 -0400 +++ b/src/share/vm/runtime/arguments.cpp Tue Apr 29 19:31:29 2008 -0400 @@ -1125,6 +1125,11 @@ } } +inline uintx max_heap_for_compressed_oops() { + LP64_ONLY(return oopDesc::OopEncodingHeapMax - MaxPermSize - os::vm_page_size()); + NOT_LP64(return DefaultMaxRAM); +} + bool Arguments::should_auto_select_low_pause_collector() { if (UseAutoGCSelectPolicy && !FLAG_IS_DEFAULT(MaxGCPauseMillis) && @@ -1169,7 +1174,7 @@ // field offset to determine free list chunk markers. // Check that UseCompressedOops can be set with the max heap size allocated // by ergonomics. - if (!UseConcMarkSweepGC && MaxHeapSize <= (32*G - os::vm_page_size())) { + if (!UseConcMarkSweepGC && MaxHeapSize <= max_heap_for_compressed_oops()) { if (FLAG_IS_DEFAULT(UseCompressedOops)) { FLAG_SET_ERGO(bool, UseCompressedOops, true); } @@ -1205,7 +1210,10 @@ if (FLAG_IS_DEFAULT(MaxHeapSize)) { const uint64_t reasonable_fraction = os::physical_memory() / DefaultMaxRAMFraction; - const uint64_t maximum_size = (uint64_t) DefaultMaxRAM; + const uint64_t maximum_size = (uint64_t) + (FLAG_IS_DEFAULT(DefaultMaxRAM) && UseCompressedOops ? + MIN2(max_heap_for_compressed_oops(), DefaultMaxRAM) : + DefaultMaxRAM); size_t reasonable_max = (size_t) os::allocatable_physical_memory(reasonable_fraction); if (reasonable_max > maximum_size) {