comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @ 20331:18bf0b66de52

8044406: JVM crash with JDK8 (build 1.8.0-b132) with G1 GC Summary: Fill the last card that has been allocated into with a dummy object Reviewed-by: tschatzl, mgerdin
author poonam
date Tue, 19 Aug 2014 02:05:49 -0700
parents bfba6779654b
children ff3169f25621
comparison
equal deleted inserted replaced
20329:fb971e09d20f 20331:18bf0b66de52
7051 void OldGCAllocRegion::retire_region(HeapRegion* alloc_region, 7051 void OldGCAllocRegion::retire_region(HeapRegion* alloc_region,
7052 size_t allocated_bytes) { 7052 size_t allocated_bytes) {
7053 _g1h->retire_gc_alloc_region(alloc_region, allocated_bytes, 7053 _g1h->retire_gc_alloc_region(alloc_region, allocated_bytes,
7054 GCAllocForTenured); 7054 GCAllocForTenured);
7055 } 7055 }
7056
7057 HeapRegion* OldGCAllocRegion::release() {
7058 HeapRegion* cur = get();
7059 if (cur != NULL) {
7060 // Determine how far we are from the next card boundary. If it is smaller than
7061 // the minimum object size we can allocate into, expand into the next card.
7062 HeapWord* top = cur->top();
7063 HeapWord* aligned_top = (HeapWord*)align_ptr_up(top, G1BlockOffsetSharedArray::N_bytes);
7064
7065 size_t to_allocate_words = pointer_delta(aligned_top, top, HeapWordSize);
7066
7067 if (to_allocate_words != 0) {
7068 // We are not at a card boundary. Fill up, possibly into the next, taking the
7069 // end of the region and the minimum object size into account.
7070 to_allocate_words = MIN2(pointer_delta(cur->end(), cur->top(), HeapWordSize),
7071 MAX2(to_allocate_words, G1CollectedHeap::min_fill_size()));
7072
7073 // Skip allocation if there is not enough space to allocate even the smallest
7074 // possible object. In this case this region will not be retained, so the
7075 // original problem cannot occur.
7076 if (to_allocate_words >= G1CollectedHeap::min_fill_size()) {
7077 HeapWord* dummy = attempt_allocation(to_allocate_words, true /* bot_updates */);
7078 CollectedHeap::fill_with_object(dummy, to_allocate_words);
7079 }
7080 }
7081 }
7082 return G1AllocRegion::release();
7083 }
7084
7056 // Heap region set verification 7085 // Heap region set verification
7057 7086
7058 class VerifyRegionListsClosure : public HeapRegionClosure { 7087 class VerifyRegionListsClosure : public HeapRegionClosure {
7059 private: 7088 private:
7060 HeapRegionSet* _old_set; 7089 HeapRegionSet* _old_set;