Mercurial > hg > truffle
annotate graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/LocationIdentity.java @ 18584:bf7db79a6e45
only TrustedInterfaces can be checked with VerifyUsageWithEquals
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 01 Dec 2014 15:03:05 +0100 |
parents | c83efc00f6cc |
children | 6b73ce815fc2 |
rev | line source |
---|---|
9792
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.api.meta; |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
18317
c83efc00f6cc
made LocationIdentity values support .equals() instead of identity (i.e. '==') for equality comparisons (and as hash map keys)
Doug Simon <doug.simon@oracle.com>
parents:
18307
diff
changeset
|
25 import java.util.*; |
c83efc00f6cc
made LocationIdentity values support .equals() instead of identity (i.e. '==') for equality comparisons (and as hash map keys)
Doug Simon <doug.simon@oracle.com>
parents:
18307
diff
changeset
|
26 |
9792
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 /** |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 * Marker interface for location identities. Apart from the special values {@link #ANY_LOCATION} and |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
29 * {@link #FINAL_LOCATION}, a different location identity of two memory accesses guarantees that the |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 * two accesses do not interfere. |
18317
c83efc00f6cc
made LocationIdentity values support .equals() instead of identity (i.e. '==') for equality comparisons (and as hash map keys)
Doug Simon <doug.simon@oracle.com>
parents:
18307
diff
changeset
|
31 * |
c83efc00f6cc
made LocationIdentity values support .equals() instead of identity (i.e. '==') for equality comparisons (and as hash map keys)
Doug Simon <doug.simon@oracle.com>
parents:
18307
diff
changeset
|
32 * Clients of {@link LocationIdentity} must use {@link #equals(Object)}, not {@code ==}, when |
c83efc00f6cc
made LocationIdentity values support .equals() instead of identity (i.e. '==') for equality comparisons (and as hash map keys)
Doug Simon <doug.simon@oracle.com>
parents:
18307
diff
changeset
|
33 * comparing two {@link LocationIdentity} values for equality. Likewise, they must not use |
c83efc00f6cc
made LocationIdentity values support .equals() instead of identity (i.e. '==') for equality comparisons (and as hash map keys)
Doug Simon <doug.simon@oracle.com>
parents:
18307
diff
changeset
|
34 * {@link IdentityHashMap}s with {@link LocationIdentity} values as keys. |
9792
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 */ |
18584
bf7db79a6e45
only TrustedInterfaces can be checked with VerifyUsageWithEquals
Doug Simon <doug.simon@oracle.com>
parents:
18317
diff
changeset
|
36 public interface LocationIdentity extends TrustedInterface { |
9792
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 /** |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 * Denotes any location. A write to such a location kills all values in a memory map during an |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 * analysis of memory accesses. A read from this location cannot be moved or coalesced with |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 * other reads because its interaction with other reads is not known. |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 */ |
18307
85f5227a7a37
add mutable/immutable factory methods to NamedLocationIdentity
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18259
diff
changeset
|
43 LocationIdentity ANY_LOCATION = NamedLocationIdentity.mutable("ANY_LOCATION"); |
9792
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 |
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 /** |
18231
70df63b02309
Use LocationIdentity.isImmutable instead of testing against FINAL_LOCATION
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14019
diff
changeset
|
46 * Denotes the location of a value that is guaranteed to be unchanging. |
9792
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 */ |
18307
85f5227a7a37
add mutable/immutable factory methods to NamedLocationIdentity
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18259
diff
changeset
|
48 LocationIdentity FINAL_LOCATION = NamedLocationIdentity.immutable("FINAL_LOCATION"); |
9792
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 |
14019
9d864856336a
support canonicalization of arraylength in ReadNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
9792
diff
changeset
|
50 /** |
9d864856336a
support canonicalization of arraylength in ReadNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
9792
diff
changeset
|
51 * Denotes the location of the length field of a Java array. |
9d864856336a
support canonicalization of arraylength in ReadNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
9792
diff
changeset
|
52 */ |
18307
85f5227a7a37
add mutable/immutable factory methods to NamedLocationIdentity
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18259
diff
changeset
|
53 LocationIdentity ARRAY_LENGTH_LOCATION = NamedLocationIdentity.immutable("[].length"); |
18231
70df63b02309
Use LocationIdentity.isImmutable instead of testing against FINAL_LOCATION
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14019
diff
changeset
|
54 |
70df63b02309
Use LocationIdentity.isImmutable instead of testing against FINAL_LOCATION
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14019
diff
changeset
|
55 /** |
70df63b02309
Use LocationIdentity.isImmutable instead of testing against FINAL_LOCATION
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14019
diff
changeset
|
56 * Denotes a location is unchanging in all cases. Not that this is different than the Java |
70df63b02309
Use LocationIdentity.isImmutable instead of testing against FINAL_LOCATION
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14019
diff
changeset
|
57 * notion of final which only requires definite assignment. |
70df63b02309
Use LocationIdentity.isImmutable instead of testing against FINAL_LOCATION
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14019
diff
changeset
|
58 */ |
70df63b02309
Use LocationIdentity.isImmutable instead of testing against FINAL_LOCATION
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14019
diff
changeset
|
59 default boolean isImmutable() { |
70df63b02309
Use LocationIdentity.isImmutable instead of testing against FINAL_LOCATION
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14019
diff
changeset
|
60 return false; |
70df63b02309
Use LocationIdentity.isImmutable instead of testing against FINAL_LOCATION
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14019
diff
changeset
|
61 } |
9792
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 } |