changeset 15008:01fdabd19cd5

new AnchoringNode interface
author Lukas Stadler <lukas.stadler@oracle.com>
date Mon, 07 Apr 2014 11:32:09 +0200
parents 9a73164832a9
children e49f62425090
files graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/AbstractBeginNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FloatingAnchoredNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/AnchoringNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LoweringTool.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/OptimizeGuardAnchorsPhase.java graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java
diffstat 9 files changed, 98 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/AbstractBeginNode.java	Mon Apr 07 11:32:09 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/AbstractBeginNode.java	Mon Apr 07 11:32:09 2014 +0200
@@ -34,7 +34,7 @@
 import com.oracle.graal.nodes.type.*;
 
 @NodeInfo(allowedUsageTypes = {InputType.Guard, InputType.Anchor})
-public abstract class AbstractBeginNode extends FixedWithNextNode implements StateSplit, LIRLowerable, Simplifiable, GuardingNode, IterableNodeType {
+public abstract class AbstractBeginNode extends FixedWithNextNode implements StateSplit, LIRLowerable, Simplifiable, GuardingNode, AnchoringNode, IterableNodeType {
 
     @Input(InputType.State) private FrameState stateAfter;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FloatingAnchoredNode.java	Mon Apr 07 11:32:09 2014 +0200
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.nodes;
+
+import com.oracle.graal.graph.*;
+import com.oracle.graal.nodes.calc.*;
+import com.oracle.graal.nodes.extended.*;
+import com.oracle.graal.nodes.type.*;
+
+public abstract class FloatingAnchoredNode extends FloatingNode {
+
+    @Input(InputType.Anchor) private AnchoringNode anchor;
+
+    public FloatingAnchoredNode(Stamp stamp) {
+        super(stamp);
+    }
+
+    public FloatingAnchoredNode(Stamp stamp, AnchoringNode anchor) {
+        super(stamp);
+        this.anchor = anchor;
+    }
+
+    public AnchoringNode getAnchor() {
+        return anchor;
+    }
+
+    public void setAnchor(AnchoringNode x) {
+        updateUsagesInterface(this.anchor, x);
+        this.anchor = x;
+    }
+}
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardNode.java	Mon Apr 07 11:32:09 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardNode.java	Mon Apr 07 11:32:09 2014 +0200
@@ -41,7 +41,7 @@
  * control flow would have reached the guarded node (without taking exceptions into account).
  */
 @NodeInfo(nameTemplate = "Guard(!={p#negated}) {p#reason/s}", allowedUsageTypes = {InputType.Guard})
-public class GuardNode extends FloatingGuardedNode implements Canonicalizable, IterableNodeType, GuardingNode, GuardedNode {
+public class GuardNode extends FloatingAnchoredNode implements Canonicalizable, IterableNodeType, GuardingNode {
 
     @Input(InputType.Condition) private LogicNode condition;
     private final DeoptimizationReason reason;
@@ -49,7 +49,7 @@
     private DeoptimizationAction action;
     private boolean negated;
 
-    public GuardNode(LogicNode condition, GuardingNode anchor, DeoptimizationReason reason, DeoptimizationAction action, boolean negated, Constant speculation) {
+    public GuardNode(LogicNode condition, AnchoringNode anchor, DeoptimizationReason reason, DeoptimizationAction action, boolean negated, Constant speculation) {
         super(StampFactory.forVoid(), anchor);
         this.condition = condition;
         this.reason = reason;
@@ -103,7 +103,7 @@
     public Node canonical(CanonicalizerTool tool) {
         if (condition() instanceof LogicNegationNode) {
             LogicNegationNode negation = (LogicNegationNode) condition();
-            return graph().unique(new GuardNode(negation.getInput(), getGuard(), reason, action, !negated, speculation));
+            return graph().unique(new GuardNode(negation.getInput(), getAnchor(), reason, action, !negated, speculation));
         } else if (condition() instanceof LogicConstantNode) {
             LogicConstantNode c = (LogicConstantNode) condition();
             if (c.getValue() != negated) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/AnchoringNode.java	Mon Apr 07 11:32:09 2014 +0200
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.nodes.extended;
+
+import com.oracle.graal.graph.*;
+import com.oracle.graal.nodes.*;
+
+public interface AnchoringNode extends NodeInterface {
+
+    ValueNode asNode();
+}
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LoweringTool.java	Mon Apr 07 11:32:09 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LoweringTool.java	Mon Apr 07 11:32:09 2014 +0200
@@ -52,7 +52,7 @@
      */
     FixedWithNextNode lastFixedNode();
 
-    GuardingNode getCurrentGuardAnchor();
+    AnchoringNode getCurrentGuardAnchor();
 
     /**
      * Marker interface lowering stages.
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java	Mon Apr 07 11:32:09 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java	Mon Apr 07 11:32:09 2014 +0200
@@ -93,7 +93,7 @@
                 GuardNode guard = nullGuarded.get(access.object());
                 if (guard != null && isImplicitNullCheck(access.accessLocation())) {
                     metricImplicitNullCheck.increment();
-                    access.setGuard(guard.getGuard());
+                    access.setGuard(null);
                     FixedAccessNode fixedAccess;
                     if (access instanceof FloatingAccessNode) {
                         fixedAccess = ((FloatingAccessNode) access).asFixedNode();
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java	Mon Apr 07 11:32:09 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java	Mon Apr 07 11:32:09 2014 +0200
@@ -50,11 +50,11 @@
 
         private final PhaseContext context;
         private final NodeBitMap activeGuards;
-        private GuardingNode guardAnchor;
+        private AnchoringNode guardAnchor;
         private FixedWithNextNode lastFixedNode;
         private ControlFlowGraph cfg;
 
-        public LoweringToolImpl(PhaseContext context, GuardingNode guardAnchor, NodeBitMap activeGuards, FixedWithNextNode lastFixedNode, ControlFlowGraph cfg) {
+        public LoweringToolImpl(PhaseContext context, AnchoringNode guardAnchor, NodeBitMap activeGuards, FixedWithNextNode lastFixedNode, ControlFlowGraph cfg) {
             this.context = context;
             this.guardAnchor = guardAnchor;
             this.activeGuards = activeGuards;
@@ -88,7 +88,7 @@
         }
 
         @Override
-        public GuardingNode getCurrentGuardAnchor() {
+        public AnchoringNode getCurrentGuardAnchor() {
             return guardAnchor;
         }
 
@@ -115,7 +115,7 @@
             }
 
             public void setGuard(GuardingNode guard) {
-                updateUsages(this.guard == null ? null : this.guard.asNode(), guard == null ? null : guard.asNode());
+                updateUsagesInterface(this.guard, guard);
                 this.guard = guard;
             }
 
@@ -253,9 +253,9 @@
             processBlock(schedule.getCFG().getStartBlock(), graph.createNodeBitMap(), null);
         }
 
-        private void processBlock(Block block, NodeBitMap activeGuards, GuardingNode parentAnchor) {
+        private void processBlock(Block block, NodeBitMap activeGuards, AnchoringNode parentAnchor) {
 
-            GuardingNode anchor = parentAnchor;
+            AnchoringNode anchor = parentAnchor;
             if (anchor == null) {
                 anchor = block.getBeginNode();
             }
@@ -284,7 +284,7 @@
             }
         }
 
-        private GuardingNode process(final Block b, final NodeBitMap activeGuards, final GuardingNode startAnchor) {
+        private AnchoringNode process(final Block b, final NodeBitMap activeGuards, final AnchoringNode startAnchor) {
 
             final LoweringToolImpl loweringTool = new LoweringToolImpl(context, startAnchor, activeGuards, b.getBeginNode(), schedule.getCFG());
 
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/OptimizeGuardAnchorsPhase.java	Mon Apr 07 11:32:09 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/OptimizeGuardAnchorsPhase.java	Mon Apr 07 11:32:09 2014 +0200
@@ -64,7 +64,7 @@
                     // loops never end
                     if (newAnchor != begin) {
                         for (GuardNode guard : guards.snapshot()) {
-                            guard.setGuard(newAnchor);
+                            guard.setAnchor(newAnchor);
                         }
                         metricGuardsAnchorOptimized.increment();
                     }
@@ -101,7 +101,7 @@
             }
             for (GuardNode conditonGuard : guard.condition().usages().filter(GuardNode.class)) {
                 if (conditonGuard != guard) {
-                    GuardingNode conditonGuardAnchor = conditonGuard.getGuard();
+                    AnchoringNode conditonGuardAnchor = conditonGuard.getAnchor();
                     if (conditonGuardAnchor.asNode().predecessor() == controlSplit && compatibleGuards(guard, conditonGuard)) {
                         otherGuards.add(conditonGuard);
                     }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java	Mon Apr 07 11:32:09 2014 +0200
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java	Mon Apr 07 11:32:09 2014 +0200
@@ -345,7 +345,7 @@
             buf.format(", lastAccess: %s", frn.getLastLocationAccess());
             buf.format(", object: %s", frn.object());
         } else if (n instanceof GuardNode) {
-            buf.format(", guard: %s", ((GuardNode) n).getGuard());
+            buf.format(", anchor: %s", ((GuardNode) n).getAnchor());
         }
         Debug.log("%s", buf);
     }