mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8152380: Shared symbol table should never use alternate hashcode
Reviewed-by: coleenp, jiangli
This commit is contained in:
parent
cb72aacabb
commit
ae4cc4b56a
2 changed files with 16 additions and 1 deletions
|
@ -160,6 +160,11 @@ void SymbolTable::possibly_parallel_unlink(int* processed, int* removed) {
|
|||
// Create a new table and using alternate hash code, populate the new table
|
||||
// with the existing strings. Set flag to use the alternate hash code afterwards.
|
||||
void SymbolTable::rehash_table() {
|
||||
if (DumpSharedSpaces) {
|
||||
tty->print_cr("Warning: rehash_table should not be called while dumping archive");
|
||||
return;
|
||||
}
|
||||
|
||||
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
|
||||
// This should never happen with -Xshare:dump but it might in testing mode.
|
||||
if (DumpSharedSpaces) return;
|
||||
|
@ -201,6 +206,11 @@ Symbol* SymbolTable::lookup_dynamic(int index, const char* name,
|
|||
|
||||
Symbol* SymbolTable::lookup_shared(const char* name,
|
||||
int len, unsigned int hash) {
|
||||
if (use_alternate_hashcode()) {
|
||||
// hash_code parameter may use alternate hashing algorithm but the shared table
|
||||
// always uses the same original hash code.
|
||||
hash = hash_shared_symbol(name, len);
|
||||
}
|
||||
return _shared_table.lookup(name, hash, len);
|
||||
}
|
||||
|
||||
|
@ -234,6 +244,10 @@ unsigned int SymbolTable::hash_symbol(const char* s, int len) {
|
|||
java_lang_String::hash_code((const jbyte*)s, len);
|
||||
}
|
||||
|
||||
unsigned int SymbolTable::hash_shared_symbol(const char* s, int len) {
|
||||
return java_lang_String::hash_code((const jbyte*)s, len);
|
||||
}
|
||||
|
||||
|
||||
// We take care not to be blocking while holding the
|
||||
// SymbolTable_lock. Otherwise, the system might deadlock, since the
|
||||
|
@ -536,7 +550,7 @@ bool SymbolTable::copy_compact_table(char** top, char*end) {
|
|||
HashtableEntry<Symbol*, mtSymbol>* p = the_table()->bucket(i);
|
||||
for ( ; p != NULL; p = p->next()) {
|
||||
Symbol* s = (Symbol*)(p->literal());
|
||||
unsigned int fixed_hash = hash_symbol((char*)s->bytes(), s->utf8_length());
|
||||
unsigned int fixed_hash = hash_shared_symbol((char*)s->bytes(), s->utf8_length());
|
||||
assert(fixed_hash == p->hash(), "must not rehash during dumping");
|
||||
ch_table.add(fixed_hash, s);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue