changeset 10875:a57bba2898a3

8153843: G1CardLiveDataHelper incorrectly sets next_live_bytes on dead humongous regions Reviewed-by: drwhite, tschatzl
author mgerdin
date Mon, 11 Apr 2016 09:49:10 +0200
parents f589cf9f3082
children b39019876702
files src/share/vm/gc/g1/g1CardLiveData.cpp src/share/vm/gc/g1/g1CollectedHeap.cpp
diffstat 2 files changed, 17 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc/g1/g1CardLiveData.cpp	Tue Apr 12 14:03:31 2016 +0200
+++ b/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/src/share/vm/gc/g1/g1CollectedHeap.cpp	Tue Apr 12 14:03:31 2016 +0200
+++ b/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: