# HG changeset patch # User Gilles Duboscq # Date 1337680641 -7200 # Node ID ce2398984e39f330adcf9202ba4d618619cb5054 # Parent 44c378aa4c475f36edd33bd949ce26d52cfb1747 make ValueAnchorNode able to anchor multiple values, use dependencies for anchored values diff -r 44c378aa4c47 -r ce2398984e39 graal/com.oracle.graal.graph/src/com/oracle/graal/graph/iterators/NodeIterable.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/iterators/NodeIterable.java Tue May 22 11:37:07 2012 +0200 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/iterators/NodeIterable.java Tue May 22 11:57:21 2012 +0200 @@ -43,6 +43,9 @@ public FilteredNodeIterable filter(NodePredicate predicate) { return new FilteredNodeIterable<>(this).and(predicate); } + public FilteredNodeIterable nonNull() { + return new FilteredNodeIterable<>(this).and(NodePredicates.isNotNull()); + } public List snapshot() { ArrayList list = new ArrayList<>(); for (T n : this) { diff -r 44c378aa4c47 -r ce2398984e39 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ValueAnchorNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ValueAnchorNode.java Tue May 22 11:37:07 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ValueAnchorNode.java Tue May 22 11:57:21 2012 +0200 @@ -22,12 +22,12 @@ */ package com.oracle.graal.nodes.extended; -import com.oracle.max.cri.ci.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; +import com.oracle.max.cri.ci.*; /** * The ValueAnchor instruction keeps non-CFG (floating) nodes above a certain point in the graph. @@ -35,15 +35,9 @@ public final class ValueAnchorNode extends FixedWithNextNode implements Canonicalizable, LIRLowerable, Node.IterableNodeType { - @Input private ValueNode object; - - public ValueNode object() { - return object; - } - - public ValueAnchorNode(ValueNode object) { + public ValueAnchorNode(ValueNode... values) { super(StampFactory.illegal()); - this.object = object; + this.dependencies().addAll(values); } @Override @@ -51,23 +45,36 @@ // Nothing to emit, since this node is used for structural purposes only. } + public void addAnchoredValue(ValueNode value) { + this.dependencies().add(value); + } + @Override public ValueNode canonical(CanonicalizerTool tool) { - if (object == null) { - return null; - } - if (object instanceof ConstantNode) { + if (this.predecessor() instanceof ValueAnchorNode) { + // transfer values and remove + ValueAnchorNode previousAnchor = (ValueAnchorNode) this.predecessor(); + for (Node node : dependencies().nonNull()) { + previousAnchor.dependencies().add(node); + } return null; } - if (object instanceof IntegerDivNode || object instanceof IntegerRemNode) { - if (((ArithmeticNode) object).y().isConstant()) { - CiConstant constant = ((ArithmeticNode) object).y().asConstant(); - assert constant.kind == object.kind() : constant.kind + " != " + object.kind(); - if (constant.asLong() != 0) { - return null; + for (Node node : dependencies().nonNull()) { + if (node instanceof ConstantNode) { + continue; + } + if (node instanceof IntegerDivNode || node instanceof IntegerRemNode) { + ArithmeticNode arithmeticNode = (ArithmeticNode) node; + if (arithmeticNode.y().isConstant()) { + CiConstant constant = arithmeticNode.y().asConstant(); + assert constant.kind == arithmeticNode.kind() : constant.kind + " != " + arithmeticNode.kind(); + if (constant.asLong() != 0) { + continue; + } } } + return this; // still necessary } - return this; + return null; // no node which require an anchor found } }