Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotObjectConstantImpl.java @ 22773:9273bb6ba33e
Simplify code installation interface: Use CompiledCode class instead of CompilationResult and DataSection.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Fri, 15 Jan 2016 16:50:19 +0100 |
parents | 1bbd4a7c274b |
children | f102ee538647 |
rev | line source |
---|---|
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
1 /* |
22489
24b4e5e1431c
Remove JavaConstant from Value hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
22398
diff
changeset
|
2 * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
4 * |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
8 * |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
14 * |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
18 * |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
21 * questions. |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
22 */ |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22645
diff
changeset
|
23 package jdk.vm.ci.hotspot; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
24 |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22645
diff
changeset
|
25 import static jdk.vm.ci.hotspot.HotSpotResolvedObjectTypeImpl.fromObjectClass; |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22536
diff
changeset
|
26 |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22536
diff
changeset
|
27 import java.lang.invoke.CallSite; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22536
diff
changeset
|
28 import java.lang.invoke.ConstantCallSite; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22536
diff
changeset
|
29 import java.lang.invoke.MethodHandle; |
18543
0ec7e37451c7
added HotSpotObjectConstant.getType() and restricted access to some static methods in HotSpotObjectConstantImpl
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
30 |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22645
diff
changeset
|
31 import jdk.vm.ci.inittimer.SuppressFBWarnings; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22645
diff
changeset
|
32 import jdk.vm.ci.meta.Assumptions; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22645
diff
changeset
|
33 import jdk.vm.ci.meta.Constant; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22645
diff
changeset
|
34 import jdk.vm.ci.meta.JavaConstant; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22645
diff
changeset
|
35 import jdk.vm.ci.meta.JavaKind; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22645
diff
changeset
|
36 import jdk.vm.ci.meta.ResolvedJavaType; |
18288
feef9ed5fc56
added HotSpotObjectConstant.isInternedString()
Doug Simon <doug.simon@oracle.com>
parents:
18287
diff
changeset
|
37 |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
38 /** |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
39 * Represents a constant non-{@code null} object reference, within the compiler and across the |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
40 * compiler/runtime interface. |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
41 */ |
22645
c33f0cb02b34
Add ConstantReflectionProvider.forObject method and make HotSpotObjectConstantImpl package-private.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
42 final class HotSpotObjectConstantImpl implements HotSpotObjectConstant, HotSpotProxified { |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
43 |
22645
c33f0cb02b34
Add ConstantReflectionProvider.forObject method and make HotSpotObjectConstantImpl package-private.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
44 static JavaConstant forObject(Object object) { |
18359
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18320
diff
changeset
|
45 return forObject(object, false); |
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18320
diff
changeset
|
46 } |
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18320
diff
changeset
|
47 |
18543
0ec7e37451c7
added HotSpotObjectConstant.getType() and restricted access to some static methods in HotSpotObjectConstantImpl
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
48 static JavaConstant forObject(Object object, boolean compressed) { |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
49 if (object == null) { |
18490
ca81508f2a19
Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
18472
diff
changeset
|
50 return compressed ? HotSpotCompressedNullConstant.COMPRESSED_NULL : JavaConstant.NULL_POINTER; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
51 } else { |
18359
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18320
diff
changeset
|
52 return new HotSpotObjectConstantImpl(object, compressed); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
53 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
54 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
55 |
18543
0ec7e37451c7
added HotSpotObjectConstant.getType() and restricted access to some static methods in HotSpotObjectConstantImpl
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
56 static JavaConstant forStableArray(Object object, int stableDimension, boolean isDefaultStable) { |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
57 if (object == null) { |
18490
ca81508f2a19
Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
18472
diff
changeset
|
58 return JavaConstant.NULL_POINTER; |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
59 } else { |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
60 assert object.getClass().isArray(); |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
61 return new HotSpotObjectConstantImpl(object, false, stableDimension, isDefaultStable); |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
62 } |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
63 } |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
64 |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22489
diff
changeset
|
65 public static JavaConstant forBoxedValue(JavaKind kind, Object value) { |
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22489
diff
changeset
|
66 if (kind == JavaKind.Object) { |
18262
f7d45e2426d4
converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18188
diff
changeset
|
67 return HotSpotObjectConstantImpl.forObject(value); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
68 } else { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18186
diff
changeset
|
69 return JavaConstant.forBoxedPrimitive(value); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
70 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
71 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
72 |
18543
0ec7e37451c7
added HotSpotObjectConstant.getType() and restricted access to some static methods in HotSpotObjectConstantImpl
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
73 static Object asBoxedValue(Constant constant) { |
18188
8652481a1110
Introduce new Constant interface for use in high-level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
74 if (JavaConstant.isNull(constant)) { |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
75 return null; |
18262
f7d45e2426d4
converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18188
diff
changeset
|
76 } else if (constant instanceof HotSpotObjectConstantImpl) { |
f7d45e2426d4
converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18188
diff
changeset
|
77 return ((HotSpotObjectConstantImpl) constant).object; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
78 } else { |
18188
8652481a1110
Introduce new Constant interface for use in high-level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
79 return ((JavaConstant) constant).asBoxedPrimitive(); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
80 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
81 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
82 |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
83 private final Object object; |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
84 private final boolean compressed; |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
85 private final byte stableDimension; |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
86 private final boolean isDefaultStable; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
87 |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
88 private HotSpotObjectConstantImpl(Object object, boolean compressed, int stableDimension, boolean isDefaultStable) { |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
89 this.object = object; |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
90 this.compressed = compressed; |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
91 this.stableDimension = (byte) stableDimension; |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
92 this.isDefaultStable = isDefaultStable; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
93 assert object != null; |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
94 assert stableDimension == 0 || (object != null && object.getClass().isArray()); |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
95 assert stableDimension >= 0 && stableDimension <= 255; |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
96 assert !isDefaultStable || stableDimension > 0; |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
97 } |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
98 |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
99 private HotSpotObjectConstantImpl(Object object, boolean compressed) { |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
100 this(object, compressed, 0, false); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
101 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
102 |
22489
24b4e5e1431c
Remove JavaConstant from Value hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
22398
diff
changeset
|
103 @Override |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22489
diff
changeset
|
104 public JavaKind getJavaKind() { |
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22489
diff
changeset
|
105 return JavaKind.Object; |
22489
24b4e5e1431c
Remove JavaConstant from Value hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
22398
diff
changeset
|
106 } |
24b4e5e1431c
Remove JavaConstant from Value hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
22398
diff
changeset
|
107 |
18290
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
108 /** |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
109 * Package-private accessor for the object represented by this constant. |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
110 */ |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
111 Object object() { |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
112 return object; |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
113 } |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
114 |
18289
7acff34abbf7
replaced HotSpotObjectConstantImpl.isCompressed() with HotSpotObjectConstant.isCompressed()
Doug Simon <doug.simon@oracle.com>
parents:
18288
diff
changeset
|
115 public boolean isCompressed() { |
7acff34abbf7
replaced HotSpotObjectConstantImpl.isCompressed() with HotSpotObjectConstant.isCompressed()
Doug Simon <doug.simon@oracle.com>
parents:
18288
diff
changeset
|
116 return compressed; |
7acff34abbf7
replaced HotSpotObjectConstantImpl.isCompressed() with HotSpotObjectConstant.isCompressed()
Doug Simon <doug.simon@oracle.com>
parents:
18288
diff
changeset
|
117 } |
7acff34abbf7
replaced HotSpotObjectConstantImpl.isCompressed() with HotSpotObjectConstant.isCompressed()
Doug Simon <doug.simon@oracle.com>
parents:
18288
diff
changeset
|
118 |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18186
diff
changeset
|
119 public JavaConstant compress() { |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
120 assert !compressed; |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
121 return new HotSpotObjectConstantImpl(object, true, stableDimension, isDefaultStable); |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
122 } |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
123 |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18186
diff
changeset
|
124 public JavaConstant uncompress() { |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
125 assert compressed; |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
126 return new HotSpotObjectConstantImpl(object, false, stableDimension, isDefaultStable); |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
127 } |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
128 |
18543
0ec7e37451c7
added HotSpotObjectConstant.getType() and restricted access to some static methods in HotSpotObjectConstantImpl
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
129 public HotSpotResolvedObjectType getType() { |
0ec7e37451c7
added HotSpotObjectConstant.getType() and restricted access to some static methods in HotSpotObjectConstantImpl
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
130 return fromObjectClass(object.getClass()); |
0ec7e37451c7
added HotSpotObjectConstant.getType() and restricted access to some static methods in HotSpotObjectConstantImpl
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
131 } |
0ec7e37451c7
added HotSpotObjectConstant.getType() and restricted access to some static methods in HotSpotObjectConstantImpl
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
132 |
18280
c7e0405a35d8
added HotSpotObjectConstant.getClassLoader()
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
133 public JavaConstant getClassLoader() { |
c7e0405a35d8
added HotSpotObjectConstant.getClassLoader()
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
134 if (object instanceof Class) { |
c7e0405a35d8
added HotSpotObjectConstant.getClassLoader()
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
135 /* |
c7e0405a35d8
added HotSpotObjectConstant.getClassLoader()
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
136 * This is an intrinsic for getClassLoader0, which occurs after any security checks. We |
c7e0405a35d8
added HotSpotObjectConstant.getClassLoader()
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
137 * can't call that directly so just call getClassLoader. |
c7e0405a35d8
added HotSpotObjectConstant.getClassLoader()
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
138 */ |
c7e0405a35d8
added HotSpotObjectConstant.getClassLoader()
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
139 return HotSpotObjectConstantImpl.forObject(((Class<?>) object).getClassLoader()); |
c7e0405a35d8
added HotSpotObjectConstant.getClassLoader()
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
140 } |
c7e0405a35d8
added HotSpotObjectConstant.getClassLoader()
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
141 return null; |
c7e0405a35d8
added HotSpotObjectConstant.getClassLoader()
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
142 } |
c7e0405a35d8
added HotSpotObjectConstant.getClassLoader()
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
143 |
18282
ecf3de366ecc
added HotSpotObjectConstant.getIdentityHashCode()
Doug Simon <doug.simon@oracle.com>
parents:
18280
diff
changeset
|
144 public int getIdentityHashCode() { |
ecf3de366ecc
added HotSpotObjectConstant.getIdentityHashCode()
Doug Simon <doug.simon@oracle.com>
parents:
18280
diff
changeset
|
145 return System.identityHashCode(object); |
ecf3de366ecc
added HotSpotObjectConstant.getIdentityHashCode()
Doug Simon <doug.simon@oracle.com>
parents:
18280
diff
changeset
|
146 } |
ecf3de366ecc
added HotSpotObjectConstant.getIdentityHashCode()
Doug Simon <doug.simon@oracle.com>
parents:
18280
diff
changeset
|
147 |
18284
29ba2a7cdfcb
added HotSpotObjectConstant.getComponentType()
Doug Simon <doug.simon@oracle.com>
parents:
18283
diff
changeset
|
148 public JavaConstant getComponentType() { |
29ba2a7cdfcb
added HotSpotObjectConstant.getComponentType()
Doug Simon <doug.simon@oracle.com>
parents:
18283
diff
changeset
|
149 if (object instanceof Class) { |
29ba2a7cdfcb
added HotSpotObjectConstant.getComponentType()
Doug Simon <doug.simon@oracle.com>
parents:
18283
diff
changeset
|
150 return HotSpotObjectConstantImpl.forObject(((Class<?>) object).getComponentType()); |
29ba2a7cdfcb
added HotSpotObjectConstant.getComponentType()
Doug Simon <doug.simon@oracle.com>
parents:
18283
diff
changeset
|
151 } |
29ba2a7cdfcb
added HotSpotObjectConstant.getComponentType()
Doug Simon <doug.simon@oracle.com>
parents:
18283
diff
changeset
|
152 return null; |
29ba2a7cdfcb
added HotSpotObjectConstant.getComponentType()
Doug Simon <doug.simon@oracle.com>
parents:
18283
diff
changeset
|
153 } |
29ba2a7cdfcb
added HotSpotObjectConstant.getComponentType()
Doug Simon <doug.simon@oracle.com>
parents:
18283
diff
changeset
|
154 |
18285
420161aee840
added HotSpotObjectConstant.getSuperclass()
Doug Simon <doug.simon@oracle.com>
parents:
18284
diff
changeset
|
155 public JavaConstant getSuperclass() { |
420161aee840
added HotSpotObjectConstant.getSuperclass()
Doug Simon <doug.simon@oracle.com>
parents:
18284
diff
changeset
|
156 if (object instanceof Class) { |
420161aee840
added HotSpotObjectConstant.getSuperclass()
Doug Simon <doug.simon@oracle.com>
parents:
18284
diff
changeset
|
157 return HotSpotObjectConstantImpl.forObject(((Class<?>) object).getSuperclass()); |
420161aee840
added HotSpotObjectConstant.getSuperclass()
Doug Simon <doug.simon@oracle.com>
parents:
18284
diff
changeset
|
158 } |
420161aee840
added HotSpotObjectConstant.getSuperclass()
Doug Simon <doug.simon@oracle.com>
parents:
18284
diff
changeset
|
159 return null; |
420161aee840
added HotSpotObjectConstant.getSuperclass()
Doug Simon <doug.simon@oracle.com>
parents:
18284
diff
changeset
|
160 } |
420161aee840
added HotSpotObjectConstant.getSuperclass()
Doug Simon <doug.simon@oracle.com>
parents:
18284
diff
changeset
|
161 |
18286
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
162 public JavaConstant getCallSiteTarget(Assumptions assumptions) { |
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
163 if (object instanceof CallSite) { |
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
164 CallSite callSite = (CallSite) object; |
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
165 MethodHandle target = callSite.getTarget(); |
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
166 if (!(callSite instanceof ConstantCallSite)) { |
19306
a0a760b0fb5f
pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
167 if (assumptions == null) { |
18286
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
168 return null; |
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
169 } |
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
170 assumptions.record(new Assumptions.CallSiteTargetValue(callSite, target)); |
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
171 } |
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
172 return HotSpotObjectConstantImpl.forObject(target); |
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
173 } |
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
174 return null; |
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
175 } |
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
176 |
18288
feef9ed5fc56
added HotSpotObjectConstant.isInternedString()
Doug Simon <doug.simon@oracle.com>
parents:
18287
diff
changeset
|
177 @SuppressFBWarnings(value = "ES_COMPARING_STRINGS_WITH_EQ", justification = "reference equality is what we want") |
feef9ed5fc56
added HotSpotObjectConstant.isInternedString()
Doug Simon <doug.simon@oracle.com>
parents:
18287
diff
changeset
|
178 public boolean isInternedString() { |
feef9ed5fc56
added HotSpotObjectConstant.isInternedString()
Doug Simon <doug.simon@oracle.com>
parents:
18287
diff
changeset
|
179 if (object instanceof String) { |
feef9ed5fc56
added HotSpotObjectConstant.isInternedString()
Doug Simon <doug.simon@oracle.com>
parents:
18287
diff
changeset
|
180 String s = (String) object; |
feef9ed5fc56
added HotSpotObjectConstant.isInternedString()
Doug Simon <doug.simon@oracle.com>
parents:
18287
diff
changeset
|
181 return s.intern() == s; |
feef9ed5fc56
added HotSpotObjectConstant.isInternedString()
Doug Simon <doug.simon@oracle.com>
parents:
18287
diff
changeset
|
182 } |
feef9ed5fc56
added HotSpotObjectConstant.isInternedString()
Doug Simon <doug.simon@oracle.com>
parents:
18287
diff
changeset
|
183 return false; |
feef9ed5fc56
added HotSpotObjectConstant.isInternedString()
Doug Simon <doug.simon@oracle.com>
parents:
18287
diff
changeset
|
184 } |
feef9ed5fc56
added HotSpotObjectConstant.isInternedString()
Doug Simon <doug.simon@oracle.com>
parents:
18287
diff
changeset
|
185 |
18533
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
186 public <T> T asObject(Class<T> type) { |
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
187 if (type.isInstance(object)) { |
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
188 return type.cast(object); |
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
189 } |
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
190 return null; |
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
191 } |
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
192 |
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
193 public Object asObject(ResolvedJavaType type) { |
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
194 if (type.isInstance(this)) { |
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
195 return object; |
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
196 } |
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
197 return null; |
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
198 } |
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
199 |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
200 @Override |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
201 public boolean isNull() { |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
202 return false; |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
203 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
204 |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
205 @Override |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
206 public boolean isDefaultForKind() { |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
207 return false; |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
208 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
209 |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
210 @Override |
18186
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
211 public Object asBoxedPrimitive() { |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
212 throw new IllegalArgumentException(); |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
213 } |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
214 |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
215 @Override |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
216 public int asInt() { |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
217 throw new IllegalArgumentException(); |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
218 } |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
219 |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
220 @Override |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
221 public boolean asBoolean() { |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
222 throw new IllegalArgumentException(); |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
223 } |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
224 |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
225 @Override |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
226 public long asLong() { |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
227 throw new IllegalArgumentException(); |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
228 } |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
229 |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
230 @Override |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
231 public float asFloat() { |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
232 throw new IllegalArgumentException(); |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
233 } |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
234 |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
235 @Override |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
236 public double asDouble() { |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
237 throw new IllegalArgumentException(); |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
238 } |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
239 |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
240 @Override |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
241 public int hashCode() { |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
242 return System.identityHashCode(object); |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
243 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
244 |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
245 @Override |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
246 public boolean equals(Object o) { |
18471
7b60f8334af0
Compare compressed flag in HotSpotObjectConstantImpl#equals and reference equality in HotSpotConstantReflectionProvider#constantEquals
Andreas Woess <andreas.woess@jku.at>
parents:
18359
diff
changeset
|
247 if (o == this) { |
7b60f8334af0
Compare compressed flag in HotSpotObjectConstantImpl#equals and reference equality in HotSpotConstantReflectionProvider#constantEquals
Andreas Woess <andreas.woess@jku.at>
parents:
18359
diff
changeset
|
248 return true; |
7b60f8334af0
Compare compressed flag in HotSpotObjectConstantImpl#equals and reference equality in HotSpotConstantReflectionProvider#constantEquals
Andreas Woess <andreas.woess@jku.at>
parents:
18359
diff
changeset
|
249 } else if (o instanceof HotSpotObjectConstantImpl) { |
7b60f8334af0
Compare compressed flag in HotSpotObjectConstantImpl#equals and reference equality in HotSpotConstantReflectionProvider#constantEquals
Andreas Woess <andreas.woess@jku.at>
parents:
18359
diff
changeset
|
250 HotSpotObjectConstantImpl other = (HotSpotObjectConstantImpl) o; |
22489
24b4e5e1431c
Remove JavaConstant from Value hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
22398
diff
changeset
|
251 return object == other.object && compressed == other.compressed && stableDimension == other.stableDimension && isDefaultStable == other.isDefaultStable; |
18471
7b60f8334af0
Compare compressed flag in HotSpotObjectConstantImpl#equals and reference equality in HotSpotConstantReflectionProvider#constantEquals
Andreas Woess <andreas.woess@jku.at>
parents:
18359
diff
changeset
|
252 } |
7b60f8334af0
Compare compressed flag in HotSpotObjectConstantImpl#equals and reference equality in HotSpotConstantReflectionProvider#constantEquals
Andreas Woess <andreas.woess@jku.at>
parents:
18359
diff
changeset
|
253 return false; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
254 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
255 |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
256 @Override |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
257 public String toValueString() { |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
258 if (object instanceof String) { |
22093
eb025d2d7ce2
Distinguish "null" from null in toValueString
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22087
diff
changeset
|
259 return "\"" + (String) object + "\""; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
260 } else { |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22489
diff
changeset
|
261 return JavaKind.Object.format(object); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
262 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
263 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
264 |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
265 @Override |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
266 public String toString() { |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22489
diff
changeset
|
267 return (compressed ? "NarrowOop" : getJavaKind().getJavaName()) + "[" + JavaKind.Object.format(object) + "]"; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
268 } |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
269 |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
270 /** |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
271 * Number of stable dimensions if this constant is a stable array. |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
272 */ |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
273 public int getStableDimension() { |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
274 return stableDimension & 0xff; |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
275 } |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
276 |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
277 /** |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
278 * Returns {@code true} if this is a stable array constant and its elements should be considered |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
279 * as stable regardless of whether they are default values. |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
280 */ |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
281 public boolean isDefaultStable() { |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
282 return isDefaultStable; |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
283 } |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
284 } |