Mercurial > hg > graal-compiler
diff 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 |
line wrap: on
line diff
--- a/src/share/vm/utilities/hashtable.hpp Mon Jun 11 13:10:14 2012 -0400 +++ b/src/share/vm/utilities/hashtable.hpp Wed Jun 13 19:52:59 2012 -0400 @@ -159,8 +159,6 @@ // Reverse the order of elements in each of the buckets. void reverse(); - static unsigned int hash_symbol(const char* s, int len); - private: // Instance variables int _table_size; @@ -179,6 +177,11 @@ void verify_lookup_length(double load); #endif + enum { + rehash_count = 100, + rehash_multiple = 60 + }; + void initialize(int table_size, int entry_size, int number_of_entries); // Accessor @@ -193,6 +196,34 @@ // Table entry management BasicHashtableEntry* new_entry(unsigned int hashValue); + // Check that the table is unbalanced + bool check_rehash_table(int count); + + // Used when moving the entry to another table + // Clean up links, but do not add to free_list + void unlink_entry(BasicHashtableEntry* entry) { + entry->set_next(NULL); + --_number_of_entries; + } + + // Move over freelist and free block for allocation + void copy_freelist(BasicHashtable* src) { + _free_list = src->_free_list; + src->_free_list = NULL; + _first_free_entry = src->_first_free_entry; + src->_first_free_entry = NULL; + _end_block = src->_end_block; + src->_end_block = NULL; + } + + // Free the buckets in this hashtable + void free_buckets() { + if (NULL != _buckets) { + FREE_C_HEAP_ARRAY(HashtableBucket, _buckets); + _buckets = NULL; + } + } + public: int table_size() { return _table_size; } void set_entry(int index, BasicHashtableEntry* entry); @@ -249,6 +280,10 @@ HashtableEntry<T>** bucket_addr(int i) { return (HashtableEntry<T>**)BasicHashtable::bucket_addr(i); } + + // Function to move these elements into the new table. + void move_to(Hashtable<T>* new_table); + virtual unsigned int new_hash(T) { ShouldNotReachHere(); return 0; } // should be overridden };