< prev index next >

src/share/vm/classfile/symbolTable.cpp

Print this page
rev 11777 : [mq]: gcinterface.patch


 416     }
 417   }
 418 }
 419 
 420 Symbol* SymbolTable::new_permanent_symbol(const char* name, TRAPS) {
 421   unsigned int hash;
 422   Symbol* result = SymbolTable::lookup_only((char*)name, (int)strlen(name), hash);
 423   if (result != NULL) {
 424     return result;
 425   }
 426   // Grab SymbolTable_lock first.
 427   MutexLocker ml(SymbolTable_lock, THREAD);
 428 
 429   SymbolTable* table = the_table();
 430   int index = table->hash_to_index(hash);
 431   return table->basic_add(index, (u1*)name, (int)strlen(name), hash, false, THREAD);
 432 }
 433 
 434 Symbol* SymbolTable::basic_add(int index_arg, u1 *name, int len,
 435                                unsigned int hashValue_arg, bool c_heap, TRAPS) {
 436   assert(!Universe::heap()->is_in_reserved(name),
 437          "proposed name of symbol must be stable");
 438 
 439   // Don't allow symbols to be created which cannot fit in a Symbol*.
 440   if (len > Symbol::max_length()) {
 441     THROW_MSG_0(vmSymbols::java_lang_InternalError(),
 442                 "name is too long to represent");
 443   }
 444 
 445   // Cannot hit a safepoint in this function because the "this" pointer can move.
 446   NoSafepointVerifier nsv;
 447 
 448   // Check if the symbol table has been rehashed, if so, need to recalculate
 449   // the hash value and index.
 450   unsigned int hashValue;
 451   int index;
 452   if (use_alternate_hashcode()) {
 453     hashValue = hash_symbol((const char*)name, len);
 454     index = hash_to_index(hashValue);
 455   } else {
 456     hashValue = hashValue_arg;




 416     }
 417   }
 418 }
 419 
 420 Symbol* SymbolTable::new_permanent_symbol(const char* name, TRAPS) {
 421   unsigned int hash;
 422   Symbol* result = SymbolTable::lookup_only((char*)name, (int)strlen(name), hash);
 423   if (result != NULL) {
 424     return result;
 425   }
 426   // Grab SymbolTable_lock first.
 427   MutexLocker ml(SymbolTable_lock, THREAD);
 428 
 429   SymbolTable* table = the_table();
 430   int index = table->hash_to_index(hash);
 431   return table->basic_add(index, (u1*)name, (int)strlen(name), hash, false, THREAD);
 432 }
 433 
 434 Symbol* SymbolTable::basic_add(int index_arg, u1 *name, int len,
 435                                unsigned int hashValue_arg, bool c_heap, TRAPS) {
 436   assert(!GC::gc()->heap()->is_in_reserved(name),
 437          "proposed name of symbol must be stable");
 438 
 439   // Don't allow symbols to be created which cannot fit in a Symbol*.
 440   if (len > Symbol::max_length()) {
 441     THROW_MSG_0(vmSymbols::java_lang_InternalError(),
 442                 "name is too long to represent");
 443   }
 444 
 445   // Cannot hit a safepoint in this function because the "this" pointer can move.
 446   NoSafepointVerifier nsv;
 447 
 448   // Check if the symbol table has been rehashed, if so, need to recalculate
 449   // the hash value and index.
 450   unsigned int hashValue;
 451   int index;
 452   if (use_alternate_hashcode()) {
 453     hashValue = hash_symbol((const char*)name, len);
 454     index = hash_to_index(hashValue);
 455   } else {
 456     hashValue = hashValue_arg;


< prev index next >