Mercurial > hg > graal-jvmci-8
comparison src/share/vm/ci/ciObject.hpp @ 6725:da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author | coleenp |
---|---|
date | Sat, 01 Sep 2012 13:25:18 -0400 |
parents | 1d7922586cf6 |
children | f6b0eb4e44cf |
comparison
equal
deleted
inserted
replaced
6724:36d1d483d5d6 | 6725:da91efe96a93 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
23 */ | 23 */ |
24 | 24 |
25 #ifndef SHARE_VM_CI_CIOBJECT_HPP | 25 #ifndef SHARE_VM_CI_CIOBJECT_HPP |
26 #define SHARE_VM_CI_CIOBJECT_HPP | 26 #define SHARE_VM_CI_CIOBJECT_HPP |
27 | 27 |
28 #include "ci/ciBaseObject.hpp" | |
28 #include "ci/ciClassList.hpp" | 29 #include "ci/ciClassList.hpp" |
29 #include "memory/allocation.hpp" | 30 #include "memory/allocation.hpp" |
30 #include "runtime/handles.hpp" | 31 #include "runtime/handles.hpp" |
31 #include "runtime/jniHandles.hpp" | 32 #include "runtime/jniHandles.hpp" |
32 | 33 |
43 // GC and compilation can proceed independently without | 44 // GC and compilation can proceed independently without |
44 // interference. | 45 // interference. |
45 // | 46 // |
46 // Within the VM, the oop and klass hierarchies are separate. | 47 // Within the VM, the oop and klass hierarchies are separate. |
47 // The compiler interface does not preserve this separation -- | 48 // The compiler interface does not preserve this separation -- |
48 // the distinction between `klassOop' and `Klass' are not | 49 // the distinction between `Klass*' and `Klass' are not |
49 // reflected in the interface and instead the Klass hierarchy | 50 // reflected in the interface and instead the Klass hierarchy |
50 // is directly modeled as the subclasses of ciKlass. | 51 // is directly modeled as the subclasses of ciKlass. |
51 class ciObject : public ResourceObj { | 52 class ciObject : public ciBaseObject { |
52 CI_PACKAGE_ACCESS | 53 CI_PACKAGE_ACCESS |
53 friend class ciEnv; | 54 friend class ciEnv; |
54 | 55 |
55 private: | 56 private: |
56 // A JNI handle referring to an oop in the VM. This | 57 // A JNI handle referring to an oop in the VM. This |
57 // handle may, in a small set of cases, correctly be NULL. | 58 // handle may, in a small set of cases, correctly be NULL. |
58 jobject _handle; | 59 jobject _handle; |
59 ciKlass* _klass; | 60 ciKlass* _klass; |
60 uint _ident; | |
61 | 61 |
62 enum { FLAG_BITS = 2 }; | |
63 enum { | |
64 PERM_FLAG = 1, | |
65 SCAVENGABLE_FLAG = 2 | |
66 }; | |
67 protected: | 62 protected: |
68 ciObject(); | 63 ciObject(); |
69 ciObject(oop o); | 64 ciObject(oop o); |
70 ciObject(Handle h); | 65 ciObject(Handle h); |
71 ciObject(ciKlass* klass); | 66 ciObject(ciKlass* klass); |
75 oop get_oop() const { | 70 oop get_oop() const { |
76 assert(_handle != NULL, "null oop"); | 71 assert(_handle != NULL, "null oop"); |
77 return JNIHandles::resolve_non_null(_handle); | 72 return JNIHandles::resolve_non_null(_handle); |
78 } | 73 } |
79 | 74 |
80 void init_flags_from(oop x) { | 75 void init_flags_from(oop x); |
81 int flags = 0; | |
82 if (x != NULL) { | |
83 if (x->is_perm()) | |
84 flags |= PERM_FLAG; | |
85 if (x->is_scavengable()) | |
86 flags |= SCAVENGABLE_FLAG; | |
87 } | |
88 _ident |= flags; | |
89 } | |
90 | 76 |
91 // Virtual behavior of the print() method. | 77 // Virtual behavior of the print() method. |
92 virtual void print_impl(outputStream* st) {} | 78 virtual void print_impl(outputStream* st) {} |
93 | 79 |
94 virtual const char* type_string() { return "ciObject"; } | 80 virtual const char* type_string() { return "ciObject"; } |
95 | 81 |
96 void set_ident(uint id); | |
97 public: | 82 public: |
98 // The klass of this ciObject. | 83 // The klass of this ciObject. |
99 ciKlass* klass(); | 84 ciKlass* klass(); |
100 | |
101 // A number unique to this object. | |
102 uint ident(); | |
103 | 85 |
104 // Are two ciObjects equal? | 86 // Are two ciObjects equal? |
105 bool equals(ciObject* obj); | 87 bool equals(ciObject* obj); |
106 | 88 |
107 // A hash value for the convenience of compilers. | 89 // A hash value for the convenience of compilers. |
117 | 99 |
118 // Tells if this oop should be made a constant. | 100 // Tells if this oop should be made a constant. |
119 // True if is_perm is true or ScavengeRootsInCode > 1. | 101 // True if is_perm is true or ScavengeRootsInCode > 1. |
120 bool should_be_constant(); | 102 bool should_be_constant(); |
121 | 103 |
122 // Is this object guaranteed to be in the permanent part of the heap? | |
123 // If so, CollectedHeap::can_elide_permanent_oop_store_barriers is relevant. | |
124 // If the answer is false, no guarantees are made. | |
125 bool is_perm() { return (_ident & PERM_FLAG) != 0; } | |
126 | |
127 // Might this object possibly move during a scavenge operation? | 104 // Might this object possibly move during a scavenge operation? |
128 // If the answer is true and ScavengeRootsInCode==0, the oop cannot be embedded in code. | 105 // If the answer is true and ScavengeRootsInCode==0, the oop cannot be embedded in code. |
129 bool is_scavengable() { return (_ident & SCAVENGABLE_FLAG) != 0; } | 106 bool is_scavengable() { return (_ident & SCAVENGABLE_FLAG) != 0; } |
130 | 107 |
131 // The address which the compiler should embed into the | 108 // The address which the compiler should embed into the |
135 // | 112 // |
136 // Usage note: no address arithmetic allowed. Oop must | 113 // Usage note: no address arithmetic allowed. Oop must |
137 // be registered with the oopRecorder. | 114 // be registered with the oopRecorder. |
138 jobject constant_encoding(); | 115 jobject constant_encoding(); |
139 | 116 |
117 virtual bool is_object() const { return true; } | |
118 | |
140 // What kind of ciObject is this? | 119 // What kind of ciObject is this? |
141 virtual bool is_null_object() const { return false; } | 120 virtual bool is_null_object() const { return false; } |
142 virtual bool is_call_site() const { return false; } | 121 virtual bool is_call_site() const { return false; } |
143 virtual bool is_cpcache() const { return false; } | 122 virtual bool is_cpcache() const { return false; } |
144 virtual bool is_instance() { return false; } | 123 virtual bool is_instance() { return false; } |
145 virtual bool is_member_name() const { return false; } | 124 virtual bool is_member_name() const { return false; } |
146 virtual bool is_method() { return false; } | |
147 virtual bool is_method_data() { return false; } | |
148 virtual bool is_method_handle() const { return false; } | 125 virtual bool is_method_handle() const { return false; } |
149 virtual bool is_array() { return false; } | 126 virtual bool is_array() { return false; } |
150 virtual bool is_obj_array() { return false; } | 127 virtual bool is_obj_array() { return false; } |
151 virtual bool is_type_array() { return false; } | 128 virtual bool is_type_array() { return false; } |
152 virtual bool is_symbol() { return false; } | |
153 virtual bool is_type() { return false; } | |
154 virtual bool is_return_address() { return false; } | |
155 virtual bool is_klass() { return false; } | |
156 virtual bool is_instance_klass() { return false; } | |
157 virtual bool is_method_klass() { return false; } | |
158 virtual bool is_array_klass() { return false; } | |
159 virtual bool is_obj_array_klass() { return false; } | |
160 virtual bool is_type_array_klass() { return false; } | |
161 virtual bool is_symbol_klass() { return false; } | |
162 virtual bool is_klass_klass() { return false; } | |
163 virtual bool is_instance_klass_klass() { return false; } | |
164 virtual bool is_array_klass_klass() { return false; } | |
165 virtual bool is_obj_array_klass_klass() { return false; } | |
166 virtual bool is_type_array_klass_klass() { return false; } | |
167 | 129 |
168 // Is this a type or value which has no associated class? | 130 // Is this a type or value which has no associated class? |
169 // It is true of primitive types and null objects. | 131 // It is true of primitive types and null objects. |
170 virtual bool is_classless() const { return false; } | 132 virtual bool is_classless() const { return false; } |
171 | 133 |
172 // Is this ciObject a Java Language Object? That is, | 134 // Note: some ciObjects refer to oops which have yet to be created. |
173 // is the ciObject an instance or an array | 135 // We refer to these as "unloaded". Specifically, there are |
174 virtual bool is_java_object() { return false; } | 136 // unloaded instances of java.lang.Class, |
175 | 137 // java.lang.invoke.MethodHandle, and java.lang.invoke.MethodType. |
176 // Does this ciObject represent a Java Language class? | 138 // By convention the ciNullObject is considered loaded, and |
177 // That is, is the ciObject an instanceKlass or arrayKlass? | 139 // primitive types are considered loaded. |
178 virtual bool is_java_klass() { return false; } | |
179 | |
180 // Is this ciObject the ciInstanceKlass representing | |
181 // java.lang.Object()? | |
182 virtual bool is_java_lang_Object() { return false; } | |
183 | |
184 // Does this ciObject refer to a real oop in the VM? | |
185 // | |
186 // Note: some ciObjects refer to oops which have yet to be | |
187 // created. We refer to these as "unloaded". Specifically, | |
188 // there are unloaded ciMethods, ciObjArrayKlasses, and | |
189 // ciInstanceKlasses. By convention the ciNullObject is | |
190 // considered loaded, and primitive types are considered loaded. | |
191 bool is_loaded() const { | 140 bool is_loaded() const { |
192 return handle() != NULL || is_classless(); | 141 return handle() != NULL || is_classless(); |
193 } | 142 } |
194 | 143 |
195 // Subclass casting with assertions. | 144 // Subclass casting with assertions. |
199 } | 148 } |
200 ciCallSite* as_call_site() { | 149 ciCallSite* as_call_site() { |
201 assert(is_call_site(), "bad cast"); | 150 assert(is_call_site(), "bad cast"); |
202 return (ciCallSite*) this; | 151 return (ciCallSite*) this; |
203 } | 152 } |
204 ciCPCache* as_cpcache() { | |
205 assert(is_cpcache(), "bad cast"); | |
206 return (ciCPCache*) this; | |
207 } | |
208 ciInstance* as_instance() { | 153 ciInstance* as_instance() { |
209 assert(is_instance(), "bad cast"); | 154 assert(is_instance(), "bad cast"); |
210 return (ciInstance*)this; | 155 return (ciInstance*)this; |
211 } | 156 } |
212 ciMemberName* as_member_name() { | 157 ciMemberName* as_member_name() { |
213 assert(is_member_name(), "bad cast"); | 158 assert(is_member_name(), "bad cast"); |
214 return (ciMemberName*)this; | 159 return (ciMemberName*)this; |
215 } | |
216 ciMethod* as_method() { | |
217 assert(is_method(), "bad cast"); | |
218 return (ciMethod*)this; | |
219 } | |
220 ciMethodData* as_method_data() { | |
221 assert(is_method_data(), "bad cast"); | |
222 return (ciMethodData*)this; | |
223 } | 160 } |
224 ciMethodHandle* as_method_handle() { | 161 ciMethodHandle* as_method_handle() { |
225 assert(is_method_handle(), "bad cast"); | 162 assert(is_method_handle(), "bad cast"); |
226 return (ciMethodHandle*) this; | 163 return (ciMethodHandle*) this; |
227 } | 164 } |
235 } | 172 } |
236 ciTypeArray* as_type_array() { | 173 ciTypeArray* as_type_array() { |
237 assert(is_type_array(), "bad cast"); | 174 assert(is_type_array(), "bad cast"); |
238 return (ciTypeArray*)this; | 175 return (ciTypeArray*)this; |
239 } | 176 } |
240 ciSymbol* as_symbol() { | |
241 assert(is_symbol(), "bad cast"); | |
242 return (ciSymbol*)this; | |
243 } | |
244 ciType* as_type() { | |
245 assert(is_type(), "bad cast"); | |
246 return (ciType*)this; | |
247 } | |
248 ciReturnAddress* as_return_address() { | |
249 assert(is_return_address(), "bad cast"); | |
250 return (ciReturnAddress*)this; | |
251 } | |
252 ciKlass* as_klass() { | |
253 assert(is_klass(), "bad cast"); | |
254 return (ciKlass*)this; | |
255 } | |
256 ciInstanceKlass* as_instance_klass() { | |
257 assert(is_instance_klass(), "bad cast"); | |
258 return (ciInstanceKlass*)this; | |
259 } | |
260 ciMethodKlass* as_method_klass() { | |
261 assert(is_method_klass(), "bad cast"); | |
262 return (ciMethodKlass*)this; | |
263 } | |
264 ciArrayKlass* as_array_klass() { | |
265 assert(is_array_klass(), "bad cast"); | |
266 return (ciArrayKlass*)this; | |
267 } | |
268 ciObjArrayKlass* as_obj_array_klass() { | |
269 assert(is_obj_array_klass(), "bad cast"); | |
270 return (ciObjArrayKlass*)this; | |
271 } | |
272 ciTypeArrayKlass* as_type_array_klass() { | |
273 assert(is_type_array_klass(), "bad cast"); | |
274 return (ciTypeArrayKlass*)this; | |
275 } | |
276 ciKlassKlass* as_klass_klass() { | |
277 assert(is_klass_klass(), "bad cast"); | |
278 return (ciKlassKlass*)this; | |
279 } | |
280 ciInstanceKlassKlass* as_instance_klass_klass() { | |
281 assert(is_instance_klass_klass(), "bad cast"); | |
282 return (ciInstanceKlassKlass*)this; | |
283 } | |
284 ciArrayKlassKlass* as_array_klass_klass() { | |
285 assert(is_array_klass_klass(), "bad cast"); | |
286 return (ciArrayKlassKlass*)this; | |
287 } | |
288 ciObjArrayKlassKlass* as_obj_array_klass_klass() { | |
289 assert(is_obj_array_klass_klass(), "bad cast"); | |
290 return (ciObjArrayKlassKlass*)this; | |
291 } | |
292 ciTypeArrayKlassKlass* as_type_array_klass_klass() { | |
293 assert(is_type_array_klass_klass(), "bad cast"); | |
294 return (ciTypeArrayKlassKlass*)this; | |
295 } | |
296 | 177 |
297 // Print debugging output about this ciObject. | 178 // Print debugging output about this ciObject. |
298 void print(outputStream* st); | 179 void print(outputStream* st); |
299 void print() { print(tty); } // GDB cannot handle default arguments | 180 void print() { print(tty); } // GDB cannot handle default arguments |
300 | 181 |