Mercurial > hg > truffle
annotate src/share/vm/ci/ciObject.hpp @ 3187:6ff76a1b8339
The benchmark tool should now print zero values to the csv file, if a benchmark fails
author | Josef Haider <josef.haider@khg.jku.at> |
---|---|
date | Thu, 07 Jul 2011 19:43:17 +0200 |
parents | 0654ee04b214 |
children | be4ca325525a |
rev | line source |
---|---|
0 | 1 /* |
2426
1d1603768966
7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents:
2177
diff
changeset
|
2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1138
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1138
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1138
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_CI_CIOBJECT_HPP |
26 #define SHARE_VM_CI_CIOBJECT_HPP | |
27 | |
28 #include "ci/ciClassList.hpp" | |
29 #include "memory/allocation.hpp" | |
30 #include "runtime/handles.hpp" | |
31 #include "runtime/jniHandles.hpp" | |
32 | |
0 | 33 // ciObject |
34 // | |
35 // This class represents an oop in the HotSpot virtual machine. | |
36 // Its subclasses are structured in a hierarchy which mirrors | |
37 // an aggregate of the VM's oop and klass hierarchies (see | |
38 // oopHierarchy.hpp). Each instance of ciObject holds a handle | |
39 // to a corresponding oop on the VM side and provides routines | |
40 // for accessing the information in its oop. By using the ciObject | |
41 // hierarchy for accessing oops in the VM, the compiler ensures | |
42 // that it is safe with respect to garbage collection; that is, | |
43 // GC and compilation can proceed independently without | |
44 // interference. | |
45 // | |
46 // Within the VM, the oop and klass hierarchies are separate. | |
47 // The compiler interface does not preserve this separation -- | |
48 // the distinction between `klassOop' and `Klass' are not | |
49 // reflected in the interface and instead the Klass hierarchy | |
50 // is directly modeled as the subclasses of ciKlass. | |
51 class ciObject : public ResourceObj { | |
52 CI_PACKAGE_ACCESS | |
53 friend class ciEnv; | |
54 | |
55 private: | |
56 // A JNI handle referring to an oop in the VM. This | |
57 // handle may, in a small set of cases, correctly be NULL. | |
58 jobject _handle; | |
59 ciKlass* _klass; | |
60 uint _ident; | |
1478
5571b97fc1ec
More JNI global handle clean ups.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1406
diff
changeset
|
61 bool _temp_global; |
0 | 62 |
989 | 63 enum { FLAG_BITS = 2 }; |
0 | 64 enum { |
989 | 65 PERM_FLAG = 1, |
66 SCAVENGABLE_FLAG = 2 | |
0 | 67 }; |
68 protected: | |
69 ciObject(); | |
70 ciObject(oop o); | |
71 ciObject(Handle h); | |
72 ciObject(ciKlass* klass); | |
73 | |
1406
35069ca331f2
Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
1138
diff
changeset
|
74 public: |
1478
5571b97fc1ec
More JNI global handle clean ups.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1406
diff
changeset
|
75 virtual void cleanup() { |
5571b97fc1ec
More JNI global handle clean ups.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1406
diff
changeset
|
76 if (_temp_global && _handle != NULL && JNIHandles::is_global_handle(_handle)) { |
5571b97fc1ec
More JNI global handle clean ups.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1406
diff
changeset
|
77 JNIHandles::destroy_global(_handle); |
5571b97fc1ec
More JNI global handle clean ups.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1406
diff
changeset
|
78 } |
5571b97fc1ec
More JNI global handle clean ups.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1406
diff
changeset
|
79 } |
0 | 80 jobject handle() const { return _handle; } |
81 // Get the VM oop that this object holds. | |
82 oop get_oop() const { | |
83 assert(_handle != NULL, "null oop"); | |
84 return JNIHandles::resolve_non_null(_handle); | |
85 } | |
1406
35069ca331f2
Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
1138
diff
changeset
|
86 protected: |
0 | 87 |
989 | 88 void init_flags_from(oop x) { |
89 int flags = 0; | |
90 if (x != NULL) { | |
91 if (x->is_perm()) | |
92 flags |= PERM_FLAG; | |
93 if (x->is_scavengable()) | |
94 flags |= SCAVENGABLE_FLAG; | |
95 } | |
96 _ident |= flags; | |
0 | 97 } |
98 | |
99 // Virtual behavior of the print() method. | |
100 virtual void print_impl(outputStream* st) {} | |
101 | |
102 virtual const char* type_string() { return "ciObject"; } | |
103 | |
104 void set_ident(uint id); | |
105 public: | |
106 // The klass of this ciObject. | |
107 ciKlass* klass(); | |
108 | |
109 // A number unique to this object. | |
110 uint ident(); | |
111 | |
112 // Are two ciObjects equal? | |
113 bool equals(ciObject* obj); | |
114 | |
115 // A hash value for the convenience of compilers. | |
116 int hash(); | |
117 | |
989 | 118 // Tells if this oop has an encoding as a constant. |
119 // True if is_scavengable is false. | |
120 // Also true if ScavengeRootsInCode is non-zero. | |
0 | 121 // If it does not have an encoding, the compiler is responsible for |
122 // making other arrangements for dealing with the oop. | |
989 | 123 // See ciEnv::make_array |
124 bool can_be_constant(); | |
125 | |
126 // Tells if this oop should be made a constant. | |
127 // True if is_scavengable is false or ScavengeRootsInCode > 1. | |
128 bool should_be_constant(); | |
0 | 129 |
130 // Is this object guaranteed to be in the permanent part of the heap? | |
131 // If so, CollectedHeap::can_elide_permanent_oop_store_barriers is relevant. | |
132 // If the answer is false, no guarantees are made. | |
133 bool is_perm() { return (_ident & PERM_FLAG) != 0; } | |
134 | |
989 | 135 // Might this object possibly move during a scavenge operation? |
136 // If the answer is true and ScavengeRootsInCode==0, the oop cannot be embedded in code. | |
137 bool is_scavengable() { return (_ident & SCAVENGABLE_FLAG) != 0; } | |
138 | |
0 | 139 // The address which the compiler should embed into the |
140 // generated code to represent this oop. This address | |
141 // is not the true address of the oop -- it will get patched | |
142 // during nmethod creation. | |
143 // | |
144 // Usage note: no address arithmetic allowed. Oop must | |
145 // be registered with the oopRecorder. | |
989 | 146 jobject constant_encoding(); |
0 | 147 |
148 // What kind of ciObject is this? | |
149 virtual bool is_null_object() const { return false; } | |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1137
diff
changeset
|
150 virtual bool is_call_site() const { return false; } |
1137
97125851f396
6829187: compiler optimizations required for JSR 292
twisti
parents:
989
diff
changeset
|
151 virtual bool is_cpcache() const { return false; } |
0 | 152 virtual bool is_instance() { return false; } |
153 virtual bool is_method() { return false; } | |
154 virtual bool is_method_data() { return false; } | |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1137
diff
changeset
|
155 virtual bool is_method_handle() const { return false; } |
0 | 156 virtual bool is_array() { return false; } |
157 virtual bool is_obj_array() { return false; } | |
158 virtual bool is_type_array() { return false; } | |
159 virtual bool is_symbol() { return false; } | |
160 virtual bool is_type() { return false; } | |
161 virtual bool is_return_address() { return false; } | |
162 virtual bool is_klass() { return false; } | |
163 virtual bool is_instance_klass() { return false; } | |
164 virtual bool is_method_klass() { return false; } | |
165 virtual bool is_array_klass() { return false; } | |
166 virtual bool is_obj_array_klass() { return false; } | |
167 virtual bool is_type_array_klass() { return false; } | |
168 virtual bool is_symbol_klass() { return false; } | |
169 virtual bool is_klass_klass() { return false; } | |
170 virtual bool is_instance_klass_klass() { return false; } | |
171 virtual bool is_array_klass_klass() { return false; } | |
172 virtual bool is_obj_array_klass_klass() { return false; } | |
173 virtual bool is_type_array_klass_klass() { return false; } | |
174 | |
175 // Is this a type or value which has no associated class? | |
176 // It is true of primitive types and null objects. | |
177 virtual bool is_classless() const { return false; } | |
178 | |
179 // Is this ciObject a Java Language Object? That is, | |
180 // is the ciObject an instance or an array | |
181 virtual bool is_java_object() { return false; } | |
182 | |
183 // Does this ciObject represent a Java Language class? | |
184 // That is, is the ciObject an instanceKlass or arrayKlass? | |
185 virtual bool is_java_klass() { return false; } | |
186 | |
187 // Is this ciObject the ciInstanceKlass representing | |
188 // java.lang.Object()? | |
189 virtual bool is_java_lang_Object() { return false; } | |
190 | |
191 // Does this ciObject refer to a real oop in the VM? | |
192 // | |
193 // Note: some ciObjects refer to oops which have yet to be | |
194 // created. We refer to these as "unloaded". Specifically, | |
195 // there are unloaded ciMethods, ciObjArrayKlasses, and | |
196 // ciInstanceKlasses. By convention the ciNullObject is | |
197 // considered loaded, and primitive types are considered loaded. | |
198 bool is_loaded() const { | |
199 return handle() != NULL || is_classless(); | |
200 } | |
201 | |
202 // Subclass casting with assertions. | |
203 ciNullObject* as_null_object() { | |
204 assert(is_null_object(), "bad cast"); | |
205 return (ciNullObject*)this; | |
206 } | |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1137
diff
changeset
|
207 ciCallSite* as_call_site() { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1137
diff
changeset
|
208 assert(is_call_site(), "bad cast"); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1137
diff
changeset
|
209 return (ciCallSite*) this; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1137
diff
changeset
|
210 } |
1137
97125851f396
6829187: compiler optimizations required for JSR 292
twisti
parents:
989
diff
changeset
|
211 ciCPCache* as_cpcache() { |
97125851f396
6829187: compiler optimizations required for JSR 292
twisti
parents:
989
diff
changeset
|
212 assert(is_cpcache(), "bad cast"); |
97125851f396
6829187: compiler optimizations required for JSR 292
twisti
parents:
989
diff
changeset
|
213 return (ciCPCache*) this; |
97125851f396
6829187: compiler optimizations required for JSR 292
twisti
parents:
989
diff
changeset
|
214 } |
0 | 215 ciInstance* as_instance() { |
216 assert(is_instance(), "bad cast"); | |
217 return (ciInstance*)this; | |
218 } | |
219 ciMethod* as_method() { | |
220 assert(is_method(), "bad cast"); | |
221 return (ciMethod*)this; | |
222 } | |
223 ciMethodData* as_method_data() { | |
224 assert(is_method_data(), "bad cast"); | |
225 return (ciMethodData*)this; | |
226 } | |
1138
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1137
diff
changeset
|
227 ciMethodHandle* as_method_handle() { |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1137
diff
changeset
|
228 assert(is_method_handle(), "bad cast"); |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1137
diff
changeset
|
229 return (ciMethodHandle*) this; |
dd57230ba8fe
6893268: additional dynamic language related optimizations in C2
twisti
parents:
1137
diff
changeset
|
230 } |
0 | 231 ciArray* as_array() { |
232 assert(is_array(), "bad cast"); | |
233 return (ciArray*)this; | |
234 } | |
235 ciObjArray* as_obj_array() { | |
236 assert(is_obj_array(), "bad cast"); | |
237 return (ciObjArray*)this; | |
238 } | |
239 ciTypeArray* as_type_array() { | |
240 assert(is_type_array(), "bad cast"); | |
241 return (ciTypeArray*)this; | |
242 } | |
243 ciSymbol* as_symbol() { | |
244 assert(is_symbol(), "bad cast"); | |
245 return (ciSymbol*)this; | |
246 } | |
247 ciType* as_type() { | |
248 assert(is_type(), "bad cast"); | |
249 return (ciType*)this; | |
250 } | |
251 ciReturnAddress* as_return_address() { | |
252 assert(is_return_address(), "bad cast"); | |
253 return (ciReturnAddress*)this; | |
254 } | |
255 ciKlass* as_klass() { | |
256 assert(is_klass(), "bad cast"); | |
257 return (ciKlass*)this; | |
258 } | |
259 ciInstanceKlass* as_instance_klass() { | |
260 assert(is_instance_klass(), "bad cast"); | |
261 return (ciInstanceKlass*)this; | |
262 } | |
263 ciMethodKlass* as_method_klass() { | |
264 assert(is_method_klass(), "bad cast"); | |
265 return (ciMethodKlass*)this; | |
266 } | |
267 ciArrayKlass* as_array_klass() { | |
268 assert(is_array_klass(), "bad cast"); | |
269 return (ciArrayKlass*)this; | |
270 } | |
271 ciObjArrayKlass* as_obj_array_klass() { | |
272 assert(is_obj_array_klass(), "bad cast"); | |
273 return (ciObjArrayKlass*)this; | |
274 } | |
275 ciTypeArrayKlass* as_type_array_klass() { | |
276 assert(is_type_array_klass(), "bad cast"); | |
277 return (ciTypeArrayKlass*)this; | |
278 } | |
279 ciKlassKlass* as_klass_klass() { | |
280 assert(is_klass_klass(), "bad cast"); | |
281 return (ciKlassKlass*)this; | |
282 } | |
283 ciInstanceKlassKlass* as_instance_klass_klass() { | |
284 assert(is_instance_klass_klass(), "bad cast"); | |
285 return (ciInstanceKlassKlass*)this; | |
286 } | |
287 ciArrayKlassKlass* as_array_klass_klass() { | |
288 assert(is_array_klass_klass(), "bad cast"); | |
289 return (ciArrayKlassKlass*)this; | |
290 } | |
291 ciObjArrayKlassKlass* as_obj_array_klass_klass() { | |
292 assert(is_obj_array_klass_klass(), "bad cast"); | |
293 return (ciObjArrayKlassKlass*)this; | |
294 } | |
295 ciTypeArrayKlassKlass* as_type_array_klass_klass() { | |
296 assert(is_type_array_klass_klass(), "bad cast"); | |
297 return (ciTypeArrayKlassKlass*)this; | |
298 } | |
299 | |
300 // Print debugging output about this ciObject. | |
301 void print(outputStream* st = tty); | |
302 | |
303 // Print debugging output about the oop this ciObject represents. | |
304 void print_oop(outputStream* st = tty); | |
305 }; | |
1972 | 306 |
307 #endif // SHARE_VM_CI_CIOBJECT_HPP |