< prev index next >

src/hotspot/share/classfile/symbolTable.cpp

Print this page




 195 
 196   the_table()->move_to(new_table);
 197 
 198   // Delete the table and buckets (entries are reused in new table).
 199   delete _the_table;
 200   // Don't check if we need rehashing until the table gets unbalanced again.
 201   // Then rehash with a new global seed.
 202   _needs_rehashing = false;
 203   _the_table = new_table;
 204 }
 205 
 206 // Lookup a symbol in a bucket.
 207 
 208 Symbol* SymbolTable::lookup_dynamic(int index, const char* name,
 209                                     int len, unsigned int hash) {
 210   int count = 0;
 211   for (HashtableEntry<Symbol*, mtSymbol>* e = bucket(index); e != NULL; e = e->next()) {
 212     count++;  // count all entries in this bucket, not just ones with same hash
 213     if (e->hash() == hash) {
 214       Symbol* sym = e->literal();
 215       if (sym->equals(name, len)) {
 216         // something is referencing this symbol now.
 217         sym->increment_refcount();
 218         return sym;
 219       }
 220     }
 221   }
 222   // If the bucket size is too deep check if this hash code is insufficient.
 223   if (count >= rehash_count && !needs_rehashing()) {
 224     _needs_rehashing = check_rehash_table(count);
 225   }
 226   return NULL;
 227 }
 228 
 229 Symbol* SymbolTable::lookup_shared(const char* name,
 230                                    int len, unsigned int hash) {
 231   if (use_alternate_hashcode()) {
 232     // hash_code parameter may use alternate hashing algorithm but the shared table
 233     // always uses the same original hash code.
 234     hash = hash_shared_symbol(name, len);
 235   }
 236   return _shared_table.lookup(name, hash, len);
 237 }




 195 
 196   the_table()->move_to(new_table);
 197 
 198   // Delete the table and buckets (entries are reused in new table).
 199   delete _the_table;
 200   // Don't check if we need rehashing until the table gets unbalanced again.
 201   // Then rehash with a new global seed.
 202   _needs_rehashing = false;
 203   _the_table = new_table;
 204 }
 205 
 206 // Lookup a symbol in a bucket.
 207 
 208 Symbol* SymbolTable::lookup_dynamic(int index, const char* name,
 209                                     int len, unsigned int hash) {
 210   int count = 0;
 211   for (HashtableEntry<Symbol*, mtSymbol>* e = bucket(index); e != NULL; e = e->next()) {
 212     count++;  // count all entries in this bucket, not just ones with same hash
 213     if (e->hash() == hash) {
 214       Symbol* sym = e->literal();
 215       if (sym->equals(name, len) && sym->try_increment_refcount()) {
 216         // something is referencing this symbol now.

 217         return sym;
 218       }
 219     }
 220   }
 221   // If the bucket size is too deep check if this hash code is insufficient.
 222   if (count >= rehash_count && !needs_rehashing()) {
 223     _needs_rehashing = check_rehash_table(count);
 224   }
 225   return NULL;
 226 }
 227 
 228 Symbol* SymbolTable::lookup_shared(const char* name,
 229                                    int len, unsigned int hash) {
 230   if (use_alternate_hashcode()) {
 231     // hash_code parameter may use alternate hashing algorithm but the shared table
 232     // always uses the same original hash code.
 233     hash = hash_shared_symbol(name, len);
 234   }
 235   return _shared_table.lookup(name, hash, len);
 236 }


< prev index next >