Mercurial > hg > graal-compiler
diff src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @ 642:660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
Summary: Use zero based compressed oops if java heap is below 32gb and unscaled compressed oops if java heap is below 4gb.
Reviewed-by: never, twisti, jcoomes, coleenp
author | kvn |
---|---|
date | Thu, 12 Mar 2009 10:37:46 -0700 |
parents | bcedf688d882 |
children | bd441136a5ce |
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Wed Mar 11 14:16:13 2009 -0700 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Thu Mar 12 10:37:46 2009 -0700 @@ -1360,9 +1360,34 @@ // Reserve the maximum. PermanentGenerationSpec* pgs = collector_policy()->permanent_generation(); // Includes the perm-gen. + + const size_t total_reserved = max_byte_size + pgs->max_size(); + char* addr = Universe::preferred_heap_base(total_reserved, Universe::UnscaledNarrowOop); + ReservedSpace heap_rs(max_byte_size + pgs->max_size(), HeapRegion::GrainBytes, - false /*ism*/); + false /*ism*/, addr); + + if (UseCompressedOops) { + if (addr != NULL && !heap_rs.is_reserved()) { + // Failed to reserve at specified address - the requested memory + // region is taken already, for example, by 'java' launcher. + // Try again to reserver heap higher. + addr = Universe::preferred_heap_base(total_reserved, Universe::ZeroBasedNarrowOop); + ReservedSpace heap_rs0(total_reserved, HeapRegion::GrainBytes, + false /*ism*/, addr); + if (addr != NULL && !heap_rs0.is_reserved()) { + // Failed to reserve at specified address again - give up. + addr = Universe::preferred_heap_base(total_reserved, Universe::HeapBasedNarrowOop); + assert(addr == NULL, ""); + ReservedSpace heap_rs1(total_reserved, HeapRegion::GrainBytes, + false /*ism*/, addr); + heap_rs = heap_rs1; + } else { + heap_rs = heap_rs0; + } + } + } if (!heap_rs.is_reserved()) { vm_exit_during_initialization("Could not reserve enough space for object heap");