changeset 7197:c04f46b4abe4

8068036: assert(is_available(index)) failed in G1 cset Summary: Some verification code iterated over the heap using the region mapping array. This is not allowed. Changed to use the regular iteration method with closure. Reviewed-by: jwilhelm, brutisso
author tschatzl
date Tue, 31 Mar 2015 11:36:37 +0200
parents 3ca53859c3c7
children 12eb26c15642
files src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp
diffstat 2 files changed, 36 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Thu Mar 19 15:25:54 2015 +0100
+++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Tue Mar 31 11:36:37 2015 +0200
@@ -6017,56 +6017,68 @@
   guarantee(!cl.failures(), "bitmap verification");
 }
 
-bool G1CollectedHeap::check_cset_fast_test() {
-  bool failures = false;
-  for (uint i = 0; i < _hrm.length(); i += 1) {
-    HeapRegion* hr = _hrm.at(i);
-    InCSetState cset_state = (InCSetState) _in_cset_fast_test.get_by_index((uint) i);
+class G1CheckCSetFastTableClosure : public HeapRegionClosure {
+ private:
+  bool _failures;
+ public:
+  G1CheckCSetFastTableClosure() : HeapRegionClosure(), _failures(false) { }
+
+  virtual bool doHeapRegion(HeapRegion* hr) {
+    uint i = hr->hrm_index();
+    InCSetState cset_state = (InCSetState) G1CollectedHeap::heap()->_in_cset_fast_test.get_by_index(i);
     if (hr->isHumongous()) {
       if (hr->in_collection_set()) {
         gclog_or_tty->print_cr("\n## humongous region %u in CSet", i);
-        failures = true;
-        break;
+        _failures = true;
+        return true;
       }
       if (cset_state.is_in_cset()) {
         gclog_or_tty->print_cr("\n## inconsistent cset state %d for humongous region %u", cset_state.value(), i);
-        failures = true;
-        break;
+        _failures = true;
+        return true;
       }
       if (hr->continuesHumongous() && cset_state.is_humongous()) {
         gclog_or_tty->print_cr("\n## inconsistent cset state %d for continues humongous region %u", cset_state.value(), i);
-        failures = true;
-        break;
+        _failures = true;
+        return true;
       }
     } else {
       if (cset_state.is_humongous()) {
         gclog_or_tty->print_cr("\n## inconsistent cset state %d for non-humongous region %u", cset_state.value(), i);
-        failures = true;
-        break;
+        _failures = true;
+        return true;
       }
       if (hr->in_collection_set() != cset_state.is_in_cset()) {
         gclog_or_tty->print_cr("\n## in CSet %d / cset state %d inconsistency for region %u",
                                hr->in_collection_set(), cset_state.value(), i);
-        failures = true;
-        break;
+       _failures = true;
+       return true;
       }
       if (cset_state.is_in_cset()) {
         if (hr->is_young() != (cset_state.is_young())) {
           gclog_or_tty->print_cr("\n## is_young %d / cset state %d inconsistency for region %u",
                                  hr->is_young(), cset_state.value(), i);
-          failures = true;
-          break;
+          _failures = true;
+          return true;
         }
         if (hr->is_old() != (cset_state.is_old())) {
           gclog_or_tty->print_cr("\n## is_old %d / cset state %d inconsistency for region %u",
                                  hr->is_old(), cset_state.value(), i);
-          failures = true;
-          break;
+          _failures = true;
+          return true;
         }
       }
     }
-  }
-  return !failures;
+    return false;
+  }
+
+  bool failures() const { return _failures; }
+};
+
+bool G1CollectedHeap::check_cset_fast_test() {
+  G1CheckCSetFastTableClosure cl;
+  _hrm.iterate(&cl);
+  return !cl.failures();
 }
 #endif // PRODUCT
 
--- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Thu Mar 19 15:25:54 2015 +0100
+++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Tue Mar 31 11:36:37 2015 +0200
@@ -213,6 +213,9 @@
   // Other related classes.
   friend class G1MarkSweep;
 
+  // Testing classes.
+  friend class G1CheckCSetFastTableClosure;
+
 private:
   // The one and only G1CollectedHeap, so static functions can find it.
   static G1CollectedHeap* _g1h;