src/share/vm/classfile/symbolTable.cpp
Index
Unified diffs
Context diffs
Sdiffs
Wdiffs
Patch
New
Old
Previous File
Next File
*** old/src/share/vm/classfile/symbolTable.cpp Fri Apr 25 14:05:09 2014
--- new/src/share/vm/classfile/symbolTable.cpp Fri Apr 25 14:05:09 2014
*** 207,231 ****
--- 207,231 ----
}
return NULL;
}
// Pick hashing algorithm.
! unsigned int SymbolTable::hash_symbol(const char* s, int len) {
! unsigned int SymbolTable::hash_symbol(const char* name, int len) {
return use_alternate_hashcode() ?
! AltHashing::murmur3_32(seed(), (const jbyte*)s, len) :
! java_lang_String::hash_code(s, len);
! AltHashing::murmur3_32(seed(), (const jbyte*)name, len) :
! java_lang_String::hash_code(name, len);
}
// We take care not to be blocking while holding the
// SymbolTable_lock. Otherwise, the system might deadlock, since the
// symboltable is used during compilation (VM_thread) The lock free
// synchronization is simplified by the fact that we do not delete
// entries in the symbol table during normal execution (only during
// safepoints).
! Symbol* SymbolTable::lookup_and_add(const char* name, int len, TRAPS) {
unsigned int hashValue = hash_symbol(name, len);
int index = the_table()->hash_to_index(hashValue);
Symbol* s = the_table()->lookup(index, name, len, hashValue);
*** 237,247 ****
--- 237,247 ----
// Otherwise, add to symbol to table
return the_table()->basic_add(index, (u1*)name, len, hashValue, true, CHECK_NULL);
}
! Symbol* SymbolTable::lookup_and_add(const Symbol* sym, int begin, int end, TRAPS) {
char* buffer;
int index, len;
unsigned int hashValue;
char* name;
{
*** 276,286 ****
--- 276,286 ----
MutexLocker ml(SymbolTable_lock, THREAD);
return the_table()->basic_add(index, (u1*)buffer, len, hashValue, true, CHECK_NULL);
}
! Symbol* SymbolTable::lookup_only(const char* name, int len,
! Symbol* SymbolTable::lookup_and_hash(const char* name, int len,
unsigned int& hash) {
hash = hash_symbol(name, len);
int index = the_table()->hash_to_index(hash);
Symbol* s = the_table()->lookup(index, name, len, hash);
*** 306,343 ****
--- 306,343 ----
}
// Suggestion: Push unicode-based lookup all the way into the hashing
// and probing logic, so there is no need for convert_to_utf8 until
// an actual new Symbol* is created.
! Symbol* SymbolTable::lookup_unicode(const jchar* name, int utf16_length, TRAPS) {
! Symbol* SymbolTable::lookup_and_add_unicode(const jchar* name, int utf16_length, TRAPS) {
int utf8_length = UNICODE::utf8_length((jchar*) name, utf16_length);
char stack_buf[128];
if (utf8_length < (int) sizeof(stack_buf)) {
char* chars = stack_buf;
UNICODE::convert_to_utf8(name, utf16_length, chars);
! return lookup_and_add(chars, utf8_length, THREAD);
} else {
ResourceMark rm(THREAD);
- char* chars = NEW_RESOURCE_ARRAY(char, utf8_length + 1);;
UNICODE::convert_to_utf8(name, utf16_length, chars);
! return lookup_and_add(chars, utf8_length, THREAD);
}
}
! Symbol* SymbolTable::lookup_only_unicode(const jchar* name, int utf16_length,
! Symbol* SymbolTable::lookup_and_hash_unicode(const jchar* name, int utf16_length,
unsigned int& hash) {
int utf8_length = UNICODE::utf8_length((jchar*) name, utf16_length);
char stack_buf[128];
if (utf8_length < (int) sizeof(stack_buf)) {
char* chars = stack_buf;
UNICODE::convert_to_utf8(name, utf16_length, chars);
! return lookup_only(chars, utf8_length, hash);
! return lookup_and_hash(chars, utf8_length, hash);
} else {
ResourceMark rm;
- char* chars = NEW_RESOURCE_ARRAY(char, utf8_length + 1);;
UNICODE::convert_to_utf8(name, utf16_length, chars);
! return lookup_only(chars, utf8_length, hash);
! return lookup_and_hash(chars, utf8_length, hash);
}
}
void SymbolTable::add(ClassLoaderData* loader_data, constantPoolHandle cp,
int names_count,
*** 360,370 ****
--- 360,370 ----
}
}
Symbol* SymbolTable::new_permanent_symbol(const char* name, TRAPS) {
unsigned int hash;
! Symbol* result = SymbolTable::lookup_only((char*)name, (int)strlen(name), hash);
! Symbol* result = SymbolTable::lookup_and_hash((char*)name, (int)strlen(name), hash);
if (result != NULL) {
return result;
}
// Grab SymbolTable_lock first.
MutexLocker ml(SymbolTable_lock, THREAD);
*** 423,433 ****
--- 423,432 ----
bool SymbolTable::basic_add(ClassLoaderData* loader_data, constantPoolHandle cp,
int names_count,
const char** names, int* lengths,
int* cp_indices, unsigned int* hashValues,
TRAPS) {
// Check symbol names are not too long. If any are too long, don't add any.
for (int i = 0; i< names_count; i++) {
if (lengths[i] > Symbol::max_length()) {
THROW_MSG_0(vmSymbols::java_lang_InternalError(),
"name is too long to represent");
*** 467,477 ****
--- 466,475 ----
}
}
return true;
}
void SymbolTable::verify() {
for (int i = 0; i < the_table()->table_size(); ++i) {
HashtableEntry<Symbol*, mtSymbol>* p = the_table()->bucket(i);
for ( ; p != NULL; p = p->next()) {
Symbol* s = (Symbol*)(p->literal());
*** 486,496 ****
--- 484,493 ----
void SymbolTable::dump(outputStream* st) {
the_table()->dump_table(st, "SymbolTable");
}
//---------------------------------------------------------------------------
// Non-product code
#ifndef PRODUCT
src/share/vm/classfile/symbolTable.cpp
Index
Unified diffs
Context diffs
Sdiffs
Wdiffs
Patch
New
Old
Previous File
Next File