Print this page
rev 1025 : imported patch indy.compiler.patch
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/vm/ci/ciObject.hpp
+++ new/src/share/vm/ci/ciObject.hpp
1 1 /*
2 2 * Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 21 * have any questions.
22 22 *
23 23 */
24 24
25 25 // ciObject
26 26 //
27 27 // This class represents an oop in the HotSpot virtual machine.
28 28 // Its subclasses are structured in a hierarchy which mirrors
29 29 // an aggregate of the VM's oop and klass hierarchies (see
30 30 // oopHierarchy.hpp). Each instance of ciObject holds a handle
31 31 // to a corresponding oop on the VM side and provides routines
32 32 // for accessing the information in its oop. By using the ciObject
33 33 // hierarchy for accessing oops in the VM, the compiler ensures
34 34 // that it is safe with respect to garbage collection; that is,
35 35 // GC and compilation can proceed independently without
36 36 // interference.
37 37 //
38 38 // Within the VM, the oop and klass hierarchies are separate.
39 39 // The compiler interface does not preserve this separation --
40 40 // the distinction between `klassOop' and `Klass' are not
41 41 // reflected in the interface and instead the Klass hierarchy
42 42 // is directly modeled as the subclasses of ciKlass.
43 43 class ciObject : public ResourceObj {
44 44 CI_PACKAGE_ACCESS
45 45 friend class ciEnv;
46 46
47 47 private:
48 48 // A JNI handle referring to an oop in the VM. This
49 49 // handle may, in a small set of cases, correctly be NULL.
50 50 jobject _handle;
51 51 ciKlass* _klass;
52 52 uint _ident;
53 53
54 54 enum { FLAG_BITS = 2 };
55 55 enum {
56 56 PERM_FLAG = 1,
57 57 SCAVENGABLE_FLAG = 2
58 58 };
59 59 protected:
60 60 ciObject();
61 61 ciObject(oop o);
62 62 ciObject(Handle h);
63 63 ciObject(ciKlass* klass);
64 64
65 65 jobject handle() const { return _handle; }
66 66 // Get the VM oop that this object holds.
67 67 oop get_oop() const {
68 68 assert(_handle != NULL, "null oop");
69 69 return JNIHandles::resolve_non_null(_handle);
70 70 }
71 71
72 72 void init_flags_from(oop x) {
73 73 int flags = 0;
74 74 if (x != NULL) {
75 75 if (x->is_perm())
76 76 flags |= PERM_FLAG;
77 77 if (x->is_scavengable())
78 78 flags |= SCAVENGABLE_FLAG;
79 79 }
80 80 _ident |= flags;
81 81 }
82 82
83 83 // Virtual behavior of the print() method.
84 84 virtual void print_impl(outputStream* st) {}
85 85
86 86 virtual const char* type_string() { return "ciObject"; }
87 87
88 88 void set_ident(uint id);
89 89 public:
90 90 // The klass of this ciObject.
91 91 ciKlass* klass();
92 92
93 93 // A number unique to this object.
94 94 uint ident();
95 95
96 96 // Are two ciObjects equal?
97 97 bool equals(ciObject* obj);
98 98
99 99 // A hash value for the convenience of compilers.
100 100 int hash();
101 101
102 102 // Tells if this oop has an encoding as a constant.
103 103 // True if is_scavengable is false.
104 104 // Also true if ScavengeRootsInCode is non-zero.
105 105 // If it does not have an encoding, the compiler is responsible for
106 106 // making other arrangements for dealing with the oop.
107 107 // See ciEnv::make_array
108 108 bool can_be_constant();
109 109
110 110 // Tells if this oop should be made a constant.
111 111 // True if is_scavengable is false or ScavengeRootsInCode > 1.
112 112 bool should_be_constant();
113 113
114 114 // Is this object guaranteed to be in the permanent part of the heap?
115 115 // If so, CollectedHeap::can_elide_permanent_oop_store_barriers is relevant.
116 116 // If the answer is false, no guarantees are made.
117 117 bool is_perm() { return (_ident & PERM_FLAG) != 0; }
118 118
119 119 // Might this object possibly move during a scavenge operation?
120 120 // If the answer is true and ScavengeRootsInCode==0, the oop cannot be embedded in code.
121 121 bool is_scavengable() { return (_ident & SCAVENGABLE_FLAG) != 0; }
122 122
123 123 // The address which the compiler should embed into the
↓ open down ↓ |
123 lines elided |
↑ open up ↑ |
124 124 // generated code to represent this oop. This address
125 125 // is not the true address of the oop -- it will get patched
126 126 // during nmethod creation.
127 127 //
128 128 // Usage note: no address arithmetic allowed. Oop must
129 129 // be registered with the oopRecorder.
130 130 jobject constant_encoding();
131 131
132 132 // What kind of ciObject is this?
133 133 virtual bool is_null_object() const { return false; }
134 + virtual bool is_cpcache() const { return false; }
134 135 virtual bool is_instance() { return false; }
135 136 virtual bool is_method() { return false; }
136 137 virtual bool is_method_data() { return false; }
137 138 virtual bool is_array() { return false; }
138 139 virtual bool is_obj_array() { return false; }
139 140 virtual bool is_type_array() { return false; }
140 141 virtual bool is_symbol() { return false; }
141 142 virtual bool is_type() { return false; }
142 143 virtual bool is_return_address() { return false; }
143 144 virtual bool is_klass() { return false; }
144 145 virtual bool is_instance_klass() { return false; }
145 146 virtual bool is_method_klass() { return false; }
146 147 virtual bool is_array_klass() { return false; }
147 148 virtual bool is_obj_array_klass() { return false; }
148 149 virtual bool is_type_array_klass() { return false; }
149 150 virtual bool is_symbol_klass() { return false; }
150 151 virtual bool is_klass_klass() { return false; }
151 152 virtual bool is_instance_klass_klass() { return false; }
152 153 virtual bool is_array_klass_klass() { return false; }
153 154 virtual bool is_obj_array_klass_klass() { return false; }
154 155 virtual bool is_type_array_klass_klass() { return false; }
155 156
156 157 // Is this a type or value which has no associated class?
157 158 // It is true of primitive types and null objects.
158 159 virtual bool is_classless() const { return false; }
159 160
160 161 // Is this ciObject a Java Language Object? That is,
161 162 // is the ciObject an instance or an array
162 163 virtual bool is_java_object() { return false; }
163 164
164 165 // Does this ciObject represent a Java Language class?
165 166 // That is, is the ciObject an instanceKlass or arrayKlass?
166 167 virtual bool is_java_klass() { return false; }
167 168
168 169 // Is this ciObject the ciInstanceKlass representing
169 170 // java.lang.Object()?
170 171 virtual bool is_java_lang_Object() { return false; }
171 172
172 173 // Does this ciObject refer to a real oop in the VM?
173 174 //
174 175 // Note: some ciObjects refer to oops which have yet to be
175 176 // created. We refer to these as "unloaded". Specifically,
176 177 // there are unloaded ciMethods, ciObjArrayKlasses, and
177 178 // ciInstanceKlasses. By convention the ciNullObject is
↓ open down ↓ |
34 lines elided |
↑ open up ↑ |
178 179 // considered loaded, and primitive types are considered loaded.
179 180 bool is_loaded() const {
180 181 return handle() != NULL || is_classless();
181 182 }
182 183
183 184 // Subclass casting with assertions.
184 185 ciNullObject* as_null_object() {
185 186 assert(is_null_object(), "bad cast");
186 187 return (ciNullObject*)this;
187 188 }
189 + ciCPCache* as_cpcache() {
190 + assert(is_cpcache(), "bad cast");
191 + return (ciCPCache*) this;
192 + }
188 193 ciInstance* as_instance() {
189 194 assert(is_instance(), "bad cast");
190 195 return (ciInstance*)this;
191 196 }
192 197 ciMethod* as_method() {
193 198 assert(is_method(), "bad cast");
194 199 return (ciMethod*)this;
195 200 }
196 201 ciMethodData* as_method_data() {
197 202 assert(is_method_data(), "bad cast");
198 203 return (ciMethodData*)this;
199 204 }
200 205 ciArray* as_array() {
201 206 assert(is_array(), "bad cast");
202 207 return (ciArray*)this;
203 208 }
204 209 ciObjArray* as_obj_array() {
205 210 assert(is_obj_array(), "bad cast");
206 211 return (ciObjArray*)this;
207 212 }
208 213 ciTypeArray* as_type_array() {
209 214 assert(is_type_array(), "bad cast");
210 215 return (ciTypeArray*)this;
211 216 }
212 217 ciSymbol* as_symbol() {
213 218 assert(is_symbol(), "bad cast");
214 219 return (ciSymbol*)this;
215 220 }
216 221 ciType* as_type() {
217 222 assert(is_type(), "bad cast");
218 223 return (ciType*)this;
219 224 }
220 225 ciReturnAddress* as_return_address() {
221 226 assert(is_return_address(), "bad cast");
222 227 return (ciReturnAddress*)this;
223 228 }
224 229 ciKlass* as_klass() {
225 230 assert(is_klass(), "bad cast");
226 231 return (ciKlass*)this;
227 232 }
228 233 ciInstanceKlass* as_instance_klass() {
229 234 assert(is_instance_klass(), "bad cast");
230 235 return (ciInstanceKlass*)this;
231 236 }
232 237 ciMethodKlass* as_method_klass() {
233 238 assert(is_method_klass(), "bad cast");
234 239 return (ciMethodKlass*)this;
235 240 }
236 241 ciArrayKlass* as_array_klass() {
237 242 assert(is_array_klass(), "bad cast");
238 243 return (ciArrayKlass*)this;
239 244 }
240 245 ciObjArrayKlass* as_obj_array_klass() {
241 246 assert(is_obj_array_klass(), "bad cast");
242 247 return (ciObjArrayKlass*)this;
243 248 }
244 249 ciTypeArrayKlass* as_type_array_klass() {
245 250 assert(is_type_array_klass(), "bad cast");
246 251 return (ciTypeArrayKlass*)this;
247 252 }
248 253 ciSymbolKlass* as_symbol_klass() {
249 254 assert(is_symbol_klass(), "bad cast");
250 255 return (ciSymbolKlass*)this;
251 256 }
252 257 ciKlassKlass* as_klass_klass() {
253 258 assert(is_klass_klass(), "bad cast");
254 259 return (ciKlassKlass*)this;
255 260 }
256 261 ciInstanceKlassKlass* as_instance_klass_klass() {
257 262 assert(is_instance_klass_klass(), "bad cast");
258 263 return (ciInstanceKlassKlass*)this;
259 264 }
260 265 ciArrayKlassKlass* as_array_klass_klass() {
261 266 assert(is_array_klass_klass(), "bad cast");
262 267 return (ciArrayKlassKlass*)this;
263 268 }
264 269 ciObjArrayKlassKlass* as_obj_array_klass_klass() {
265 270 assert(is_obj_array_klass_klass(), "bad cast");
266 271 return (ciObjArrayKlassKlass*)this;
267 272 }
268 273 ciTypeArrayKlassKlass* as_type_array_klass_klass() {
269 274 assert(is_type_array_klass_klass(), "bad cast");
270 275 return (ciTypeArrayKlassKlass*)this;
271 276 }
272 277
273 278 // Print debugging output about this ciObject.
274 279 void print(outputStream* st = tty);
275 280
276 281 // Print debugging output about the oop this ciObject represents.
277 282 void print_oop(outputStream* st = tty);
278 283 };
↓ open down ↓ |
81 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX