8166898: G1SATBCardTableLoggingModRefBS::invalidate() incorrect with whole_heap == true
authorlmesnik
Thu, 24 Nov 2016 16:48:22 +0300
changeset 42598 45562c0473fb
parent 42597 a9611bab7578
child 42599 313ee598a1a3
8166898: G1SATBCardTableLoggingModRefBS::invalidate() incorrect with whole_heap == true Reviewed-by: tschatzl, kbarrett
hotspot/src/share/vm/gc/g1/g1SATBCardTableModRefBS.cpp
hotspot/src/share/vm/gc/g1/g1SATBCardTableModRefBS.hpp
hotspot/src/share/vm/gc/shared/cardTableModRefBS.cpp
hotspot/src/share/vm/gc/shared/cardTableModRefBS.hpp
hotspot/src/share/vm/gc/shared/cardTableRS.hpp
hotspot/src/share/vm/gc/shared/modRefBarrierSet.hpp
--- a/hotspot/src/share/vm/gc/g1/g1SATBCardTableModRefBS.cpp	Thu Nov 24 11:27:57 2016 +0100
+++ b/hotspot/src/share/vm/gc/g1/g1SATBCardTableModRefBS.cpp	Thu Nov 24 16:48:22 2016 +0300
@@ -178,44 +178,37 @@
 }
 
 void
-G1SATBCardTableLoggingModRefBS::invalidate(MemRegion mr, bool whole_heap) {
+G1SATBCardTableLoggingModRefBS::invalidate(MemRegion mr) {
   volatile jbyte* byte = byte_for(mr.start());
   jbyte* last_byte = byte_for(mr.last());
   Thread* thr = Thread::current();
-  if (whole_heap) {
-    while (byte <= last_byte) {
-      *byte = dirty_card;
-      byte++;
-    }
-  } else {
     // skip all consecutive young cards
-    for (; byte <= last_byte && *byte == g1_young_gen; byte++);
+  for (; byte <= last_byte && *byte == g1_young_gen; byte++);
 
-    if (byte <= last_byte) {
-      OrderAccess::storeload();
-      // Enqueue if necessary.
-      if (thr->is_Java_thread()) {
-        JavaThread* jt = (JavaThread*)thr;
-        for (; byte <= last_byte; byte++) {
-          if (*byte == g1_young_gen) {
-            continue;
-          }
-          if (*byte != dirty_card) {
-            *byte = dirty_card;
-            jt->dirty_card_queue().enqueue(byte);
-          }
+  if (byte <= last_byte) {
+    OrderAccess::storeload();
+    // Enqueue if necessary.
+    if (thr->is_Java_thread()) {
+      JavaThread* jt = (JavaThread*)thr;
+      for (; byte <= last_byte; byte++) {
+        if (*byte == g1_young_gen) {
+          continue;
         }
-      } else {
-        MutexLockerEx x(Shared_DirtyCardQ_lock,
-                        Mutex::_no_safepoint_check_flag);
-        for (; byte <= last_byte; byte++) {
-          if (*byte == g1_young_gen) {
-            continue;
-          }
-          if (*byte != dirty_card) {
-            *byte = dirty_card;
-            _dcqs.shared_dirty_card_queue()->enqueue(byte);
-          }
+        if (*byte != dirty_card) {
+          *byte = dirty_card;
+          jt->dirty_card_queue().enqueue(byte);
+        }
+      }
+    } else {
+      MutexLockerEx x(Shared_DirtyCardQ_lock,
+                      Mutex::_no_safepoint_check_flag);
+      for (; byte <= last_byte; byte++) {
+        if (*byte == g1_young_gen) {
+          continue;
+        }
+        if (*byte != dirty_card) {
+          *byte = dirty_card;
+          _dcqs.shared_dirty_card_queue()->enqueue(byte);
         }
       }
     }
--- a/hotspot/src/share/vm/gc/g1/g1SATBCardTableModRefBS.hpp	Thu Nov 24 11:27:57 2016 +0100
+++ b/hotspot/src/share/vm/gc/g1/g1SATBCardTableModRefBS.hpp	Thu Nov 24 16:48:22 2016 +0300
@@ -152,7 +152,7 @@
 
   // NB: if you do a whole-heap invalidation, the "usual invariant" defined
   // above no longer applies.
-  void invalidate(MemRegion mr, bool whole_heap = false);
+  void invalidate(MemRegion mr);
 
   void write_region_work(MemRegion mr)    { invalidate(mr); }
   void write_ref_array_work(MemRegion mr) { invalidate(mr); }
--- a/hotspot/src/share/vm/gc/shared/cardTableModRefBS.cpp	Thu Nov 24 11:27:57 2016 +0100
+++ b/hotspot/src/share/vm/gc/shared/cardTableModRefBS.cpp	Thu Nov 24 16:48:22 2016 +0300
@@ -380,7 +380,7 @@
   }
 }
 
-void CardTableModRefBS::invalidate(MemRegion mr, bool whole_heap) {
+void CardTableModRefBS::invalidate(MemRegion mr) {
   assert((HeapWord*)align_size_down((uintptr_t)mr.start(), HeapWordSize) == mr.start(), "Unaligned start");
   assert((HeapWord*)align_size_up  ((uintptr_t)mr.end(),   HeapWordSize) == mr.end(),   "Unaligned end"  );
   for (int i = 0; i < _cur_covered_regions; i++) {
--- a/hotspot/src/share/vm/gc/shared/cardTableModRefBS.hpp	Thu Nov 24 11:27:57 2016 +0100
+++ b/hotspot/src/share/vm/gc/shared/cardTableModRefBS.hpp	Thu Nov 24 16:48:22 2016 +0300
@@ -260,7 +260,7 @@
   }
 
   // ModRefBS functions.
-  virtual void invalidate(MemRegion mr, bool whole_heap = false);
+  virtual void invalidate(MemRegion mr);
   void clear(MemRegion mr);
   void dirty(MemRegion mr);
 
--- a/hotspot/src/share/vm/gc/shared/cardTableRS.hpp	Thu Nov 24 11:27:57 2016 +0100
+++ b/hotspot/src/share/vm/gc/shared/cardTableRS.hpp	Thu Nov 24 16:48:22 2016 +0300
@@ -159,8 +159,8 @@
   void clear(MemRegion mr) { _ct_bs->clear(mr); }
   void clear_into_younger(Generation* old_gen);
 
-  void invalidate(MemRegion mr, bool whole_heap = false) {
-    _ct_bs->invalidate(mr, whole_heap);
+  void invalidate(MemRegion mr) {
+    _ct_bs->invalidate(mr);
   }
   void invalidate_or_clear(Generation* old_gen);
 
--- a/hotspot/src/share/vm/gc/shared/modRefBarrierSet.hpp	Thu Nov 24 11:27:57 2016 +0100
+++ b/hotspot/src/share/vm/gc/shared/modRefBarrierSet.hpp	Thu Nov 24 16:48:22 2016 +0300
@@ -86,10 +86,8 @@
     assert(false, "can't call");
   }
 
-  // Causes all refs in "mr" to be assumed to be modified.  If "whole_heap"
-  // is true, the caller asserts that the entire heap is being invalidated,
-  // which may admit an optimized implementation for some barriers.
-  virtual void invalidate(MemRegion mr, bool whole_heap = false) = 0;
+  // Causes all refs in "mr" to be assumed to be modified.
+  virtual void invalidate(MemRegion mr) = 0;
 
   // The caller guarantees that "mr" contains no references.  (Perhaps it's
   // objects have been moved elsewhere.)