Mercurial > hg > graal-compiler
annotate graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotObjectConstantImpl.java @ 21652:5f3dda39d205
Truffle: add DynamicObject#containsKey, make flags parameter optional, minor simplifications
author | Andreas Woess <andreas.woess@oracle.com> |
---|---|
date | Mon, 01 Jun 2015 12:55:56 +0200 |
parents | 48c1ebd24120 |
children |
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 /* |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
2 * Copyright (c) 2009, 2014, 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 */ |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
23 package com.oracle.jvmci.hotspot; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
24 |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
25 import static com.oracle.jvmci.hotspot.HotSpotResolvedObjectTypeImpl.*; |
18543
0ec7e37451c7
added HotSpotObjectConstant.getType() and restricted access to some static methods in HotSpotObjectConstantImpl
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
26 |
18286
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
27 import java.lang.invoke.*; |
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
28 |
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:
21552
diff
changeset
|
29 import com.oracle.jvmci.meta.*; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
30 |
20973
cb406df0ecc3
Visit CompositeValues manually
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
31 import edu.umd.cs.findbugs.annotations.*; |
18288
feef9ed5fc56
added HotSpotObjectConstant.isInternedString()
Doug Simon <doug.simon@oracle.com>
parents:
18287
diff
changeset
|
32 |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
33 /** |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
34 * 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
|
35 * compiler/runtime interface. |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
36 */ |
18867
7f4cb7587f4c
localized replay compilation marker interface to HotSpot specific code
Doug Simon <doug.simon@oracle.com>
parents:
18655
diff
changeset
|
37 public final class HotSpotObjectConstantImpl extends AbstractValue 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
|
38 |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
39 public static JavaConstant forObject(Object object) { |
18359
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18320
diff
changeset
|
40 return forObject(object, false); |
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18320
diff
changeset
|
41 } |
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18320
diff
changeset
|
42 |
18543
0ec7e37451c7
added HotSpotObjectConstant.getType() and restricted access to some static methods in HotSpotObjectConstantImpl
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
43 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
|
44 if (object == null) { |
18490
ca81508f2a19
Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
18472
diff
changeset
|
45 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
|
46 } else { |
18359
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18320
diff
changeset
|
47 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
|
48 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
49 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
50 |
18543
0ec7e37451c7
added HotSpotObjectConstant.getType() and restricted access to some static methods in HotSpotObjectConstantImpl
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
51 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
|
52 if (object == null) { |
18490
ca81508f2a19
Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
18472
diff
changeset
|
53 return JavaConstant.NULL_POINTER; |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
54 } else { |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
55 assert object.getClass().isArray(); |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
56 return new HotSpotObjectConstantImpl(object, false, stableDimension, isDefaultStable); |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
57 } |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
58 } |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
59 |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18186
diff
changeset
|
60 public static JavaConstant forBoxedValue(Kind kind, Object value) { |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
61 if (kind == Kind.Object) { |
18262
f7d45e2426d4
converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18188
diff
changeset
|
62 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
|
63 } else { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18186
diff
changeset
|
64 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
|
65 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
66 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
67 |
18543
0ec7e37451c7
added HotSpotObjectConstant.getType() and restricted access to some static methods in HotSpotObjectConstantImpl
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
68 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
|
69 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
|
70 return null; |
18262
f7d45e2426d4
converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18188
diff
changeset
|
71 } else if (constant instanceof HotSpotObjectConstantImpl) { |
f7d45e2426d4
converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18188
diff
changeset
|
72 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
|
73 } else { |
18188
8652481a1110
Introduce new Constant interface for use in high-level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
74 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
|
75 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
76 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
77 |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
78 private final Object object; |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
79 private final boolean compressed; |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
80 private final byte stableDimension; |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
81 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
|
82 |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
83 private HotSpotObjectConstantImpl(Object object, boolean compressed, int stableDimension, boolean isDefaultStable) { |
16116
9e5a323e0a1e
Remove hotspot specific NarrowOop kind, use LIRKind.reference(Kind.Int) instead.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
84 super(LIRKind.reference(compressed ? Kind.Int : Kind.Object)); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
85 this.object = object; |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
86 this.compressed = compressed; |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
87 this.stableDimension = (byte) stableDimension; |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
88 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
|
89 assert object != null; |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
90 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
|
91 assert stableDimension >= 0 && stableDimension <= 255; |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
92 assert !isDefaultStable || stableDimension > 0; |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
93 } |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
94 |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
95 private HotSpotObjectConstantImpl(Object object, boolean compressed) { |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
96 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
|
97 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
98 |
18290
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
99 /** |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
100 * Package-private accessor for the object represented by this constant. |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
101 */ |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
102 Object object() { |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
103 return object; |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
104 } |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
105 |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
106 /** |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
107 * Determines if the object represented by this constant is {@link Object#equals(Object) equal} |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
108 * to a given object. |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
109 */ |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
110 public boolean isEqualTo(Object obj) { |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
111 return object.equals(obj); |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
112 } |
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 /** |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
115 * Gets the class of the object represented by this constant. |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
116 */ |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
117 public Class<?> getObjectClass() { |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
118 return object.getClass(); |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
119 } |
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
120 |
18289
7acff34abbf7
replaced HotSpotObjectConstantImpl.isCompressed() with HotSpotObjectConstant.isCompressed()
Doug Simon <doug.simon@oracle.com>
parents:
18288
diff
changeset
|
121 public boolean isCompressed() { |
7acff34abbf7
replaced HotSpotObjectConstantImpl.isCompressed() with HotSpotObjectConstant.isCompressed()
Doug Simon <doug.simon@oracle.com>
parents:
18288
diff
changeset
|
122 return compressed; |
7acff34abbf7
replaced HotSpotObjectConstantImpl.isCompressed() with HotSpotObjectConstant.isCompressed()
Doug Simon <doug.simon@oracle.com>
parents:
18288
diff
changeset
|
123 } |
7acff34abbf7
replaced HotSpotObjectConstantImpl.isCompressed() with HotSpotObjectConstant.isCompressed()
Doug Simon <doug.simon@oracle.com>
parents:
18288
diff
changeset
|
124 |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18186
diff
changeset
|
125 public JavaConstant compress() { |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
126 assert !compressed; |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
127 return new HotSpotObjectConstantImpl(object, true, stableDimension, isDefaultStable); |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
128 } |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
129 |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18186
diff
changeset
|
130 public JavaConstant uncompress() { |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
131 assert compressed; |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
132 return new HotSpotObjectConstantImpl(object, false, stableDimension, isDefaultStable); |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
133 } |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
134 |
18543
0ec7e37451c7
added HotSpotObjectConstant.getType() and restricted access to some static methods in HotSpotObjectConstantImpl
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
135 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
|
136 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
|
137 } |
0ec7e37451c7
added HotSpotObjectConstant.getType() and restricted access to some static methods in HotSpotObjectConstantImpl
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
138 |
18280
c7e0405a35d8
added HotSpotObjectConstant.getClassLoader()
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
139 public JavaConstant getClassLoader() { |
c7e0405a35d8
added HotSpotObjectConstant.getClassLoader()
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
140 if (object instanceof Class) { |
c7e0405a35d8
added HotSpotObjectConstant.getClassLoader()
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
141 /* |
c7e0405a35d8
added HotSpotObjectConstant.getClassLoader()
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
142 * 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
|
143 * can't call that directly so just call getClassLoader. |
c7e0405a35d8
added HotSpotObjectConstant.getClassLoader()
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
144 */ |
c7e0405a35d8
added HotSpotObjectConstant.getClassLoader()
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
145 return HotSpotObjectConstantImpl.forObject(((Class<?>) object).getClassLoader()); |
c7e0405a35d8
added HotSpotObjectConstant.getClassLoader()
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
146 } |
c7e0405a35d8
added HotSpotObjectConstant.getClassLoader()
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
147 return null; |
c7e0405a35d8
added HotSpotObjectConstant.getClassLoader()
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
148 } |
c7e0405a35d8
added HotSpotObjectConstant.getClassLoader()
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
149 |
18282
ecf3de366ecc
added HotSpotObjectConstant.getIdentityHashCode()
Doug Simon <doug.simon@oracle.com>
parents:
18280
diff
changeset
|
150 public int getIdentityHashCode() { |
ecf3de366ecc
added HotSpotObjectConstant.getIdentityHashCode()
Doug Simon <doug.simon@oracle.com>
parents:
18280
diff
changeset
|
151 return System.identityHashCode(object); |
ecf3de366ecc
added HotSpotObjectConstant.getIdentityHashCode()
Doug Simon <doug.simon@oracle.com>
parents:
18280
diff
changeset
|
152 } |
ecf3de366ecc
added HotSpotObjectConstant.getIdentityHashCode()
Doug Simon <doug.simon@oracle.com>
parents:
18280
diff
changeset
|
153 |
18284
29ba2a7cdfcb
added HotSpotObjectConstant.getComponentType()
Doug Simon <doug.simon@oracle.com>
parents:
18283
diff
changeset
|
154 public JavaConstant getComponentType() { |
29ba2a7cdfcb
added HotSpotObjectConstant.getComponentType()
Doug Simon <doug.simon@oracle.com>
parents:
18283
diff
changeset
|
155 if (object instanceof Class) { |
29ba2a7cdfcb
added HotSpotObjectConstant.getComponentType()
Doug Simon <doug.simon@oracle.com>
parents:
18283
diff
changeset
|
156 return HotSpotObjectConstantImpl.forObject(((Class<?>) object).getComponentType()); |
29ba2a7cdfcb
added HotSpotObjectConstant.getComponentType()
Doug Simon <doug.simon@oracle.com>
parents:
18283
diff
changeset
|
157 } |
29ba2a7cdfcb
added HotSpotObjectConstant.getComponentType()
Doug Simon <doug.simon@oracle.com>
parents:
18283
diff
changeset
|
158 return null; |
29ba2a7cdfcb
added HotSpotObjectConstant.getComponentType()
Doug Simon <doug.simon@oracle.com>
parents:
18283
diff
changeset
|
159 } |
29ba2a7cdfcb
added HotSpotObjectConstant.getComponentType()
Doug Simon <doug.simon@oracle.com>
parents:
18283
diff
changeset
|
160 |
18285
420161aee840
added HotSpotObjectConstant.getSuperclass()
Doug Simon <doug.simon@oracle.com>
parents:
18284
diff
changeset
|
161 public JavaConstant getSuperclass() { |
420161aee840
added HotSpotObjectConstant.getSuperclass()
Doug Simon <doug.simon@oracle.com>
parents:
18284
diff
changeset
|
162 if (object instanceof Class) { |
420161aee840
added HotSpotObjectConstant.getSuperclass()
Doug Simon <doug.simon@oracle.com>
parents:
18284
diff
changeset
|
163 return HotSpotObjectConstantImpl.forObject(((Class<?>) object).getSuperclass()); |
420161aee840
added HotSpotObjectConstant.getSuperclass()
Doug Simon <doug.simon@oracle.com>
parents:
18284
diff
changeset
|
164 } |
420161aee840
added HotSpotObjectConstant.getSuperclass()
Doug Simon <doug.simon@oracle.com>
parents:
18284
diff
changeset
|
165 return null; |
420161aee840
added HotSpotObjectConstant.getSuperclass()
Doug Simon <doug.simon@oracle.com>
parents:
18284
diff
changeset
|
166 } |
420161aee840
added HotSpotObjectConstant.getSuperclass()
Doug Simon <doug.simon@oracle.com>
parents:
18284
diff
changeset
|
167 |
18286
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
168 public JavaConstant getCallSiteTarget(Assumptions assumptions) { |
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
169 if (object instanceof CallSite) { |
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
170 CallSite callSite = (CallSite) object; |
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
171 MethodHandle target = callSite.getTarget(); |
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
172 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
|
173 if (assumptions == null) { |
18286
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 assumptions.record(new Assumptions.CallSiteTargetValue(callSite, target)); |
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
177 } |
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
178 return HotSpotObjectConstantImpl.forObject(target); |
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
179 } |
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
180 return null; |
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
181 } |
ffcbc50063a3
added HotSpotObjectConstant.getCallSiteTarget()
Doug Simon <doug.simon@oracle.com>
parents:
18285
diff
changeset
|
182 |
18288
feef9ed5fc56
added HotSpotObjectConstant.isInternedString()
Doug Simon <doug.simon@oracle.com>
parents:
18287
diff
changeset
|
183 @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
|
184 public boolean isInternedString() { |
feef9ed5fc56
added HotSpotObjectConstant.isInternedString()
Doug Simon <doug.simon@oracle.com>
parents:
18287
diff
changeset
|
185 if (object instanceof String) { |
feef9ed5fc56
added HotSpotObjectConstant.isInternedString()
Doug Simon <doug.simon@oracle.com>
parents:
18287
diff
changeset
|
186 String s = (String) object; |
feef9ed5fc56
added HotSpotObjectConstant.isInternedString()
Doug Simon <doug.simon@oracle.com>
parents:
18287
diff
changeset
|
187 return s.intern() == s; |
feef9ed5fc56
added HotSpotObjectConstant.isInternedString()
Doug Simon <doug.simon@oracle.com>
parents:
18287
diff
changeset
|
188 } |
feef9ed5fc56
added HotSpotObjectConstant.isInternedString()
Doug Simon <doug.simon@oracle.com>
parents:
18287
diff
changeset
|
189 return false; |
feef9ed5fc56
added HotSpotObjectConstant.isInternedString()
Doug Simon <doug.simon@oracle.com>
parents:
18287
diff
changeset
|
190 } |
feef9ed5fc56
added HotSpotObjectConstant.isInternedString()
Doug Simon <doug.simon@oracle.com>
parents:
18287
diff
changeset
|
191 |
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
|
192 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
|
193 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
|
194 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
|
195 } |
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 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
|
197 } |
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 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
|
200 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
|
201 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
|
202 } |
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
|
203 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
|
204 } |
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
|
205 |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
206 @Override |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
207 public boolean isNull() { |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
208 return false; |
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 |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
211 @Override |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
212 public boolean isDefaultForKind() { |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
213 return false; |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
214 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
215 |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
216 @Override |
18186
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
217 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
|
218 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
|
219 } |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
220 |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
221 @Override |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
222 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
|
223 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
|
224 } |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
225 |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
226 @Override |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
227 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
|
228 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
|
229 } |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
230 |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
231 @Override |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
232 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
|
233 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
|
234 } |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
235 |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
236 @Override |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
237 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
|
238 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
|
239 } |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
240 |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
241 @Override |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
242 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
|
243 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
|
244 } |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
245 |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
246 @Override |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
247 public int hashCode() { |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
248 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
|
249 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
250 |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
251 @Override |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
252 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
|
253 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
|
254 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
|
255 } 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
|
256 HotSpotObjectConstantImpl other = (HotSpotObjectConstantImpl) o; |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
257 return super.equals(o) && 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
|
258 } |
7b60f8334af0
Compare compressed flag in HotSpotObjectConstantImpl#equals and reference equality in HotSpotConstantReflectionProvider#constantEquals
Andreas Woess <andreas.woess@jku.at>
parents:
18359
diff
changeset
|
259 return false; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
260 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
261 |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
262 @Override |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
263 public String toValueString() { |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
264 if (object instanceof String) { |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
265 return (String) object; |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
266 } else { |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
267 return Kind.Object.format(object); |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
268 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
269 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
270 |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
271 @Override |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
272 public String toString() { |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
273 return (compressed ? "NarrowOop" : getKind().getJavaName()) + "[" + Kind.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
|
274 } |
18472
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 * 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
|
278 */ |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
279 public int getStableDimension() { |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
280 return stableDimension & 0xff; |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
281 } |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
282 |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
283 /** |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
284 * 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
|
285 * 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
|
286 */ |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
287 public boolean isDefaultStable() { |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
288 return isDefaultStable; |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
289 } |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
290 } |