comparison src/share/vm/compiler/compileBroker.cpp @ 3294:86ebb26bcdeb

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
author johnc
date Wed, 27 Apr 2011 14:40:41 -0700
parents dbccacb79c63
children f56542cb325a
comparison
equal deleted inserted replaced
3293:1f4413413144 3294:86ebb26bcdeb
971 // in the case that this is a blocking compile request, is to have 971 // in the case that this is a blocking compile request, is to have
972 // all subsequent blocking requesters wait for completion of 972 // all subsequent blocking requesters wait for completion of
973 // ongoing compiles. Note that in this case we'll need a protocol 973 // ongoing compiles. Note that in this case we'll need a protocol
974 // for freeing the associated compile tasks. [Or we could have 974 // for freeing the associated compile tasks. [Or we could have
975 // a single static monitor on which all these waiters sleep.] 975 // a single static monitor on which all these waiters sleep.]
976 return;
977 }
978
979 // If the requesting thread is holding the pending list lock
980 // then we just return. We can't risk blocking while holding
981 // the pending list lock or a 3-way deadlock may occur
982 // between the reference handler thread, a GC (instigated
983 // by a compiler thread), and compiled method registration.
984 if (instanceRefKlass::owns_pending_list_lock(JavaThread::current())) {
976 return; 985 return;
977 } 986 }
978 987
979 // Outputs from the following MutexLocker block: 988 // Outputs from the following MutexLocker block:
980 CompileTask* task = NULL; 989 CompileTask* task = NULL;
1302 // CompileBroker::is_compile_blocking 1311 // CompileBroker::is_compile_blocking
1303 // 1312 //
1304 // Should the current thread be blocked until this compilation request 1313 // Should the current thread be blocked until this compilation request
1305 // has been fulfilled? 1314 // has been fulfilled?
1306 bool CompileBroker::is_compile_blocking(methodHandle method, int osr_bci) { 1315 bool CompileBroker::is_compile_blocking(methodHandle method, int osr_bci) {
1307 if (!BackgroundCompilation) { 1316 assert(!instanceRefKlass::owns_pending_list_lock(JavaThread::current()), "possible deadlock");
1308 Symbol* class_name = method->method_holder()->klass_part()->name(); 1317 return !BackgroundCompilation;
1309 if (class_name->starts_with("java/lang/ref/Reference", 23)) {
1310 // The reference handler thread can dead lock with the GC if compilation is blocking,
1311 // so we avoid blocking compiles for anything in the java.lang.ref.Reference class,
1312 // including inner classes such as ReferenceHandler.
1313 return false;
1314 }
1315 return true;
1316 }
1317 return false;
1318 } 1318 }
1319 1319
1320 1320
1321 // ------------------------------------------------------------------ 1321 // ------------------------------------------------------------------
1322 // CompileBroker::preload_classes 1322 // CompileBroker::preload_classes