changeset 10080:e04f128d719c

cannot use DeoptimizationAction.None for deoptimizing instanceof snippet since it will miss application phase changes, causing repeated and expensive deoptimization
author Doug Simon <doug.simon@oracle.com>
date Tue, 18 Jun 2013 12:46:06 +0200
parents 77772d794ffd
children 20fd8760cb34
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java	Tue Jun 18 11:01:32 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java	Tue Jun 18 12:46:06 2013 +0200
@@ -83,8 +83,8 @@
         if (probability(NOT_FREQUENT_PROBABILITY, checkNull && object == null)) {
             isNull.inc();
             if (!nullSeen) {
-                // In this case, the execution is contradicting the profile
-                // so invalidating and re-profiling is justified.
+                // See comment below for other deoptimization path; the
+                // same reasoning applies here.
                 DeoptimizeNode.deopt(InvalidateReprofile, OptimizedTypeCheckViolated);
             }
             return falseValue;
@@ -100,9 +100,11 @@
                 return positive ? trueValue : falseValue;
             }
         }
-        // Don't throw away the code as we assume this is a rare event
-        // that will periodically occur.
-        DeoptimizeNode.deopt(DeoptimizationAction.None, OptimizedTypeCheckViolated);
+        // This maybe just be a rare event but it might also indicate a phase change
+        // in the application. Ideally we want to use DeoptimizationAction.None for
+        // the former but the cost is too high if indeed it is the latter. As such,
+        // we defensively opt for InvalidateReprofile.
+        DeoptimizeNode.deopt(DeoptimizationAction.InvalidateReprofile, OptimizedTypeCheckViolated);
         return falseValue;
     }