Mercurial > hg > truffle
diff graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/LocationIdentity.java @ 19845:3d0116ec99c5
Create utilities LocationIdentity#isAny, LocationIdentity#isSingle, LocationIdentity#any, LocationIdentity#overlaps.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sat, 14 Mar 2015 01:28:20 +0100 |
parents | 426461951938 |
children | 66d45b977e44 |
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/LocationIdentity.java Sat Mar 14 01:09:21 2015 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/LocationIdentity.java Sat Mar 14 01:28:20 2015 +0100 @@ -40,7 +40,7 @@ * analysis of memory accesses. A read from this location cannot be moved or coalesced with * other reads because its interaction with other reads is not known. */ - public static final LocationIdentity ANY_LOCATION = NamedLocationIdentity.mutable("ANY_LOCATION"); + private static final LocationIdentity ANY_LOCATION = NamedLocationIdentity.mutable("ANY_LOCATION"); /** * Denotes the location of a value that is guaranteed to be unchanging. @@ -52,15 +52,37 @@ */ public static final LocationIdentity ARRAY_LENGTH_LOCATION = NamedLocationIdentity.immutable("[].length"); + protected final boolean immutable; + + public static LocationIdentity any() { + return ANY_LOCATION; + } + + protected LocationIdentity(boolean immutable) { + this.immutable = immutable; + } + /** * Denotes a location is unchanging in all cases. Not that this is different than the Java * notion of final which only requires definite assignment. */ - public boolean isImmutable() { - return false; + public final boolean isImmutable() { + return immutable; + } + + public final boolean isMutable() { + return !immutable; } - public boolean isMutable() { - return !isImmutable(); + public final boolean isAny() { + return this == ANY_LOCATION; + } + + public final boolean isSingle() { + return this != ANY_LOCATION; + } + + public final boolean overlaps(LocationIdentity other) { + return isAny() || other.isAny() || this.equals(other); } }