diff src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @ 23626:8daf136b3218

8145442: Add the facility to verify remembered sets for G1 Summary: Implement remembered sets verification for G1 with option VerifyRememberedSets Reviewed-by: jmasa, mgerdin
author poonam
date Mon, 01 Feb 2016 13:19:14 -0800
parents f3f2f71d2dc8
children b5f3a471e646 6c57a16d0238
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Wed Feb 03 19:13:31 2016 +0300
+++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Mon Feb 01 13:19:14 2016 -0800
@@ -3839,6 +3839,16 @@
   _surviving_young_words = NULL;
 }
 
+class VerifyRegionRemSetClosure : public HeapRegionClosure {
+  public:
+    bool doHeapRegion(HeapRegion* hr) {
+      if (!hr->continuesHumongous()) {
+        hr->verify_rem_set();
+      }
+      return false;
+    }
+};
+
 #ifdef ASSERT
 class VerifyCSetClosure: public HeapRegionClosure {
 public:
@@ -4015,6 +4025,14 @@
       increment_total_collections(false /* full gc */);
       increment_gc_time_stamp();
 
+      if (VerifyRememberedSets) {
+        if (!VerifySilently) {
+          gclog_or_tty->print_cr("[Verifying RemSets before GC]");
+        }
+        VerifyRegionRemSetClosure v_cl;
+        heap_region_iterate(&v_cl);
+      }
+
       verify_before_gc();
       check_bitmaps("GC Start");
 
@@ -4246,6 +4264,14 @@
         // scanning cards (see CR 7039627).
         increment_gc_time_stamp();
 
+        if (VerifyRememberedSets) {
+          if (!VerifySilently) {
+            gclog_or_tty->print_cr("[Verifying RemSets after GC]");
+          }
+          VerifyRegionRemSetClosure v_cl;
+          heap_region_iterate(&v_cl);
+        }
+
         verify_after_gc();
         check_bitmaps("GC End");