# HG changeset patch # User Doug Simon # Date 1427983706 -7200 # Node ID bf4526ed41bd0b44c1cf0041a0de39325c3ba9d1 # Parent 7de9e37f368ddae42fb789a9ec78efd012c42445 fix canonicalization of ObjectEqualsNode to TypeCheckNode (again) diff -r 7de9e37f368d -r bf4526ed41bd graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java --- 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 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. */