annotate graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ObjectLocationIdentity.java @ 12426:492c428f6035

made use of substitution when deriving a new Providers object
author Doug Simon <doug.simon@oracle.com>
date Mon, 14 Oct 2013 11:24:04 +0200
parents e04a86167368
children f5c368c08508
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11925
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2013, 2013, Oracle and/or its affiliates. All rights reserved.
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.api.meta;
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
11926
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11925
diff changeset
25 import java.util.*;
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11925
diff changeset
26
11925
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
27 /**
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28 * A {@link LocationIdentity} warpping an object.
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
29 */
11926
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11925
diff changeset
30 public final class ObjectLocationIdentity implements LocationIdentity {
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11925
diff changeset
31
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11925
diff changeset
32 private static IdentityHashMap<Object, LocationIdentity> map = new IdentityHashMap<>();
11925
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34 private Object object;
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35
11926
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11925
diff changeset
36 public static LocationIdentity create(Object object) {
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11925
diff changeset
37 synchronized (map) {
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11925
diff changeset
38 if (map.containsKey(object)) {
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11925
diff changeset
39 return map.get(object);
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11925
diff changeset
40 } else {
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11925
diff changeset
41 ObjectLocationIdentity locationIdentity = new ObjectLocationIdentity(object);
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11925
diff changeset
42 map.put(object, locationIdentity);
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11925
diff changeset
43 return locationIdentity;
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11925
diff changeset
44 }
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11925
diff changeset
45 }
11925
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
46 }
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
47
11926
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11925
diff changeset
48 private ObjectLocationIdentity(Object object) {
e04a86167368 Add support for unsafe access in early read elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11925
diff changeset
49 this.object = object;
11925
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50 }
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
52 @Override
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
53 public String toString() {
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
54 return "Identity(" + object + ")";
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
55 }
fe71a5ed24c2 Add object location identity class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56 }