214 _card_ind((SparsePRTEntry::cards_num() - 1)),
215 _rsht(rsht) {}
216
217 bool has_next(size_t& card_index);
218 };
219
220 // Concurrent access to a SparsePRT must be serialized by some external mutex.
221
222 class SparsePRTIter;
223 class SparsePRTCleanupTask;
224
225 class SparsePRT {
226 friend class SparsePRTCleanupTask;
227
228 // Iterations are done on the _cur hash table, since they only need to
229 // see entries visible at the start of a collection pause.
230 // All other operations are done using the _next hash table.
231 RSHashTable* _cur;
232 RSHashTable* _next;
233
234 HeapRegion* _hr;
235
236 enum SomeAdditionalPrivateConstants {
237 InitialCapacity = 16
238 };
239
240 void expand();
241
242 bool _expanded;
243
244 bool expanded() { return _expanded; }
245 void set_expanded(bool b) { _expanded = b; }
246
247 SparsePRT* _next_expanded;
248
249 SparsePRT* next_expanded() { return _next_expanded; }
250 void set_next_expanded(SparsePRT* nxt) { _next_expanded = nxt; }
251
252 bool should_be_on_expanded_list();
253
254 static SparsePRT* volatile _head_expanded_list;
255
256 public:
257 SparsePRT(HeapRegion* hr);
258
259 ~SparsePRT();
260
261 size_t occupied() const { return _next->occupied_cards(); }
262 size_t mem_size() const;
263
264 // Attempts to ensure that the given card_index in the given region is in
265 // the sparse table. If successful (because the card was already
266 // present, or because it was successfully added) returns "true".
267 // Otherwise, returns "false" to indicate that the addition would
268 // overflow the entry for the region. The caller must transfer these
269 // entries to a larger-capacity representation.
270 bool add_card(RegionIdx_t region_id, CardIdx_t card_index);
271
272 // Return the pointer to the entry associated with the given region.
273 SparsePRTEntry* get_entry(RegionIdx_t region_ind);
274
275 // If there is an entry for "region_ind", removes it and return "true";
276 // otherwise returns "false."
277 bool delete_entry(RegionIdx_t region_ind);
|
214 _card_ind((SparsePRTEntry::cards_num() - 1)),
215 _rsht(rsht) {}
216
217 bool has_next(size_t& card_index);
218 };
219
220 // Concurrent access to a SparsePRT must be serialized by some external mutex.
221
222 class SparsePRTIter;
223 class SparsePRTCleanupTask;
224
225 class SparsePRT {
226 friend class SparsePRTCleanupTask;
227
228 // Iterations are done on the _cur hash table, since they only need to
229 // see entries visible at the start of a collection pause.
230 // All other operations are done using the _next hash table.
231 RSHashTable* _cur;
232 RSHashTable* _next;
233
234 enum SomeAdditionalPrivateConstants {
235 InitialCapacity = 16
236 };
237
238 void expand();
239
240 bool _expanded;
241
242 bool expanded() { return _expanded; }
243 void set_expanded(bool b) { _expanded = b; }
244
245 SparsePRT* _next_expanded;
246
247 SparsePRT* next_expanded() { return _next_expanded; }
248 void set_next_expanded(SparsePRT* nxt) { _next_expanded = nxt; }
249
250 bool should_be_on_expanded_list();
251
252 static SparsePRT* volatile _head_expanded_list;
253
254 public:
255 SparsePRT();
256
257 ~SparsePRT();
258
259 size_t occupied() const { return _next->occupied_cards(); }
260 size_t mem_size() const;
261
262 // Attempts to ensure that the given card_index in the given region is in
263 // the sparse table. If successful (because the card was already
264 // present, or because it was successfully added) returns "true".
265 // Otherwise, returns "false" to indicate that the addition would
266 // overflow the entry for the region. The caller must transfer these
267 // entries to a larger-capacity representation.
268 bool add_card(RegionIdx_t region_id, CardIdx_t card_index);
269
270 // Return the pointer to the entry associated with the given region.
271 SparsePRTEntry* get_entry(RegionIdx_t region_ind);
272
273 // If there is an entry for "region_ind", removes it and return "true";
274 // otherwise returns "false."
275 bool delete_entry(RegionIdx_t region_ind);
|