comparison 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
comparison
equal deleted inserted replaced
19844:426461951938 19845:3d0116ec99c5
38 /** 38 /**
39 * Denotes any location. A write to such a location kills all values in a memory map during an 39 * Denotes any location. A write to such a location kills all values in a memory map during an
40 * analysis of memory accesses. A read from this location cannot be moved or coalesced with 40 * analysis of memory accesses. A read from this location cannot be moved or coalesced with
41 * other reads because its interaction with other reads is not known. 41 * other reads because its interaction with other reads is not known.
42 */ 42 */
43 public static final LocationIdentity ANY_LOCATION = NamedLocationIdentity.mutable("ANY_LOCATION"); 43 private static final LocationIdentity ANY_LOCATION = NamedLocationIdentity.mutable("ANY_LOCATION");
44 44
45 /** 45 /**
46 * Denotes the location of a value that is guaranteed to be unchanging. 46 * Denotes the location of a value that is guaranteed to be unchanging.
47 */ 47 */
48 public static final LocationIdentity FINAL_LOCATION = NamedLocationIdentity.immutable("FINAL_LOCATION"); 48 public static final LocationIdentity FINAL_LOCATION = NamedLocationIdentity.immutable("FINAL_LOCATION");
50 /** 50 /**
51 * Denotes the location of the length field of a Java array. 51 * Denotes the location of the length field of a Java array.
52 */ 52 */
53 public static final LocationIdentity ARRAY_LENGTH_LOCATION = NamedLocationIdentity.immutable("[].length"); 53 public static final LocationIdentity ARRAY_LENGTH_LOCATION = NamedLocationIdentity.immutable("[].length");
54 54
55 protected final boolean immutable;
56
57 public static LocationIdentity any() {
58 return ANY_LOCATION;
59 }
60
61 protected LocationIdentity(boolean immutable) {
62 this.immutable = immutable;
63 }
64
55 /** 65 /**
56 * Denotes a location is unchanging in all cases. Not that this is different than the Java 66 * Denotes a location is unchanging in all cases. Not that this is different than the Java
57 * notion of final which only requires definite assignment. 67 * notion of final which only requires definite assignment.
58 */ 68 */
59 public boolean isImmutable() { 69 public final boolean isImmutable() {
60 return false; 70 return immutable;
61 } 71 }
62 72
63 public boolean isMutable() { 73 public final boolean isMutable() {
64 return !isImmutable(); 74 return !immutable;
75 }
76
77 public final boolean isAny() {
78 return this == ANY_LOCATION;
79 }
80
81 public final boolean isSingle() {
82 return this != ANY_LOCATION;
83 }
84
85 public final boolean overlaps(LocationIdentity other) {
86 return isAny() || other.isAny() || this.equals(other);
65 } 87 }
66 } 88 }