< prev index next >

src/hotspot/share/jvmci/jvmciRuntime.cpp

Print this page

        

@@ -936,10 +936,12 @@
     int exception_line = THREAD->exception_line();
     CLEAR_PENDING_EXCEPTION;
     if (exception->is_a(SystemDictionary::ThreadDeath_klass())) {
       // Don't print anything if we are being killed.
     } else {
+      java_lang_Throwable::print(exception(), tty);
+      tty->cr();
       java_lang_Throwable::print_stack_trace(exception, tty);
 
       // Clear and ignore any exceptions raised during printing
       CLEAR_PENDING_EXCEPTION;
     }

@@ -1337,22 +1339,10 @@
   // without any intervening modification of the system
   // dictionary.  That means they were invalidly constructed.
   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
 
   JVMCICompileState* compile_state = JVMCIENV->compile_state();

@@ -1370,11 +1360,13 @@
   }
 
   HandleMark hm;
   JVMCIObject receiver = get_HotSpotJVMCIRuntime(JVMCIENV);
   if (JVMCIENV->has_pending_exception()) {
-    fatal_exception_in_compile(JVMCIENV, thread, "Exception during HotSpotJVMCIRuntime initialization");
+    JVMCIENV->describe_pending_exception(true);
+    compile_state->set_failure(false, "exception getting HotSpotJVMCIRuntime object");
+    return;
   }
   JVMCIObject jvmci_method = JVMCIENV->get_jvmci_method(method, JVMCIENV);
   if (JVMCIENV->has_pending_exception()) {
     JVMCIENV->describe_pending_exception(true);
     compile_state->set_failure(false, "exception getting JVMCI wrapper method");

@@ -1403,13 +1395,15 @@
       }
     } else {
       assert(false, "JVMCICompiler.compileMethod should always return non-null");
     }
   } else {
-    // An uncaught exception here implies failure during compiler initialization.
-    // The only sensible thing to do here is to exit the VM.
-    fatal_exception_in_compile(JVMCIENV, thread, "Exception during JVMCI compiler initialization");
+    // An uncaught exception was thrown during compilation. Generally these
+    // should be handled by the Java code in some useful way but if they leak
+    // through to here report them instead of dying or silently ignoring them.
+    JVMCIENV->describe_pending_exception(true);
+    compile_state->set_failure(false, "unexpected exception thrown");
   }
   if (compiler->is_bootstrapping()) {
     compiler->set_bootstrap_compilation_request_handled();
   }
 }

@@ -1424,11 +1418,10 @@
                                 int orig_pc_offset,
                                 CodeBuffer* code_buffer,
                                 int frame_words,
                                 OopMapSet* oop_map_set,
                                 ExceptionHandlerTable* handler_table,
-                                ImplicitExceptionTable* implicit_exception_table,
                                 AbstractCompiler* compiler,
                                 DebugInformationRecorder* debug_info,
                                 Dependencies* dependencies,
                                 int compile_id,
                                 bool has_unsafe_access,

@@ -1494,18 +1487,19 @@
       // All buffers in the CodeBuffer are allocated in the CodeCache.
       // If the code buffer is created on each compile attempt
       // as in C2, then it must be freed.
       //code_buffer->free_blob();
     } else {
+      ImplicitExceptionTable implicit_tbl;
       nm =  nmethod::new_nmethod(method,
                                  compile_id,
                                  entry_bci,
                                  offsets,
                                  orig_pc_offset,
                                  debug_info, dependencies, code_buffer,
                                  frame_words, oop_map_set,
-                                 handler_table, implicit_exception_table,
+                                 handler_table, &implicit_tbl,
                                  compiler, comp_level,
                                  speculations, speculations_len,
                                  nmethod_mirror_index, nmethod_mirror_name, failed_speculations);
 
 

@@ -1542,27 +1536,29 @@
               }
               if (old != NULL ) {
                 old->make_not_entrant();
               }
             }
-
-            LogTarget(Info, nmethod, install) lt;
-            if (lt.is_enabled()) {
+            if (TraceNMethodInstalls) {
               ResourceMark rm;
               char *method_name = method->name_and_sig_as_C_string();
-              lt.print("Installing method (%d) %s [entry point: %p]",
-                        comp_level, method_name, nm->entry_point());
+              ttyLocker ttyl;
+              tty->print_cr("Installing method (%d) %s [entry point: %p]",
+                            comp_level,
+                            method_name, nm->entry_point());
             }
             // Allow the code to be executed
             method->set_code(method, nm);
           } else {
-            LogTarget(Info, nmethod, install) lt;
-            if (lt.is_enabled()) {
+            if (TraceNMethodInstalls ) {
               ResourceMark rm;
               char *method_name = method->name_and_sig_as_C_string();
-              lt.print("Installing osr method (%d) %s @ %d",
-                        comp_level, method_name, entry_bci);
+              ttyLocker ttyl;
+              tty->print_cr("Installing osr method (%d) %s @ %d",
+                            comp_level,
+                            method_name,
+                            entry_bci);
             }
             InstanceKlass::cast(method->method_holder())->add_osr_nmethod(nm);
           }
         } else {
           assert(!nmethod_mirror.is_hotspot() || data->get_nmethod_mirror(nm) == HotSpotJVMCI::resolve(nmethod_mirror), "must be");
< prev index next >