changeset 9195:78017d2c8bea

InstanceOfNode: remove duplicated code
author Bernhard Urban <bernhard.urban@jku.at>
date Fri, 19 Apr 2013 10:09:30 +0200
parents cdd10396f2ad
children 31c1168e1a8e
files graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java
diffstat 1 files changed, 8 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java	Fri Apr 19 14:06:22 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java	Fri Apr 19 10:09:30 2013 +0200
@@ -63,7 +63,7 @@
         ObjectStamp stamp = object().objectStamp();
         ResolvedJavaType stampType = stamp.type();
 
-        if (stamp.isExactType()) {
+        if (stamp.isExactType() || stampType != null) {
             boolean subType = type().isAssignableFrom(stampType);
 
             if (subType) {
@@ -77,27 +77,15 @@
                     return graph().unique(new IsNullNode(object()));
                 }
             } else {
-                // since this type check failed for an exact type we know that it can never succeed
-                // at run time.
-                // we also don't care about null values, since they will also make the check fail.
-                return LogicConstantNode.contradiction(graph());
-            }
-        } else if (stampType != null) {
-            boolean subType = type().isAssignableFrom(stampType);
-
-            if (subType) {
-                if (stamp.nonNull()) {
-                    // the instanceOf matches, so return true
-                    return LogicConstantNode.tautology(graph());
+                if (stamp.isExactType()) {
+                    // since this type check failed for an exact type we know that it can never
+                    // succeed at run time. we also don't care about null values, since they will
+                    // also make the check fail.
+                    return LogicConstantNode.contradiction(graph());
                 } else {
-                    // the instanceof matches if the object is non-null, so return true depending on
-                    // the null-ness.
-                    negateUsages();
-                    return graph().unique(new IsNullNode(object()));
+                    // since the subtype comparison was only performed on a declared type we don't
+                    // really know if it might be true at run time...
                 }
-            } else {
-                // since the subtype comparison was only performed on a declared type we don't
-                // really know if it might be true at run time...
             }
         }
         if (object().objectStamp().alwaysNull()) {