< prev index next >

src/hotspot/share/runtime/sharedRuntime.cpp

Print this page

        

@@ -762,13 +762,22 @@
   // Increment counter for hs_err file reporting
   Atomic::inc(&Exceptions::_stack_overflow_errors);
   throw_and_post_jvmti_exception(thread, exception);
 }
 
+#if INCLUDE_JVMCI
+address SharedRuntime::deoptimize_for_implicit_exception(JavaThread* thread, address pc, CompiledMethod* nm, int deopt_reason) {
+  assert(deopt_reason > Deoptimization::Reason_none && deopt_reason < Deoptimization::Reason_LIMIT, "invalid deopt reason");
+  thread->set_jvmci_implicit_exception_pc(pc);
+  thread->set_pending_deoptimization(Deoptimization::make_trap_request((Deoptimization::DeoptReason)deopt_reason, Deoptimization::Action_reinterpret));
+  return (SharedRuntime::deopt_blob()->implicit_exception_uncommon_trap());
+}
+#endif // INCLUDE_JVMCI
+
 address SharedRuntime::continuation_for_implicit_exception(JavaThread* thread,
                                                            address pc,
-                                                           ImplicitExceptionKind exception_kind)
+                                                           SharedRuntime::ImplicitExceptionKind exception_kind)
 {
   address target_pc = NULL;
 
   if (Interpreter::contains(pc)) {
 #ifdef CC_INTERP

@@ -865,11 +874,23 @@
           }
 
 #ifndef PRODUCT
           _implicit_null_throws++;
 #endif
-          target_pc = cm->continuation_for_implicit_null_exception(pc);
+#if INCLUDE_JVMCI
+          if (cm->is_compiled_by_jvmci() && cm->pc_desc_at(pc) != NULL) {
+            // If there's no PcDesc then we'll die way down inside of
+            // deopt instead of just getting normal error reporting,
+            // so only go there if it will succeed.
+            return deoptimize_for_implicit_exception(thread, pc, cm, Deoptimization::Reason_null_check);
+          } else {
+#endif // INCLUDE_JVMCI
+          assert (cm->is_nmethod(), "Expect nmethod");
+          target_pc = ((nmethod*)cm)->continuation_for_implicit_exception(pc);
+#if INCLUDE_JVMCI
+          }
+#endif // INCLUDE_JVMCI
           // If there's an unexpected fault, target_pc might be NULL,
           // in which case we want to fall through into the normal
           // error handling code.
         }
 

@@ -881,11 +902,19 @@
         CompiledMethod* cm = CodeCache::find_compiled(pc);
         guarantee(cm != NULL, "must have containing compiled method for implicit division-by-zero exceptions");
 #ifndef PRODUCT
         _implicit_div0_throws++;
 #endif
-        target_pc = cm->continuation_for_implicit_div0_exception(pc);
+#if INCLUDE_JVMCI
+        if (cm->is_compiled_by_jvmci() && cm->pc_desc_at(pc) != NULL) {
+          return deoptimize_for_implicit_exception(thread, pc, cm, Deoptimization::Reason_div0_check);
+        } else {
+#endif // INCLUDE_JVMCI
+        target_pc = cm->continuation_for_implicit_exception(pc);
+#if INCLUDE_JVMCI
+        }
+#endif // INCLUDE_JVMCI
         // If there's an unexpected fault, target_pc might be NULL,
         // in which case we want to fall through into the normal
         // error handling code.
         break; // fall through
       }
< prev index next >