79 |
79 |
80 volatile size_t _hot_cache_par_claimed_idx; |
80 volatile size_t _hot_cache_par_claimed_idx; |
81 |
81 |
82 char _pad_after[DEFAULT_CACHE_LINE_SIZE]; |
82 char _pad_after[DEFAULT_CACHE_LINE_SIZE]; |
83 |
83 |
|
84 // Records whether insertion overflowed the hot card cache at least once. This |
|
85 // avoids the need for a separate atomic counter of how many valid entries are |
|
86 // in the HCC. |
|
87 volatile bool _cache_wrapped_around; |
|
88 |
84 // The number of cached cards a thread claims when flushing the cache |
89 // The number of cached cards a thread claims when flushing the cache |
85 static const int ClaimChunkSize = 32; |
90 static const int ClaimChunkSize = 32; |
86 |
91 |
87 public: |
92 public: |
88 static bool default_use_cache() { |
93 static bool default_use_cache() { |
123 // Resets the hot card cache and discards the entries. |
128 // Resets the hot card cache and discards the entries. |
124 void reset_hot_cache() { |
129 void reset_hot_cache() { |
125 assert(SafepointSynchronize::is_at_safepoint(), "Should be at a safepoint"); |
130 assert(SafepointSynchronize::is_at_safepoint(), "Should be at a safepoint"); |
126 assert(Thread::current()->is_VM_thread(), "Current thread should be the VMthread"); |
131 assert(Thread::current()->is_VM_thread(), "Current thread should be the VMthread"); |
127 if (default_use_cache()) { |
132 if (default_use_cache()) { |
128 reset_hot_cache_internal(); |
133 reset_hot_cache_internal(); |
129 } |
134 } |
130 } |
135 } |
131 |
136 |
132 // Zeros the values in the card counts table for the given region |
137 // Zeros the values in the card counts table for the given region |
133 void reset_card_counts(HeapRegion* hr); |
138 void reset_card_counts(HeapRegion* hr); |
134 |
139 |
|
140 // Number of entries in the HCC. |
|
141 size_t num_entries() const { |
|
142 return _cache_wrapped_around ? _hot_cache_size : _hot_cache_idx + 1; |
|
143 } |
135 private: |
144 private: |
136 void reset_hot_cache_internal() { |
145 void reset_hot_cache_internal() { |
137 assert(_hot_cache != NULL, "Logic"); |
146 assert(_hot_cache != NULL, "Logic"); |
138 _hot_cache_idx = 0; |
147 _hot_cache_idx = 0; |
139 for (size_t i = 0; i < _hot_cache_size; i++) { |
148 for (size_t i = 0; i < _hot_cache_size; i++) { |
140 _hot_cache[i] = NULL; |
149 _hot_cache[i] = NULL; |
141 } |
150 } |
|
151 _cache_wrapped_around = false; |
142 } |
152 } |
143 }; |
153 }; |
144 |
154 |
145 #endif // SHARE_GC_G1_G1HOTCARDCACHE_HPP |
155 #endif // SHARE_GC_G1_G1HOTCARDCACHE_HPP |