# HG changeset patch # User coleenp # Date 1558361167 14400 # Node ID 2523496f510735574628e18a17ee2ec22d16afc2 # Parent af28daff6b982541f528eca8e07f8c2c94fd4c23 8221967: InternTest.java timed out Summary: Move redundant table lookup and make rehashing be a needed guaranteed safepoint cleanup action. Reviewed-by: dholmes, rehn diff -r af28daff6b98 -r 2523496f5107 src/hotspot/share/classfile/stringTable.cpp --- a/src/hotspot/share/classfile/stringTable.cpp Mon May 20 09:43:46 2019 -0400 +++ b/src/hotspot/share/classfile/stringTable.cpp Mon May 20 10:06:07 2019 -0400 @@ -372,16 +372,19 @@ bool rehash_warning; do { - if (_local_table->get(THREAD, lookup, stg, &rehash_warning)) { - update_needs_rehash(rehash_warning); - return stg.get_res_oop(); - } + // Callers have already looked up the String using the jchar* name, so just go to add. WeakHandle wh = WeakHandle::create(string_h); // The hash table takes ownership of the WeakHandle, even if it's not inserted. if (_local_table->insert(THREAD, lookup, wh, &rehash_warning)) { update_needs_rehash(rehash_warning); return wh.resolve(); } + // In case another thread did a concurrent add, return value already in the table. + // This could fail if the String got gc'ed concurrently, so loop back until success. + if (_local_table->get(THREAD, lookup, stg, &rehash_warning)) { + update_needs_rehash(rehash_warning); + return stg.get_res_oop(); + } } while(true); } diff -r af28daff6b98 -r 2523496f5107 src/hotspot/share/classfile/symbolTable.cpp --- a/src/hotspot/share/classfile/symbolTable.cpp Mon May 20 09:43:46 2019 -0400 +++ b/src/hotspot/share/classfile/symbolTable.cpp Mon May 20 10:06:07 2019 -0400 @@ -481,14 +481,17 @@ Thread* THREAD = Thread::current(); do { + // Callers have looked up the symbol once, insert the symbol. + sym = allocate_symbol(name, len, heap); + if (_local_table->insert(THREAD, lookup, sym, &rehash_warning, &clean_hint)) { + break; + } + // In case another thread did a concurrent add, return value already in the table. + // This could fail if the symbol got deleted concurrently, so loop back until success. if (_local_table->get(THREAD, lookup, stg, &rehash_warning)) { sym = stg.get_res_sym(); break; } - sym = allocate_symbol(name, len, heap); - if (_local_table->insert(THREAD, lookup, sym, &rehash_warning, &clean_hint)) { - break; - } } while(true); update_needs_rehash(rehash_warning); diff -r af28daff6b98 -r 2523496f5107 src/hotspot/share/runtime/safepoint.cpp --- a/src/hotspot/share/runtime/safepoint.cpp Mon May 20 09:43:46 2019 -0400 +++ b/src/hotspot/share/runtime/safepoint.cpp Mon May 20 10:06:07 2019 -0400 @@ -516,6 +516,8 @@ if (ObjectSynchronizer::is_cleanup_needed()) return true; // Need a safepoint if some inline cache buffers is non-empty if (!InlineCacheBuffer::is_empty()) return true; + if (StringTable::needs_rehashing()) return true; + if (SymbolTable::needs_rehashing()) return true; return false; }