Mercurial > hg > graal-jvmci-8
comparison src/share/vm/utilities/hashtable.hpp @ 6162:e9140bf80b4a
7158800: Improve storage of symbol tables
Summary: Use an alternate version of hashing algorithm for symbol string tables and after a certain bucket size to improve performance
Reviewed-by: pbk, kamg, dlong, kvn, fparain
author | coleenp |
---|---|
date | Wed, 13 Jun 2012 19:52:59 -0400 |
parents | b2cd0ee8f778 |
children | 246d977b51f2 |
comparison
equal
deleted
inserted
replaced
6129:4d399f013e5a | 6162:e9140bf80b4a |
---|---|
156 return h; | 156 return h; |
157 } | 157 } |
158 | 158 |
159 // Reverse the order of elements in each of the buckets. | 159 // Reverse the order of elements in each of the buckets. |
160 void reverse(); | 160 void reverse(); |
161 | |
162 static unsigned int hash_symbol(const char* s, int len); | |
163 | 161 |
164 private: | 162 private: |
165 // Instance variables | 163 // Instance variables |
166 int _table_size; | 164 int _table_size; |
167 HashtableBucket* _buckets; | 165 HashtableBucket* _buckets; |
177 int _lookup_count; | 175 int _lookup_count; |
178 int _lookup_length; | 176 int _lookup_length; |
179 void verify_lookup_length(double load); | 177 void verify_lookup_length(double load); |
180 #endif | 178 #endif |
181 | 179 |
180 enum { | |
181 rehash_count = 100, | |
182 rehash_multiple = 60 | |
183 }; | |
184 | |
182 void initialize(int table_size, int entry_size, int number_of_entries); | 185 void initialize(int table_size, int entry_size, int number_of_entries); |
183 | 186 |
184 // Accessor | 187 // Accessor |
185 int entry_size() const { return _entry_size; } | 188 int entry_size() const { return _entry_size; } |
186 | 189 |
190 // The following method is not MT-safe and must be done under lock. | 193 // The following method is not MT-safe and must be done under lock. |
191 BasicHashtableEntry** bucket_addr(int i) { return _buckets[i].entry_addr(); } | 194 BasicHashtableEntry** bucket_addr(int i) { return _buckets[i].entry_addr(); } |
192 | 195 |
193 // Table entry management | 196 // Table entry management |
194 BasicHashtableEntry* new_entry(unsigned int hashValue); | 197 BasicHashtableEntry* new_entry(unsigned int hashValue); |
198 | |
199 // Check that the table is unbalanced | |
200 bool check_rehash_table(int count); | |
201 | |
202 // Used when moving the entry to another table | |
203 // Clean up links, but do not add to free_list | |
204 void unlink_entry(BasicHashtableEntry* entry) { | |
205 entry->set_next(NULL); | |
206 --_number_of_entries; | |
207 } | |
208 | |
209 // Move over freelist and free block for allocation | |
210 void copy_freelist(BasicHashtable* src) { | |
211 _free_list = src->_free_list; | |
212 src->_free_list = NULL; | |
213 _first_free_entry = src->_first_free_entry; | |
214 src->_first_free_entry = NULL; | |
215 _end_block = src->_end_block; | |
216 src->_end_block = NULL; | |
217 } | |
218 | |
219 // Free the buckets in this hashtable | |
220 void free_buckets() { | |
221 if (NULL != _buckets) { | |
222 FREE_C_HEAP_ARRAY(HashtableBucket, _buckets); | |
223 _buckets = NULL; | |
224 } | |
225 } | |
195 | 226 |
196 public: | 227 public: |
197 int table_size() { return _table_size; } | 228 int table_size() { return _table_size; } |
198 void set_entry(int index, BasicHashtableEntry* entry); | 229 void set_entry(int index, BasicHashtableEntry* entry); |
199 | 230 |
247 | 278 |
248 // The following method is not MT-safe and must be done under lock. | 279 // The following method is not MT-safe and must be done under lock. |
249 HashtableEntry<T>** bucket_addr(int i) { | 280 HashtableEntry<T>** bucket_addr(int i) { |
250 return (HashtableEntry<T>**)BasicHashtable::bucket_addr(i); | 281 return (HashtableEntry<T>**)BasicHashtable::bucket_addr(i); |
251 } | 282 } |
283 | |
284 // Function to move these elements into the new table. | |
285 void move_to(Hashtable<T>* new_table); | |
286 virtual unsigned int new_hash(T) { ShouldNotReachHere(); return 0; } // should be overridden | |
252 }; | 287 }; |
253 | 288 |
254 | 289 |
255 // Verions of hashtable where two handles are used to compute the index. | 290 // Verions of hashtable where two handles are used to compute the index. |
256 | 291 |