annotate src/share/vm/c1/c1_ValueType.hpp @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 1999-2005 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 // type hierarchy
a61af66fc99e Initial load
duke
parents:
diff changeset
26 class ValueType;
a61af66fc99e Initial load
duke
parents:
diff changeset
27 class VoidType;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 class IntType;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 class IntConstant;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 class IntInterval;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 class LongType;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 class LongConstant;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 class FloatType;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 class FloatConstant;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 class DoubleType;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 class DoubleConstant;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 class ObjectType;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 class ObjectConstant;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 class ArrayType;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 class ArrayConstant;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 class InstanceType;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 class InstanceConstant;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 class ClassType;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 class ClassConstant;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 class AddressType;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 class AddressConstant;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 class IllegalType;
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // predefined types
a61af66fc99e Initial load
duke
parents:
diff changeset
51 extern VoidType* voidType;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 extern IntType* intType;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 extern LongType* longType;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 extern FloatType* floatType;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 extern DoubleType* doubleType;
a61af66fc99e Initial load
duke
parents:
diff changeset
56 extern ObjectType* objectType;
a61af66fc99e Initial load
duke
parents:
diff changeset
57 extern ArrayType* arrayType;
a61af66fc99e Initial load
duke
parents:
diff changeset
58 extern InstanceType* instanceType;
a61af66fc99e Initial load
duke
parents:
diff changeset
59 extern ClassType* classType;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 extern AddressType* addressType;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 extern IllegalType* illegalType;
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // predefined constants
a61af66fc99e Initial load
duke
parents:
diff changeset
65 extern IntConstant* intZero;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 extern IntConstant* intOne;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 extern ObjectConstant* objectNull;
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // tags
a61af66fc99e Initial load
duke
parents:
diff changeset
71 enum ValueTag {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // all legal tags must come first
a61af66fc99e Initial load
duke
parents:
diff changeset
73 intTag,
a61af66fc99e Initial load
duke
parents:
diff changeset
74 longTag,
a61af66fc99e Initial load
duke
parents:
diff changeset
75 floatTag,
a61af66fc99e Initial load
duke
parents:
diff changeset
76 doubleTag,
a61af66fc99e Initial load
duke
parents:
diff changeset
77 objectTag,
a61af66fc99e Initial load
duke
parents:
diff changeset
78 addressTag,
a61af66fc99e Initial load
duke
parents:
diff changeset
79 number_of_legal_tags,
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // all other tags must follow afterwards
a61af66fc99e Initial load
duke
parents:
diff changeset
81 voidTag = number_of_legal_tags,
a61af66fc99e Initial load
duke
parents:
diff changeset
82 illegalTag,
a61af66fc99e Initial load
duke
parents:
diff changeset
83 number_of_tags
a61af66fc99e Initial load
duke
parents:
diff changeset
84 };
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 class ValueType: public CompilationResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
89 const int _size;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 const ValueTag _tag;
a61af66fc99e Initial load
duke
parents:
diff changeset
91 ValueType();
a61af66fc99e Initial load
duke
parents:
diff changeset
92 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
93 ValueType(ValueTag tag, int size): _tag(tag), _size(size) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // initialization
a61af66fc99e Initial load
duke
parents:
diff changeset
97 static void initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
100 virtual ValueType* base() const = 0; // the 'canonical' type (e.g., intType for an IntConstant)
a61af66fc99e Initial load
duke
parents:
diff changeset
101 ValueTag tag() const { return _tag; } // the 'canonical' tag (useful for type matching)
a61af66fc99e Initial load
duke
parents:
diff changeset
102 int size() const { // the size of an object of the type in words
a61af66fc99e Initial load
duke
parents:
diff changeset
103 assert(_size > -1, "shouldn't be asking for size");
a61af66fc99e Initial load
duke
parents:
diff changeset
104 return _size;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
106 virtual const char tchar() const = 0; // the type 'character' for printing
a61af66fc99e Initial load
duke
parents:
diff changeset
107 virtual const char* name() const = 0; // the type name for printing
a61af66fc99e Initial load
duke
parents:
diff changeset
108 virtual bool is_constant() const { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // testers
a61af66fc99e Initial load
duke
parents:
diff changeset
111 bool is_void() { return tag() == voidTag; }
a61af66fc99e Initial load
duke
parents:
diff changeset
112 bool is_int() { return tag() == intTag; }
a61af66fc99e Initial load
duke
parents:
diff changeset
113 bool is_long() { return tag() == longTag; }
a61af66fc99e Initial load
duke
parents:
diff changeset
114 bool is_float() { return tag() == floatTag; }
a61af66fc99e Initial load
duke
parents:
diff changeset
115 bool is_double() { return tag() == doubleTag; }
a61af66fc99e Initial load
duke
parents:
diff changeset
116 bool is_object() { return as_ObjectType() != NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
117 bool is_array() { return as_ArrayType() != NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
118 bool is_instance() { return as_InstanceType() != NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
119 bool is_class() { return as_ClassType() != NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
120 bool is_address() { return as_AddressType() != NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
121 bool is_illegal() { return tag() == illegalTag; }
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 bool is_int_kind() const { return tag() == intTag || tag() == longTag; }
a61af66fc99e Initial load
duke
parents:
diff changeset
124 bool is_float_kind() const { return tag() == floatTag || tag() == doubleTag; }
a61af66fc99e Initial load
duke
parents:
diff changeset
125 bool is_object_kind() const { return tag() == objectTag; }
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 bool is_single_word() const { return _size == 1; }
a61af66fc99e Initial load
duke
parents:
diff changeset
128 bool is_double_word() const { return _size == 2; }
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // casting
a61af66fc99e Initial load
duke
parents:
diff changeset
131 virtual VoidType* as_VoidType() { return NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
132 virtual IntType* as_IntType() { return NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
133 virtual LongType* as_LongType() { return NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 virtual FloatType* as_FloatType() { return NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
135 virtual DoubleType* as_DoubleType() { return NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
136 virtual ObjectType* as_ObjectType() { return NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
137 virtual ArrayType* as_ArrayType() { return NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
138 virtual InstanceType* as_InstanceType() { return NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
139 virtual ClassType* as_ClassType() { return NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
140 virtual AddressType* as_AddressType() { return NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
141 virtual IllegalType* as_IllegalType() { return NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 virtual IntConstant* as_IntConstant() { return NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
144 virtual LongConstant* as_LongConstant() { return NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
145 virtual FloatConstant* as_FloatConstant() { return NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
146 virtual DoubleConstant* as_DoubleConstant() { return NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
147 virtual ObjectConstant* as_ObjectConstant() { return NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
148 virtual InstanceConstant* as_InstanceConstant(){ return NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
149 virtual ClassConstant* as_ClassConstant() { return NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
150 virtual ArrayConstant* as_ArrayConstant() { return NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
151 virtual AddressConstant* as_AddressConstant() { return NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // type operations
a61af66fc99e Initial load
duke
parents:
diff changeset
154 ValueType* meet(ValueType* y) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
155 ValueType* join(ValueType* y) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
156
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
158 void print(outputStream* s = tty) { s->print(name()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
159 };
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162 class VoidType: public ValueType {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
164 VoidType(): ValueType(voidTag, 0) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
165 virtual ValueType* base() const { return voidType; }
a61af66fc99e Initial load
duke
parents:
diff changeset
166 virtual const char tchar() const { return 'v'; }
a61af66fc99e Initial load
duke
parents:
diff changeset
167 virtual const char* name() const { return "void"; }
a61af66fc99e Initial load
duke
parents:
diff changeset
168 virtual VoidType* as_VoidType() { return this; }
a61af66fc99e Initial load
duke
parents:
diff changeset
169 };
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171
a61af66fc99e Initial load
duke
parents:
diff changeset
172 class IntType: public ValueType {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
174 IntType(): ValueType(intTag, 1) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
175 virtual ValueType* base() const { return intType; }
a61af66fc99e Initial load
duke
parents:
diff changeset
176 virtual const char tchar() const { return 'i'; }
a61af66fc99e Initial load
duke
parents:
diff changeset
177 virtual const char* name() const { return "int"; }
a61af66fc99e Initial load
duke
parents:
diff changeset
178 virtual IntType* as_IntType() { return this; }
a61af66fc99e Initial load
duke
parents:
diff changeset
179 };
a61af66fc99e Initial load
duke
parents:
diff changeset
180
a61af66fc99e Initial load
duke
parents:
diff changeset
181
a61af66fc99e Initial load
duke
parents:
diff changeset
182 class IntConstant: public IntType {
a61af66fc99e Initial load
duke
parents:
diff changeset
183 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
184 jint _value;
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
187 IntConstant(jint value) { _value = value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 jint value() const { return _value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 virtual bool is_constant() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
192 virtual IntConstant* as_IntConstant() { return this; }
a61af66fc99e Initial load
duke
parents:
diff changeset
193 };
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195
a61af66fc99e Initial load
duke
parents:
diff changeset
196 class IntInterval: public IntType {
a61af66fc99e Initial load
duke
parents:
diff changeset
197 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
198 jint _beg;
a61af66fc99e Initial load
duke
parents:
diff changeset
199 jint _end;
a61af66fc99e Initial load
duke
parents:
diff changeset
200
a61af66fc99e Initial load
duke
parents:
diff changeset
201 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
202 IntInterval(jint beg, jint end) {
a61af66fc99e Initial load
duke
parents:
diff changeset
203 assert(beg <= end, "illegal interval");
a61af66fc99e Initial load
duke
parents:
diff changeset
204 _beg = beg;
a61af66fc99e Initial load
duke
parents:
diff changeset
205 _end = end;
a61af66fc99e Initial load
duke
parents:
diff changeset
206 }
a61af66fc99e Initial load
duke
parents:
diff changeset
207
a61af66fc99e Initial load
duke
parents:
diff changeset
208 jint beg() const { return _beg; }
a61af66fc99e Initial load
duke
parents:
diff changeset
209 jint end() const { return _end; }
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 virtual bool is_interval() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
212 };
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214
a61af66fc99e Initial load
duke
parents:
diff changeset
215 class LongType: public ValueType {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
217 LongType(): ValueType(longTag, 2) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
218 virtual ValueType* base() const { return longType; }
a61af66fc99e Initial load
duke
parents:
diff changeset
219 virtual const char tchar() const { return 'l'; }
a61af66fc99e Initial load
duke
parents:
diff changeset
220 virtual const char* name() const { return "long"; }
a61af66fc99e Initial load
duke
parents:
diff changeset
221 virtual LongType* as_LongType() { return this; }
a61af66fc99e Initial load
duke
parents:
diff changeset
222 };
a61af66fc99e Initial load
duke
parents:
diff changeset
223
a61af66fc99e Initial load
duke
parents:
diff changeset
224
a61af66fc99e Initial load
duke
parents:
diff changeset
225 class LongConstant: public LongType {
a61af66fc99e Initial load
duke
parents:
diff changeset
226 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
227 jlong _value;
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
230 LongConstant(jlong value) { _value = value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232 jlong value() const { return _value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
233
a61af66fc99e Initial load
duke
parents:
diff changeset
234 virtual bool is_constant() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
235 virtual LongConstant* as_LongConstant() { return this; }
a61af66fc99e Initial load
duke
parents:
diff changeset
236 };
a61af66fc99e Initial load
duke
parents:
diff changeset
237
a61af66fc99e Initial load
duke
parents:
diff changeset
238
a61af66fc99e Initial load
duke
parents:
diff changeset
239 class FloatType: public ValueType {
a61af66fc99e Initial load
duke
parents:
diff changeset
240 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
241 FloatType(): ValueType(floatTag, 1) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
242 virtual ValueType* base() const { return floatType; }
a61af66fc99e Initial load
duke
parents:
diff changeset
243 virtual const char tchar() const { return 'f'; }
a61af66fc99e Initial load
duke
parents:
diff changeset
244 virtual const char* name() const { return "float"; }
a61af66fc99e Initial load
duke
parents:
diff changeset
245 virtual FloatType* as_FloatType() { return this; }
a61af66fc99e Initial load
duke
parents:
diff changeset
246 };
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248
a61af66fc99e Initial load
duke
parents:
diff changeset
249 class FloatConstant: public FloatType {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
251 jfloat _value;
a61af66fc99e Initial load
duke
parents:
diff changeset
252
a61af66fc99e Initial load
duke
parents:
diff changeset
253 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
254 FloatConstant(jfloat value) { _value = value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
255
a61af66fc99e Initial load
duke
parents:
diff changeset
256 jfloat value() const { return _value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
257
a61af66fc99e Initial load
duke
parents:
diff changeset
258 virtual bool is_constant() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
259 virtual FloatConstant* as_FloatConstant() { return this; }
a61af66fc99e Initial load
duke
parents:
diff changeset
260 };
a61af66fc99e Initial load
duke
parents:
diff changeset
261
a61af66fc99e Initial load
duke
parents:
diff changeset
262
a61af66fc99e Initial load
duke
parents:
diff changeset
263 class DoubleType: public ValueType {
a61af66fc99e Initial load
duke
parents:
diff changeset
264 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
265 DoubleType(): ValueType(doubleTag, 2) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
266 virtual ValueType* base() const { return doubleType; }
a61af66fc99e Initial load
duke
parents:
diff changeset
267 virtual const char tchar() const { return 'd'; }
a61af66fc99e Initial load
duke
parents:
diff changeset
268 virtual const char* name() const { return "double"; }
a61af66fc99e Initial load
duke
parents:
diff changeset
269 virtual DoubleType* as_DoubleType() { return this; }
a61af66fc99e Initial load
duke
parents:
diff changeset
270 };
a61af66fc99e Initial load
duke
parents:
diff changeset
271
a61af66fc99e Initial load
duke
parents:
diff changeset
272
a61af66fc99e Initial load
duke
parents:
diff changeset
273 class DoubleConstant: public DoubleType {
a61af66fc99e Initial load
duke
parents:
diff changeset
274 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
275 jdouble _value;
a61af66fc99e Initial load
duke
parents:
diff changeset
276
a61af66fc99e Initial load
duke
parents:
diff changeset
277 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
278 DoubleConstant(jdouble value) { _value = value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
279
a61af66fc99e Initial load
duke
parents:
diff changeset
280 jdouble value() const { return _value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
281
a61af66fc99e Initial load
duke
parents:
diff changeset
282 virtual bool is_constant() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
283 virtual DoubleConstant* as_DoubleConstant() { return this; }
a61af66fc99e Initial load
duke
parents:
diff changeset
284 };
a61af66fc99e Initial load
duke
parents:
diff changeset
285
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 class ObjectType: public ValueType {
a61af66fc99e Initial load
duke
parents:
diff changeset
288 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
289 ObjectType(): ValueType(objectTag, 1) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
290 virtual ValueType* base() const { return objectType; }
a61af66fc99e Initial load
duke
parents:
diff changeset
291 virtual const char tchar() const { return 'a'; }
a61af66fc99e Initial load
duke
parents:
diff changeset
292 virtual const char* name() const { return "object"; }
a61af66fc99e Initial load
duke
parents:
diff changeset
293 virtual ObjectType* as_ObjectType() { return this; }
a61af66fc99e Initial load
duke
parents:
diff changeset
294 virtual ciObject* constant_value() const { ShouldNotReachHere(); return NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
295 bool is_loaded() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
296 jobject encoding() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
297 };
a61af66fc99e Initial load
duke
parents:
diff changeset
298
a61af66fc99e Initial load
duke
parents:
diff changeset
299
a61af66fc99e Initial load
duke
parents:
diff changeset
300 class ObjectConstant: public ObjectType {
a61af66fc99e Initial load
duke
parents:
diff changeset
301 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
302 ciObject* _value;
a61af66fc99e Initial load
duke
parents:
diff changeset
303
a61af66fc99e Initial load
duke
parents:
diff changeset
304 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
305 ObjectConstant(ciObject* value) { _value = value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
306
a61af66fc99e Initial load
duke
parents:
diff changeset
307 ciObject* value() const { return _value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
308
a61af66fc99e Initial load
duke
parents:
diff changeset
309 virtual bool is_constant() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
310 virtual ObjectConstant* as_ObjectConstant() { return this; }
a61af66fc99e Initial load
duke
parents:
diff changeset
311 virtual ciObject* constant_value() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
312 };
a61af66fc99e Initial load
duke
parents:
diff changeset
313
a61af66fc99e Initial load
duke
parents:
diff changeset
314
a61af66fc99e Initial load
duke
parents:
diff changeset
315 class ArrayType: public ObjectType {
a61af66fc99e Initial load
duke
parents:
diff changeset
316 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
317 virtual ArrayType* as_ArrayType() { return this; }
a61af66fc99e Initial load
duke
parents:
diff changeset
318 };
a61af66fc99e Initial load
duke
parents:
diff changeset
319
a61af66fc99e Initial load
duke
parents:
diff changeset
320
a61af66fc99e Initial load
duke
parents:
diff changeset
321 class ArrayConstant: public ArrayType {
a61af66fc99e Initial load
duke
parents:
diff changeset
322 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
323 ciArray* _value;
a61af66fc99e Initial load
duke
parents:
diff changeset
324
a61af66fc99e Initial load
duke
parents:
diff changeset
325 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
326 ArrayConstant(ciArray* value) { _value = value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
327
a61af66fc99e Initial load
duke
parents:
diff changeset
328 ciArray* value() const { return _value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
329
a61af66fc99e Initial load
duke
parents:
diff changeset
330 virtual bool is_constant() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
331
a61af66fc99e Initial load
duke
parents:
diff changeset
332 virtual ArrayConstant* as_ArrayConstant() { return this; }
a61af66fc99e Initial load
duke
parents:
diff changeset
333 virtual ciObject* constant_value() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
334 };
a61af66fc99e Initial load
duke
parents:
diff changeset
335
a61af66fc99e Initial load
duke
parents:
diff changeset
336
a61af66fc99e Initial load
duke
parents:
diff changeset
337 class InstanceType: public ObjectType {
a61af66fc99e Initial load
duke
parents:
diff changeset
338 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
339 virtual InstanceType* as_InstanceType() { return this; }
a61af66fc99e Initial load
duke
parents:
diff changeset
340 };
a61af66fc99e Initial load
duke
parents:
diff changeset
341
a61af66fc99e Initial load
duke
parents:
diff changeset
342
a61af66fc99e Initial load
duke
parents:
diff changeset
343 class InstanceConstant: public InstanceType {
a61af66fc99e Initial load
duke
parents:
diff changeset
344 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
345 ciInstance* _value;
a61af66fc99e Initial load
duke
parents:
diff changeset
346
a61af66fc99e Initial load
duke
parents:
diff changeset
347 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
348 InstanceConstant(ciInstance* value) { _value = value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
349
a61af66fc99e Initial load
duke
parents:
diff changeset
350 ciInstance* value() const { return _value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
351
a61af66fc99e Initial load
duke
parents:
diff changeset
352 virtual bool is_constant() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
353
a61af66fc99e Initial load
duke
parents:
diff changeset
354 virtual InstanceConstant* as_InstanceConstant(){ return this; }
a61af66fc99e Initial load
duke
parents:
diff changeset
355 virtual ciObject* constant_value() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
356 };
a61af66fc99e Initial load
duke
parents:
diff changeset
357
a61af66fc99e Initial load
duke
parents:
diff changeset
358
a61af66fc99e Initial load
duke
parents:
diff changeset
359 class ClassType: public ObjectType {
a61af66fc99e Initial load
duke
parents:
diff changeset
360 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
361 virtual ClassType* as_ClassType() { return this; }
a61af66fc99e Initial load
duke
parents:
diff changeset
362 };
a61af66fc99e Initial load
duke
parents:
diff changeset
363
a61af66fc99e Initial load
duke
parents:
diff changeset
364
a61af66fc99e Initial load
duke
parents:
diff changeset
365 class ClassConstant: public ClassType {
a61af66fc99e Initial load
duke
parents:
diff changeset
366 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
367 ciInstanceKlass* _value;
a61af66fc99e Initial load
duke
parents:
diff changeset
368
a61af66fc99e Initial load
duke
parents:
diff changeset
369 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
370 ClassConstant(ciInstanceKlass* value) { _value = value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
371
a61af66fc99e Initial load
duke
parents:
diff changeset
372 ciInstanceKlass* value() const { return _value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
373
a61af66fc99e Initial load
duke
parents:
diff changeset
374 virtual bool is_constant() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
375
a61af66fc99e Initial load
duke
parents:
diff changeset
376 virtual ClassConstant* as_ClassConstant() { return this; }
a61af66fc99e Initial load
duke
parents:
diff changeset
377 virtual ciObject* constant_value() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
378 };
a61af66fc99e Initial load
duke
parents:
diff changeset
379
a61af66fc99e Initial load
duke
parents:
diff changeset
380
a61af66fc99e Initial load
duke
parents:
diff changeset
381 class AddressType: public ValueType {
a61af66fc99e Initial load
duke
parents:
diff changeset
382 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
383 AddressType(): ValueType(addressTag, 1) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
384 virtual ValueType* base() const { return addressType; }
a61af66fc99e Initial load
duke
parents:
diff changeset
385 virtual const char tchar() const { return 'r'; }
a61af66fc99e Initial load
duke
parents:
diff changeset
386 virtual const char* name() const { return "address"; }
a61af66fc99e Initial load
duke
parents:
diff changeset
387 virtual AddressType* as_AddressType() { return this; }
a61af66fc99e Initial load
duke
parents:
diff changeset
388 };
a61af66fc99e Initial load
duke
parents:
diff changeset
389
a61af66fc99e Initial load
duke
parents:
diff changeset
390
a61af66fc99e Initial load
duke
parents:
diff changeset
391 class AddressConstant: public AddressType {
a61af66fc99e Initial load
duke
parents:
diff changeset
392 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
393 jint _value;
a61af66fc99e Initial load
duke
parents:
diff changeset
394
a61af66fc99e Initial load
duke
parents:
diff changeset
395 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
396 AddressConstant(jint value) { _value = value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
397
a61af66fc99e Initial load
duke
parents:
diff changeset
398 jint value() const { return _value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
399
a61af66fc99e Initial load
duke
parents:
diff changeset
400 virtual bool is_constant() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
401
a61af66fc99e Initial load
duke
parents:
diff changeset
402 virtual AddressConstant* as_AddressConstant() { return this; }
a61af66fc99e Initial load
duke
parents:
diff changeset
403 };
a61af66fc99e Initial load
duke
parents:
diff changeset
404
a61af66fc99e Initial load
duke
parents:
diff changeset
405
a61af66fc99e Initial load
duke
parents:
diff changeset
406 class IllegalType: public ValueType {
a61af66fc99e Initial load
duke
parents:
diff changeset
407 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
408 IllegalType(): ValueType(illegalTag, -1) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
409 virtual ValueType* base() const { return illegalType; }
a61af66fc99e Initial load
duke
parents:
diff changeset
410 virtual const char tchar() const { return ' '; }
a61af66fc99e Initial load
duke
parents:
diff changeset
411 virtual const char* name() const { return "illegal"; }
a61af66fc99e Initial load
duke
parents:
diff changeset
412 virtual IllegalType* as_IllegalType() { return this; }
a61af66fc99e Initial load
duke
parents:
diff changeset
413 };
a61af66fc99e Initial load
duke
parents:
diff changeset
414
a61af66fc99e Initial load
duke
parents:
diff changeset
415
a61af66fc99e Initial load
duke
parents:
diff changeset
416 // conversion between ValueTypes, BasicTypes, and ciConstants
a61af66fc99e Initial load
duke
parents:
diff changeset
417 ValueType* as_ValueType(BasicType type);
a61af66fc99e Initial load
duke
parents:
diff changeset
418 ValueType* as_ValueType(ciConstant value);
a61af66fc99e Initial load
duke
parents:
diff changeset
419 BasicType as_BasicType(ValueType* type);
a61af66fc99e Initial load
duke
parents:
diff changeset
420
a61af66fc99e Initial load
duke
parents:
diff changeset
421 inline ValueType* as_ValueType(ciType* type) { return as_ValueType(type->basic_type()); }