< prev index next >

src/hotspot/share/gc/cms/cmsCardTable.cpp

Print this page

        

@@ -21,10 +21,11 @@
  * questions.
  *
  */
 
 #include "precompiled.hpp"
+#include "gc/cms/cmsCardTable.hpp"
 #include "gc/cms/cmsHeap.hpp"
 #include "gc/shared/cardTableBarrierSet.hpp"
 #include "gc/shared/cardTableRS.hpp"
 #include "gc/shared/collectedHeap.hpp"
 #include "gc/shared/space.inline.hpp"

@@ -34,11 +35,28 @@
 #include "runtime/java.hpp"
 #include "runtime/mutexLocker.hpp"
 #include "runtime/orderAccess.inline.hpp"
 #include "runtime/vmThread.hpp"
 
-void CardTableRS::
+CMSCardTable::CMSCardTable(MemRegion whole_heap) :
+    CardTableRS(whole_heap, CMSPrecleaningEnabled /* scanned_concurrently */) {
+}
+
+// Returns the number of chunks necessary to cover "mr".
+size_t CMSCardTable::chunks_to_cover(MemRegion mr) {
+  return (size_t)(addr_to_chunk_index(mr.last()) -
+                  addr_to_chunk_index(mr.start()) + 1);
+}
+
+// Returns the index of the chunk in a stride which
+// covers the given address.
+uintptr_t CMSCardTable::addr_to_chunk_index(const void* addr) {
+  uintptr_t card = (uintptr_t) byte_for(addr);
+  return card / ParGCCardsPerStrideChunk;
+}
+
+void CMSCardTable::
 non_clean_card_iterate_parallel_work(Space* sp, MemRegion mr,
                                      OopsInGenClosure* cl,
                                      CardTableRS* ct,
                                      uint n_threads) {
   assert(n_threads > 0, "expected n_threads > 0");

@@ -80,11 +98,11 @@
     }
   }
 }
 
 void
-CardTableRS::
+CMSCardTable::
 process_stride(Space* sp,
                MemRegion used,
                jint stride, int n_strides,
                OopsInGenClosure* cl,
                CardTableRS* ct,

@@ -160,11 +178,11 @@
     chunk_card_start += ParGCCardsPerStrideChunk * n_strides;
   }
 }
 
 void
-CardTableRS::
+CMSCardTable::
 process_chunk_boundaries(Space* sp,
                          DirtyCardToOopClosure* dcto_cl,
                          MemRegion chunk_mr,
                          MemRegion used,
                          jbyte** lowest_non_clean,

@@ -369,11 +387,11 @@
   dcto_cl->set_last_bottom(max_to_do);
 #endif
 }
 
 void
-CardTableRS::
+CMSCardTable::
 get_LNC_array_for_space(Space* sp,
                         jbyte**& lowest_non_clean,
                         uintptr_t& lowest_non_clean_base_chunk_index,
                         size_t& lowest_non_clean_chunk_size) {
 

@@ -428,5 +446,28 @@
   // In any case, now do the initialization.
   lowest_non_clean                  = _lowest_non_clean[i];
   lowest_non_clean_base_chunk_index = _lowest_non_clean_base_chunk_index[i];
   lowest_non_clean_chunk_size       = _lowest_non_clean_chunk_size[i];
 }
+
+#ifdef ASSERT
+void CMSCardTable::verify_used_region_at_save_marks(Space* sp) const {
+  MemRegion ur    = sp->used_region();
+  MemRegion urasm = sp->used_region_at_save_marks();
+
+  if (!ur.contains(urasm)) {
+    log_warning(gc)("CMS+ParNew: Did you forget to call save_marks()? "
+                    "[" PTR_FORMAT ", " PTR_FORMAT ") is not contained in "
+                    "[" PTR_FORMAT ", " PTR_FORMAT ")",
+                    p2i(urasm.start()), p2i(urasm.end()), p2i(ur.start()), p2i(ur.end()));
+    MemRegion ur2 = sp->used_region();
+    MemRegion urasm2 = sp->used_region_at_save_marks();
+    if (!ur.equals(ur2)) {
+      log_warning(gc)("CMS+ParNew: Flickering used_region()!!");
+    }
+    if (!urasm.equals(urasm2)) {
+      log_warning(gc)("CMS+ParNew: Flickering used_region_at_save_marks()!!");
+    }
+    ShouldNotReachHere();
+  }
+}
+#endif // ASSERT
< prev index next >