annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCompressedNullConstant.java @ 19871:51da1608115e

Move isCompressed method to HotSpotConstant interface.
author Roland Schatz <roland.schatz@oracle.com>
date Fri, 13 Mar 2015 15:20:16 +0100
parents ca81508f2a19
children 082417ac43e4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 */
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.hotspot.meta;
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
24
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
25 import com.oracle.graal.api.meta.*;
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
26
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
27 /**
18490
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18329
diff changeset
28 * 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
29 */
18320
0093dcea7092 converted JavaConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
30 public final class HotSpotCompressedNullConstant extends AbstractValue implements JavaConstant, HotSpotConstant {
15909
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
31
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
32 private static final long serialVersionUID = 8906209595800783961L;
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() {
16116
9e5a323e0a1e Remove hotspot specific NarrowOop kind, use LIRKind.reference(Kind.Int) instead.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
37 super(LIRKind.reference(Kind.Int));
15909
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
38 }
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
39
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
40 @Override
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
41 public boolean isNull() {
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
42 return true;
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
43 }
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
44
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
45 @Override
19871
51da1608115e Move isCompressed method to HotSpotConstant interface.
Roland Schatz <roland.schatz@oracle.com>
parents: 18490
diff changeset
46 public boolean isCompressed() {
51da1608115e Move isCompressed method to HotSpotConstant interface.
Roland Schatz <roland.schatz@oracle.com>
parents: 18490
diff changeset
47 return true;
51da1608115e Move isCompressed method to HotSpotConstant interface.
Roland Schatz <roland.schatz@oracle.com>
parents: 18490
diff changeset
48 }
51da1608115e Move isCompressed method to HotSpotConstant interface.
Roland Schatz <roland.schatz@oracle.com>
parents: 18490
diff changeset
49
51da1608115e Move isCompressed method to HotSpotConstant interface.
Roland Schatz <roland.schatz@oracle.com>
parents: 18490
diff changeset
50 @Override
15909
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
51 public boolean isDefaultForKind() {
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
52 return true;
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
53 }
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
54
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
55 @Override
18186
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17446
diff changeset
56 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
57 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
58 }
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17446
diff changeset
59
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17446
diff changeset
60 @Override
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17446
diff changeset
61 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
62 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
63 }
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17446
diff changeset
64
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17446
diff changeset
65 @Override
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17446
diff changeset
66 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
67 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
68 }
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 @Override
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17446
diff changeset
71 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
72 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
73 }
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 @Override
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17446
diff changeset
76 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
77 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
78 }
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 @Override
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 17446
diff changeset
81 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
82 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
83 }
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 @Override
18329
75e72d395820 fixed toString() for JavaConstants
Doug Simon <doug.simon@oracle.com>
parents: 18320
diff changeset
86 public String toString() {
75e72d395820 fixed toString() for JavaConstants
Doug Simon <doug.simon@oracle.com>
parents: 18320
diff changeset
87 return JavaConstant.toString(this);
75e72d395820 fixed toString() for JavaConstants
Doug Simon <doug.simon@oracle.com>
parents: 18320
diff changeset
88 }
75e72d395820 fixed toString() for JavaConstants
Doug Simon <doug.simon@oracle.com>
parents: 18320
diff changeset
89
75e72d395820 fixed toString() for JavaConstants
Doug Simon <doug.simon@oracle.com>
parents: 18320
diff changeset
90 @Override
15909
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
91 public String toValueString() {
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
92 return "null";
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
93 }
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
94
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
95 @Override
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
96 public int hashCode() {
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
97 return System.identityHashCode(this);
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
98 }
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
99
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
100 @Override
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
101 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
102 return o instanceof HotSpotCompressedNullConstant;
15909
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
103 }
e43591136d9f Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
104 }