--- a/hotspot/src/share/vm/classfile/symbolTable.cpp Fri Mar 25 15:50:31 2016 -0400
+++ b/hotspot/src/share/vm/classfile/symbolTable.cpp Wed Mar 23 09:00:22 2016 -0700
@@ -160,6 +160,11 @@
// 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_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 @@
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 @@
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);
}