# HG changeset patch # User Gilles Duboscq # Date 1373546872 -7200 # Node ID 41e9c884582695ada650c9ee3ac66c5af00b838b # Parent a643c88d164f6e7e314d01cd6ab323a275bceeb8 Improve instanceof canonicalization diff -r a643c88d164f -r 41e9c8845826 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java Thu Jul 11 14:45:31 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java Thu Jul 11 14:47:52 2013 +0200 @@ -61,8 +61,11 @@ assert object() != null : this; ObjectStamp stamp = object().objectStamp(); + if (object().objectStamp().alwaysNull()) { + return LogicConstantNode.contradiction(graph()); + } + ResolvedJavaType stampType = stamp.type(); - if (stamp.isExactType() || stampType != null) { boolean subType = type().isAssignableFrom(stampType); @@ -83,14 +86,15 @@ // also make the check fail. return LogicConstantNode.contradiction(graph()); } else { + boolean superType = stampType.isAssignableFrom(type()); + if (!superType && !stampType.isInterface() && !type().isInterface()) { + return LogicConstantNode.contradiction(graph()); + } // 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()) { - return LogicConstantNode.contradiction(graph()); - } return this; }