changeset 5865:d6765d84974a

Merge
author Gilles Duboscq <duboscq@ssw.jku.at>
date Fri, 20 Jul 2012 12:05:39 +0200
parents 59f209dd356b (current diff) 1cb45c7dba55 (diff)
children 5d6e6837c4ed
files
diffstat 2 files changed, 23 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/TailDuplicationPhase.java	Fri Jul 20 12:05:20 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/TailDuplicationPhase.java	Fri Jul 20 12:05:39 2012 +0200
@@ -232,6 +232,7 @@
             final HashSet<Node> duplicatedNodes = buildDuplicatedNodeSet(fixedNodes, stateAfter);
             mergeAfter.clearEnds();
             expandDuplicated(duplicatedNodes, mergeAfter);
+            retargetDependencies(duplicatedNodes, anchor);
 
             List<EndNode> endSnapshot = merge.forwardEnds().snapshot();
             List<PhiNode> phiSnapshot = merge.phis().snapshot();
@@ -491,6 +492,27 @@
         }
 
         /**
+         * Moves all depdendencies that point outside the duplicated area to the supplied value anchor node.
+         *
+         * @param duplicatedNodes The set of duplicated nodes.
+         * @param anchor The node that will be the new target for all dependencies that point outside the duplicated set of nodes.
+         */
+        private static void retargetDependencies(HashSet<Node> duplicatedNodes, ValueAnchorNode anchor) {
+            for (Node node : duplicatedNodes) {
+                if (node instanceof ValueNode) {
+                    NodeInputList<ValueNode> dependencies = ((ValueNode) node).dependencies();
+                    for (int i = 0; i < dependencies.size(); i++) {
+                        Node dependency = dependencies.get(i);
+                        if (dependency != null && !duplicatedNodes.contains(dependency)) {
+                            Debug.log("retargeting dependency %s to %s on %s", dependency, anchor, node);
+                            dependencies.set(i, anchor);
+                        }
+                    }
+                }
+            }
+        }
+
+        /**
          * Checks if the given node has usages that are not within the given set of nodes.
          *
          * @param node The node whose usages are checked.
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardNode.java	Fri Jul 20 12:05:20 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardNode.java	Fri Jul 20 12:05:39 2012 +0200
@@ -45,21 +45,11 @@
 public final class GuardNode extends FloatingNode implements Canonicalizable, LIRLowerable, TypeFeedbackProvider, Node.IterableNodeType, Negatable {
 
     @Input private BooleanNode condition;
-    @Input(notDataflow = true) private FixedNode anchor;
     private final DeoptimizationReason reason;
     private final DeoptimizationAction action;
     private boolean negated;
     private final long leafGraphId;
 
-    public FixedNode anchor() {
-        return anchor;
-    }
-
-    public void setAnchor(FixedNode x) {
-        updateUsages(anchor, x);
-        anchor = x;
-    }
-
     /**
      * The instruction that produces the tested boolean value.
      */
@@ -85,9 +75,8 @@
     }
 
     public GuardNode(BooleanNode condition, FixedNode anchor, DeoptimizationReason reason, DeoptimizationAction action, boolean negated, long leafGraphId) {
-        super(StampFactory.dependency());
+        super(StampFactory.dependency(), anchor);
         this.condition = condition;
-        this.anchor = anchor;
         this.reason = reason;
         this.action = action;
         this.negated = negated;