# HG changeset patch # User coleenp # Date 1558019229 14400 # Node ID 631d51796dbfba3f496587dfe0020eea8b5f3f92 # Parent e9f5e06a0dd71bfd2b7fad20bdb3ce0311923961 8223585: vmTestbase/runtime/pcl/* get SEGV in MetadataOnStackClosure::do_metadata(Metadata*)+0x0 Summary: adjust old method table by only one thread. Reviewed-by: kvn, jcbeyler, sspitsyn diff -r e9f5e06a0dd7 -r 631d51796dbf src/hotspot/share/code/codeCache.cpp --- a/src/hotspot/share/code/codeCache.cpp Thu May 16 16:42:14 2019 +0200 +++ b/src/hotspot/share/code/codeCache.cpp Thu May 16 11:07:09 2019 -0400 @@ -1055,7 +1055,7 @@ // Remove this method when zombied or unloaded. void CodeCache::unregister_old_nmethod(CompiledMethod* c) { - assert_locked_or_safepoint(CodeCache_lock); + assert_lock_strong(CodeCache_lock); if (old_compiled_method_table != NULL) { int index = old_compiled_method_table->find(c); if (index != -1) { @@ -1070,7 +1070,11 @@ if (old_compiled_method_table != NULL) { length = old_compiled_method_table->length(); for (int i = 0; i < length; i++) { - old_compiled_method_table->at(i)->metadata_do(f); + CompiledMethod* cm = old_compiled_method_table->at(i); + // Only walk alive nmethods, the dead ones will get removed by the sweeper. + if (cm->is_alive()) { + old_compiled_method_table->at(i)->metadata_do(f); + } } } log_debug(redefine, class, nmethod)("Walked %d nmethods for mark_on_stack", length); diff -r e9f5e06a0dd7 -r 631d51796dbf src/hotspot/share/code/nmethod.cpp --- a/src/hotspot/share/code/nmethod.cpp Thu May 16 16:42:14 2019 +0200 +++ b/src/hotspot/share/code/nmethod.cpp Thu May 16 11:07:09 2019 -0400 @@ -1143,7 +1143,6 @@ MutexLocker ml(SafepointSynchronize::is_at_safepoint() ? NULL : CodeCache_lock, Mutex::_no_safepoint_check_flag); Universe::heap()->unregister_nmethod(this); - CodeCache::unregister_old_nmethod(this); } // Clear the method of this dead nmethod @@ -1336,7 +1335,6 @@ MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); if (nmethod_needs_unregister) { Universe::heap()->unregister_nmethod(this); - CodeCache::unregister_old_nmethod(this); } flush_dependencies(/*delete_immediately*/true); } @@ -1415,6 +1413,7 @@ } Universe::heap()->flush_nmethod(this); + CodeCache::unregister_old_nmethod(this); CodeBlob::flush(); CodeCache::free(this);