changeset 20899:7b0ff8da6057

Make compilation fail if incompatible stamps are combined.
author Roland Schatz <roland.schatz@oracle.com>
date Mon, 13 Apr 2015 13:40:50 +0200
parents 343021aacd2f
children c893d4112f30
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/StampFactory.java graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/VoidStamp.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/MetaspacePointerStamp.java
diffstat 7 files changed, 19 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/AbstractObjectStamp.java	Mon Apr 13 12:03:42 2015 +0200
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/AbstractObjectStamp.java	Mon Apr 13 13:40:50 2015 +0200
@@ -98,9 +98,6 @@
         if (this == otherStamp) {
             return this;
         }
-        if (!isCompatible(otherStamp)) {
-            return StampFactory.illegal(Kind.Illegal);
-        }
         AbstractObjectStamp other = (AbstractObjectStamp) otherStamp;
         if (isIllegal()) {
             return other;
@@ -170,9 +167,6 @@
         if (this == otherStamp) {
             return this;
         }
-        if (!isCompatible(otherStamp)) {
-            return StampFactory.illegal(Kind.Illegal);
-        }
         AbstractObjectStamp other = (AbstractObjectStamp) otherStamp;
         if (isIllegal()) {
             return this;
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/FloatStamp.java	Mon Apr 13 12:03:42 2015 +0200
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/FloatStamp.java	Mon Apr 13 13:40:50 2015 +0200
@@ -176,9 +176,6 @@
         if (otherStamp == this) {
             return this;
         }
-        if (!(otherStamp instanceof FloatStamp)) {
-            return StampFactory.illegal(Kind.Illegal);
-        }
         FloatStamp other = (FloatStamp) otherStamp;
         assert getBits() == other.getBits();
         double meetUpperBound = meetBounds(upperBound, other.upperBound, Math::max);
@@ -198,9 +195,6 @@
         if (otherStamp == this) {
             return this;
         }
-        if (!(otherStamp instanceof FloatStamp)) {
-            return StampFactory.illegal(Kind.Illegal);
-        }
         FloatStamp other = (FloatStamp) otherStamp;
         assert getBits() == other.getBits();
         double joinUpperBound = Math.min(upperBound, other.upperBound);
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IllegalStamp.java	Mon Apr 13 12:03:42 2015 +0200
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IllegalStamp.java	Mon Apr 13 13:40:50 2015 +0200
@@ -27,7 +27,9 @@
 import com.oracle.graal.compiler.common.spi.*;
 
 /**
- * This stamp represents the illegal type. Values with this type can not exist at run time.
+ * This stamp represents the type of the {@link Kind#Illegal} value in the second slot of
+ * {@link Kind#Long} and {@link Kind#Double} values. It can only appear in framestates or virtual
+ * objects.
  */
 public final class IllegalStamp extends Stamp {
 
@@ -56,7 +58,8 @@
 
     @Override
     public Stamp constant(Constant c, MetaAccessProvider meta) {
-        throw GraalInternalError.shouldNotReachHere("illegal stamp has no value");
+        assert ((PrimitiveConstant) c).getKind() == Kind.Illegal;
+        return this;
     }
 
     @Override
@@ -66,17 +69,19 @@
 
     @Override
     public Stamp meet(Stamp other) {
+        assert other instanceof IllegalStamp;
         return this;
     }
 
     @Override
     public Stamp join(Stamp other) {
+        assert other instanceof IllegalStamp;
         return this;
     }
 
     @Override
     public boolean isCompatible(Stamp stamp) {
-        return false;
+        return stamp instanceof IllegalStamp;
     }
 
     @Override
@@ -91,6 +96,7 @@
 
     @Override
     public Stamp improveWith(Stamp other) {
+        assert other instanceof IllegalStamp;
         return this;
     }
 
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IntegerStamp.java	Mon Apr 13 12:03:42 2015 +0200
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IntegerStamp.java	Mon Apr 13 13:40:50 2015 +0200
@@ -253,9 +253,6 @@
         if (otherStamp == this) {
             return this;
         }
-        if (!(otherStamp instanceof IntegerStamp)) {
-            return StampFactory.illegal(Kind.Illegal);
-        }
         IntegerStamp other = (IntegerStamp) otherStamp;
         return createStamp(other, Math.max(upperBound, other.upperBound), Math.min(lowerBound, other.lowerBound), downMask & other.downMask, upMask | other.upMask);
     }
@@ -265,9 +262,6 @@
         if (otherStamp == this) {
             return this;
         }
-        if (!(otherStamp instanceof IntegerStamp)) {
-            return StampFactory.illegal(Kind.Illegal);
-        }
         IntegerStamp other = (IntegerStamp) otherStamp;
         long newDownMask = downMask | other.downMask;
         long newLowerBound = Math.max(lowerBound, other.lowerBound) | newDownMask;
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/StampFactory.java	Mon Apr 13 12:03:42 2015 +0200
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/StampFactory.java	Mon Apr 13 13:40:50 2015 +0200
@@ -76,10 +76,9 @@
         for (Kind k : Kind.values()) {
             if (stampCache[k.ordinal()] != null) {
                 illegalStampCache[k.ordinal()] = stampCache[k.ordinal()].illegal();
-            } else {
-                illegalStampCache[k.ordinal()] = IllegalStamp.getInstance();
             }
         }
+        illegalStampCache[Kind.Illegal.ordinal()] = IllegalStamp.getInstance();
     }
 
     public static Stamp tautology() {
@@ -122,10 +121,6 @@
         return positiveInt;
     }
 
-    public static Stamp illegal() {
-        return illegal(Kind.Illegal);
-    }
-
     public static Stamp illegal(Kind kind) {
         return illegalStampCache[kind.ordinal()];
     }
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/VoidStamp.java	Mon Apr 13 12:03:42 2015 +0200
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/VoidStamp.java	Mon Apr 13 13:40:50 2015 +0200
@@ -46,10 +46,8 @@
 
     @Override
     public Stamp improveWith(Stamp other) {
-        if (other instanceof VoidStamp) {
-            return this;
-        }
-        return StampFactory.illegal(Kind.Illegal);
+        assert other instanceof VoidStamp;
+        return this;
     }
 
     @Override
@@ -74,29 +72,19 @@
 
     @Override
     public Stamp meet(Stamp other) {
-        if (other instanceof IllegalStamp) {
-            return other.join(this);
-        }
-        if (this == other) {
-            return this;
-        }
-        return StampFactory.illegal(Kind.Illegal);
+        assert other instanceof VoidStamp;
+        return this;
     }
 
     @Override
     public Stamp join(Stamp other) {
-        if (other instanceof IllegalStamp) {
-            return other.join(this);
-        }
-        if (this == other) {
-            return this;
-        }
-        return StampFactory.illegal(Kind.Illegal);
+        assert other instanceof VoidStamp;
+        return this;
     }
 
     @Override
     public boolean isCompatible(Stamp stamp) {
-        return this == stamp;
+        return stamp instanceof VoidStamp;
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/MetaspacePointerStamp.java	Mon Apr 13 12:03:42 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/MetaspacePointerStamp.java	Mon Apr 13 13:40:50 2015 +0200
@@ -40,9 +40,7 @@
 
     @Override
     public Stamp meet(Stamp other) {
-        if (!isCompatible(other)) {
-            return StampFactory.illegal();
-        }
+        assert isCompatible(other);
         return this;
     }
 
@@ -53,9 +51,7 @@
 
     @Override
     public Stamp join(Stamp other) {
-        if (!isCompatible(other)) {
-            return StampFactory.illegal();
-        }
+        assert isCompatible(other);
         return this;
     }