Mercurial > hg > graal-compiler
changeset 22259:2241ccc653a0
ValuePhiNode should be an ArrayLengthProvider
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Mon, 20 Jul 2015 11:19:06 -0700 |
parents | 4a07b29e44c4 |
children | f68516869b75 |
files | graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValuePhiNode.java |
diffstat | 1 files changed, 22 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValuePhiNode.java Mon Jul 20 11:18:50 2015 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValuePhiNode.java Mon Jul 20 11:19:06 2015 -0700 @@ -25,13 +25,15 @@ import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodeinfo.*; +import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; +import com.oracle.graal.nodes.util.*; /** * Value {@link PhiNode}s merge data flow values at control flow merges. */ @NodeInfo(nameTemplate = "Phi({i#values})") -public class ValuePhiNode extends PhiNode { +public class ValuePhiNode extends PhiNode implements ArrayLengthProvider { public static final NodeClass<ValuePhiNode> TYPE = NodeClass.create(ValuePhiNode.class); @Input protected NodeInputList<ValueNode> values; @@ -65,4 +67,23 @@ } return updateStamp(valuesStamp); } + + public ValueNode length() { + if (merge() instanceof LoopBeginNode) { + return null; + } + ValueNode length = null; + for (ValueNode input : values()) { + ValueNode l = GraphUtil.arrayLength(input); + if (l == null) { + return null; + } + if (length == null) { + length = l; + } else if (length != l) { + return null; + } + } + return length; + } }