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