103 template <MEMFLAGS F> void BasicHashtable<F>::free_buckets() { |
103 template <MEMFLAGS F> void BasicHashtable<F>::free_buckets() { |
104 if (NULL != _buckets) { |
104 if (NULL != _buckets) { |
105 FREE_C_HEAP_ARRAY(HashtableBucket, _buckets); |
105 FREE_C_HEAP_ARRAY(HashtableBucket, _buckets); |
106 _buckets = NULL; |
106 _buckets = NULL; |
107 } |
107 } |
108 } |
|
109 |
|
110 template <MEMFLAGS F> void BasicHashtable<F>::BucketUnlinkContext::free_entry(BasicHashtableEntry<F>* entry) { |
|
111 entry->set_next(_removed_head); |
|
112 _removed_head = entry; |
|
113 if (_removed_tail == NULL) { |
|
114 _removed_tail = entry; |
|
115 } |
|
116 _num_removed++; |
|
117 } |
|
118 |
|
119 template <MEMFLAGS F> void BasicHashtable<F>::bulk_free_entries(BucketUnlinkContext* context) { |
|
120 if (context->_num_removed == 0) { |
|
121 assert(context->_removed_head == NULL && context->_removed_tail == NULL, |
|
122 "Zero entries in the unlink context, but elements linked from " PTR_FORMAT " to " PTR_FORMAT, |
|
123 p2i(context->_removed_head), p2i(context->_removed_tail)); |
|
124 return; |
|
125 } |
|
126 |
|
127 // MT-safe add of the list of BasicHashTableEntrys from the context to the free list. |
|
128 BasicHashtableEntry<F>* current = _free_list; |
|
129 while (true) { |
|
130 context->_removed_tail->set_next(current); |
|
131 BasicHashtableEntry<F>* old = Atomic::cmpxchg(context->_removed_head, &_free_list, current); |
|
132 if (old == current) { |
|
133 break; |
|
134 } |
|
135 current = old; |
|
136 } |
|
137 Atomic::add(-context->_num_removed, &_number_of_entries); |
|
138 } |
108 } |
139 |
109 |
140 // For oops and Strings the size of the literal is interesting. For other types, nobody cares. |
110 // For oops and Strings the size of the literal is interesting. For other types, nobody cares. |
141 static int literal_size(ConstantPool*) { return 0; } |
111 static int literal_size(ConstantPool*) { return 0; } |
142 static int literal_size(Klass*) { return 0; } |
112 static int literal_size(Klass*) { return 0; } |