diff -r 09cbc7b886b9 src/hotspot/share/jvmci/jvmciEnv.hpp --- a/src/hotspot/share/jvmci/jvmciEnv.hpp +++ b/src/hotspot/share/jvmci/jvmciEnv.hpp @@ -204,7 +204,15 @@ } } - jboolean clear_pending_exception(); + void clear_pending_exception() { + if (!is_hotspot()) { + JNIAccessMark jni(this); + jni()->ExceptionClear(); + } else { + Thread* THREAD = Thread::current(); + CLEAR_PENDING_EXCEPTION; + } + } // Prints an exception and stack trace of a pending exception. void describe_pending_exception(bool clear); diff -r 09cbc7b886b9 src/hotspot/share/jvmci/jvmciRuntime.cpp --- a/src/hotspot/share/jvmci/jvmciRuntime.cpp +++ b/src/hotspot/share/jvmci/jvmciRuntime.cpp @@ -1457,26 +1457,30 @@ HandleMark hm; #define CHECK_RETURN JVMCIENV); \ - if (HAS_PENDING_EXCEPTION) { \ - Handle exception(THREAD, PENDING_EXCEPTION); \ - CLEAR_PENDING_EXCEPTION; \ - \ - if (exception->is_a(SystemDictionary::ThreadDeath_klass())) { \ - /* In the special case of ThreadDeath, we need to reset the */ \ - /* pending async exception so that it is propagated. */ \ - thread->set_pending_async_exception(exception()); \ - return level; \ - } \ - tty->print("Uncaught exception while adjusting compilation level: "); \ - java_lang_Throwable::print(exception(), tty); \ - tty->cr(); \ - java_lang_Throwable::print_stack_trace(exception, tty); \ - if (HAS_PENDING_EXCEPTION) { \ - CLEAR_PENDING_EXCEPTION; \ - } \ - return level; \ - } \ - (void)(0 + if (JVMCIENV->has_pending_exception()) { \ + if (JVMCIENV->is_hotspot()) { \ + Handle exception(THREAD, PENDING_EXCEPTION); \ + CLEAR_PENDING_EXCEPTION; \ + \ + if (exception->is_a(SystemDictionary::ThreadDeath_klass())) { \ + /* In the special case of ThreadDeath, we need to reset the */ \ + /* pending async exception so that it is propagated. */ \ + thread->set_pending_async_exception(exception()); \ + return level; \ + } \ + tty->print("Uncaught exception while adjusting compilation level: "); \ + java_lang_Throwable::print(exception(), tty); \ + tty->cr(); \ + java_lang_Throwable::print_stack_trace(exception, tty); \ + if (HAS_PENDING_EXCEPTION) { \ + CLEAR_PENDING_EXCEPTION; \ + } \ + } else { \ + JVMCIENV->clear_pending_exception(); \ + } \ + return level; \ + } \ + (void)(0 THREAD_JVMCIENV(thread); @@ -1488,7 +1492,7 @@ sig = JVMCIENV->create_string(method->signature(), CHECK_RETURN); } - int comp_level = JVMCIENV->call_HotSpotJVMCIRuntime_adjustCompilationLevel(receiver, method->method_holder(), name, sig, is_osr, level, JVMCI_CHECK_EXIT_(level)); + int comp_level = JVMCIENV->call_HotSpotJVMCIRuntime_adjustCompilationLevel(receiver, method->method_holder(), name, sig, is_osr, level, CHECK_RETURN); if (comp_level < CompLevel_none || comp_level > CompLevel_full_optimization) { assert(false, "compilation level out of bounds"); return level;