changeset 20140:bf4526ed41bd

fix canonicalization of ObjectEqualsNode to TypeCheckNode (again)
author Doug Simon <doug.simon@oracle.com>
date Thu, 02 Apr 2015 16:08:26 +0200
parents 7de9e37f368d
children 6fbf1c53feeb
files graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java
diffstat 1 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java	Thu Apr 02 14:09:02 2015 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java	Thu Apr 02 16:08:26 2015 +0200
@@ -22,6 +22,7 @@
  */
 package com.oracle.graal.nodes.calc;
 
+import com.oracle.graal.api.meta.Assumptions.AssumptionResult;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.common.*;
 import com.oracle.graal.compiler.common.calc.*;
@@ -62,11 +63,20 @@
     protected ValueNode canonicalizeSymmetricConstant(CanonicalizerTool tool, Constant constant, ValueNode nonConstant, boolean mirrored) {
         ResolvedJavaType type = tool.getConstantReflection().asJavaType(constant);
         if (type != null && nonConstant instanceof GetClassNode) {
-            if (type.getKind() == Kind.Void) {
+            if (type.isPrimitive()) {
                 return LogicConstantNode.forBoolean(false);
             }
-            if (type.isConcrete() || type.isArray()) {
-                return TypeCheckNode.create(type, ((GetClassNode) nonConstant).getObject());
+            ResolvedJavaType exactType = type.asExactType();
+            if (exactType == null) {
+                AssumptionResult<ResolvedJavaType> leafConcreteSubtype = type.findLeafConcreteSubtype();
+                if (leafConcreteSubtype != null) {
+                    graph().getAssumptions().record(leafConcreteSubtype);
+                    exactType = leafConcreteSubtype.getResult();
+                }
+            }
+
+            if (exactType == type) {
+                return TypeCheckNode.create(exactType, ((GetClassNode) nonConstant).getObject());
             }
         }
         return super.canonicalizeSymmetricConstant(tool, constant, nonConstant, mirrored);
@@ -109,7 +119,7 @@
                 /*
                  * One of the two objects has identity, the other doesn't. In code, this looks like
                  * "Integer.valueOf(a) == new Integer(b)", which is always false.
-                 *
+                 * 
                  * In other words: an object created via valueOf can never be equal to one created
                  * by new in the same compilation unit.
                  */