188 _the_table = new_table;
189 }
190
191 // Lookup a symbol in a bucket.
192
193 Symbol* SymbolTable::lookup(int index, const char* name,
194 int len, unsigned int hash) {
195 int count = 0;
196 for (HashtableEntry<Symbol*, mtSymbol>* e = bucket(index); e != NULL; e = e->next()) {
197 count++; // count all entries in this bucket, not just ones with same hash
198 if (e->hash() == hash) {
199 Symbol* sym = e->literal();
200 if (sym->equals(name, len)) {
201 // something is referencing this symbol now.
202 sym->increment_refcount();
203 return sym;
204 }
205 }
206 }
207 // If the bucket size is too deep check if this hash code is insufficient.
208 if (count >= BasicHashtable<mtSymbol>::rehash_count && !needs_rehashing()) {
209 _needs_rehashing = check_rehash_table(count);
210 }
211 return NULL;
212 }
213
214 // Pick hashing algorithm.
215 unsigned int SymbolTable::hash_symbol(const char* s, int len) {
216 return use_alternate_hashcode() ?
217 AltHashing::murmur3_32(seed(), (const jbyte*)s, len) :
218 java_lang_String::hash_code(s, len);
219 }
220
221
222 // We take care not to be blocking while holding the
223 // SymbolTable_lock. Otherwise, the system might deadlock, since the
224 // symboltable is used during compilation (VM_thread) The lock free
225 // synchronization is simplified by the fact that we do not delete
226 // entries in the symbol table during normal execution (only during
227 // safepoints).
228
639 volatile int StringTable::_parallel_claimed_idx = 0;
640
641 // Pick hashing algorithm
642 unsigned int StringTable::hash_string(const jchar* s, int len) {
643 return use_alternate_hashcode() ? AltHashing::murmur3_32(seed(), s, len) :
644 java_lang_String::hash_code(s, len);
645 }
646
647 oop StringTable::lookup(int index, jchar* name,
648 int len, unsigned int hash) {
649 int count = 0;
650 for (HashtableEntry<oop, mtSymbol>* l = bucket(index); l != NULL; l = l->next()) {
651 count++;
652 if (l->hash() == hash) {
653 if (java_lang_String::equals(l->literal(), name, len)) {
654 return l->literal();
655 }
656 }
657 }
658 // If the bucket size is too deep check if this hash code is insufficient.
659 if (count >= BasicHashtable<mtSymbol>::rehash_count && !needs_rehashing()) {
660 _needs_rehashing = check_rehash_table(count);
661 }
662 return NULL;
663 }
664
665
666 oop StringTable::basic_add(int index_arg, Handle string, jchar* name,
667 int len, unsigned int hashValue_arg, TRAPS) {
668
669 assert(java_lang_String::equals(string(), name, len),
670 "string must be properly initialized");
671 // Cannot hit a safepoint in this function because the "this" pointer can move.
672 No_Safepoint_Verifier nsv;
673
674 // Check if the symbol table has been rehashed, if so, need to recalculate
675 // the hash value and index before second lookup.
676 unsigned int hashValue;
677 int index;
678 if (use_alternate_hashcode()) {
679 hashValue = hash_string(name, len);
|
188 _the_table = new_table;
189 }
190
191 // Lookup a symbol in a bucket.
192
193 Symbol* SymbolTable::lookup(int index, const char* name,
194 int len, unsigned int hash) {
195 int count = 0;
196 for (HashtableEntry<Symbol*, mtSymbol>* e = bucket(index); e != NULL; e = e->next()) {
197 count++; // count all entries in this bucket, not just ones with same hash
198 if (e->hash() == hash) {
199 Symbol* sym = e->literal();
200 if (sym->equals(name, len)) {
201 // something is referencing this symbol now.
202 sym->increment_refcount();
203 return sym;
204 }
205 }
206 }
207 // If the bucket size is too deep check if this hash code is insufficient.
208 if (count >= rehash_count && !needs_rehashing()) {
209 _needs_rehashing = check_rehash_table(count);
210 }
211 return NULL;
212 }
213
214 // Pick hashing algorithm.
215 unsigned int SymbolTable::hash_symbol(const char* s, int len) {
216 return use_alternate_hashcode() ?
217 AltHashing::murmur3_32(seed(), (const jbyte*)s, len) :
218 java_lang_String::hash_code(s, len);
219 }
220
221
222 // We take care not to be blocking while holding the
223 // SymbolTable_lock. Otherwise, the system might deadlock, since the
224 // symboltable is used during compilation (VM_thread) The lock free
225 // synchronization is simplified by the fact that we do not delete
226 // entries in the symbol table during normal execution (only during
227 // safepoints).
228
639 volatile int StringTable::_parallel_claimed_idx = 0;
640
641 // Pick hashing algorithm
642 unsigned int StringTable::hash_string(const jchar* s, int len) {
643 return use_alternate_hashcode() ? AltHashing::murmur3_32(seed(), s, len) :
644 java_lang_String::hash_code(s, len);
645 }
646
647 oop StringTable::lookup(int index, jchar* name,
648 int len, unsigned int hash) {
649 int count = 0;
650 for (HashtableEntry<oop, mtSymbol>* l = bucket(index); l != NULL; l = l->next()) {
651 count++;
652 if (l->hash() == hash) {
653 if (java_lang_String::equals(l->literal(), name, len)) {
654 return l->literal();
655 }
656 }
657 }
658 // If the bucket size is too deep check if this hash code is insufficient.
659 if (count >= rehash_count && !needs_rehashing()) {
660 _needs_rehashing = check_rehash_table(count);
661 }
662 return NULL;
663 }
664
665
666 oop StringTable::basic_add(int index_arg, Handle string, jchar* name,
667 int len, unsigned int hashValue_arg, TRAPS) {
668
669 assert(java_lang_String::equals(string(), name, len),
670 "string must be properly initialized");
671 // Cannot hit a safepoint in this function because the "this" pointer can move.
672 No_Safepoint_Verifier nsv;
673
674 // Check if the symbol table has been rehashed, if so, need to recalculate
675 // the hash value and index before second lookup.
676 unsigned int hashValue;
677 int index;
678 if (use_alternate_hashcode()) {
679 hashValue = hash_string(name, len);
|