921 JVMCIENV->call_HotSpotJVMCIRuntime_shutdown(_HotSpotJVMCIRuntime_instance); 922 } 923 } 924 925 void JVMCIRuntime::bootstrap_finished(TRAPS) { 926 if (is_HotSpotJVMCIRuntime_initialized()) { 927 THREAD_JVMCIENV(JavaThread::current()); 928 JVMCIENV->call_HotSpotJVMCIRuntime_bootstrapFinished(_HotSpotJVMCIRuntime_instance, JVMCIENV); 929 } 930 } 931 932 void JVMCIRuntime::describe_pending_hotspot_exception(JavaThread* THREAD, bool clear) { 933 if (HAS_PENDING_EXCEPTION) { 934 Handle exception(THREAD, PENDING_EXCEPTION); 935 const char* exception_file = THREAD->exception_file(); 936 int exception_line = THREAD->exception_line(); 937 CLEAR_PENDING_EXCEPTION; 938 if (exception->is_a(SystemDictionary::ThreadDeath_klass())) { 939 // Don't print anything if we are being killed. 940 } else { 941 java_lang_Throwable::print(exception(), tty); 942 tty->cr(); 943 java_lang_Throwable::print_stack_trace(exception, tty); 944 945 // Clear and ignore any exceptions raised during printing 946 CLEAR_PENDING_EXCEPTION; 947 } 948 if (!clear) { 949 THREAD->set_pending_exception(exception(), exception_file, exception_line); 950 } 951 } 952 } 953 954 955 void JVMCIRuntime::exit_on_pending_exception(JVMCIEnv* JVMCIENV, const char* message) { 956 JavaThread* THREAD = JavaThread::current(); 957 958 static volatile int report_error = 0; 959 if (!report_error && Atomic::cmpxchg(1, &report_error, 0) == 0) { 960 // Only report an error once 961 tty->print_raw_cr(message); 962 if (JVMCIENV != NULL) { 1380 JVMCIObject failure_message = JVMCIENV->get_HotSpotCompilationRequestResult_failureMessage(result_object); 1381 if (failure_message.is_non_null()) { 1382 // Copy failure reason into resource memory first ... 1383 const char* failure_reason = JVMCIENV->as_utf8_string(failure_message); 1384 // ... and then into the C heap. 1385 failure_reason = os::strdup(failure_reason, mtJVMCI); 1386 bool retryable = JVMCIENV->get_HotSpotCompilationRequestResult_retry(result_object) != 0; 1387 compile_state->set_failure(retryable, failure_reason, true); 1388 } else { 1389 if (compile_state->task()->code() == NULL) { 1390 compile_state->set_failure(true, "no nmethod produced"); 1391 } else { 1392 compile_state->task()->set_num_inlined_bytecodes(JVMCIENV->get_HotSpotCompilationRequestResult_inlinedBytecodes(result_object)); 1393 compiler->inc_methods_compiled(); 1394 } 1395 } 1396 } else { 1397 assert(false, "JVMCICompiler.compileMethod should always return non-null"); 1398 } 1399 } else { 1400 // An uncaught exception was thrown during compilation. Generally these 1401 // should be handled by the Java code in some useful way but if they leak 1402 // through to here report them instead of dying or silently ignoring them. 1403 JVMCIENV->describe_pending_exception(true); 1404 compile_state->set_failure(false, "unexpected exception thrown"); 1405 } 1406 if (compiler->is_bootstrapping()) { 1407 compiler->set_bootstrap_compilation_request_handled(); 1408 } 1409 } 1410 1411 1412 // ------------------------------------------------------------------ 1413 JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV, 1414 const methodHandle& method, 1415 nmethod*& nm, 1416 int entry_bci, 1417 CodeOffsets* offsets, 1418 int orig_pc_offset, 1419 CodeBuffer* code_buffer, 1420 int frame_words, 1421 OopMapSet* oop_map_set, 1422 ExceptionHandlerTable* handler_table, 1423 AbstractCompiler* compiler, 1424 DebugInformationRecorder* debug_info, | 921 JVMCIENV->call_HotSpotJVMCIRuntime_shutdown(_HotSpotJVMCIRuntime_instance); 922 } 923 } 924 925 void JVMCIRuntime::bootstrap_finished(TRAPS) { 926 if (is_HotSpotJVMCIRuntime_initialized()) { 927 THREAD_JVMCIENV(JavaThread::current()); 928 JVMCIENV->call_HotSpotJVMCIRuntime_bootstrapFinished(_HotSpotJVMCIRuntime_instance, JVMCIENV); 929 } 930 } 931 932 void JVMCIRuntime::describe_pending_hotspot_exception(JavaThread* THREAD, bool clear) { 933 if (HAS_PENDING_EXCEPTION) { 934 Handle exception(THREAD, PENDING_EXCEPTION); 935 const char* exception_file = THREAD->exception_file(); 936 int exception_line = THREAD->exception_line(); 937 CLEAR_PENDING_EXCEPTION; 938 if (exception->is_a(SystemDictionary::ThreadDeath_klass())) { 939 // Don't print anything if we are being killed. 940 } else { 941 java_lang_Throwable::print_stack_trace(exception, tty); 942 943 // Clear and ignore any exceptions raised during printing 944 CLEAR_PENDING_EXCEPTION; 945 } 946 if (!clear) { 947 THREAD->set_pending_exception(exception(), exception_file, exception_line); 948 } 949 } 950 } 951 952 953 void JVMCIRuntime::exit_on_pending_exception(JVMCIEnv* JVMCIENV, const char* message) { 954 JavaThread* THREAD = JavaThread::current(); 955 956 static volatile int report_error = 0; 957 if (!report_error && Atomic::cmpxchg(1, &report_error, 0) == 0) { 958 // Only report an error once 959 tty->print_raw_cr(message); 960 if (JVMCIENV != NULL) { 1378 JVMCIObject failure_message = JVMCIENV->get_HotSpotCompilationRequestResult_failureMessage(result_object); 1379 if (failure_message.is_non_null()) { 1380 // Copy failure reason into resource memory first ... 1381 const char* failure_reason = JVMCIENV->as_utf8_string(failure_message); 1382 // ... and then into the C heap. 1383 failure_reason = os::strdup(failure_reason, mtJVMCI); 1384 bool retryable = JVMCIENV->get_HotSpotCompilationRequestResult_retry(result_object) != 0; 1385 compile_state->set_failure(retryable, failure_reason, true); 1386 } else { 1387 if (compile_state->task()->code() == NULL) { 1388 compile_state->set_failure(true, "no nmethod produced"); 1389 } else { 1390 compile_state->task()->set_num_inlined_bytecodes(JVMCIENV->get_HotSpotCompilationRequestResult_inlinedBytecodes(result_object)); 1391 compiler->inc_methods_compiled(); 1392 } 1393 } 1394 } else { 1395 assert(false, "JVMCICompiler.compileMethod should always return non-null"); 1396 } 1397 } else { 1398 // An uncaught exception here implies failure during compiler initialization. 1399 // The only sensible thing to do here is to exit the VM. 1400 1401 // Only report initialization failure once 1402 static volatile int report_init_failure = 0; 1403 if (!report_init_failure && Atomic::cmpxchg(1, &report_init_failure, 0) == 0) { 1404 tty->print_cr("Exception during JVMCI compiler initialization:"); 1405 JVMCIENV->describe_pending_exception(true); 1406 } 1407 JVMCIENV->clear_pending_exception(); 1408 before_exit((JavaThread*) THREAD); 1409 vm_exit(-1); 1410 } 1411 if (compiler->is_bootstrapping()) { 1412 compiler->set_bootstrap_compilation_request_handled(); 1413 } 1414 } 1415 1416 1417 // ------------------------------------------------------------------ 1418 JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV, 1419 const methodHandle& method, 1420 nmethod*& nm, 1421 int entry_bci, 1422 CodeOffsets* offsets, 1423 int orig_pc_offset, 1424 CodeBuffer* code_buffer, 1425 int frame_words, 1426 OopMapSet* oop_map_set, 1427 ExceptionHandlerTable* handler_table, 1428 AbstractCompiler* compiler, 1429 DebugInformationRecorder* debug_info, |