src/hotspot/share/compiler/compileBroker.cpp
changeset 54669 ad45b3802d4e
parent 54645 05aaccf7d558
child 54732 2d012a75d35c
equal deleted inserted replaced
54668:0bda2308eded 54669:ad45b3802d4e
    66 #include "utilities/macros.hpp"
    66 #include "utilities/macros.hpp"
    67 #ifdef COMPILER1
    67 #ifdef COMPILER1
    68 #include "c1/c1_Compiler.hpp"
    68 #include "c1/c1_Compiler.hpp"
    69 #endif
    69 #endif
    70 #if INCLUDE_JVMCI
    70 #if INCLUDE_JVMCI
    71 #include "jvmci/jvmciCompiler.hpp"
    71 #include "jvmci/jvmciEnv.hpp"
    72 #include "jvmci/jvmciRuntime.hpp"
    72 #include "jvmci/jvmciRuntime.hpp"
    73 #include "jvmci/jvmciJavaClasses.hpp"
       
    74 #include "runtime/vframe.hpp"
    73 #include "runtime/vframe.hpp"
    75 #endif
    74 #endif
    76 #ifdef COMPILER2
    75 #ifdef COMPILER2
    77 #include "opto/c2compiler.hpp"
    76 #include "opto/c2compiler.hpp"
    78 #endif
    77 #endif
  1062       // The compilation falls outside the allowed range.
  1061       // The compilation falls outside the allowed range.
  1063       return;
  1062       return;
  1064     }
  1063     }
  1065 
  1064 
  1066 #if INCLUDE_JVMCI
  1065 #if INCLUDE_JVMCI
  1067     if (UseJVMCICompiler) {
  1066     if (UseJVMCICompiler && blocking && !UseJVMCINativeLibrary) {
  1068       if (blocking) {
  1067       // Don't allow blocking compiles for requests triggered by JVMCI.
  1069         // Don't allow blocking compiles for requests triggered by JVMCI.
  1068       if (thread->is_Compiler_thread()) {
  1070         if (thread->is_Compiler_thread()) {
  1069         blocking = false;
       
  1070       }
       
  1071 
       
  1072       // Don't allow blocking compiles if inside a class initializer or while performing class loading
       
  1073       vframeStream vfst((JavaThread*) thread);
       
  1074       for (; !vfst.at_end(); vfst.next()) {
       
  1075         if (vfst.method()->is_static_initializer() ||
       
  1076             (vfst.method()->method_holder()->is_subclass_of(SystemDictionary::ClassLoader_klass()) &&
       
  1077                 vfst.method()->name() == vmSymbols::loadClass_name())) {
  1071           blocking = false;
  1078           blocking = false;
       
  1079           break;
  1072         }
  1080         }
  1073 
  1081       }
  1074         // Don't allow blocking compiles if inside a class initializer or while performing class loading
  1082 
  1075         vframeStream vfst((JavaThread*) thread);
  1083       // Don't allow blocking compilation requests to JVMCI
  1076         for (; !vfst.at_end(); vfst.next()) {
  1084       // if JVMCI itself is not yet initialized
  1077           if (vfst.method()->is_static_initializer() ||
  1085       if (!JVMCI::is_compiler_initialized() && compiler(comp_level)->is_jvmci()) {
  1078               (vfst.method()->method_holder()->is_subclass_of(SystemDictionary::ClassLoader_klass()) &&
  1086         blocking = false;
  1079                   vfst.method()->name() == vmSymbols::loadClass_name())) {
  1087       }
  1080             blocking = false;
  1088 
  1081             break;
  1089       // Don't allow blocking compilation requests if we are in JVMCIRuntime::shutdown
  1082           }
  1090       // to avoid deadlock between compiler thread(s) and threads run at shutdown
  1083         }
  1091       // such as the DestroyJavaVM thread.
  1084 
  1092       if (JVMCI::shutdown_called()) {
  1085         // Don't allow blocking compilation requests to JVMCI
  1093         blocking = false;
  1086         // if JVMCI itself is not yet initialized
       
  1087         if (!JVMCIRuntime::is_HotSpotJVMCIRuntime_initialized() && compiler(comp_level)->is_jvmci()) {
       
  1088           blocking = false;
       
  1089         }
       
  1090 
       
  1091         // Don't allow blocking compilation requests if we are in JVMCIRuntime::shutdown
       
  1092         // to avoid deadlock between compiler thread(s) and threads run at shutdown
       
  1093         // such as the DestroyJavaVM thread.
       
  1094         if (JVMCIRuntime::shutdown_called()) {
       
  1095           blocking = false;
       
  1096         }
       
  1097       }
  1094       }
  1098     }
  1095     }
  1099 #endif // INCLUDE_JVMCI
  1096 #endif // INCLUDE_JVMCI
  1100 
  1097 
  1101     // We will enter the compilation in the queue.
  1098     // We will enter the compilation in the queue.
  1191       compilation_is_prohibited(method, osr_bci, comp_level, directive->ExcludeOption)) {
  1188       compilation_is_prohibited(method, osr_bci, comp_level, directive->ExcludeOption)) {
  1192     return NULL;
  1189     return NULL;
  1193   }
  1190   }
  1194 
  1191 
  1195 #if INCLUDE_JVMCI
  1192 #if INCLUDE_JVMCI
  1196   if (comp->is_jvmci() && !JVMCIRuntime::can_initialize_JVMCI()) {
  1193   if (comp->is_jvmci() && !JVMCI::can_initialize_JVMCI()) {
  1197     return NULL;
  1194     return NULL;
  1198   }
  1195   }
  1199 #endif
  1196 #endif
  1200 
  1197 
  1201   if (osr_bci == InvocationEntryBci) {
  1198   if (osr_bci == InvocationEntryBci) {
  2059     TraceTime t1("compilation", &time);
  2056     TraceTime t1("compilation", &time);
  2060     EventCompilation event;
  2057     EventCompilation event;
  2061 
  2058 
  2062     // Skip redefined methods
  2059     // Skip redefined methods
  2063     if (target_handle->is_old()) {
  2060     if (target_handle->is_old()) {
  2064         failure_reason = "redefined method";
  2061       failure_reason = "redefined method";
       
  2062       retry_message = "not retryable";
       
  2063       compilable = ciEnv::MethodCompilable_never;
       
  2064     } else {
       
  2065       JVMCICompileState compile_state(task, system_dictionary_modification_counter);
       
  2066       JVMCIEnv env(&compile_state, __FILE__, __LINE__);
       
  2067       methodHandle method(thread, target_handle);
       
  2068       env.runtime()->compile_method(&env, jvmci, method, osr_bci);
       
  2069 
       
  2070       failure_reason = compile_state.failure_reason();
       
  2071       failure_reason_on_C_heap = compile_state.failure_reason_on_C_heap();
       
  2072       if (!compile_state.retryable()) {
  2065         retry_message = "not retryable";
  2073         retry_message = "not retryable";
  2066         compilable = ciEnv::MethodCompilable_never;
  2074         compilable = ciEnv::MethodCompilable_not_at_tier;
  2067     } else {
  2075       }
  2068         JVMCIEnv env(task, system_dictionary_modification_counter);
  2076       if (task->code() == NULL) {
  2069         methodHandle method(thread, target_handle);
  2077         assert(failure_reason != NULL, "must specify failure_reason");
  2070         jvmci->compile_method(method, osr_bci, &env);
  2078       }
  2071 
       
  2072         failure_reason = env.failure_reason();
       
  2073         failure_reason_on_C_heap = env.failure_reason_on_C_heap();
       
  2074         if (!env.retryable()) {
       
  2075           retry_message = "not retryable";
       
  2076           compilable = ciEnv::MethodCompilable_not_at_tier;
       
  2077         }
       
  2078     }
  2079     }
  2079     post_compile(thread, task, task->code() != NULL, NULL, compilable, failure_reason);
  2080     post_compile(thread, task, task->code() != NULL, NULL, compilable, failure_reason);
  2080     if (event.should_commit()) {
  2081     if (event.should_commit()) {
  2081       post_compilation_event(&event, task);
  2082       post_compilation_event(&event, task);
  2082     }
  2083     }