changeset 20121:5f533a5c2aaf

Merge.
author Doug Simon <doug.simon@oracle.com>
date Wed, 01 Apr 2015 17:36:51 +0200
parents bba2b55908a1 (current diff) 45d46b136777 (diff)
children b9f65c441427
files
diffstat 9 files changed, 68 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/AbstractObjectStamp.java	Wed Apr 01 17:12:52 2015 +0200
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/AbstractObjectStamp.java	Wed Apr 01 17:36:51 2015 +0200
@@ -86,7 +86,11 @@
     }
 
     protected void appendString(StringBuilder str) {
-        str.append(nonNull() ? "!" : "").append(exactType ? "#" : "").append(' ').append(type == null ? "-" : type.getName()).append(alwaysNull() ? " NULL" : "");
+        if (this.isIllegal()) {
+            str.append(" illegal");
+        } else {
+            str.append(nonNull() ? "!" : "").append(exactType ? "#" : "").append(' ').append(type == null ? "-" : type.getName()).append(alwaysNull() ? " NULL" : "");
+        }
     }
 
     @Override
@@ -98,9 +102,9 @@
             return StampFactory.illegal(Kind.Illegal);
         }
         AbstractObjectStamp other = (AbstractObjectStamp) otherStamp;
-        if (!isLegal()) {
+        if (isIllegal()) {
             return other;
-        } else if (!other.isLegal()) {
+        } else if (other.isIllegal()) {
             return this;
         }
         ResolvedJavaType meetType;
@@ -154,14 +158,15 @@
      * this reason, in some cases a {@code castTo} operation is preferable in order to keep at least
      * the {@link AbstractList} type.
      *
-     * @param to the stamp this stamp should be casted to
-     * @return This stamp casted to the {@code to} stamp
+     * @param other the stamp this stamp should be casted to
+     * @return the new improved stamp or {@code null} if this stamp cannot be improved
      */
-    public Stamp castTo(ObjectStamp to) {
-        return join0(to, true);
+    @Override
+    public Stamp improveWith(Stamp other) {
+        return join0(other, true);
     }
 
-    private Stamp join0(Stamp otherStamp, boolean castToOther) {
+    private Stamp join0(Stamp otherStamp, boolean improve) {
         if (this == otherStamp) {
             return this;
         }
@@ -169,9 +174,9 @@
             return StampFactory.illegal(Kind.Illegal);
         }
         AbstractObjectStamp other = (AbstractObjectStamp) otherStamp;
-        if (!isLegal()) {
+        if (isIllegal()) {
             return this;
-        } else if (!other.isLegal()) {
+        } else if (other.isIllegal()) {
             return other;
         }
 
@@ -200,9 +205,9 @@
                     joinAlwaysNull = true;
                 }
             } else {
-                if (castToOther) {
-                    joinType = other.type;
-                    joinExactType = other.exactType;
+                if (improve) {
+                    joinType = type;
+                    joinExactType = exactType;
                 } else {
                     joinType = null;
                 }
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/ArithmeticStamp.java	Wed Apr 01 17:12:52 2015 +0200
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/ArithmeticStamp.java	Wed Apr 01 17:36:51 2015 +0200
@@ -45,6 +45,11 @@
     public abstract SerializableConstant deserialize(ByteBuffer buffer);
 
     @Override
+    public Stamp improveWith(Stamp other) {
+        return this.join(other);
+    }
+
+    @Override
     public int hashCode() {
         final int prime = 31;
         int result = 1;
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IllegalStamp.java	Wed Apr 01 17:12:52 2015 +0200
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IllegalStamp.java	Wed Apr 01 17:36:51 2015 +0200
@@ -90,6 +90,11 @@
     }
 
     @Override
+    public Stamp improveWith(Stamp other) {
+        return this;
+    }
+
+    @Override
     public Constant readConstant(MemoryAccessProvider provider, Constant base, long displacement) {
         throw GraalInternalError.shouldNotReachHere("can't read values of illegal stamp");
     }
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/Stamp.java	Wed Apr 01 17:12:52 2015 +0200
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/Stamp.java	Wed Apr 01 17:36:51 2015 +0200
@@ -40,7 +40,7 @@
     public abstract ResolvedJavaType javaType(MetaAccessProvider metaAccess);
 
     public boolean alwaysDistinct(Stamp other) {
-        return !join(other).isLegal();
+        return join(other).isIllegal();
     }
 
     /**
@@ -106,6 +106,13 @@
     public abstract boolean isLegal();
 
     /**
+     * Tests whether this stamp represents an illegal value.
+     */
+    public final boolean isIllegal() {
+        return !isLegal();
+    }
+
+    /**
      * If this stamp represents a single value, the methods returns this single value. It returns
      * null otherwise.
      *
@@ -123,17 +130,27 @@
 
     /**
      * Tries to improve this stamp with the stamp given as parameter. If successful, returns the new
+     * improved stamp. Otherwise, returns a stamp equal to this.
+     *
+     * @param other the stamp that should be used to improve this stamp
+     * @return the newly improved stamp or a stamp equal to {@code this} if an improvement was not
+     *         possible
+     */
+    public abstract Stamp improveWith(Stamp other);
+
+    /**
+     * Tries to improve this stamp with the stamp given as parameter. If successful, returns the new
      * improved stamp. Otherwise, returns null.
      *
      * @param other the stamp that should be used to improve this stamp
-     * @return the newly improved stamp of null if an improvement was not possible
+     * @return the newly improved stamp or {@code null} if an improvement was not possible
      */
-    public Stamp tryImprove(Stamp other) {
-        Stamp newStamp = this.join(other);
-        if (newStamp.equals(this)) {
+    public final Stamp tryImproveWith(Stamp other) {
+        Stamp improved = improveWith(other);
+        if (improved.equals(this)) {
             return null;
         }
-        return newStamp;
+        return improved;
     }
 
     public boolean neverDistinct(Stamp other) {
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/VoidStamp.java	Wed Apr 01 17:12:52 2015 +0200
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/VoidStamp.java	Wed Apr 01 17:36:51 2015 +0200
@@ -45,6 +45,14 @@
     }
 
     @Override
+    public Stamp improveWith(Stamp other) {
+        if (other instanceof VoidStamp) {
+            return this;
+        }
+        return StampFactory.illegal(Kind.Illegal);
+    }
+
+    @Override
     public LIRKind getLIRKind(LIRKindTool tool) {
         throw GraalInternalError.shouldNotReachHere("void stamp has no value");
     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/MetaspacePointerStamp.java	Wed Apr 01 17:12:52 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/MetaspacePointerStamp.java	Wed Apr 01 17:36:51 2015 +0200
@@ -47,6 +47,11 @@
     }
 
     @Override
+    public Stamp improveWith(Stamp other) {
+        return this;
+    }
+
+    @Override
     public Stamp join(Stamp other) {
         if (!isCompatible(other)) {
             return StampFactory.illegal();
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardedValueNode.java	Wed Apr 01 17:12:52 2015 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardedValueNode.java	Wed Apr 01 17:36:51 2015 +0200
@@ -66,10 +66,7 @@
 
     @Override
     public boolean inferStamp() {
-        if (piStamp instanceof ObjectStamp && object().stamp() instanceof ObjectStamp) {
-            return updateStamp(((ObjectStamp) object().stamp()).castTo((ObjectStamp) piStamp));
-        }
-        return updateStamp(object().stamp().join(piStamp));
+        return updateStamp(piStamp.improveWith(object().stamp()));
     }
 
     @Override
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PiNode.java	Wed Apr 01 17:12:52 2015 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PiNode.java	Wed Apr 01 17:36:51 2015 +0200
@@ -84,10 +84,7 @@
         if (piStamp == StampFactory.forNodeIntrinsic()) {
             return false;
         }
-        if (piStamp instanceof ObjectStamp && object.stamp() instanceof ObjectStamp) {
-            return updateStamp(((ObjectStamp) object.stamp()).castTo((ObjectStamp) piStamp));
-        }
-        return updateStamp(piStamp.join(object().stamp()));
+        return updateStamp(piStamp.improveWith(object().stamp()));
     }
 
     @Override
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java	Wed Apr 01 17:12:52 2015 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java	Wed Apr 01 17:36:51 2015 +0200
@@ -113,10 +113,7 @@
      */
     @Override
     public void lower(LoweringTool tool) {
-        Stamp newStamp = StampFactory.declaredTrusted(type);
-        if (stamp() instanceof ObjectStamp && object().stamp() instanceof ObjectStamp) {
-            newStamp = ((ObjectStamp) object().stamp()).castTo((ObjectStamp) newStamp);
-        }
+        Stamp newStamp = StampFactory.declaredTrusted(type).improveWith(object().stamp());
         ValueNode condition;
         ValueNode theValue = object;
         if (newStamp instanceof IllegalStamp) {
@@ -156,7 +153,7 @@
     public boolean inferStamp() {
         if (object().stamp() instanceof ObjectStamp) {
             ObjectStamp castStamp = (ObjectStamp) StampFactory.declaredTrusted(type);
-            return updateStamp(((ObjectStamp) object().stamp()).castTo(castStamp));
+            return updateStamp(castStamp.improveWith(object().stamp()));
         }
         return false;
     }