Blame SOURCES/8162384-pr3122-rh1358661.patch

2b939e
# HG changeset patch
2b939e
# User roland
2b939e
# Date 1469615613 -7200
2b939e
#      Wed Jul 27 12:33:33 2016 +0200
2b939e
# Node ID fd29eff8b797daa41a68394ced7fe80c9e8c96e9
2b939e
# Parent  ee9bffb3bd390b2ad805c7b59d7d2ab8a68a4367
2b939e
8162384, PR3122: Performance regression: bimorphic inlining may be bypassed by type speculation
2b939e
Summary: when speculation fails at a call fallback to profile data at the call site
2b939e
Reviewed-by: kvn
2b939e
2b939e
diff -r ee9bffb3bd39 -r fd29eff8b797 src/share/vm/opto/doCall.cpp
2b939e
--- openjdk/hotspot/src/share/vm/opto/doCall.cpp	Mon Aug 01 16:33:54 2016 +0100
2b939e
+++ openjdk/hotspot/src/share/vm/opto/doCall.cpp	Wed Jul 27 12:33:33 2016 +0200
2b939e
@@ -205,16 +205,22 @@
2b939e
 
2b939e
       int morphism = profile.morphism();
2b939e
       if (speculative_receiver_type != NULL) {
2b939e
-        // We have a speculative type, we should be able to resolve
2b939e
-        // the call. We do that before looking at the profiling at
2b939e
-        // this invoke because it may lead to bimorphic inlining which
2b939e
-        // a speculative type should help us avoid.
2b939e
-        receiver_method = callee->resolve_invoke(jvms->method()->holder(),
2b939e
-                                                 speculative_receiver_type);
2b939e
-        if (receiver_method == NULL) {
2b939e
+        if (!too_many_traps(caller, bci, Deoptimization::Reason_speculate_class_check)) {
2b939e
+          // We have a speculative type, we should be able to resolve
2b939e
+          // the call. We do that before looking at the profiling at
2b939e
+          // this invoke because it may lead to bimorphic inlining which
2b939e
+          // a speculative type should help us avoid.
2b939e
+          receiver_method = callee->resolve_invoke(jvms->method()->holder(),
2b939e
+                                                   speculative_receiver_type);
2b939e
+          if (receiver_method == NULL) {
2b939e
+            speculative_receiver_type = NULL;
2b939e
+          } else {
2b939e
+            morphism = 1;
2b939e
+          }
2b939e
+        } else {
2b939e
+          // speculation failed before. Use profiling at the call
2b939e
+          // (could allow bimorphic inlining for instance).
2b939e
           speculative_receiver_type = NULL;
2b939e
-        } else {
2b939e
-          morphism = 1;
2b939e
         }
2b939e
       }
2b939e
       if (receiver_method == NULL &&
2b939e
@@ -252,7 +258,7 @@
2b939e
                                     Deoptimization::Reason_bimorphic :
2b939e
                                     (speculative_receiver_type == NULL ? Deoptimization::Reason_class_check : Deoptimization::Reason_speculate_class_check);
2b939e
           if ((morphism == 1 || (morphism == 2 && next_hit_cg != NULL)) &&
2b939e
-              !too_many_traps(jvms->method(), jvms->bci(), reason)
2b939e
+              !too_many_traps(caller, bci, reason)
2b939e
              ) {
2b939e
             // Generate uncommon trap for class check failure path
2b939e
             // in case of monomorphic or bimorphic virtual call site.