Blame SOURCES/8162384-pr3122-rh1358661.patch

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