changeset 18360:6a5dc0bbebe7

Introduce PointerEqualsNode for metaspace pointer comparison.
author Roland Schatz <roland.schatz@oracle.com>
date Wed, 12 Nov 2014 11:48:54 +0100
parents a3a2359ac88e
children 6ac7e9c85be6
files graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/CompareNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/PointerEqualsNode.java
diffstat 3 files changed, 84 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/CompareNode.java	Tue Nov 11 18:34:21 2014 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/CompareNode.java	Wed Nov 12 11:48:54 2014 +0100
@@ -25,6 +25,7 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.common.*;
 import com.oracle.graal.compiler.common.calc.*;
+import com.oracle.graal.compiler.common.type.*;
 import com.oracle.graal.graph.spi.*;
 import com.oracle.graal.nodeinfo.*;
 import com.oracle.graal.nodes.*;
@@ -93,7 +94,7 @@
     @Override
     public ValueNode canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) {
         if (forX.isConstant() && forY.isConstant()) {
-            return LogicConstantNode.forBoolean(condition().foldCondition(forX.asJavaConstant(), forY.asJavaConstant(), tool.getConstantReflection(), unorderedIsTrue()));
+            return LogicConstantNode.forBoolean(condition().foldCondition(forX.asConstant(), forY.asConstant(), tool.getConstantReflection(), unorderedIsTrue()));
         }
         ValueNode result;
         if (forX.isConstant()) {
@@ -156,8 +157,10 @@
 
         CompareNode comparison;
         if (condition == Condition.EQ) {
-            if (x.getKind() == Kind.Object) {
+            if (x.stamp() instanceof AbstractObjectStamp) {
                 comparison = ObjectEqualsNode.create(x, y);
+            } else if (x.stamp() instanceof AbstractPointerStamp) {
+                comparison = PointerEqualsNode.create(x, y);
             } else {
                 assert x.getKind().isNumericInteger();
                 comparison = IntegerEqualsNode.create(x, y);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java	Tue Nov 11 18:34:21 2014 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java	Wed Nov 12 11:48:54 2014 +0100
@@ -23,16 +23,15 @@
 package com.oracle.graal.nodes.calc;
 
 import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.calc.*;
+import com.oracle.graal.compiler.common.type.*;
 import com.oracle.graal.graph.spi.*;
 import com.oracle.graal.nodeinfo.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
-import com.oracle.graal.nodes.util.*;
 
 @NodeInfo(shortName = "==")
-public class ObjectEqualsNode extends CompareNode implements Virtualizable {
+public class ObjectEqualsNode extends PointerEqualsNode implements Virtualizable {
 
     /**
      * Constructs a new object equality comparison node.
@@ -46,18 +45,8 @@
 
     protected ObjectEqualsNode(ValueNode x, ValueNode y) {
         super(x, y);
-        assert x.getKind() == Kind.Object;
-        assert y.getKind() == Kind.Object;
-    }
-
-    @Override
-    public Condition condition() {
-        return Condition.EQ;
-    }
-
-    @Override
-    public boolean unorderedIsTrue() {
-        return false;
+        assert x.stamp() instanceof AbstractObjectStamp;
+        assert y.stamp() instanceof AbstractObjectStamp;
     }
 
     @Override
@@ -66,11 +55,6 @@
         if (result != this) {
             return result;
         }
-        if (GraphUtil.unproxify(forX) == GraphUtil.unproxify(forY)) {
-            return LogicConstantNode.tautology();
-        } else if (forX.stamp().alwaysDistinct(forY.stamp())) {
-            return LogicConstantNode.contradiction();
-        }
         if (StampTool.isObjectAlwaysNull(forX)) {
             return IsNullNode.create(forY);
         } else if (StampTool.isObjectAlwaysNull(forY)) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/PointerEqualsNode.java	Wed Nov 12 11:48:54 2014 +0100
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2011, 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.calc;
+
+import com.oracle.graal.compiler.common.calc.*;
+import com.oracle.graal.compiler.common.type.*;
+import com.oracle.graal.graph.spi.*;
+import com.oracle.graal.nodeinfo.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.util.*;
+
+@NodeInfo(shortName = "==")
+public class PointerEqualsNode extends CompareNode {
+
+    /**
+     * Constructs a new pointer equality comparison node.
+     *
+     * @param x the instruction producing the first input to the instruction
+     * @param y the instruction that produces the second input to this instruction
+     */
+    public static PointerEqualsNode create(ValueNode x, ValueNode y) {
+        return new PointerEqualsNode(x, y);
+    }
+
+    protected PointerEqualsNode(ValueNode x, ValueNode y) {
+        super(x, y);
+        assert x.stamp() instanceof AbstractPointerStamp;
+        assert y.stamp() instanceof AbstractPointerStamp;
+    }
+
+    @Override
+    public Condition condition() {
+        return Condition.EQ;
+    }
+
+    @Override
+    public boolean unorderedIsTrue() {
+        return false;
+    }
+
+    @Override
+    public ValueNode canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) {
+        if (GraphUtil.unproxify(forX) == GraphUtil.unproxify(forY)) {
+            return LogicConstantNode.tautology();
+        } else if (forX.stamp().alwaysDistinct(forY.stamp())) {
+            return LogicConstantNode.contradiction();
+        }
+        return super.canonical(tool, forX, forY);
+    }
+
+    @Override
+    protected CompareNode duplicateModified(ValueNode newX, ValueNode newY) {
+        return PointerEqualsNode.create(newX, newY);
+    }
+}