83 entry->set_literal(obj); 84 return entry; 85 } 86 87 // Check to see if the hashtable is unbalanced. The caller set a flag to 88 // rehash at the next safepoint. If this bucket is 60 times greater than the 89 // expected average bucket length, it's an unbalanced hashtable. 90 // This is somewhat an arbitrary heuristic but if one bucket gets to 91 // rehash_count which is currently 100, there's probably something wrong. 92 93 template <class T, MEMFLAGS F> bool RehashableHashtable<T, F>::check_rehash_table(int count) { 94 assert(this->table_size() != 0, "underflow"); 95 if (count > (((double)this->number_of_entries()/(double)this->table_size())*rehash_multiple)) { 96 // Set a flag for the next safepoint, which should be at some guaranteed 97 // safepoint interval. 98 return true; 99 } 100 return false; 101 } 102 103 template <class T, MEMFLAGS F> juint RehashableHashtable<T, F>::_seed = 0; 104 105 // Create a new table and using alternate hash code, populate the new table 106 // with the existing elements. This can be used to change the hash code 107 // and could in the future change the size of the table. 108 109 template <class T, MEMFLAGS F> void RehashableHashtable<T, F>::move_to(RehashableHashtable<T, F>* new_table) { 110 111 // Initialize the global seed for hashing. 112 _seed = AltHashing::compute_seed(); 113 assert(seed() != 0, "shouldn't be zero"); 114 115 int saved_entry_count = this->number_of_entries(); 116 117 // Iterate through the table and create a new entry for the new table 118 for (int i = 0; i < new_table->table_size(); ++i) { 119 for (HashtableEntry<T, F>* p = this->bucket(i); p != NULL; ) { 120 HashtableEntry<T, F>* next = p->next(); 121 T string = p->literal(); 122 // Use alternate hashing algorithm on the symbol in the first table 123 unsigned int hashValue = string->new_hash(seed()); 124 // Get a new index relative to the new table (can also change size) | 83 entry->set_literal(obj); 84 return entry; 85 } 86 87 // Check to see if the hashtable is unbalanced. The caller set a flag to 88 // rehash at the next safepoint. If this bucket is 60 times greater than the 89 // expected average bucket length, it's an unbalanced hashtable. 90 // This is somewhat an arbitrary heuristic but if one bucket gets to 91 // rehash_count which is currently 100, there's probably something wrong. 92 93 template <class T, MEMFLAGS F> bool RehashableHashtable<T, F>::check_rehash_table(int count) { 94 assert(this->table_size() != 0, "underflow"); 95 if (count > (((double)this->number_of_entries()/(double)this->table_size())*rehash_multiple)) { 96 // Set a flag for the next safepoint, which should be at some guaranteed 97 // safepoint interval. 98 return true; 99 } 100 return false; 101 } 102 103 // Create a new table and using alternate hash code, populate the new table 104 // with the existing elements. This can be used to change the hash code 105 // and could in the future change the size of the table. 106 107 template <class T, MEMFLAGS F> void RehashableHashtable<T, F>::move_to(RehashableHashtable<T, F>* new_table) { 108 109 // Initialize the global seed for hashing. 110 _seed = AltHashing::compute_seed(); 111 assert(seed() != 0, "shouldn't be zero"); 112 113 int saved_entry_count = this->number_of_entries(); 114 115 // Iterate through the table and create a new entry for the new table 116 for (int i = 0; i < new_table->table_size(); ++i) { 117 for (HashtableEntry<T, F>* p = this->bucket(i); p != NULL; ) { 118 HashtableEntry<T, F>* next = p->next(); 119 T string = p->literal(); 120 // Use alternate hashing algorithm on the symbol in the first table 121 unsigned int hashValue = string->new_hash(seed()); 122 // Get a new index relative to the new table (can also change size) |