Mercurial > hg > truffle
annotate graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotMetaspaceConstantImpl.java @ 21762:1025d6dc645a
Merge.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sat, 06 Jun 2015 15:13:09 +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 /* |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. |
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 |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
25 import java.util.*; |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
26 |
21554
b1530a6cce8c
renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21552
diff
changeset
|
27 import com.oracle.jvmci.hotspot.HotSpotVMConfig.CompressEncoding; |
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:
21554
diff
changeset
|
28 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
|
29 |
18867
7f4cb7587f4c
localized replay compilation marker interface to HotSpot specific code
Doug Simon <doug.simon@oracle.com>
parents:
18655
diff
changeset
|
30 public final class HotSpotMetaspaceConstantImpl extends PrimitiveConstant implements HotSpotMetaspaceConstant, VMConstant, HotSpotProxified { |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
31 |
18296
a6e7531d3dd3
made HotSpotMetaspaceConstantImpl.forMetaspaceObject and HotSpotMetaspaceConstantImpl.getMetaspaceObject package private
Doug Simon <doug.simon@oracle.com>
parents:
18266
diff
changeset
|
32 static HotSpotMetaspaceConstantImpl forMetaspaceObject(Kind kind, long primitive, Object metaspaceObject, boolean compressed) { |
18266
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
33 return new HotSpotMetaspaceConstantImpl(kind, primitive, metaspaceObject, compressed); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
34 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
35 |
18359
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18302
diff
changeset
|
36 static Object getMetaspaceObject(Constant constant) { |
18266
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
37 return ((HotSpotMetaspaceConstantImpl) constant).metaspaceObject; |
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 |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
40 private final Object metaspaceObject; |
18176
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
41 private final boolean compressed; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
42 |
18266
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
43 private HotSpotMetaspaceConstantImpl(Kind kind, long primitive, Object metaspaceObject, 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 super(kind, primitive); |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
45 this.metaspaceObject = metaspaceObject; |
18176
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
46 this.compressed = compressed; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
47 } |
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 @Override |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
50 public int hashCode() { |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
51 return super.hashCode() ^ System.identityHashCode(metaspaceObject); |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
52 } |
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 @Override |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
55 public boolean equals(Object o) { |
18266
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
56 return o == this || (o instanceof HotSpotMetaspaceConstantImpl && super.equals(o) && Objects.equals(metaspaceObject, ((HotSpotMetaspaceConstantImpl) o).metaspaceObject)); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
57 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
58 |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
59 @Override |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
60 public String toString() { |
18176
c2270ad35f57
Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
61 return super.toString() + "{" + metaspaceObject + (compressed ? ";compressed}" : "}"); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
62 } |
18266
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
63 |
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
64 public boolean isCompressed() { |
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
65 return compressed; |
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
66 } |
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
67 |
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
68 public JavaConstant compress(CompressEncoding encoding) { |
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
69 assert !isCompressed(); |
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
70 HotSpotMetaspaceConstantImpl res = HotSpotMetaspaceConstantImpl.forMetaspaceObject(Kind.Int, encoding.compress(asLong()), metaspaceObject, true); |
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
71 assert res.isCompressed(); |
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
72 return res; |
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
73 } |
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
74 |
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
75 public JavaConstant uncompress(CompressEncoding encoding) { |
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
76 assert isCompressed(); |
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
77 HotSpotMetaspaceConstantImpl res = HotSpotMetaspaceConstantImpl.forMetaspaceObject(Kind.Long, encoding.uncompress(asInt()), metaspaceObject, false); |
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
78 assert !res.isCompressed(); |
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
79 return res; |
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
80 } |
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
81 |
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
82 public HotSpotResolvedObjectType asResolvedJavaType() { |
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
83 if (metaspaceObject instanceof HotSpotResolvedObjectType) { |
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
84 return (HotSpotResolvedObjectType) metaspaceObject; |
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
85 } |
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
86 return null; |
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
87 } |
18543
99bfecda9d2e
expose raw metaspace value via HotSpotMetaspaceConstant
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
88 |
99bfecda9d2e
expose raw metaspace value via HotSpotMetaspaceConstant
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
89 public long rawValue() { |
99bfecda9d2e
expose raw metaspace value via HotSpotMetaspaceConstant
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
90 return asLong(); |
99bfecda9d2e
expose raw metaspace value via HotSpotMetaspaceConstant
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
91 } |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
92 } |