changeset 15911:03e09ed7039d

Use correct stamp when creating ConstantNode.
author Roland Schatz <roland.schatz@oracle.com>
date Mon, 26 May 2014 16:16:47 +0200
parents 79a0d9065849
children c44f617fb8d7
files graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/AbstractObjectStamp.java graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/FloatStamp.java graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IllegalStamp.java graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IntegerStamp.java graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/Stamp.java graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/VoidStamp.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ConstantNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NarrowNode.java
diffstat 8 files changed, 40 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/AbstractObjectStamp.java	Mon May 26 16:13:58 2014 +0200
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/AbstractObjectStamp.java	Mon May 26 16:16:47 2014 +0200
@@ -53,6 +53,12 @@
     }
 
     @Override
+    public Stamp constant(Constant c, MetaAccessProvider meta) {
+        ResolvedJavaType constType = c.isNull() ? null : meta.lookupJavaType(c);
+        return copyWith(constType, c.isNonNull(), c.isNonNull(), c.isNull());
+    }
+
+    @Override
     public boolean isLegal() {
         return !exactType || (type != null && (isConcreteType(type)));
     }
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/FloatStamp.java	Mon May 26 16:13:58 2014 +0200
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/FloatStamp.java	Mon May 26 16:16:47 2014 +0200
@@ -54,6 +54,12 @@
     }
 
     @Override
+    public Stamp constant(Constant c, MetaAccessProvider meta) {
+        assert c.getKind().isNumericFloat() && c.getKind().getBitCount() == getBits();
+        return StampFactory.forConstant(c);
+    }
+
+    @Override
     public boolean isLegal() {
         return lowerBound <= upperBound || !nonNaN;
     }
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IllegalStamp.java	Mon May 26 16:13:58 2014 +0200
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IllegalStamp.java	Mon May 26 16:16:47 2014 +0200
@@ -55,6 +55,11 @@
     }
 
     @Override
+    public Stamp constant(Constant c, MetaAccessProvider meta) {
+        throw GraalInternalError.shouldNotReachHere("illegal stamp has no value");
+    }
+
+    @Override
     public ResolvedJavaType javaType(MetaAccessProvider metaAccess) {
         throw GraalInternalError.shouldNotReachHere("illegal stamp has no Java type");
     }
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IntegerStamp.java	Mon May 26 16:13:58 2014 +0200
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IntegerStamp.java	Mon May 26 16:16:47 2014 +0200
@@ -64,6 +64,12 @@
     }
 
     @Override
+    public Stamp constant(Constant c, MetaAccessProvider meta) {
+        long value = c.asLong();
+        return StampFactory.forInteger(getBits(), value, value);
+    }
+
+    @Override
     public boolean isLegal() {
         return lowerBound <= upperBound;
     }
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/Stamp.java	Mon May 26 16:13:58 2014 +0200
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/Stamp.java	Mon May 26 16:16:47 2014 +0200
@@ -88,6 +88,15 @@
     public abstract Stamp illegal();
 
     /**
+     * If it is possible to represent single value stamps of this kind, this method returns the
+     * stamp representing the single value c. stamp.constant(c).asConstant() should be equal to c.
+     * <p>
+     * If it is not possible to represent single value stamps, this method returns a stamp that
+     * includes c, and is otherwise as narrow as possible.
+     */
+    public abstract Stamp constant(Constant c, MetaAccessProvider meta);
+
+    /**
      * Test whether two stamps have the same base type.
      */
     public abstract boolean isCompatible(Stamp other);
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/VoidStamp.java	Mon May 26 16:13:58 2014 +0200
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/VoidStamp.java	Mon May 26 16:16:47 2014 +0200
@@ -102,6 +102,11 @@
         return true;
     }
 
+    @Override
+    public Stamp constant(Constant c, MetaAccessProvider meta) {
+        throw GraalInternalError.shouldNotReachHere("void stamp has no value");
+    }
+
     private static VoidStamp instance = new VoidStamp();
 
     static VoidStamp getInstance() {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ConstantNode.java	Mon May 26 16:13:58 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ConstantNode.java	Mon May 26 16:16:47 2014 +0200
@@ -153,13 +153,7 @@
     }
 
     public static ConstantNode forConstant(Stamp stamp, Constant constant, MetaAccessProvider metaAccess, StructuredGraph graph) {
-        if (stamp instanceof PrimitiveStamp) {
-            return forPrimitive(stamp, constant, graph);
-        } else {
-            ConstantNode ret = forConstant(constant, metaAccess, graph);
-            assert ret.stamp().isCompatible(stamp);
-            return ret;
-        }
+        return graph.unique(new ConstantNode(constant, stamp.constant(constant, metaAccess)));
     }
 
     /**
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NarrowNode.java	Mon May 26 16:13:58 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NarrowNode.java	Mon May 26 16:16:47 2014 +0200
@@ -41,7 +41,8 @@
     }
 
     public static long narrow(long value, int resultBits) {
-        return value & IntegerStamp.defaultMask(resultBits);
+        long ret = value & IntegerStamp.defaultMask(resultBits);
+        return SignExtendNode.signExtend(ret, resultBits);
     }
 
     @Override