Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompressedNullConstant.java @ 23677:eb166b568645
Merge
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Thu, 09 Jun 2016 18:58:09 -0700 |
parents | 1bbd4a7c274b |
children |
rev | line source |
---|---|
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
1 /* |
19871
51da1608115e
Move isCompressed method to HotSpotConstant interface.
Roland Schatz <roland.schatz@oracle.com>
parents:
18490
diff
changeset
|
2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
4 * |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
8 * |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
14 * |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
18 * |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
22 */ |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22590
diff
changeset
|
23 package jdk.vm.ci.hotspot; |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
24 |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22590
diff
changeset
|
25 import jdk.vm.ci.meta.Constant; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22590
diff
changeset
|
26 import jdk.vm.ci.meta.JavaConstant; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22590
diff
changeset
|
27 import jdk.vm.ci.meta.JavaKind; |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
28 |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
29 /** |
18490
ca81508f2a19
Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
18329
diff
changeset
|
30 * The compressed representation of the {@link JavaConstant#NULL_POINTER null constant}. |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
31 */ |
22489
24b4e5e1431c
Remove JavaConstant from Value hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
32 public final class HotSpotCompressedNullConstant implements JavaConstant, HotSpotConstant { |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
33 |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18186
diff
changeset
|
34 public static final JavaConstant COMPRESSED_NULL = new HotSpotCompressedNullConstant(); |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
35 |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
36 private HotSpotCompressedNullConstant() { |
22489
24b4e5e1431c
Remove JavaConstant from Value hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
37 } |
24b4e5e1431c
Remove JavaConstant from Value hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
38 |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22489
diff
changeset
|
39 public JavaKind getJavaKind() { |
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22489
diff
changeset
|
40 return JavaKind.Object; |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
41 } |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
42 |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
43 @Override |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
44 public boolean isNull() { |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
45 return true; |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
46 } |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
47 |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
48 @Override |
19871
51da1608115e
Move isCompressed method to HotSpotConstant interface.
Roland Schatz <roland.schatz@oracle.com>
parents:
18490
diff
changeset
|
49 public boolean isCompressed() { |
51da1608115e
Move isCompressed method to HotSpotConstant interface.
Roland Schatz <roland.schatz@oracle.com>
parents:
18490
diff
changeset
|
50 return true; |
51da1608115e
Move isCompressed method to HotSpotConstant interface.
Roland Schatz <roland.schatz@oracle.com>
parents:
18490
diff
changeset
|
51 } |
51da1608115e
Move isCompressed method to HotSpotConstant interface.
Roland Schatz <roland.schatz@oracle.com>
parents:
18490
diff
changeset
|
52 |
22590
3f6488b29c1a
Remove rawValue from HotSpotMetaspaceConstantImpl, patch raw pointer at code installation time.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
53 public Constant compress() { |
3f6488b29c1a
Remove rawValue from HotSpotMetaspaceConstantImpl, patch raw pointer at code installation time.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
54 throw new IllegalArgumentException(); |
3f6488b29c1a
Remove rawValue from HotSpotMetaspaceConstantImpl, patch raw pointer at code installation time.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
55 } |
3f6488b29c1a
Remove rawValue from HotSpotMetaspaceConstantImpl, patch raw pointer at code installation time.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
56 |
3f6488b29c1a
Remove rawValue from HotSpotMetaspaceConstantImpl, patch raw pointer at code installation time.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
57 public Constant uncompress() { |
3f6488b29c1a
Remove rawValue from HotSpotMetaspaceConstantImpl, patch raw pointer at code installation time.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
58 return NULL_POINTER; |
3f6488b29c1a
Remove rawValue from HotSpotMetaspaceConstantImpl, patch raw pointer at code installation time.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
59 } |
3f6488b29c1a
Remove rawValue from HotSpotMetaspaceConstantImpl, patch raw pointer at code installation time.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
60 |
19871
51da1608115e
Move isCompressed method to HotSpotConstant interface.
Roland Schatz <roland.schatz@oracle.com>
parents:
18490
diff
changeset
|
61 @Override |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
62 public boolean isDefaultForKind() { |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
63 return true; |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
64 } |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
65 |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
66 @Override |
18186
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
67 public Object asBoxedPrimitive() { |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
68 throw new IllegalArgumentException(); |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
69 } |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
70 |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
71 @Override |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
72 public int asInt() { |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
73 throw new IllegalArgumentException(); |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
74 } |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
75 |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
76 @Override |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
77 public boolean asBoolean() { |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
78 throw new IllegalArgumentException(); |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
79 } |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
80 |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
81 @Override |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
82 public long asLong() { |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
83 throw new IllegalArgumentException(); |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
84 } |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
85 |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
86 @Override |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
87 public float asFloat() { |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
88 throw new IllegalArgumentException(); |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
89 } |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
90 |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
91 @Override |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
92 public double asDouble() { |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
93 throw new IllegalArgumentException(); |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
94 } |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
95 |
ef357effbda7
Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents:
17446
diff
changeset
|
96 @Override |
18329
75e72d395820
fixed toString() for JavaConstants
Doug Simon <doug.simon@oracle.com>
parents:
18320
diff
changeset
|
97 public String toString() { |
75e72d395820
fixed toString() for JavaConstants
Doug Simon <doug.simon@oracle.com>
parents:
18320
diff
changeset
|
98 return JavaConstant.toString(this); |
75e72d395820
fixed toString() for JavaConstants
Doug Simon <doug.simon@oracle.com>
parents:
18320
diff
changeset
|
99 } |
75e72d395820
fixed toString() for JavaConstants
Doug Simon <doug.simon@oracle.com>
parents:
18320
diff
changeset
|
100 |
75e72d395820
fixed toString() for JavaConstants
Doug Simon <doug.simon@oracle.com>
parents:
18320
diff
changeset
|
101 @Override |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
102 public String toValueString() { |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
103 return "null"; |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
104 } |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
105 |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
106 @Override |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
107 public int hashCode() { |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
108 return System.identityHashCode(this); |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
109 } |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
110 |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
111 @Override |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
112 public boolean equals(Object o) { |
18490
ca81508f2a19
Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
18329
diff
changeset
|
113 return o instanceof HotSpotCompressedNullConstant; |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
114 } |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
115 } |