1142 vframeStream vfst((JavaThread*) thread);
1143 for (; !vfst.at_end(); vfst.next()) {
1144 if (vfst.method()->is_static_initializer() ||
1145 (vfst.method()->method_holder()->is_subclass_of(SystemDictionary::ClassLoader_klass()) &&
1146 vfst.method()->name() == vmSymbols::loadClass_name())) {
1147 blocking = false;
1148 break;
1149 }
1150 }
1151 }
1152
1153 // Don't allow blocking compilation requests to JVMCI
1154 // if JVMCI itself is not yet initialized
1155 if (!JVMCI::is_compiler_initialized() && compiler(comp_level)->is_jvmci()) {
1156 blocking = false;
1157 }
1158
1159 // Don't allow blocking compilation requests if we are in JVMCIRuntime::shutdown
1160 // to avoid deadlock between compiler thread(s) and threads run at shutdown
1161 // such as the DestroyJavaVM thread.
1162 if (JVMCI::shutdown_called()) {
1163 blocking = false;
1164 }
1165 }
1166 #endif // INCLUDE_JVMCI
1167
1168 // We will enter the compilation in the queue.
1169 // 14012000: Note that this sets the queued_for_compile bits in
1170 // the target method. We can now reason that a method cannot be
1171 // queued for compilation more than once, as follows:
1172 // Before a thread queues a task for compilation, it first acquires
1173 // the compile queue lock, then checks if the method's queued bits
1174 // are set or it has already been compiled. Thus there can not be two
1175 // instances of a compilation task for the same method on the
1176 // compilation queue. Consider now the case where the compilation
1177 // thread has already removed a task for that method from the queue
1178 // and is in the midst of compiling it. In this case, the
1179 // queued_for_compile bits must be set in the method (and these
1180 // will be visible to the current thread, since the bits were set
1181 // under protection of the compile queue lock, which we hold now.
1182 // When the compilation completes, the compiler thread first sets
2112 // Allocate a new set of JNI handles.
2113 push_jni_handle_block();
2114 Method* target_handle = task->method();
2115 int compilable = ciEnv::MethodCompilable;
2116 const char* failure_reason = NULL;
2117 bool failure_reason_on_C_heap = false;
2118 const char* retry_message = NULL;
2119
2120 int system_dictionary_modification_counter;
2121 {
2122 MutexLocker locker(Compile_lock, thread);
2123 system_dictionary_modification_counter = SystemDictionary::number_of_modifications();
2124 }
2125
2126 #if INCLUDE_JVMCI
2127 if (UseJVMCICompiler && comp != NULL && comp->is_jvmci()) {
2128 JVMCICompiler* jvmci = (JVMCICompiler*) comp;
2129
2130 TraceTime t1("compilation", &time);
2131 EventCompilation event;
2132
2133 // Skip redefined methods
2134 if (target_handle->is_old()) {
2135 failure_reason = "redefined method";
2136 retry_message = "not retryable";
2137 compilable = ciEnv::MethodCompilable_never;
2138 } else {
2139 JVMCICompileState compile_state(task, system_dictionary_modification_counter);
2140 JVMCIEnv env(thread, &compile_state, __FILE__, __LINE__);
2141 methodHandle method(thread, target_handle);
2142 env.runtime()->compile_method(&env, jvmci, method, osr_bci);
2143
2144 failure_reason = compile_state.failure_reason();
2145 failure_reason_on_C_heap = compile_state.failure_reason_on_C_heap();
2146 if (!compile_state.retryable()) {
2147 retry_message = "not retryable";
2148 compilable = ciEnv::MethodCompilable_not_at_tier;
2149 }
2150 if (task->code() == NULL) {
2151 assert(failure_reason != NULL, "must specify failure_reason");
2152 }
2153 }
2154 post_compile(thread, task, task->code() != NULL, NULL, compilable, failure_reason);
2155 if (event.should_commit()) {
2156 post_compilation_event(&event, task);
2157 }
2158
2159 } else
2160 #endif // INCLUDE_JVMCI
2161 {
2162 NoHandleMark nhm;
|
1142 vframeStream vfst((JavaThread*) thread);
1143 for (; !vfst.at_end(); vfst.next()) {
1144 if (vfst.method()->is_static_initializer() ||
1145 (vfst.method()->method_holder()->is_subclass_of(SystemDictionary::ClassLoader_klass()) &&
1146 vfst.method()->name() == vmSymbols::loadClass_name())) {
1147 blocking = false;
1148 break;
1149 }
1150 }
1151 }
1152
1153 // Don't allow blocking compilation requests to JVMCI
1154 // if JVMCI itself is not yet initialized
1155 if (!JVMCI::is_compiler_initialized() && compiler(comp_level)->is_jvmci()) {
1156 blocking = false;
1157 }
1158
1159 // Don't allow blocking compilation requests if we are in JVMCIRuntime::shutdown
1160 // to avoid deadlock between compiler thread(s) and threads run at shutdown
1161 // such as the DestroyJavaVM thread.
1162 if (JVMCI::in_shutdown()) {
1163 blocking = false;
1164 }
1165 }
1166 #endif // INCLUDE_JVMCI
1167
1168 // We will enter the compilation in the queue.
1169 // 14012000: Note that this sets the queued_for_compile bits in
1170 // the target method. We can now reason that a method cannot be
1171 // queued for compilation more than once, as follows:
1172 // Before a thread queues a task for compilation, it first acquires
1173 // the compile queue lock, then checks if the method's queued bits
1174 // are set or it has already been compiled. Thus there can not be two
1175 // instances of a compilation task for the same method on the
1176 // compilation queue. Consider now the case where the compilation
1177 // thread has already removed a task for that method from the queue
1178 // and is in the midst of compiling it. In this case, the
1179 // queued_for_compile bits must be set in the method (and these
1180 // will be visible to the current thread, since the bits were set
1181 // under protection of the compile queue lock, which we hold now.
1182 // When the compilation completes, the compiler thread first sets
2112 // Allocate a new set of JNI handles.
2113 push_jni_handle_block();
2114 Method* target_handle = task->method();
2115 int compilable = ciEnv::MethodCompilable;
2116 const char* failure_reason = NULL;
2117 bool failure_reason_on_C_heap = false;
2118 const char* retry_message = NULL;
2119
2120 int system_dictionary_modification_counter;
2121 {
2122 MutexLocker locker(Compile_lock, thread);
2123 system_dictionary_modification_counter = SystemDictionary::number_of_modifications();
2124 }
2125
2126 #if INCLUDE_JVMCI
2127 if (UseJVMCICompiler && comp != NULL && comp->is_jvmci()) {
2128 JVMCICompiler* jvmci = (JVMCICompiler*) comp;
2129
2130 TraceTime t1("compilation", &time);
2131 EventCompilation event;
2132 JVMCIRuntime *runtime = NULL;
2133
2134 if (JVMCI::in_shutdown()) {
2135 failure_reason = "in JVMCI shutdown";
2136 retry_message = "not retryable";
2137 compilable = ciEnv::MethodCompilable_never;
2138 } else if (target_handle->is_old()) {
2139 // Skip redefined methods
2140 failure_reason = "redefined method";
2141 retry_message = "not retryable";
2142 compilable = ciEnv::MethodCompilable_never;
2143 } else {
2144 JVMCICompileState compile_state(task, system_dictionary_modification_counter);
2145 JVMCIEnv env(thread, &compile_state, __FILE__, __LINE__);
2146 methodHandle method(thread, target_handle);
2147 runtime = env.runtime();
2148 runtime->compile_method(&env, jvmci, method, osr_bci);
2149
2150 failure_reason = compile_state.failure_reason();
2151 failure_reason_on_C_heap = compile_state.failure_reason_on_C_heap();
2152 if (!compile_state.retryable()) {
2153 retry_message = "not retryable";
2154 compilable = ciEnv::MethodCompilable_not_at_tier;
2155 }
2156 if (task->code() == NULL) {
2157 assert(failure_reason != NULL, "must specify failure_reason");
2158 }
2159 }
2160 post_compile(thread, task, task->code() != NULL, NULL, compilable, failure_reason);
2161 if (event.should_commit()) {
2162 post_compilation_event(&event, task);
2163 }
2164
2165 } else
2166 #endif // INCLUDE_JVMCI
2167 {
2168 NoHandleMark nhm;
|