Mercurial > hg > truffle
annotate graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/AbstractValue.java @ 21624:dcf65e8b9fd9
Merge.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Mon, 01 Jun 2015 00:44:38 +0200 |
parents | 48c1ebd24120 |
children | 26774dc3a5e7 |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
15453
diff
changeset
|
2 * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
21556
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
23 package com.oracle.jvmci.meta; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
25 /** |
18319
56cc1a799a60
(re)converted Value to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18186
diff
changeset
|
26 * Abstract base class for values. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
27 */ |
21411
082417ac43e4
removed com.oracle.graal.hotspot.server and uses of Serializable it depended upon (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18319
diff
changeset
|
28 public abstract class AbstractValue implements Value, KindProvider { |
18186
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
29 |
18319
56cc1a799a60
(re)converted Value to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18186
diff
changeset
|
30 public static final AllocatableValue ILLEGAL = Value.ILLEGAL; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 |
18186
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
32 private final Kind kind; |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
33 private final LIRKind lirKind; |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
34 |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
35 /** |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
36 * Initializes a new value of the specified kind. |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
37 * |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
38 * @param lirKind the kind |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
39 */ |
18319
56cc1a799a60
(re)converted Value to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18186
diff
changeset
|
40 protected AbstractValue(LIRKind lirKind) { |
18186
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
41 this.lirKind = lirKind; |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
42 if (getPlatformKind() instanceof Kind) { |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
43 this.kind = (Kind) getPlatformKind(); |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
44 } else { |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
45 this.kind = Kind.Illegal; |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
46 } |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
47 } |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
48 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
50 * Returns a String representation of the kind, which should be the end of all |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
51 * {@link #toString()} implementation of subclasses. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 */ |
18186
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
53 protected final String getKindSuffix() { |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6477
diff
changeset
|
54 return "|" + getKind().getTypeChar(); |
6329
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5851
diff
changeset
|
55 } |
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5851
diff
changeset
|
56 |
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5851
diff
changeset
|
57 /** |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6477
diff
changeset
|
58 * Returns the kind of this value. |
6329
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5851
diff
changeset
|
59 */ |
18186
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
60 public final Kind getKind() { |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
61 return kind; |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
62 } |
9422
149fe42411df
Use platform specific kind in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
9296
diff
changeset
|
63 |
18186
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
64 public final LIRKind getLIRKind() { |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
65 return lirKind; |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
66 } |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
15453
diff
changeset
|
67 |
9422
149fe42411df
Use platform specific kind in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
9296
diff
changeset
|
68 /** |
149fe42411df
Use platform specific kind in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
9296
diff
changeset
|
69 * Returns the platform specific kind used to store this value. |
149fe42411df
Use platform specific kind in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
9296
diff
changeset
|
70 */ |
18186
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
71 public final PlatformKind getPlatformKind() { |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
72 return lirKind.getPlatformKind(); |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
73 } |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
74 |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
75 @Override |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
76 public int hashCode() { |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
77 return 41 + lirKind.hashCode(); |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
78 } |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
79 |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
80 @Override |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
81 public boolean equals(Object obj) { |
18319
56cc1a799a60
(re)converted Value to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18186
diff
changeset
|
82 if (obj instanceof AbstractValue) { |
56cc1a799a60
(re)converted Value to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18186
diff
changeset
|
83 AbstractValue that = (AbstractValue) obj; |
18186
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
84 return kind.equals(that.kind) && lirKind.equals(that.lirKind); |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
85 } |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
86 return false; |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
87 } |
16735
55c59139cc57
Add identityEquals to Value.
Josef Eisl <josef.eisl@jku.at>
parents:
16094
diff
changeset
|
88 |
55c59139cc57
Add identityEquals to Value.
Josef Eisl <josef.eisl@jku.at>
parents:
16094
diff
changeset
|
89 /** |
55c59139cc57
Add identityEquals to Value.
Josef Eisl <josef.eisl@jku.at>
parents:
16094
diff
changeset
|
90 * Checks if this value is identical to {@code other}. |
55c59139cc57
Add identityEquals to Value.
Josef Eisl <josef.eisl@jku.at>
parents:
16094
diff
changeset
|
91 * |
55c59139cc57
Add identityEquals to Value.
Josef Eisl <josef.eisl@jku.at>
parents:
16094
diff
changeset
|
92 * Warning: Use with caution! Usually equivalence {@link #equals(Object)} is sufficient and |
55c59139cc57
Add identityEquals to Value.
Josef Eisl <josef.eisl@jku.at>
parents:
16094
diff
changeset
|
93 * should be used. |
55c59139cc57
Add identityEquals to Value.
Josef Eisl <josef.eisl@jku.at>
parents:
16094
diff
changeset
|
94 */ |
16736
1227fb471b6d
Add ExcludeFromIdentityComparisonVerification annotation.
Josef Eisl <josef.eisl@jku.at>
parents:
16735
diff
changeset
|
95 @ExcludeFromIdentityComparisonVerification |
18319
56cc1a799a60
(re)converted Value to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18186
diff
changeset
|
96 public final boolean identityEquals(AbstractValue other) { |
16735
55c59139cc57
Add identityEquals to Value.
Josef Eisl <josef.eisl@jku.at>
parents:
16094
diff
changeset
|
97 return this == other; |
55c59139cc57
Add identityEquals to Value.
Josef Eisl <josef.eisl@jku.at>
parents:
16094
diff
changeset
|
98 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
99 } |