8181858: [JVMCI] JVMCI should update the trap counters when invalidating for Reason_not_compiled_exception_handler
authornever
Mon, 28 Aug 2017 15:21:47 +0000
changeset 46998 efb404beeefb
parent 46995 9e3267ffe6ec
child 46999 dd86717fe58b
8181858: [JVMCI] JVMCI should update the trap counters when invalidating for Reason_not_compiled_exception_handler Reviewed-by: kvn
hotspot/src/share/vm/runtime/deoptimization.cpp
hotspot/src/share/vm/runtime/deoptimization.hpp
hotspot/src/share/vm/runtime/sharedRuntime.cpp
--- a/hotspot/src/share/vm/runtime/deoptimization.cpp	Mon Aug 28 14:07:07 2017 +0000
+++ b/hotspot/src/share/vm/runtime/deoptimization.cpp	Mon Aug 28 15:21:47 2017 +0000
@@ -1373,6 +1373,30 @@
 
 }
 
+#if INCLUDE_JVMCI
+address Deoptimization::deoptimize_for_missing_exception_handler(CompiledMethod* cm) {
+  // there is no exception handler for this pc => deoptimize
+  cm->make_not_entrant();
+
+  // Use Deoptimization::deoptimize for all of its side-effects:
+  // revoking biases of monitors, gathering traps statistics, logging...
+  // it also patches the return pc but we do not care about that
+  // since we return a continuation to the deopt_blob below.
+  JavaThread* thread = JavaThread::current();
+  RegisterMap reg_map(thread, UseBiasedLocking);
+  frame runtime_frame = thread->last_frame();
+  frame caller_frame = runtime_frame.sender(&reg_map);
+  assert(caller_frame.cb()->as_nmethod_or_null() == cm, "expect top frame nmethod");
+  Deoptimization::deoptimize(thread, caller_frame, &reg_map, Deoptimization::Reason_not_compiled_exception_handler);
+
+  MethodData* trap_mdo = get_method_data(thread, cm->method(), true);
+  if (trap_mdo != NULL) {
+    trap_mdo->inc_trap_count(Deoptimization::Reason_not_compiled_exception_handler);
+  }
+
+  return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
+}
+#endif
 
 void Deoptimization::deoptimize_frame_internal(JavaThread* thread, intptr_t* id, DeoptReason reason) {
   assert(thread == Thread::current() || SafepointSynchronize::is_at_safepoint(),
--- a/hotspot/src/share/vm/runtime/deoptimization.hpp	Mon Aug 28 14:07:07 2017 +0000
+++ b/hotspot/src/share/vm/runtime/deoptimization.hpp	Mon Aug 28 15:21:47 2017 +0000
@@ -136,6 +136,10 @@
   static void deoptimize(JavaThread* thread, frame fr, RegisterMap *reg_map);
   static void deoptimize(JavaThread* thread, frame fr, RegisterMap *reg_map, DeoptReason reason);
 
+#if INCLUDE_JVMCI
+  static address deoptimize_for_missing_exception_handler(CompiledMethod* cm);
+#endif
+
   private:
   // Does the actual work for deoptimizing a single frame
   static void deoptimize_single_frame(JavaThread* thread, frame fr, DeoptReason reason);
--- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp	Mon Aug 28 14:07:07 2017 +0000
+++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp	Mon Aug 28 15:21:47 2017 +0000
@@ -638,20 +638,7 @@
     if (t != NULL) {
       return cm->code_begin() + t->pco();
     } else {
-      // there is no exception handler for this pc => deoptimize
-      cm->make_not_entrant();
-
-      // Use Deoptimization::deoptimize for all of its side-effects:
-      // revoking biases of monitors, gathering traps statistics, logging...
-      // it also patches the return pc but we do not care about that
-      // since we return a continuation to the deopt_blob below.
-      JavaThread* thread = JavaThread::current();
-      RegisterMap reg_map(thread, UseBiasedLocking);
-      frame runtime_frame = thread->last_frame();
-      frame caller_frame = runtime_frame.sender(&reg_map);
-      Deoptimization::deoptimize(thread, caller_frame, &reg_map, Deoptimization::Reason_not_compiled_exception_handler);
-
-      return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
+      return Deoptimization::deoptimize_for_missing_exception_handler(cm);
     }
   }
 #endif // INCLUDE_JVMCI