135 // Declares the entry "fi" to be free. (It must have already been
136 // deleted from any bucket lists.
137 void free_entry(int fi);
138
139 public:
140 RSHashTable(size_t capacity);
141 ~RSHashTable();
142
143 static const int NullEntry = -1;
144
145 bool should_expand() const { return _occupied_entries == _num_entries; }
146
147 // Attempts to ensure that the given card_index in the given region is in
148 // the sparse table. If successful (because the card was already
149 // present, or because it was successfully added) returns "true".
150 // Otherwise, returns "false" to indicate that the addition would
151 // overflow the entry for the region. The caller must transfer these
152 // entries to a larger-capacity representation.
153 bool add_card(RegionIdx_t region_id, CardIdx_t card_index);
154
155 bool get_cards(RegionIdx_t region_id, CardIdx_t* cards);
156
157 bool delete_entry(RegionIdx_t region_id);
158
159 bool contains_card(RegionIdx_t region_id, CardIdx_t card_index) const;
160
161 void add_entry(SparsePRTEntry* e);
162
163 SparsePRTEntry* get_entry(RegionIdx_t region_id) const;
164
165 void clear();
166
167 size_t capacity() const { return _capacity; }
168 size_t capacity_mask() const { return _capacity_mask; }
169 size_t occupied_entries() const { return _occupied_entries; }
170 size_t occupied_cards() const { return _occupied_cards; }
171 size_t mem_size() const;
172 // The number of SparsePRTEntry instances available.
173 size_t num_entries() const { return _num_entries; }
174
175 SparsePRTEntry* entry(int i) const {
176 assert(i >= 0 && (size_t)i < _num_entries, "precondition");
242 bool add_card(RegionIdx_t region_id, CardIdx_t card_index);
243
244 // Return the pointer to the entry associated with the given region.
245 SparsePRTEntry* get_entry(RegionIdx_t region_ind);
246
247 // If there is an entry for "region_ind", removes it and return "true";
248 // otherwise returns "false."
249 bool delete_entry(RegionIdx_t region_ind);
250
251 // Clear the table, and reinitialize to initial capacity.
252 void clear();
253
254 bool contains_card(RegionIdx_t region_id, CardIdx_t card_index) const {
255 return _table->contains_card(region_id, card_index);
256 }
257 };
258
259 class SparsePRTIter: public RSHashTableIter {
260 public:
261 SparsePRTIter(const SparsePRT* sprt) :
262 RSHashTableIter(sprt->_table) {}
263
264 bool has_next(size_t& card_index) {
265 return RSHashTableIter::has_next(card_index);
266 }
267 };
268
269 #endif // SHARE_VM_GC_G1_SPARSEPRT_HPP
|
135 // Declares the entry "fi" to be free. (It must have already been
136 // deleted from any bucket lists.
137 void free_entry(int fi);
138
139 public:
140 RSHashTable(size_t capacity);
141 ~RSHashTable();
142
143 static const int NullEntry = -1;
144
145 bool should_expand() const { return _occupied_entries == _num_entries; }
146
147 // Attempts to ensure that the given card_index in the given region is in
148 // the sparse table. If successful (because the card was already
149 // present, or because it was successfully added) returns "true".
150 // Otherwise, returns "false" to indicate that the addition would
151 // overflow the entry for the region. The caller must transfer these
152 // entries to a larger-capacity representation.
153 bool add_card(RegionIdx_t region_id, CardIdx_t card_index);
154
155 bool delete_entry(RegionIdx_t region_id);
156
157 bool contains_card(RegionIdx_t region_id, CardIdx_t card_index) const;
158
159 void add_entry(SparsePRTEntry* e);
160
161 SparsePRTEntry* get_entry(RegionIdx_t region_id) const;
162
163 void clear();
164
165 size_t capacity() const { return _capacity; }
166 size_t capacity_mask() const { return _capacity_mask; }
167 size_t occupied_entries() const { return _occupied_entries; }
168 size_t occupied_cards() const { return _occupied_cards; }
169 size_t mem_size() const;
170 // The number of SparsePRTEntry instances available.
171 size_t num_entries() const { return _num_entries; }
172
173 SparsePRTEntry* entry(int i) const {
174 assert(i >= 0 && (size_t)i < _num_entries, "precondition");
240 bool add_card(RegionIdx_t region_id, CardIdx_t card_index);
241
242 // Return the pointer to the entry associated with the given region.
243 SparsePRTEntry* get_entry(RegionIdx_t region_ind);
244
245 // If there is an entry for "region_ind", removes it and return "true";
246 // otherwise returns "false."
247 bool delete_entry(RegionIdx_t region_ind);
248
249 // Clear the table, and reinitialize to initial capacity.
250 void clear();
251
252 bool contains_card(RegionIdx_t region_id, CardIdx_t card_index) const {
253 return _table->contains_card(region_id, card_index);
254 }
255 };
256
257 class SparsePRTIter: public RSHashTableIter {
258 public:
259 SparsePRTIter(const SparsePRT* sprt) :
260 RSHashTableIter(sprt->_table) { }
261
262 bool has_next(size_t& card_index) {
263 return RSHashTableIter::has_next(card_index);
264 }
265 };
266
267 #endif // SHARE_VM_GC_G1_SPARSEPRT_HPP
|