# HG changeset patch # User Roland Schatz # Date 1428925250 -7200 # Node ID 7b0ff8da60574cce12680bdf374207c343ef5a1b # Parent 343021aacd2f9328fed463018121b79d99c797bc Make compilation fail if incompatible stamps are combined. diff -r 343021aacd2f -r 7b0ff8da6057 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/AbstractObjectStamp.java --- 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; diff -r 343021aacd2f -r 7b0ff8da6057 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/FloatStamp.java --- 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); diff -r 343021aacd2f -r 7b0ff8da6057 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IllegalStamp.java --- 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; } diff -r 343021aacd2f -r 7b0ff8da6057 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IntegerStamp.java --- 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; diff -r 343021aacd2f -r 7b0ff8da6057 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/StampFactory.java --- 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()]; } diff -r 343021aacd2f -r 7b0ff8da6057 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/VoidStamp.java --- 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 diff -r 343021aacd2f -r 7b0ff8da6057 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/MetaspacePointerStamp.java --- 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; }