src/hotspot/share/jvmci/jvmciRuntime.cpp
changeset 55317 b76aee290002
parent 55293 d19dc5b10fbb
child 55454 8892555795cd
--- a/src/hotspot/share/jvmci/jvmciRuntime.cpp	Mon Jun 10 13:42:11 2019 -0400
+++ b/src/hotspot/share/jvmci/jvmciRuntime.cpp	Mon Jun 10 15:55:11 2019 -0700
@@ -1339,6 +1339,18 @@
   return JVMCI::dependencies_invalid;
 }
 
+// Reports a pending exception and exits the VM.
+static void fatal_exception_in_compile(JVMCIEnv* JVMCIENV, JavaThread* thread, const char* msg) {
+  // Only report a fatal JVMCI compilation exception once
+  static volatile int report_init_failure = 0;
+  if (!report_init_failure && Atomic::cmpxchg(1, &report_init_failure, 0) == 0) {
+      tty->print_cr("%s:", msg);
+      JVMCIENV->describe_pending_exception(true);
+  }
+  JVMCIENV->clear_pending_exception();
+  before_exit(thread);
+  vm_exit(-1);
+}
 
 void JVMCIRuntime::compile_method(JVMCIEnv* JVMCIENV, JVMCICompiler* compiler, const methodHandle& method, int entry_bci) {
   JVMCI_EXCEPTION_CONTEXT
@@ -1360,9 +1372,7 @@
   HandleMark hm;
   JVMCIObject receiver = get_HotSpotJVMCIRuntime(JVMCIENV);
   if (JVMCIENV->has_pending_exception()) {
-    JVMCIENV->describe_pending_exception(true);
-    compile_state->set_failure(false, "exception getting HotSpotJVMCIRuntime object");
-    return;
+    fatal_exception_in_compile(JVMCIENV, thread, "Exception during HotSpotJVMCIRuntime initialization");
   }
   JVMCIObject jvmci_method = JVMCIENV->get_jvmci_method(method, JVMCIENV);
   if (JVMCIENV->has_pending_exception()) {
@@ -1397,16 +1407,7 @@
   } else {
     // An uncaught exception here implies failure during compiler initialization.
     // The only sensible thing to do here is to exit the VM.
-
-    // Only report initialization failure once
-    static volatile int report_init_failure = 0;
-    if (!report_init_failure && Atomic::cmpxchg(1, &report_init_failure, 0) == 0) {
-        tty->print_cr("Exception during JVMCI compiler initialization:");
-        JVMCIENV->describe_pending_exception(true);
-    }
-    JVMCIENV->clear_pending_exception();
-    before_exit((JavaThread*) THREAD);
-    vm_exit(-1);
+    fatal_exception_in_compile(JVMCIENV, thread, "Exception during JVMCI compiler initialization");
   }
   if (compiler->is_bootstrapping()) {
     compiler->set_bootstrap_compilation_request_handled();