From 195509ea7bf1ec4fedfaf25478ed0b92f8ce3aaf Mon Sep 17 00:00:00 2001 From: johnc Date: Thu, 11 Mar 2010 11:44:43 -0800 Subject: [PATCH] 6755988: G1: assert(new_obj != 0 || ... "should be forwarded") Summary: A TLAB became large enough to be considered a humongous object allowing multiple objects to be allocated in a humongous region, which violates a basic assumption about humongous regions. The changes ensure that TLABs cannot be regarded as humongous. Reviewed-by: iveresov, tonyp --- .../gc_implementation/g1/g1CollectedHeap.cpp | 19 +++++++++++-------- .../gc_implementation/g1/g1CollectedHeap.hpp | 7 ++++++- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index 0f844041e..8c77e5af0 100644 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -2102,18 +2102,21 @@ size_t G1CollectedHeap::tlab_capacity(Thread* ignored) const { size_t G1CollectedHeap::unsafe_max_tlab_alloc(Thread* ignored) const { // Return the remaining space in the cur alloc region, but not less than // the min TLAB size. - // Also, no more than half the region size, since we can't allow tlabs to - // grow big enough to accomodate humongous objects. - // We need to story it locally, since it might change between when we - // test for NULL and when we use it later. + // Also, this value can be at most the humongous object threshold, + // since we can't allow tlabs to grow big enough to accomodate + // humongous objects. + + // We need to store the cur alloc region locally, since it might change + // between when we test for NULL and when we use it later. ContiguousSpace* cur_alloc_space = _cur_alloc_region; + size_t max_tlab_size = _humongous_object_threshold_in_words * wordSize; + if (cur_alloc_space == NULL) { - return HeapRegion::GrainBytes/2; + return max_tlab_size; } else { - return MAX2(MIN2(cur_alloc_space->free(), - (size_t)(HeapRegion::GrainBytes/2)), - (size_t)MinTLABSize); + return MIN2(MAX2(cur_alloc_space->free(), (size_t)MinTLABSize), + max_tlab_size); } } diff --git a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp index c9c586750..54715bd7b 100644 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @@ -1055,7 +1055,12 @@ public: // Returns "true" iff the given word_size is "very large". static bool isHumongous(size_t word_size) { - return word_size >= _humongous_object_threshold_in_words; + // Note this has to be strictly greater-than as the TLABs + // are capped at the humongous thresold and we want to + // ensure that we don't try to allocate a TLAB as + // humongous and that we don't allocate a humongous + // object in a TLAB. + return word_size > _humongous_object_threshold_in_words; } // Update mod union table with the set of dirty cards. -- GitLab