173 entry->set_next(_removed_head);
174 _removed_head = entry;
175 if (_removed_tail == NULL) {
176 _removed_tail = entry;
177 }
178 _num_removed++;
179 }
180
181 template <MEMFLAGS F> void BasicHashtable<F>::bulk_free_entries(BucketUnlinkContext* context) {
182 if (context->_num_removed == 0) {
183 assert(context->_removed_head == NULL && context->_removed_tail == NULL,
184 "Zero entries in the unlink context, but elements linked from " PTR_FORMAT " to " PTR_FORMAT,
185 p2i(context->_removed_head), p2i(context->_removed_tail));
186 return;
187 }
188
189 // MT-safe add of the list of BasicHashTableEntrys from the context to the free list.
190 BasicHashtableEntry<F>* current = _free_list;
191 while (true) {
192 context->_removed_tail->set_next(current);
193 BasicHashtableEntry<F>* old = (BasicHashtableEntry<F>*)Atomic::cmpxchg_ptr(context->_removed_head, &_free_list, current);
194 if (old == current) {
195 break;
196 }
197 current = old;
198 }
199 Atomic::add(-context->_num_removed, &_number_of_entries);
200 }
201 // Copy the table to the shared space.
202 template <MEMFLAGS F> size_t BasicHashtable<F>::count_bytes_for_table() {
203 size_t bytes = 0;
204 bytes += sizeof(intptr_t); // len
205
206 for (int i = 0; i < _table_size; ++i) {
207 for (BasicHashtableEntry<F>** p = _buckets[i].entry_addr();
208 *p != NULL;
209 p = (*p)->next_addr()) {
210 bytes += entry_size();
211 }
212 }
213
|
173 entry->set_next(_removed_head);
174 _removed_head = entry;
175 if (_removed_tail == NULL) {
176 _removed_tail = entry;
177 }
178 _num_removed++;
179 }
180
181 template <MEMFLAGS F> void BasicHashtable<F>::bulk_free_entries(BucketUnlinkContext* context) {
182 if (context->_num_removed == 0) {
183 assert(context->_removed_head == NULL && context->_removed_tail == NULL,
184 "Zero entries in the unlink context, but elements linked from " PTR_FORMAT " to " PTR_FORMAT,
185 p2i(context->_removed_head), p2i(context->_removed_tail));
186 return;
187 }
188
189 // MT-safe add of the list of BasicHashTableEntrys from the context to the free list.
190 BasicHashtableEntry<F>* current = _free_list;
191 while (true) {
192 context->_removed_tail->set_next(current);
193 BasicHashtableEntry<F>* old = Atomic::cmpxchg(context->_removed_head, &_free_list, current);
194 if (old == current) {
195 break;
196 }
197 current = old;
198 }
199 Atomic::add(-context->_num_removed, &_number_of_entries);
200 }
201 // Copy the table to the shared space.
202 template <MEMFLAGS F> size_t BasicHashtable<F>::count_bytes_for_table() {
203 size_t bytes = 0;
204 bytes += sizeof(intptr_t); // len
205
206 for (int i = 0; i < _table_size; ++i) {
207 for (BasicHashtableEntry<F>** p = _buckets[i].entry_addr();
208 *p != NULL;
209 p = (*p)->next_addr()) {
210 bytes += entry_size();
211 }
212 }
213
|