# HG changeset patch # User Doug Simon # Date 1404988412 -7200 # Node ID ce66965596836e9ca9a577b9566780d6be2ad25e # Parent 4584f29431be708eca954734a5b75c380e4ea3ce better fix for deadlock in GraalVM under -Xcomp (JBS:GRAAL-48) diff -r 4584f29431be -r ce6696559683 src/share/vm/compiler/compileBroker.cpp --- a/src/share/vm/compiler/compileBroker.cpp Thu Jul 10 10:20:55 2014 +0200 +++ b/src/share/vm/compiler/compileBroker.cpp Thu Jul 10 12:33:32 2014 +0200 @@ -51,6 +51,9 @@ #endif #ifdef GRAAL #include "graal/graalCompiler.hpp" +#ifdef COMPILERGRAAL +#include "runtime/vframe.hpp" +#endif #endif #ifdef COMPILER2 #include "opto/c2compiler.hpp" @@ -1187,10 +1190,22 @@ blocking = is_compile_blocking(method, osr_bci); #ifdef COMPILERGRAAL - // Don't allow blocking compiles for requests triggered by Graal. - if (blocking && thread->is_Compiler_thread()) { - blocking = false; + if (blocking) { + // Don't allow blocking compiles for requests triggered by Graal. + if (thread->is_Compiler_thread()) { + blocking = false; + } + + // Don't allow blocking compiles if inside a class initializer + vframeStream vfst((JavaThread*) thread); + for (; !vfst.at_end(); vfst.next()) { + if (vfst.method()->is_static_initializer()) { + blocking = false; + break; + } + } } + // Don't allow blocking compiles #endif // We will enter the compilation in the queue. diff -r 4584f29431be -r ce6696559683 src/share/vm/runtime/thread.cpp --- a/src/share/vm/runtime/thread.cpp Thu Jul 10 10:20:55 2014 +0200 +++ b/src/share/vm/runtime/thread.cpp Thu Jul 10 12:33:32 2014 +0200 @@ -3745,18 +3745,7 @@ #endif // initialize compiler(s) -#if defined(COMPILERGRAAL) - if (Arguments::mode() != Arguments::_comp) { - // Only initialize compilation if not -Xcomp. Deadlock can - // occur during the class initialization below as follows: - // 1. This thread acquires the initialization lock for a class - // and then blocks while waiting for some method to be compiled. - // 2. Graal compilation thread(s) try to access the locked class - // and will block waiting for the initialization lock. This - // prevents the requested compilation in 1 from completing. - CompileBroker::compilation_init(); - } -#elif defined(COMPILER1) || defined(COMPILER2) || defined(SHARK) || defined(COMPILERGRAAL) +#if defined(COMPILER1) || defined(COMPILER2) || defined(SHARK) || defined(COMPILERGRAAL) CompileBroker::compilation_init(); #endif @@ -3770,13 +3759,6 @@ initialize_class(vmSymbols::java_lang_invoke_MethodHandleNatives(), CHECK_0); } -#if defined(COMPILERGRAAL) - if (Arguments::mode() == Arguments::_comp) { - // Do deferred compilation initialization (see above) now. - CompileBroker::compilation_init(); - } -#endif - #if INCLUDE_MANAGEMENT Management::initialize(THREAD); #endif // INCLUDE_MANAGEMENT