22 * |
22 * |
23 */ |
23 */ |
24 |
24 |
25 #include "precompiled.hpp" |
25 #include "precompiled.hpp" |
26 #include "memory/allocation.inline.hpp" |
26 #include "memory/allocation.inline.hpp" |
|
27 #include "memory/filemap.hpp" |
27 #include "memory/resourceArea.hpp" |
28 #include "memory/resourceArea.hpp" |
28 #include "oops/oop.inline.hpp" |
29 #include "oops/oop.inline.hpp" |
29 #include "runtime/safepoint.hpp" |
30 #include "runtime/safepoint.hpp" |
30 #include "utilities/dtrace.hpp" |
31 #include "utilities/dtrace.hpp" |
31 #include "utilities/hashtable.hpp" |
32 #include "utilities/hashtable.hpp" |
117 // Use alternate hashing algorithm on the symbol in the first table |
118 // Use alternate hashing algorithm on the symbol in the first table |
118 unsigned int hashValue = new_hash(string); |
119 unsigned int hashValue = new_hash(string); |
119 // Get a new index relative to the new table (can also change size) |
120 // Get a new index relative to the new table (can also change size) |
120 int index = new_table->hash_to_index(hashValue); |
121 int index = new_table->hash_to_index(hashValue); |
121 p->set_hash(hashValue); |
122 p->set_hash(hashValue); |
|
123 // Keep the shared bit in the Hashtable entry to indicate that this entry |
|
124 // can't be deleted. The shared bit is the LSB in the _next field so |
|
125 // walking the hashtable past these entries requires |
|
126 // BasicHashtableEntry::make_ptr() call. |
|
127 bool keep_shared = p->is_shared(); |
122 unlink_entry(p); |
128 unlink_entry(p); |
123 new_table->add_entry(index, p); |
129 new_table->add_entry(index, p); |
|
130 if (keep_shared) { |
|
131 p->set_shared(); |
|
132 } |
124 p = next; |
133 p = next; |
125 } |
134 } |
126 } |
135 } |
127 // give the new table the free list as well |
136 // give the new table the free list as well |
128 new_table->copy_freelist(this); |
137 new_table->copy_freelist(this); |
132 // for the elements has been used in a new table and is not |
141 // for the elements has been used in a new table and is not |
133 // destroyed. The memory reuse will benefit resizing the SystemDictionary |
142 // destroyed. The memory reuse will benefit resizing the SystemDictionary |
134 // to avoid a memory allocation spike at safepoint. |
143 // to avoid a memory allocation spike at safepoint. |
135 free_buckets(); |
144 free_buckets(); |
136 } |
145 } |
|
146 |
|
147 void BasicHashtable::free_buckets() { |
|
148 if (NULL != _buckets) { |
|
149 // Don't delete the buckets in the shared space. They aren't |
|
150 // allocated by os::malloc |
|
151 if (!UseSharedSpaces || |
|
152 !FileMapInfo::current_info()->is_in_shared_space(_buckets)) { |
|
153 FREE_C_HEAP_ARRAY(HashtableBucket, _buckets); |
|
154 } |
|
155 _buckets = NULL; |
|
156 } |
|
157 } |
|
158 |
137 |
159 |
138 // Reverse the order of elements in the hash buckets. |
160 // Reverse the order of elements in the hash buckets. |
139 |
161 |
140 void BasicHashtable::reverse() { |
162 void BasicHashtable::reverse() { |
141 |
163 |