Wed, 27 Apr 2011 14:40:41 -0700
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
src/share/vm/compiler/compileBroker.cpp | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/vm/compiler/compileBroker.cpp Tue Apr 26 21:17:24 2011 -0700 1.2 +++ b/src/share/vm/compiler/compileBroker.cpp Wed Apr 27 14:40:41 2011 -0700 1.3 @@ -976,6 +976,15 @@ 1.4 return; 1.5 } 1.6 1.7 + // If the requesting thread is holding the pending list lock 1.8 + // then we just return. We can't risk blocking while holding 1.9 + // the pending list lock or a 3-way deadlock may occur 1.10 + // between the reference handler thread, a GC (instigated 1.11 + // by a compiler thread), and compiled method registration. 1.12 + if (instanceRefKlass::owns_pending_list_lock(JavaThread::current())) { 1.13 + return; 1.14 + } 1.15 + 1.16 // Outputs from the following MutexLocker block: 1.17 CompileTask* task = NULL; 1.18 bool blocking = false; 1.19 @@ -1304,17 +1313,8 @@ 1.20 // Should the current thread be blocked until this compilation request 1.21 // has been fulfilled? 1.22 bool CompileBroker::is_compile_blocking(methodHandle method, int osr_bci) { 1.23 - if (!BackgroundCompilation) { 1.24 - Symbol* class_name = method->method_holder()->klass_part()->name(); 1.25 - if (class_name->starts_with("java/lang/ref/Reference", 23)) { 1.26 - // The reference handler thread can dead lock with the GC if compilation is blocking, 1.27 - // so we avoid blocking compiles for anything in the java.lang.ref.Reference class, 1.28 - // including inner classes such as ReferenceHandler. 1.29 - return false; 1.30 - } 1.31 - return true; 1.32 - } 1.33 - return false; 1.34 + assert(!instanceRefKlass::owns_pending_list_lock(JavaThread::current()), "possible deadlock"); 1.35 + return !BackgroundCompilation; 1.36 } 1.37 1.38