< prev index next >

src/hotspot/share/jvmci/jvmciCompiler.cpp

Print this page




 105   _bootstrapping = false;
 106   JVMCIRuntime::bootstrap_finished(CHECK);
 107 }
 108 
 109 #define CHECK_EXIT THREAD); \
 110 if (HAS_PENDING_EXCEPTION) { \
 111   char buf[256]; \
 112   jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
 113   JVMCICompiler::exit_on_pending_exception(PENDING_EXCEPTION, buf); \
 114   return; \
 115 } \
 116 (void)(0
 117 
 118 void JVMCICompiler::compile_method(const methodHandle& method, int entry_bci, JVMCIEnv* env) {
 119   JVMCI_EXCEPTION_CONTEXT
 120 
 121   bool is_osr = entry_bci != InvocationEntryBci;
 122   if (_bootstrapping && is_osr) {
 123       // no OSR compilations during bootstrap - the compiler is just too slow at this point,
 124       // and we know that there are no endless loops

 125       return;
 126   }
 127 
 128   JVMCIRuntime::initialize_well_known_classes(CHECK_EXIT);
 129 
 130   HandleMark hm;
 131   Handle receiver = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK_EXIT);
 132 
 133   JavaValue method_result(T_OBJECT);
 134   JavaCallArguments args;
 135   args.push_long((jlong) (address) method());
 136   JavaCalls::call_static(&method_result, SystemDictionary::HotSpotResolvedJavaMethodImpl_klass(),
 137                          vmSymbols::fromMetaspace_name(), vmSymbols::method_fromMetaspace_signature(), &args, THREAD);
 138 
 139   JavaValue result(T_OBJECT);
 140   if (!HAS_PENDING_EXCEPTION) {
 141     JavaCallArguments args;
 142     args.push_oop(receiver);
 143     args.push_oop(Handle(THREAD, (oop)method_result.get_jobject()));
 144     args.push_int(entry_bci);
 145     args.push_long((jlong) (address) env);
 146     args.push_int(env->task()->compile_id());
 147     JavaCalls::call_special(&result, receiver->klass(),
 148                             vmSymbols::compileMethod_name(), vmSymbols::compileMethod_signature(), &args, THREAD);
 149   }
 150 
 151   // An uncaught exception was thrown during compilation.  Generally these
 152   // should be handled by the Java code in some useful way but if they leak
 153   // through to here report them instead of dying or silently ignoring them.
 154   if (HAS_PENDING_EXCEPTION) {
 155     Handle exception(THREAD, PENDING_EXCEPTION);
 156     CLEAR_PENDING_EXCEPTION;
 157 
 158     java_lang_Throwable::java_printStackTrace(exception, THREAD);
 159     if (HAS_PENDING_EXCEPTION) {
 160       CLEAR_PENDING_EXCEPTION;
 161     }
 162 
 163     env->set_failure("exception throw", false);
 164   } else {
 165     oop result_object = (oop) result.get_jobject();
 166     if (result_object != NULL) {
 167       oop failure_message = HotSpotCompilationRequestResult::failureMessage(result_object);
 168       if (failure_message != NULL) {

 169         const char* failure_reason = java_lang_String::as_utf8_string(failure_message);
 170         env->set_failure(failure_reason, HotSpotCompilationRequestResult::retry(result_object) != 0);



 171       } else {
 172         if (env->task()->code() == NULL) {
 173           env->set_failure("no nmethod produced", true);
 174         } else {
 175           env->task()->set_num_inlined_bytecodes(HotSpotCompilationRequestResult::inlinedBytecodes(result_object));
 176           Atomic::inc(&_methods_compiled);
 177         }
 178       }
 179     } else {
 180       assert(false, "JVMCICompiler.compileMethod should always return non-null");
 181     }
 182   }
 183   if (_bootstrapping) {
 184     _bootstrap_compilation_request_handled = true;
 185   }
 186 }
 187 
 188 CompLevel JVMCIRuntime::adjust_comp_level(const methodHandle& method, bool is_osr, CompLevel level, JavaThread* thread) {
 189   if (!thread->adjusting_comp_level()) {
 190     thread->set_adjusting_comp_level(true);
 191     level = adjust_comp_level_inner(method, is_osr, level, thread);
 192     thread->set_adjusting_comp_level(false);
 193   }




 105   _bootstrapping = false;
 106   JVMCIRuntime::bootstrap_finished(CHECK);
 107 }
 108 
 109 #define CHECK_EXIT THREAD); \
 110 if (HAS_PENDING_EXCEPTION) { \
 111   char buf[256]; \
 112   jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
 113   JVMCICompiler::exit_on_pending_exception(PENDING_EXCEPTION, buf); \
 114   return; \
 115 } \
 116 (void)(0
 117 
 118 void JVMCICompiler::compile_method(const methodHandle& method, int entry_bci, JVMCIEnv* env) {
 119   JVMCI_EXCEPTION_CONTEXT
 120 
 121   bool is_osr = entry_bci != InvocationEntryBci;
 122   if (_bootstrapping && is_osr) {
 123       // no OSR compilations during bootstrap - the compiler is just too slow at this point,
 124       // and we know that there are no endless loops
 125       env->set_failure(true, "No OSR during boostrap");
 126       return;
 127   }
 128 
 129   JVMCIRuntime::initialize_well_known_classes(CHECK_EXIT);
 130 
 131   HandleMark hm;
 132   Handle receiver = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK_EXIT);
 133 
 134   JavaValue method_result(T_OBJECT);
 135   JavaCallArguments args;
 136   args.push_long((jlong) (address) method());
 137   JavaCalls::call_static(&method_result, SystemDictionary::HotSpotResolvedJavaMethodImpl_klass(),
 138                          vmSymbols::fromMetaspace_name(), vmSymbols::method_fromMetaspace_signature(), &args, THREAD);
 139 
 140   JavaValue result(T_OBJECT);
 141   if (!HAS_PENDING_EXCEPTION) {
 142     JavaCallArguments args;
 143     args.push_oop(receiver);
 144     args.push_oop(Handle(THREAD, (oop)method_result.get_jobject()));
 145     args.push_int(entry_bci);
 146     args.push_long((jlong) (address) env);
 147     args.push_int(env->task()->compile_id());
 148     JavaCalls::call_special(&result, receiver->klass(),
 149                             vmSymbols::compileMethod_name(), vmSymbols::compileMethod_signature(), &args, THREAD);
 150   }
 151 
 152   // An uncaught exception was thrown during compilation.  Generally these
 153   // should be handled by the Java code in some useful way but if they leak
 154   // through to here report them instead of dying or silently ignoring them.
 155   if (HAS_PENDING_EXCEPTION) {
 156     Handle exception(THREAD, PENDING_EXCEPTION);
 157     CLEAR_PENDING_EXCEPTION;
 158 
 159     java_lang_Throwable::java_printStackTrace(exception, THREAD);
 160     if (HAS_PENDING_EXCEPTION) {
 161       CLEAR_PENDING_EXCEPTION;
 162     }
 163 
 164     env->set_failure(false, "unexpected exception thrown");
 165   } else {
 166     oop result_object = (oop) result.get_jobject();
 167     if (result_object != NULL) {
 168       oop failure_message = HotSpotCompilationRequestResult::failureMessage(result_object);
 169       if (failure_message != NULL) {
 170         // Copy failure reason into resource memory first ...
 171         const char* failure_reason = java_lang_String::as_utf8_string(failure_message);
 172         // ... and then into the C heap.
 173         failure_reason = os::strdup(failure_reason, mtCompiler);
 174         bool retryable = HotSpotCompilationRequestResult::retry(result_object) != 0;
 175         env->set_failure(retryable, failure_reason, true);
 176       } else {
 177         if (env->task()->code() == NULL) {
 178           env->set_failure(true, "no nmethod produced");
 179         } else {
 180           env->task()->set_num_inlined_bytecodes(HotSpotCompilationRequestResult::inlinedBytecodes(result_object));
 181           Atomic::inc(&_methods_compiled);
 182         }
 183       }
 184     } else {
 185       assert(false, "JVMCICompiler.compileMethod should always return non-null");
 186     }
 187   }
 188   if (_bootstrapping) {
 189     _bootstrap_compilation_request_handled = true;
 190   }
 191 }
 192 
 193 CompLevel JVMCIRuntime::adjust_comp_level(const methodHandle& method, bool is_osr, CompLevel level, JavaThread* thread) {
 194   if (!thread->adjusting_comp_level()) {
 195     thread->set_adjusting_comp_level(true);
 196     level = adjust_comp_level_inner(method, is_osr, level, thread);
 197     thread->set_adjusting_comp_level(false);
 198   }


< prev index next >