changeset 5830:f28115ee6108

Do without the Top stamp for now, too little benefits
author Gilles Duboscq <duboscq@ssw.jku.at>
date Fri, 13 Jul 2012 11:29:15 +0200
parents 547587296886
children ed08c40d67de
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/ReadEliminationPhase.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/FloatStamp.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/GenericStamp.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/IntegerStamp.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/ObjectStamp.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampFactory.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/TopStamp.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/WordStamp.java
diffstat 9 files changed, 6 insertions(+), 80 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/ReadEliminationPhase.java	Thu Jul 12 18:58:36 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/ReadEliminationPhase.java	Fri Jul 13 11:29:15 2012 +0200
@@ -27,7 +27,6 @@
 import com.oracle.graal.debug.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.PhiNode.PhiType;
 import com.oracle.graal.nodes.extended.*;
 
 public class ReadEliminationPhase extends Phase {
@@ -39,20 +38,11 @@
         for (FloatingReadNode n : graph.getNodes(FloatingReadNode.class)) {
             if (isReadEliminable(n)) {
                 NodeMap<ValueNode> nodeMap = n.graph().createNodeMap();
-                ValueNode value = getValue(n.lastLocationAccess(), nodeMap);
+                ValueNode value = getValue(n, n.lastLocationAccess(), nodeMap);
                 Debug.log("Eliminated memory read %1.1s and replaced with node %s", n, value);
                 graph.replaceFloating(n, value);
             }
         }
-        // get a proper stamp for the new phis
-        while (!newPhis.isEmpty()) {
-            PhiNode phi = newPhis.poll();
-            if (phi.inferStamp()) {
-                for (PhiNode usagePhi : phi.usages().filter(PhiNode.class)) {
-                    newPhis.add(usagePhi);
-                }
-            }
-        }
     }
 
     private boolean isReadEliminable(FloatingReadNode n) {
@@ -82,7 +72,7 @@
         return false;
     }
 
-    private ValueNode getValue(Node lastLocationAccess, NodeMap<ValueNode> nodeMap) {
+    private ValueNode getValue(FloatingReadNode n, Node lastLocationAccess, NodeMap<ValueNode> nodeMap) {
         ValueNode exisiting = nodeMap.get(lastLocationAccess);
         if (exisiting != null) {
             return exisiting;
@@ -92,10 +82,10 @@
         }
         if (lastLocationAccess instanceof PhiNode) {
             PhiNode phi = (PhiNode) lastLocationAccess;
-            PhiNode newPhi = phi.graph().add(new PhiNode(PhiType.Value, phi.merge()));
+            PhiNode newPhi = phi.graph().add(new PhiNode(n.kind(), phi.merge()));
             nodeMap.set(lastLocationAccess, newPhi);
             for (ValueNode value : phi.values()) {
-                newPhi.addInput(getValue(value, nodeMap));
+                newPhi.addInput(getValue(n, value, nodeMap));
             }
             newPhis.add(newPhi);
             return newPhi;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java	Thu Jul 12 18:58:36 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java	Fri Jul 13 11:29:15 2012 +0200
@@ -36,7 +36,7 @@
 public final class PhiNode extends FloatingNode implements Canonicalizable, Node.IterableNodeType {
 
     public static enum PhiType {
-        Value(StampFactory.top()), // normal value phis
+        Value(null), // normal value phis
         Memory(StampFactory.dependency());
 
         public final Stamp stamp;
@@ -62,9 +62,7 @@
     }
 
     /**
-     * Create a phi with the specified {@link PhiType}.
-     * If you use this to create a {@link PhiType#Value value} phi, its {@link Kind kind} will originally be {@link Kind#Void void} ;
-     * use {@link PhiNode#inferStamp()} to update it when it has valid inputs.
+     * Create a non-value phi ({@link PhiType#Memory} with the specified kind.
      * @param type the type of the new phi
      * @param merge the merge that the new phi belongs to
      */
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/FloatStamp.java	Thu Jul 12 18:58:36 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/FloatStamp.java	Fri Jul 13 11:29:15 2012 +0200
@@ -91,9 +91,6 @@
 
     @Override
     public Stamp meet(Stamp otherStamp) {
-        if (otherStamp == StampFactory.top()) {
-            return this;
-        }
         FloatStamp other = (FloatStamp) otherStamp;
         assert kind() == other.kind();
         double meetUpperBound = Math.max(upperBound, other.upperBound);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/GenericStamp.java	Thu Jul 12 18:58:36 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/GenericStamp.java	Fri Jul 13 11:29:15 2012 +0200
@@ -53,9 +53,6 @@
 
     @Override
     public Stamp meet(Stamp other) {
-        if (other == StampFactory.top()) {
-            return this;
-        }
         assert ((GenericStamp) other).type == type;
         return this;
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/IntegerStamp.java	Thu Jul 12 18:58:36 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/IntegerStamp.java	Fri Jul 13 11:29:15 2012 +0200
@@ -104,9 +104,6 @@
 
     @Override
     public Stamp meet(Stamp otherStamp) {
-        if (otherStamp == StampFactory.top()) {
-            return this;
-        }
         IntegerStamp other = (IntegerStamp) otherStamp;
         assert kind() == other.kind();
         long meetUpperBound = Math.max(upperBound, other.upperBound);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/ObjectStamp.java	Thu Jul 12 18:58:36 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/ObjectStamp.java	Fri Jul 13 11:29:15 2012 +0200
@@ -75,9 +75,6 @@
 
     @Override
     public Stamp meet(Stamp otherStamp) {
-        if (otherStamp == StampFactory.top()) {
-            return this;
-        }
         ObjectStamp other = (ObjectStamp) otherStamp;
         ResolvedJavaType orType = meetTypes(type(), other.type());
         boolean meetExactType = orType == type && orType == other.type && exactType && other.exactType;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampFactory.java	Thu Jul 12 18:58:36 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampFactory.java	Fri Jul 13 11:29:15 2012 +0200
@@ -28,7 +28,6 @@
 
 
 public class StampFactory {
-    private static final TopStamp top = new TopStamp();
     private static final Stamp[] stampCache = new Stamp[Kind.values().length];
     private static final Stamp objectStamp = new ObjectStamp(null, false, false);
     private static final Stamp objectNonNullStamp = new ObjectStamp(null, false, true);
@@ -98,10 +97,6 @@
         return positiveInt;
     }
 
-    public static Stamp top() {
-        return top;
-    }
-
     public static Stamp forInteger(Kind kind, long lowerBound, long upperBound, long mask) {
         return new IntegerStamp(kind, lowerBound, upperBound, mask);
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/TopStamp.java	Thu Jul 12 18:58:36 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2012, 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.type;
-
-
-public final class TopStamp extends Stamp {
-
-    TopStamp() {
-        super(null);
-    }
-
-    @Override
-    public boolean alwaysDistinct(Stamp other) {
-        return false;
-    }
-
-    @Override
-    public Stamp meet(Stamp other) {
-        return other;
-    }
-
-}
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/WordStamp.java	Thu Jul 12 18:58:36 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/WordStamp.java	Fri Jul 13 11:29:15 2012 +0200
@@ -56,9 +56,6 @@
 
     @Override
     public Stamp meet(Stamp otherStamp) {
-        if (otherStamp == StampFactory.top()) {
-            return this;
-        }
         WordStamp other = (WordStamp) otherStamp;
         if (other.nonNull == nonNull) {
             return this;