Mercurial > hg > truffle
changeset 5388:e4321a9bc0cb
use exactType and assumptions to canonicalize ReadHubNode
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Fri, 11 May 2012 15:17:53 +0200 |
parents | b6aaf6de4053 |
children | 612b4f099362 |
files | graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadHubNode.java |
diffstat | 1 files changed, 19 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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; + } }