Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/Value.java @ 24155:88bd5f7522a1 jvmci-0.30
update hgignore and undo change to hotspot/.project
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 07 Jul 2017 15:08:58 +0200 |
parents | 282873d0192c |
children |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
23396
9ed5b586018b
Replace LIRKind with abstract base class (JDK-8156942).
Roland Schatz <roland.schatz@oracle.com>
parents:
22672
diff
changeset
|
2 * Copyright (c) 2009, 2016, 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 */ |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22533
diff
changeset
|
23 package jdk.vm.ci.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 /** |
22504
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
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 */ |
22504
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
28 public abstract class Value { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 |
22504
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
30 public static final Value[] NO_VALUES = new Value[0]; |
21728
99fe8116f3e8
Make shared NO_VALUES array
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21556
diff
changeset
|
31 |
22504
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
32 public static final AllocatableValue ILLEGAL = new IllegalValue(); |
21729
e7f5ddef438d
Make illegal value a nested class
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21728
diff
changeset
|
33 |
22504
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
34 private static final class IllegalValue extends AllocatableValue { |
21729
e7f5ddef438d
Make illegal value a nested class
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21728
diff
changeset
|
35 private IllegalValue() { |
23396
9ed5b586018b
Replace LIRKind with abstract base class (JDK-8156942).
Roland Schatz <roland.schatz@oracle.com>
parents:
22672
diff
changeset
|
36 super(ValueKind.Illegal); |
21729
e7f5ddef438d
Make illegal value a nested class
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21728
diff
changeset
|
37 } |
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
|
38 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
39 @Override |
4169
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
40 public String toString() { |
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
41 return "-"; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
42 } |
19699
50b6f616b3c7
Use ILLEGAL.equals(value) in ValueUtil.isIllegal
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18584
diff
changeset
|
43 |
50b6f616b3c7
Use ILLEGAL.equals(value) in ValueUtil.isIllegal
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18584
diff
changeset
|
44 @Override |
50b6f616b3c7
Use ILLEGAL.equals(value) in ValueUtil.isIllegal
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18584
diff
changeset
|
45 public boolean equals(Object other) { |
19752
edf663acfb3f
Do not rely on object identity when comparing Value.ILLEGAL
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19699
diff
changeset
|
46 // Due to de-serialization this object may exist multiple times. So we compare classes |
edf663acfb3f
Do not rely on object identity when comparing Value.ILLEGAL
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19699
diff
changeset
|
47 // instead of the individual objects. (This anonymous class has always the same meaning) |
21729
e7f5ddef438d
Make illegal value a nested class
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21728
diff
changeset
|
48 return other instanceof IllegalValue; |
19699
50b6f616b3c7
Use ILLEGAL.equals(value) in ValueUtil.isIllegal
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18584
diff
changeset
|
49 } |
21729
e7f5ddef438d
Make illegal value a nested class
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21728
diff
changeset
|
50 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 |
23396
9ed5b586018b
Replace LIRKind with abstract base class (JDK-8156942).
Roland Schatz <roland.schatz@oracle.com>
parents:
22672
diff
changeset
|
52 private final ValueKind<?> valueKind; |
22504
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
53 |
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
54 /** |
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
55 * Initializes a new value of the specified kind. |
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
56 * |
23396
9ed5b586018b
Replace LIRKind with abstract base class (JDK-8156942).
Roland Schatz <roland.schatz@oracle.com>
parents:
22672
diff
changeset
|
57 * @param valueKind the kind |
22504
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
58 */ |
23396
9ed5b586018b
Replace LIRKind with abstract base class (JDK-8156942).
Roland Schatz <roland.schatz@oracle.com>
parents:
22672
diff
changeset
|
59 protected Value(ValueKind<?> valueKind) { |
9ed5b586018b
Replace LIRKind with abstract base class (JDK-8156942).
Roland Schatz <roland.schatz@oracle.com>
parents:
22672
diff
changeset
|
60 this.valueKind = valueKind; |
22504
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
61 } |
22402
37ec3ff2f8e0
Remove unused interface KindProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
62 |
22504
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
63 /** |
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
64 * Returns a String representation of the kind, which should be the end of all |
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
65 * {@link #toString()} implementation of subclasses. |
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
66 */ |
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
67 protected final String getKindSuffix() { |
23708
282873d0192c
Provide more control over the kind reported when printing Values
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
23396
diff
changeset
|
68 return "|" + valueKind.getKindSuffix(); |
22504
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
69 } |
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
70 |
23396
9ed5b586018b
Replace LIRKind with abstract base class (JDK-8156942).
Roland Schatz <roland.schatz@oracle.com>
parents:
22672
diff
changeset
|
71 public final ValueKind<?> getValueKind() { |
9ed5b586018b
Replace LIRKind with abstract base class (JDK-8156942).
Roland Schatz <roland.schatz@oracle.com>
parents:
22672
diff
changeset
|
72 return valueKind; |
9ed5b586018b
Replace LIRKind with abstract base class (JDK-8156942).
Roland Schatz <roland.schatz@oracle.com>
parents:
22672
diff
changeset
|
73 } |
9ed5b586018b
Replace LIRKind with abstract base class (JDK-8156942).
Roland Schatz <roland.schatz@oracle.com>
parents:
22672
diff
changeset
|
74 |
9ed5b586018b
Replace LIRKind with abstract base class (JDK-8156942).
Roland Schatz <roland.schatz@oracle.com>
parents:
22672
diff
changeset
|
75 public final <K extends ValueKind<K>> K getValueKind(Class<K> cls) { |
9ed5b586018b
Replace LIRKind with abstract base class (JDK-8156942).
Roland Schatz <roland.schatz@oracle.com>
parents:
22672
diff
changeset
|
76 return cls.cast(valueKind); |
22504
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
77 } |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
15453
diff
changeset
|
78 |
9422
149fe42411df
Use platform specific kind in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
9296
diff
changeset
|
79 /** |
149fe42411df
Use platform specific kind in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
9296
diff
changeset
|
80 * 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
|
81 */ |
22504
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
82 public final PlatformKind getPlatformKind() { |
23396
9ed5b586018b
Replace LIRKind with abstract base class (JDK-8156942).
Roland Schatz <roland.schatz@oracle.com>
parents:
22672
diff
changeset
|
83 return valueKind.getPlatformKind(); |
22504
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
84 } |
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
85 |
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
86 @Override |
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
87 public int hashCode() { |
23396
9ed5b586018b
Replace LIRKind with abstract base class (JDK-8156942).
Roland Schatz <roland.schatz@oracle.com>
parents:
22672
diff
changeset
|
88 return 41 + valueKind.hashCode(); |
22504
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
89 } |
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
90 |
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
91 @Override |
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
92 public boolean equals(Object obj) { |
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
93 if (obj instanceof Value) { |
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
94 Value that = (Value) obj; |
23396
9ed5b586018b
Replace LIRKind with abstract base class (JDK-8156942).
Roland Schatz <roland.schatz@oracle.com>
parents:
22672
diff
changeset
|
95 return valueKind.equals(that.valueKind); |
22504
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
96 } |
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
97 return false; |
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
98 } |
16735
55c59139cc57
Add identityEquals to Value.
Josef Eisl <josef.eisl@jku.at>
parents:
16094
diff
changeset
|
99 |
55c59139cc57
Add identityEquals to Value.
Josef Eisl <josef.eisl@jku.at>
parents:
16094
diff
changeset
|
100 /** |
55c59139cc57
Add identityEquals to Value.
Josef Eisl <josef.eisl@jku.at>
parents:
16094
diff
changeset
|
101 * Checks if this value is identical to {@code other}. |
55c59139cc57
Add identityEquals to Value.
Josef Eisl <josef.eisl@jku.at>
parents:
16094
diff
changeset
|
102 * |
55c59139cc57
Add identityEquals to Value.
Josef Eisl <josef.eisl@jku.at>
parents:
16094
diff
changeset
|
103 * 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
|
104 * should be used. |
55c59139cc57
Add identityEquals to Value.
Josef Eisl <josef.eisl@jku.at>
parents:
16094
diff
changeset
|
105 */ |
22504
943c2bf064fa
Collapse Value and AbstractValue into a single abstract base class.
Roland Schatz <roland.schatz@oracle.com>
parents:
22402
diff
changeset
|
106 public final boolean identityEquals(Value other) { |
16735
55c59139cc57
Add identityEquals to Value.
Josef Eisl <josef.eisl@jku.at>
parents:
16094
diff
changeset
|
107 return this == other; |
55c59139cc57
Add identityEquals to Value.
Josef Eisl <josef.eisl@jku.at>
parents:
16094
diff
changeset
|
108 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
109 } |