# HG changeset patch # User johnc # Date 1303940441 25200 # Node ID cf46e123429d554fae45a60e6aa1af77ba367cb0 # Parent 456b8d0486b579c000a3e407e26e6db396d91486 7037756: Deadlock in compiler thread similiar to 6789220 Summary: Avoid blocking in CompileBroker::compile_method_base() if the current thread holds the pending list lock. Reviewed-by: never, brutisso, ysr diff -r 456b8d0486b5 -r cf46e123429d hotspot/src/share/vm/compiler/compileBroker.cpp --- a/hotspot/src/share/vm/compiler/compileBroker.cpp Tue Apr 26 21:17:24 2011 -0700 +++ b/hotspot/src/share/vm/compiler/compileBroker.cpp Wed Apr 27 14:40:41 2011 -0700 @@ -976,6 +976,15 @@ return; } + // If the requesting thread is holding the pending list lock + // then we just return. We can't risk blocking while holding + // the pending list lock or a 3-way deadlock may occur + // between the reference handler thread, a GC (instigated + // by a compiler thread), and compiled method registration. + if (instanceRefKlass::owns_pending_list_lock(JavaThread::current())) { + return; + } + // Outputs from the following MutexLocker block: CompileTask* task = NULL; bool blocking = false; @@ -1304,17 +1313,8 @@ // Should the current thread be blocked until this compilation request // has been fulfilled? bool CompileBroker::is_compile_blocking(methodHandle method, int osr_bci) { - if (!BackgroundCompilation) { - Symbol* class_name = method->method_holder()->klass_part()->name(); - if (class_name->starts_with("java/lang/ref/Reference", 23)) { - // The reference handler thread can dead lock with the GC if compilation is blocking, - // so we avoid blocking compiles for anything in the java.lang.ref.Reference class, - // including inner classes such as ReferenceHandler. - return false; - } - return true; - } - return false; + assert(!instanceRefKlass::owns_pending_list_lock(JavaThread::current()), "possible deadlock"); + return !BackgroundCompilation; }