< prev index next >

src/hotspot/share/gc/g1/g1HotCardCache.hpp

Print this page
rev 57124 : imported patch 8227739-merge-scan-rs-update-rs-cost
rev 57126 : [mq]: 8227739-kbarrett-review

@@ -79,10 +79,15 @@
 
   volatile size_t _hot_cache_par_claimed_idx;
 
   char _pad_after[DEFAULT_CACHE_LINE_SIZE];
 
+  // Records whether insertion overflowed the hot card cache at least once. This
+  // avoids the need for a separate atomic counter of how many valid entries are
+  // in the HCC.
+  volatile bool _cache_wrapped_around;
+
   // The number of cached cards a thread claims when flushing the cache
   static const int ClaimChunkSize = 32;
 
  public:
   static bool default_use_cache() {

@@ -130,16 +135,21 @@
   }
 
   // Zeros the values in the card counts table for the given region
   void reset_card_counts(HeapRegion* hr);
 
+  // Number of entries in the HCC.
+  size_t num_entries() const {
+    return _cache_wrapped_around ? _hot_cache_size : _hot_cache_idx + 1;
+  }
  private:
   void reset_hot_cache_internal() {
     assert(_hot_cache != NULL, "Logic");
     _hot_cache_idx = 0;
     for (size_t i = 0; i < _hot_cache_size; i++) {
       _hot_cache[i] = NULL;
     }
+    _cache_wrapped_around = false;
   }
 };
 
 #endif // SHARE_GC_G1_G1HOTCARDCACHE_HPP
< prev index next >