1 /* |
1 /* |
2 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
170 } |
170 } |
171 *bucket_addr(i) = new_list; |
171 *bucket_addr(i) = new_list; |
172 } |
172 } |
173 } |
173 } |
174 |
174 |
|
175 template <MEMFLAGS F> void BasicHashtable<F>::BucketUnlinkContext::free_entry(BasicHashtableEntry<F>* entry) { |
|
176 entry->set_next(_removed_head); |
|
177 _removed_head = entry; |
|
178 if (_removed_tail == NULL) { |
|
179 _removed_tail = entry; |
|
180 } |
|
181 _num_removed++; |
|
182 } |
|
183 |
|
184 template <MEMFLAGS F> void BasicHashtable<F>::bulk_free_entries(BucketUnlinkContext* context) { |
|
185 if (context->_num_removed == 0) { |
|
186 assert(context->_removed_head == NULL && context->_removed_tail == NULL, |
|
187 err_msg("Zero entries in the unlink context, but elements linked from " PTR_FORMAT " to " PTR_FORMAT, |
|
188 p2i(context->_removed_head), p2i(context->_removed_tail))); |
|
189 return; |
|
190 } |
|
191 |
|
192 // MT-safe add of the list of BasicHashTableEntrys from the context to the free list. |
|
193 BasicHashtableEntry<F>* current = _free_list; |
|
194 while (true) { |
|
195 context->_removed_tail->set_next(current); |
|
196 BasicHashtableEntry<F>* old = (BasicHashtableEntry<F>*)Atomic::cmpxchg_ptr(context->_removed_head, &_free_list, current); |
|
197 if (old == current) { |
|
198 break; |
|
199 } |
|
200 current = old; |
|
201 } |
|
202 Atomic::add(-context->_num_removed, &_number_of_entries); |
|
203 } |
175 |
204 |
176 // Copy the table to the shared space. |
205 // Copy the table to the shared space. |
177 |
206 |
178 template <MEMFLAGS F> void BasicHashtable<F>::copy_table(char** top, char* end) { |
207 template <MEMFLAGS F> void BasicHashtable<F>::copy_table(char** top, char* end) { |
179 |
208 |