8218163: C2: Continuous deoptimization w/ Reason_speculate_class_check and Action_none
authorvlivanov
Fri, 01 Feb 2019 18:51:14 -0800
changeset 53625 0a9dfdbb01d1
parent 53624 8b81c509995e
child 53626 e2fc434b410a
8218163: C2: Continuous deoptimization w/ Reason_speculate_class_check and Action_none Reviewed-by: kvn, neliasso
src/hotspot/share/opto/compile.hpp
src/hotspot/share/opto/doCall.cpp
src/hotspot/share/opto/graphKit.cpp
src/hotspot/share/opto/graphKit.hpp
--- a/src/hotspot/share/opto/compile.hpp	Fri Feb 01 18:50:53 2019 -0800
+++ b/src/hotspot/share/opto/compile.hpp	Fri Feb 01 18:51:14 2019 -0800
@@ -1025,6 +1025,11 @@
                       ciMethodData* logmd = NULL);
   // Report if there were too many recompiles at a method and bci.
   bool too_many_recompiles(ciMethod* method, int bci, Deoptimization::DeoptReason reason);
+  // Report if there were too many traps or recompiles at a method and bci.
+  bool too_many_traps_or_recompiles(ciMethod* method, int bci, Deoptimization::DeoptReason reason) {
+    return too_many_traps(method, bci, reason) ||
+           too_many_recompiles(method, bci, reason);
+  }
   // Return a bitset with the reasons where deoptimization is allowed,
   // i.e., where there were not too many uncommon traps.
   int _allowed_reasons;
--- a/src/hotspot/share/opto/doCall.cpp	Fri Feb 01 18:50:53 2019 -0800
+++ b/src/hotspot/share/opto/doCall.cpp	Fri Feb 01 18:51:14 2019 -0800
@@ -209,7 +209,7 @@
 
       int morphism = profile.morphism();
       if (speculative_receiver_type != NULL) {
-        if (!too_many_traps(caller, bci, Deoptimization::Reason_speculate_class_check)) {
+        if (!too_many_traps_or_recompiles(caller, bci, Deoptimization::Reason_speculate_class_check)) {
           // We have a speculative type, we should be able to resolve
           // the call. We do that before looking at the profiling at
           // this invoke because it may lead to bimorphic inlining which
@@ -262,7 +262,7 @@
                                                ? Deoptimization::Reason_bimorphic
                                                : Deoptimization::reason_class_check(speculative_receiver_type != NULL));
           if ((morphism == 1 || (morphism == 2 && next_hit_cg != NULL)) &&
-              !too_many_traps(caller, bci, reason)
+              !too_many_traps_or_recompiles(caller, bci, reason)
              ) {
             // Generate uncommon trap for class check failure path
             // in case of monomorphic or bimorphic virtual call site.
--- a/src/hotspot/share/opto/graphKit.cpp	Fri Feb 01 18:50:53 2019 -0800
+++ b/src/hotspot/share/opto/graphKit.cpp	Fri Feb 01 18:51:14 2019 -0800
@@ -2852,7 +2852,7 @@
   Deoptimization::DeoptReason reason = Deoptimization::reason_class_check(spec_klass != NULL);
 
   // Make sure we haven't already deoptimized from this tactic.
-  if (too_many_traps(reason) || too_many_recompiles(reason))
+  if (too_many_traps_or_recompiles(reason))
     return NULL;
 
   // (No, this isn't a call, but it's enough like a virtual call
@@ -2907,9 +2907,8 @@
     Deoptimization::DeoptReason class_reason = Deoptimization::Reason_speculate_class_check;
     Deoptimization::DeoptReason null_reason = Deoptimization::Reason_speculate_null_check;
 
-    if (!too_many_traps(null_reason) && !too_many_recompiles(null_reason) &&
-        !too_many_traps(class_reason) &&
-        !too_many_recompiles(class_reason)) {
+    if (!too_many_traps_or_recompiles(null_reason) &&
+        !too_many_traps_or_recompiles(class_reason)) {
       Node* not_null_obj = NULL;
       // not_null is true if we know the object is not null and
       // there's no need for a null check
@@ -2934,8 +2933,7 @@
       obj = exact_obj;
     }
   } else {
-    if (!too_many_traps(Deoptimization::Reason_null_assert) &&
-        !too_many_recompiles(Deoptimization::Reason_null_assert)) {
+    if (!too_many_traps_or_recompiles(Deoptimization::Reason_null_assert)) {
       Node* exact_obj = null_assert(obj);
       replace_in_map(obj, exact_obj);
       obj = exact_obj;
--- a/src/hotspot/share/opto/graphKit.hpp	Fri Feb 01 18:50:53 2019 -0800
+++ b/src/hotspot/share/opto/graphKit.hpp	Fri Feb 01 18:51:14 2019 -0800
@@ -751,6 +751,10 @@
     return C->too_many_recompiles(method(), bci(), reason);
   }
 
+  bool too_many_traps_or_recompiles(Deoptimization::DeoptReason reason) {
+      return C->too_many_traps_or_recompiles(method(), bci(), reason);
+  }
+
   // Returns the object (if any) which was created the moment before.
   Node* just_allocated_object(Node* current_control);