changeset 24166:dad95e57f1de

Update MDO with Reason_not_compiled_exception_handler
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Mon, 14 Aug 2017 08:55:23 -0700
parents fbcbf83757cb
children ac6f03d5b89e
files src/share/vm/runtime/deoptimization.cpp src/share/vm/runtime/deoptimization.hpp src/share/vm/runtime/sharedRuntime.cpp
diffstat 3 files changed, 23 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/runtime/deoptimization.cpp	Sat Aug 12 12:40:51 2017 +0200
+++ b/src/share/vm/runtime/deoptimization.cpp	Mon Aug 14 08:55:23 2017 -0700
@@ -1369,6 +1369,26 @@
 
 }
 
+address Deoptimization::deoptimize_for_missing_exception_handler(nmethod* nm) {
+  // there is no exception handler for this pc => deoptimize
+  nm->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() == nm, "expect top frame nmethod");
+  Deoptimization::deoptimize(thread, caller_frame, &reg_map, Deoptimization::Reason_not_compiled_exception_handler);
+
+  MethodData* trap_mdo = get_method_data(thread, nm->method(), true);
+  trap_mdo->inc_trap_count(Deoptimization::Reason_not_compiled_exception_handler);
+
+  return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
+}
 
 void Deoptimization::deoptimize_frame_internal(JavaThread* thread, intptr_t* id, DeoptReason reason) {
   assert(thread == Thread::current() || SafepointSynchronize::is_at_safepoint(),
--- a/src/share/vm/runtime/deoptimization.hpp	Sat Aug 12 12:40:51 2017 +0200
+++ b/src/share/vm/runtime/deoptimization.hpp	Mon Aug 14 08:55:23 2017 -0700
@@ -128,6 +128,8 @@
   static void deoptimize(JavaThread* thread, frame fr, RegisterMap *reg_map);
   static void deoptimize(JavaThread* thread, frame fr, RegisterMap *reg_map, DeoptReason reason);
 
+  static address deoptimize_for_missing_exception_handler(nmethod* nm);
+
   private:
   // Does the actual work for deoptimizing a single frame
   static void deoptimize_single_frame(JavaThread* thread, frame fr, DeoptReason reason);
--- a/src/share/vm/runtime/sharedRuntime.cpp	Sat Aug 12 12:40:51 2017 +0200
+++ b/src/share/vm/runtime/sharedRuntime.cpp	Mon Aug 14 08:55:23 2017 -0700
@@ -659,20 +659,7 @@
     if (t != NULL) {
       return nm->code_begin() + t->pco();
     } else {
-      // there is no exception handler for this pc => deoptimize
-      nm->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(nm);
     }
   }
 #endif