220 BasicHashtableEntry<F>* _removed_tail;
221
222 BucketUnlinkContext() : _num_processed(0), _num_removed(0), _removed_head(NULL), _removed_tail(NULL) {
223 }
224
225 void free_entry(BasicHashtableEntry<F>* entry);
226 };
227 // Add of bucket entries linked together in the given context to the global free list. This method
228 // is mt-safe wrt. to other calls of this method.
229 void bulk_free_entries(BucketUnlinkContext* context);
230 public:
231 int table_size() const { return _table_size; }
232 void set_entry(int index, BasicHashtableEntry<F>* entry);
233
234 void add_entry(int index, BasicHashtableEntry<F>* entry);
235
236 void free_entry(BasicHashtableEntry<F>* entry);
237
238 int number_of_entries() const { return _number_of_entries; }
239
240 template <class T> void verify_table(const char* table_name) PRODUCT_RETURN;
241 };
242
243
244 template <class T, MEMFLAGS F> class Hashtable : public BasicHashtable<F> {
245 friend class VMStructs;
246
247 public:
248 Hashtable(int table_size, int entry_size)
249 : BasicHashtable<F>(table_size, entry_size) { }
250
251 Hashtable(int table_size, int entry_size,
252 HashtableBucket<F>* buckets, int number_of_entries)
253 : BasicHashtable<F>(table_size, entry_size, buckets, number_of_entries) { }
254
255 // Debugging
256 void print() PRODUCT_RETURN;
257
258 unsigned int compute_hash(const Symbol* name) const {
259 return (unsigned int) name->identity_hash();
264 }
265
266 void print_table_statistics(outputStream* st, const char *table_name);
267
268 protected:
269
270 // Table entry management
271 HashtableEntry<T, F>* new_entry(unsigned int hashValue, T obj);
272 // Don't create and use freelist of HashtableEntry.
273 HashtableEntry<T, F>* allocate_new_entry(unsigned int hashValue, T obj);
274
275 // The following method is MT-safe and may be used with caution.
276 HashtableEntry<T, F>* bucket(int i) const {
277 return (HashtableEntry<T, F>*)BasicHashtable<F>::bucket(i);
278 }
279
280 // The following method is not MT-safe and must be done under lock.
281 HashtableEntry<T, F>** bucket_addr(int i) {
282 return (HashtableEntry<T, F>**)BasicHashtable<F>::bucket_addr(i);
283 }
284
285 };
286
287 template <class T, MEMFLAGS F> class RehashableHashtable : public Hashtable<T, F> {
288 friend class VMStructs;
289 protected:
290
291 enum {
292 rehash_count = 100,
293 rehash_multiple = 60
294 };
295
296 // Check that the table is unbalanced
297 bool check_rehash_table(int count);
298
299 public:
300 RehashableHashtable(int table_size, int entry_size)
301 : Hashtable<T, F>(table_size, entry_size) { }
302
303 RehashableHashtable(int table_size, int entry_size,
304 HashtableBucket<F>* buckets, int number_of_entries)
|
220 BasicHashtableEntry<F>* _removed_tail;
221
222 BucketUnlinkContext() : _num_processed(0), _num_removed(0), _removed_head(NULL), _removed_tail(NULL) {
223 }
224
225 void free_entry(BasicHashtableEntry<F>* entry);
226 };
227 // Add of bucket entries linked together in the given context to the global free list. This method
228 // is mt-safe wrt. to other calls of this method.
229 void bulk_free_entries(BucketUnlinkContext* context);
230 public:
231 int table_size() const { return _table_size; }
232 void set_entry(int index, BasicHashtableEntry<F>* entry);
233
234 void add_entry(int index, BasicHashtableEntry<F>* entry);
235
236 void free_entry(BasicHashtableEntry<F>* entry);
237
238 int number_of_entries() const { return _number_of_entries; }
239
240 bool resize(int new_size);
241
242 template <class T> void verify_table(const char* table_name) PRODUCT_RETURN;
243 };
244
245
246 template <class T, MEMFLAGS F> class Hashtable : public BasicHashtable<F> {
247 friend class VMStructs;
248
249 public:
250 Hashtable(int table_size, int entry_size)
251 : BasicHashtable<F>(table_size, entry_size) { }
252
253 Hashtable(int table_size, int entry_size,
254 HashtableBucket<F>* buckets, int number_of_entries)
255 : BasicHashtable<F>(table_size, entry_size, buckets, number_of_entries) { }
256
257 // Debugging
258 void print() PRODUCT_RETURN;
259
260 unsigned int compute_hash(const Symbol* name) const {
261 return (unsigned int) name->identity_hash();
266 }
267
268 void print_table_statistics(outputStream* st, const char *table_name);
269
270 protected:
271
272 // Table entry management
273 HashtableEntry<T, F>* new_entry(unsigned int hashValue, T obj);
274 // Don't create and use freelist of HashtableEntry.
275 HashtableEntry<T, F>* allocate_new_entry(unsigned int hashValue, T obj);
276
277 // The following method is MT-safe and may be used with caution.
278 HashtableEntry<T, F>* bucket(int i) const {
279 return (HashtableEntry<T, F>*)BasicHashtable<F>::bucket(i);
280 }
281
282 // The following method is not MT-safe and must be done under lock.
283 HashtableEntry<T, F>** bucket_addr(int i) {
284 return (HashtableEntry<T, F>**)BasicHashtable<F>::bucket_addr(i);
285 }
286 };
287
288 template <class T, MEMFLAGS F> class RehashableHashtable : public Hashtable<T, F> {
289 friend class VMStructs;
290 protected:
291
292 enum {
293 rehash_count = 100,
294 rehash_multiple = 60
295 };
296
297 // Check that the table is unbalanced
298 bool check_rehash_table(int count);
299
300 public:
301 RehashableHashtable(int table_size, int entry_size)
302 : Hashtable<T, F>(table_size, entry_size) { }
303
304 RehashableHashtable(int table_size, int entry_size,
305 HashtableBucket<F>* buckets, int number_of_entries)
|