< prev index next >

src/share/vm/jvmci/jvmciCompiler.cpp

Print this page

        

@@ -110,10 +110,19 @@
     tty->print_cr(" in " JLONG_FORMAT " ms (compiled %d methods)", os::javaTimeMillis() - start, _methodsCompiled);
   }
   _bootstrapping = false;
 }
 
+#define CHECK_ABORT THREAD); \
+if (HAS_PENDING_EXCEPTION) { \
+  char buf[256]; \
+  jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
+  JVMCICompiler::abort_on_pending_exception(PENDING_EXCEPTION, buf); \
+  return; \
+} \
+(void)(0
+
 void JVMCICompiler::compile_method(const methodHandle& method, int entry_bci, JVMCIEnv* env) {
   JVMCI_EXCEPTION_CONTEXT
 
   bool is_osr = entry_bci != InvocationEntryBci;
   if (_bootstrapping && is_osr) {

@@ -148,25 +157,47 @@
 
   // 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.
   if (HAS_PENDING_EXCEPTION) {
-    Handle throwable = PENDING_EXCEPTION;
+    Handle exception(THREAD, PENDING_EXCEPTION);
     CLEAR_PENDING_EXCEPTION;
 
-    JVMCIRuntime::call_printStackTrace(throwable, THREAD);
-    if (HAS_PENDING_EXCEPTION) {
-      CLEAR_PENDING_EXCEPTION;
+    {
+      ttyLocker ttyl;
+      java_lang_Throwable::print_stack_trace(exception, tty);
     }
 
     // Something went wrong so disable compilation at this level
     method->set_not_compilable(CompLevel_full_optimization);
   } else {
     _methodsCompiled++;
   }
 }
 
+/**
+ * Aborts the VM due to an unexpected exception.
+ */
+void JVMCICompiler::abort_on_pending_exception(Handle exception, const char* message, bool dump_core) {
+  Thread* THREAD = Thread::current();
+  CLEAR_PENDING_EXCEPTION;
+
+  {
+    ttyLocker ttyl;
+    tty->print_raw_cr(message);
+    java_lang_Throwable::print_stack_trace(exception, tty);
+  }
+
+  // Give other aborting threads to also print their stack traces.
+  // This can be very useful when debugging class initialization
+  // failures.
+  assert(THREAD->is_Java_thread(), "compiler threads should be Java threads");
+  const bool interruptible = true;
+  os::sleep(THREAD, 200, interruptible);
+
+  vm_abort(dump_core);
+}
 
 // Compilation entry point for methods
 void JVMCICompiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci, DirectiveSet* directive) {
   ShouldNotReachHere();
 }
< prev index next >