mirror of
https://github.com/openjdk/jdk8u.git
synced 2025-12-10 10:44:16 -06:00
8325600: Better symbol storage
Reviewed-by: mbalao, andrew Backport-of: da06689bf6fde7b6dd8efc2f0c39fc95adcdb69d
This commit is contained in:
parent
dfbb2cfbc4
commit
18b3ca58d7
@ -237,10 +237,10 @@ unsigned int SymbolTable::hash_symbol(const char* s, int len) {
|
||||
// safepoints).
|
||||
|
||||
// Symbols should represent entities from the constant pool that are
|
||||
// limited to 64K in length, but usage errors creep in allowing Symbols
|
||||
// limited to <64K in length, but usage errors creep in allowing Symbols
|
||||
// to be used for arbitrary strings. For debug builds we will assert if
|
||||
// a string is too long, whereas product builds will truncate it.
|
||||
Symbol* SymbolTable::lookup(const char* name, int len, TRAPS) {
|
||||
static int check_length(const char* name, int len) {
|
||||
assert(len <= Symbol::max_length(),
|
||||
"String length exceeds the maximum Symbol length");
|
||||
if (len > Symbol::max_length()) {
|
||||
@ -248,6 +248,11 @@ Symbol* SymbolTable::lookup(const char* name, int len, TRAPS) {
|
||||
"length of %d and has been truncated", name, (name + len - 80), Symbol::max_length());
|
||||
len = Symbol::max_length();
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
Symbol* SymbolTable::lookup(const char* name, int len, TRAPS) {
|
||||
len = check_length(name, len);
|
||||
unsigned int hashValue = hash_symbol(name, len);
|
||||
int index = the_table()->hash_to_index(hashValue);
|
||||
|
||||
@ -387,7 +392,8 @@ void SymbolTable::add(ClassLoaderData* loader_data, constantPoolHandle cp,
|
||||
|
||||
Symbol* SymbolTable::new_permanent_symbol(const char* name, TRAPS) {
|
||||
unsigned int hash;
|
||||
Symbol* result = SymbolTable::lookup_only((char*)name, (int)strlen(name), hash);
|
||||
int len = check_length(name, (int)strlen(name));
|
||||
Symbol* result = SymbolTable::lookup_only((char*)name, len, hash);
|
||||
if (result != NULL) {
|
||||
return result;
|
||||
}
|
||||
@ -396,7 +402,7 @@ Symbol* SymbolTable::new_permanent_symbol(const char* name, TRAPS) {
|
||||
|
||||
SymbolTable* table = the_table();
|
||||
int index = table->hash_to_index(hash);
|
||||
return table->basic_add(index, (u1*)name, (int)strlen(name), hash, false, THREAD);
|
||||
return table->basic_add(index, (u1*)name, len, hash, false, THREAD);
|
||||
}
|
||||
|
||||
Symbol* SymbolTable::basic_add(int index_arg, u1 *name, int len,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user