# HG changeset patch # User Lukas Stadler # Date 1336742273 -7200 # Node ID e4321a9bc0cb513e094441e177ebd0b19ed26481 # Parent b6aaf6de4053e536acb75d94aede042138e020c2 use exactType and assumptions to canonicalize ReadHubNode diff -r b6aaf6de4053 -r e4321a9bc0cb graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadHubNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadHubNode.java Fri May 11 15:17:17 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadHubNode.java Fri May 11 15:17:53 2012 +0200 @@ -26,9 +26,11 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; +import com.oracle.max.cri.ri.*; +import com.oracle.max.cri.ri.RiType.*; // TODO (chaeubl) this should be a FloatingNode but Lowering is not possible in that case -public final class ReadHubNode extends FixedWithNextNode implements Lowerable { +public final class ReadHubNode extends FixedWithNextNode implements Lowerable, Canonicalizable { @Input private ValueNode object; public ValueNode object() { @@ -44,4 +46,20 @@ public void lower(CiLoweringTool tool) { tool.getRuntime().lower(this, tool); } + + @Override + public ValueNode canonical(CanonicalizerTool tool) { + RiResolvedType exactType = object.exactType(); + + if (exactType == null && tool.assumptions() != null && object.declaredType() != null) { + exactType = object.declaredType().uniqueConcreteSubtype(); + if (exactType != null) { + tool.assumptions().recordConcreteSubtype(object.declaredType(), exactType); + } + } + if (exactType != null) { + return ConstantNode.forCiConstant(exactType.getEncoding(Representation.ObjectHub), tool.runtime(), graph()); + } + return this; + } }