8153843: G1CardLiveDataHelper incorrectly sets next_live_bytes on dead humongous regions
authormgerdin
Mon, 11 Apr 2016 09:49:10 +0200
changeset 37471 6ba3e52c2bd6
parent 37468 2313142725e0
child 37472 4eea82a66dab
8153843: G1CardLiveDataHelper incorrectly sets next_live_bytes on dead humongous regions Reviewed-by: drwhite, tschatzl
hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp
hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp
--- a/hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp	Tue Apr 12 14:03:31 2016 +0200
+++ b/hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp	Mon Apr 11 09:49:10 2016 +0200
@@ -206,8 +206,14 @@
       return 0;
     }
     if (hr->is_humongous()) {
-      mark_card_bitmap_range(start, hr->top());
-      return pointer_delta(hr->top(), start, 1);
+      HeapRegion* start_region = hr->humongous_start_region();
+      if (mark_bitmap->isMarked(start_region->bottom())) {
+        mark_card_bitmap_range(start, hr->top());
+        return pointer_delta(hr->top(), start, 1);
+      } else {
+        // Humongous start object was actually dead.
+        return 0;
+      }
     }
 
     assert(start <= hr->end() && start <= ntams && ntams <= hr->end(),
--- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp	Tue Apr 12 14:03:31 2016 +0200
+++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp	Mon Apr 11 09:49:10 2016 +0200
@@ -2946,13 +2946,17 @@
       : rset->is_empty();
   }
 
-  bool is_typeArray_region(HeapRegion* region) const {
-    return oop(region->bottom())->is_typeArray();
-  }
-
   bool humongous_region_is_candidate(G1CollectedHeap* heap, HeapRegion* region) const {
     assert(region->is_starts_humongous(), "Must start a humongous object");
 
+    oop obj = oop(region->bottom());
+
+    // Dead objects cannot be eager reclaim candidates. Due to class
+    // unloading it is unsafe to query their classes so we return early.
+    if (heap->is_obj_dead(obj, region)) {
+      return false;
+    }
+
     // Candidate selection must satisfy the following constraints
     // while concurrent marking is in progress:
     //
@@ -2989,7 +2993,7 @@
     // important use case for eager reclaim, and this special handling
     // may reduce needed headroom.
 
-    return is_typeArray_region(region) && is_remset_small(region);
+    return obj->is_typeArray() && is_remset_small(region);
   }
 
  public: