changeset 7724:ac3579b4adc9

remove MaterializeNode
author Lukas Stadler <lukas.stadler@jku.at>
date Tue, 05 Feb 2013 15:51:23 +0100
parents 09dd65d5e474
children 301cff1a99d1
files graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EscapeAnalysisTest.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/ClassSubstitutions.java graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MaterializeNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConditionalNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NormalizeCompareNode.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/InstanceOfSnippetsTemplates.java graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/UnsignedMathSubstitutions.java graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java
diffstat 11 files changed, 49 insertions(+), 86 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EscapeAnalysisTest.java	Tue Feb 05 01:17:52 2013 -0800
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EscapeAnalysisTest.java	Tue Feb 05 15:51:23 2013 +0100
@@ -30,6 +30,7 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.test.*;
 import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.phases.*;
 import com.oracle.graal.phases.common.*;
@@ -184,8 +185,8 @@
     public void testInstanceOf() {
         ReturnNode returnNode = testEscapeAnalysis("testInstanceOfSnippet", null, false);
         ValueNode result = returnNode.result();
-        Assert.assertTrue(result instanceof MaterializeNode);
-        Assert.assertEquals(Constant.TRUE, ((MaterializeNode) result).condition().asConstant());
+        Assert.assertTrue(result instanceof ConditionalNode);
+        Assert.assertEquals(Constant.TRUE, ((ConditionalNode) result).condition().asConstant());
     }
 
     public boolean testInstanceOfSnippet() {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/ClassSubstitutions.java	Tue Feb 05 01:17:52 2013 -0800
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/ClassSubstitutions.java	Tue Feb 05 15:51:23 2013 +0100
@@ -27,7 +27,7 @@
 
 import java.lang.reflect.*;
 
-import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.snippets.*;
 import com.oracle.graal.snippets.ClassSubstitution.MethodSubstitution;
 import com.oracle.graal.word.*;
@@ -113,6 +113,6 @@
 
     @MethodSubstitution(isStatic = false)
     public static boolean isInstance(final Class<?> thisObj, Object obj) {
-        return !thisObj.isPrimitive() && MaterializeNode.isInstance(thisObj, obj);
+        return !thisObj.isPrimitive() && ConditionalNode.materializeIsInstance(thisObj, obj);
     }
 }
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Tue Feb 05 01:17:52 2013 -0800
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Tue Feb 05 15:51:23 2013 +0100
@@ -708,7 +708,8 @@
         if (type instanceof ResolvedJavaType) {
             ResolvedJavaType resolvedType = (ResolvedJavaType) type;
             InstanceOfNode instanceOfNode = new InstanceOfNode((ResolvedJavaType) type, object, getProfileForTypeCheck(resolvedType));
-            frameState.ipush(append(MaterializeNode.create(currentGraph.unique(instanceOfNode))));
+            ConditionalNode conditional = currentGraph.unique(new ConditionalNode(currentGraph.unique(instanceOfNode), ConstantNode.forInt(1, currentGraph), ConstantNode.forInt(0, currentGraph)));
+            frameState.ipush(append(conditional));
         } else {
             BlockPlaceholderNode successor = currentGraph.add(new BlockPlaceholderNode());
             DeoptimizeNode deopt = currentGraph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.Unresolved));
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java	Tue Feb 05 01:17:52 2013 -0800
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java	Tue Feb 05 15:51:23 2013 +0100
@@ -191,7 +191,7 @@
                             return false;
                         }
                         if (trueValue.isConstant() && falseValue.isConstant()) {
-                            MaterializeNode materialize = MaterializeNode.create(condition(), trueValue, falseValue);
+                            ConditionalNode materialize = graph().unique(new ConditionalNode(condition(), trueValue, falseValue));
                             ((StructuredGraph) graph()).replaceFloating(singlePhi, materialize);
                             removeEmptyIf(tool);
                             return true;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MaterializeNode.java	Tue Feb 05 01:17:52 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2009, 2011, 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 static com.oracle.graal.nodes.calc.CompareNode.*;
-
-import com.oracle.graal.graph.*;
-import com.oracle.graal.nodes.calc.*;
-import com.oracle.graal.nodes.java.*;
-
-public final class MaterializeNode extends ConditionalNode {
-
-    private MaterializeNode(Condition condition, ValueNode x, ValueNode y) {
-        this(createCompareNode(condition, x, y), ConstantNode.forInt(1, x.graph()), ConstantNode.forInt(0, x.graph()));
-    }
-
-    private MaterializeNode(BooleanNode condition, ValueNode trueValue, ValueNode falseValue) {
-        super(condition, trueValue, falseValue);
-    }
-
-    private MaterializeNode(ValueNode type, ValueNode object) {
-        super(type.graph().add(new InstanceOfDynamicNode(type, object)), ConstantNode.forInt(1, type.graph()), ConstantNode.forInt(0, type.graph()));
-    }
-
-    public static MaterializeNode create(BooleanNode condition, ValueNode trueValue, ValueNode falseValue) {
-        Graph graph = condition.graph();
-        MaterializeNode result = new MaterializeNode(condition, trueValue, falseValue);
-        return graph.unique(result);
-
-    }
-
-    public static MaterializeNode create(BooleanNode condition) {
-        return create(condition, ConstantNode.forInt(1, condition.graph()), ConstantNode.forInt(0, condition.graph()));
-    }
-
-    @NodeIntrinsic
-    public static native boolean materialize(@ConstantNodeParameter Condition condition, int x, int y);
-
-    @NodeIntrinsic
-    public static native boolean materialize(@ConstantNodeParameter Condition condition, long x, long y);
-
-    @NodeIntrinsic
-    public static native boolean isInstance(Class mirror, Object object);
-}
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConditionalNode.java	Tue Feb 05 01:17:52 2013 -0800
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConditionalNode.java	Tue Feb 05 15:51:23 2013 +0100
@@ -22,15 +22,18 @@
  */
 package com.oracle.graal.nodes.calc;
 
+import static com.oracle.graal.nodes.calc.CompareNode.*;
+
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.spi.*;
 
 /**
  * The {@code ConditionalNode} class represents a comparison that yields one of two values. Note
  * that these nodes are not built directly from the bytecode but are introduced by canonicalization.
  */
-public class ConditionalNode extends BinaryNode implements Canonicalizable, LIRLowerable, Negatable {
+public final class ConditionalNode extends BinaryNode implements Canonicalizable, LIRLowerable, Negatable {
 
     @Input private BooleanNode condition;
 
@@ -44,6 +47,11 @@
         this.condition = condition;
     }
 
+    @Override
+    public boolean inferStamp() {
+        return updateStamp(x().stamp().meet(y().stamp()));
+    }
+
     public ValueNode trueValue() {
         return x();
     }
@@ -91,4 +99,21 @@
         ((StructuredGraph) graph()).replaceFloating(this, replacement);
         return replacement;
     }
+
+    private ConditionalNode(Condition condition, ValueNode x, ValueNode y) {
+        this(createCompareNode(condition, x, y), ConstantNode.forInt(1, x.graph()), ConstantNode.forInt(0, x.graph()));
+    }
+
+    private ConditionalNode(ValueNode type, ValueNode object) {
+        this(type.graph().add(new InstanceOfDynamicNode(type, object)), ConstantNode.forInt(1, type.graph()), ConstantNode.forInt(0, type.graph()));
+    }
+
+    @NodeIntrinsic
+    public static native boolean materializeCondition(@ConstantNodeParameter Condition condition, int x, int y);
+
+    @NodeIntrinsic
+    public static native boolean materializeCondition(@ConstantNodeParameter Condition condition, long x, long y);
+
+    @NodeIntrinsic
+    public static native boolean materializeIsInstance(Class mirror, Object object);
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NormalizeCompareNode.java	Tue Feb 05 01:17:52 2013 -0800
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NormalizeCompareNode.java	Tue Feb 05 15:51:23 2013 +0100
@@ -61,8 +61,8 @@
             lessComp = graph.unique(new IntegerLessThanNode(x(), y()));
         }
 
-        MaterializeNode equalValue = MaterializeNode.create(equalComp, ConstantNode.forInt(0, graph), ConstantNode.forInt(1, graph));
-        MaterializeNode value = MaterializeNode.create(lessComp, ConstantNode.forInt(-1, graph), equalValue);
+        ConditionalNode equalValue = graph.unique(new ConditionalNode(equalComp, ConstantNode.forInt(0, graph), ConstantNode.forInt(1, graph)));
+        ConditionalNode value = graph.unique(new ConditionalNode(lessComp, ConstantNode.forInt(-1, graph), equalValue));
 
         graph.replaceFloating(this, value);
     }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java	Tue Feb 05 01:17:52 2013 -0800
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java	Tue Feb 05 15:51:23 2013 +0100
@@ -496,8 +496,8 @@
                 for (PhiNode phi : endNode.merge().phis()) {
                     int index = endNode.merge().phiPredecessorIndex(endNode);
                     ValueNode value = phi.valueAt(index);
-                    if (value instanceof MaterializeNode) {
-                        MaterializeNode materialize = (MaterializeNode) value;
+                    if (value instanceof ConditionalNode) {
+                        ConditionalNode materialize = (ConditionalNode) value;
                         BooleanNode compare = materialize.condition();
                         ValueNode replacement = evaluateCondition(compare, materialize.trueValue(), materialize.falseValue());
 
--- a/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/InstanceOfSnippetsTemplates.java	Tue Feb 05 01:17:52 2013 -0800
+++ b/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/InstanceOfSnippetsTemplates.java	Tue Feb 05 15:51:23 2013 +0100
@@ -172,7 +172,7 @@
                 // Can simply use the phi result if the same materialized values are expected.
                 return result;
             } else {
-                return MaterializeNode.create(asCondition(trueValue), t, f);
+                return t.graph().unique(new ConditionalNode(asCondition(trueValue), t, f));
             }
         }
     }
--- a/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/UnsignedMathSubstitutions.java	Tue Feb 05 01:17:52 2013 -0800
+++ b/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/UnsignedMathSubstitutions.java	Tue Feb 05 15:51:23 2013 +0100
@@ -22,7 +22,7 @@
  */
 package com.oracle.graal.snippets;
 
-import static com.oracle.graal.nodes.MaterializeNode.*;
+import static com.oracle.graal.nodes.calc.ConditionalNode.*;
 import static com.oracle.graal.nodes.calc.Condition.*;
 
 import com.oracle.graal.api.code.*;
@@ -38,12 +38,12 @@
 
     @MethodSubstitution
     public static boolean aboveThan(int a, int b) {
-        return materialize(BT, b, a);
+        return materializeCondition(BT, b, a);
     }
 
     @MethodSubstitution
     public static boolean aboveOrEqual(int a, int b) {
-        return !materialize(BT, a, b);
+        return !materializeCondition(BT, a, b);
     }
 
     /**
@@ -51,7 +51,7 @@
      */
     @MethodSubstitution
     public static boolean belowThan(int a, int b) {
-        return materialize(BT, a, b);
+        return materializeCondition(BT, a, b);
     }
 
     /**
@@ -59,7 +59,7 @@
      */
     @MethodSubstitution
     public static boolean belowOrEqual(int a, int b) {
-        return !materialize(BT, b, a);
+        return !materializeCondition(BT, b, a);
     }
 
     /**
@@ -67,7 +67,7 @@
      */
     @MethodSubstitution
     public static boolean aboveThan(long a, long b) {
-        return materialize(BT, b, a);
+        return materializeCondition(BT, b, a);
     }
 
     /**
@@ -75,7 +75,7 @@
      */
     @MethodSubstitution
     public static boolean aboveOrEqual(long a, long b) {
-        return !materialize(BT, a, b);
+        return !materializeCondition(BT, a, b);
     }
 
     /**
@@ -83,7 +83,7 @@
      */
     @MethodSubstitution
     public static boolean belowThan(long a, long b) {
-        return materialize(BT, a, b);
+        return materializeCondition(BT, a, b);
     }
 
     /**
@@ -91,7 +91,7 @@
      */
     @MethodSubstitution
     public static boolean belowOrEqual(long a, long b) {
-        return !materialize(BT, b, a);
+        return !materializeCondition(BT, b, a);
     }
 
     /**
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java	Tue Feb 05 01:17:52 2013 -0800
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java	Tue Feb 05 15:51:23 2013 +0100
@@ -248,7 +248,7 @@
         } else {
             comparison = new IntegerLessThanNode(a, b);
         }
-        MaterializeNode materialize = MaterializeNode.create(graph.unique(comparison));
+        ConditionalNode materialize = graph.unique(new ConditionalNode(graph.unique(comparison), ConstantNode.forInt(1, graph), ConstantNode.forInt(0, graph)));
 
         ValueNode op;
         if (condition.canonicalNegate()) {