Mercurial > hg > truffle
annotate src/share/vm/oops/instanceKlassKlass.cpp @ 2212:d9e4d0aefc90
Small clean up to reduce delta to OpenJDK.
author | Thomas Wuerthinger <thomas.wuerthinger@gmail.com> |
---|---|
date | Mon, 21 Feb 2011 19:28:35 +0100 |
parents | 3582bf76420e |
children | e5383553fd4e |
rev | line source |
---|---|
0 | 1 /* |
1972 | 2 * Copyright (c) 1997, 2010, 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:
1490
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1490
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:
1490
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "classfile/javaClasses.hpp" | |
27 #include "classfile/systemDictionary.hpp" | |
28 #include "gc_implementation/shared/markSweep.inline.hpp" | |
29 #include "gc_interface/collectedHeap.inline.hpp" | |
30 #include "interpreter/oopMapCache.hpp" | |
31 #include "memory/gcLocker.hpp" | |
32 #include "oops/constantPoolOop.hpp" | |
33 #include "oops/instanceKlass.hpp" | |
34 #include "oops/instanceKlassKlass.hpp" | |
35 #include "oops/instanceRefKlass.hpp" | |
36 #include "oops/objArrayKlassKlass.hpp" | |
37 #include "oops/objArrayOop.hpp" | |
38 #include "oops/oop.inline.hpp" | |
39 #include "oops/oop.inline2.hpp" | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
40 #include "oops/symbol.hpp" |
1972 | 41 #include "oops/typeArrayOop.hpp" |
42 #include "prims/jvmtiExport.hpp" | |
43 #include "runtime/fieldDescriptor.hpp" | |
44 #ifndef SERIALGC | |
45 #include "gc_implementation/parNew/parOopClosures.inline.hpp" | |
46 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp" | |
47 #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp" | |
48 #include "memory/cardTableRS.hpp" | |
49 #include "oops/oop.pcgc.inline.hpp" | |
50 #endif | |
0 | 51 |
52 klassOop instanceKlassKlass::create_klass(TRAPS) { | |
53 instanceKlassKlass o; | |
54 KlassHandle h_this_klass(THREAD, Universe::klassKlassObj()); | |
55 KlassHandle k = base_create_klass(h_this_klass, header_size(), o.vtbl_value(), CHECK_NULL); | |
56 // Make sure size calculation is right | |
57 assert(k()->size() == align_object_size(header_size()), "wrong size for object"); | |
58 java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror | |
59 return k(); | |
60 } | |
61 | |
62 int instanceKlassKlass::oop_size(oop obj) const { | |
63 assert(obj->is_klass(), "must be klass"); | |
64 return instanceKlass::cast(klassOop(obj))->object_size(); | |
65 } | |
66 | |
67 bool instanceKlassKlass::oop_is_parsable(oop obj) const { | |
68 assert(obj->is_klass(), "must be klass"); | |
69 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
70 return (!ik->null_vtbl()) && ik->object_is_parsable(); | |
71 } | |
72 | |
73 void instanceKlassKlass::iterate_c_heap_oops(instanceKlass* ik, | |
74 OopClosure* closure) { | |
75 if (ik->oop_map_cache() != NULL) { | |
76 ik->oop_map_cache()->oop_iterate(closure); | |
77 } | |
78 | |
79 if (ik->jni_ids() != NULL) { | |
80 ik->jni_ids()->oops_do(closure); | |
81 } | |
82 } | |
83 | |
84 void instanceKlassKlass::oop_follow_contents(oop obj) { | |
85 assert(obj->is_klass(),"must be a klass"); | |
86 assert(klassOop(obj)->klass_part()->oop_is_instance_slow(), "must be instance klass"); | |
87 | |
88 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
89 ik->follow_static_fields(); | |
90 { | |
91 HandleMark hm; | |
92 ik->vtable()->oop_follow_contents(); | |
93 ik->itable()->oop_follow_contents(); | |
94 } | |
95 | |
96 MarkSweep::mark_and_push(ik->adr_array_klasses()); | |
97 MarkSweep::mark_and_push(ik->adr_methods()); | |
98 MarkSweep::mark_and_push(ik->adr_method_ordering()); | |
99 MarkSweep::mark_and_push(ik->adr_local_interfaces()); | |
100 MarkSweep::mark_and_push(ik->adr_transitive_interfaces()); | |
101 MarkSweep::mark_and_push(ik->adr_fields()); | |
102 MarkSweep::mark_and_push(ik->adr_constants()); | |
103 MarkSweep::mark_and_push(ik->adr_class_loader()); | |
104 MarkSweep::mark_and_push(ik->adr_inner_classes()); | |
105 MarkSweep::mark_and_push(ik->adr_protection_domain()); | |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
106 MarkSweep::mark_and_push(ik->adr_host_klass()); |
0 | 107 MarkSweep::mark_and_push(ik->adr_signers()); |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
665
diff
changeset
|
108 MarkSweep::mark_and_push(ik->adr_bootstrap_method()); |
0 | 109 MarkSweep::mark_and_push(ik->adr_class_annotations()); |
110 MarkSweep::mark_and_push(ik->adr_fields_annotations()); | |
111 MarkSweep::mark_and_push(ik->adr_methods_annotations()); | |
112 MarkSweep::mark_and_push(ik->adr_methods_parameter_annotations()); | |
113 MarkSweep::mark_and_push(ik->adr_methods_default_annotations()); | |
114 | |
115 // We do not follow adr_implementors() here. It is followed later | |
116 // in instanceKlass::follow_weak_klass_links() | |
117 | |
118 klassKlass::oop_follow_contents(obj); | |
119 | |
120 iterate_c_heap_oops(ik, &MarkSweep::mark_and_push_closure); | |
121 } | |
122 | |
123 #ifndef SERIALGC | |
124 void instanceKlassKlass::oop_follow_contents(ParCompactionManager* cm, | |
125 oop obj) { | |
126 assert(obj->is_klass(),"must be a klass"); | |
127 assert(klassOop(obj)->klass_part()->oop_is_instance_slow(), "must be instance klass"); | |
128 | |
129 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
130 ik->follow_static_fields(cm); | |
131 ik->vtable()->oop_follow_contents(cm); | |
132 ik->itable()->oop_follow_contents(cm); | |
133 | |
134 PSParallelCompact::mark_and_push(cm, ik->adr_array_klasses()); | |
135 PSParallelCompact::mark_and_push(cm, ik->adr_methods()); | |
136 PSParallelCompact::mark_and_push(cm, ik->adr_method_ordering()); | |
137 PSParallelCompact::mark_and_push(cm, ik->adr_local_interfaces()); | |
138 PSParallelCompact::mark_and_push(cm, ik->adr_transitive_interfaces()); | |
139 PSParallelCompact::mark_and_push(cm, ik->adr_fields()); | |
140 PSParallelCompact::mark_and_push(cm, ik->adr_constants()); | |
141 PSParallelCompact::mark_and_push(cm, ik->adr_class_loader()); | |
142 PSParallelCompact::mark_and_push(cm, ik->adr_inner_classes()); | |
143 PSParallelCompact::mark_and_push(cm, ik->adr_protection_domain()); | |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
144 PSParallelCompact::mark_and_push(cm, ik->adr_host_klass()); |
0 | 145 PSParallelCompact::mark_and_push(cm, ik->adr_signers()); |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
665
diff
changeset
|
146 PSParallelCompact::mark_and_push(cm, ik->adr_bootstrap_method()); |
0 | 147 PSParallelCompact::mark_and_push(cm, ik->adr_class_annotations()); |
148 PSParallelCompact::mark_and_push(cm, ik->adr_fields_annotations()); | |
149 PSParallelCompact::mark_and_push(cm, ik->adr_methods_annotations()); | |
150 PSParallelCompact::mark_and_push(cm, ik->adr_methods_parameter_annotations()); | |
151 PSParallelCompact::mark_and_push(cm, ik->adr_methods_default_annotations()); | |
152 | |
153 // We do not follow adr_implementor() here. It is followed later | |
154 // in instanceKlass::follow_weak_klass_links() | |
155 | |
156 klassKlass::oop_follow_contents(cm, obj); | |
157 | |
158 PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm); | |
159 iterate_c_heap_oops(ik, &mark_and_push_closure); | |
160 } | |
161 #endif // SERIALGC | |
162 | |
163 int instanceKlassKlass::oop_oop_iterate(oop obj, OopClosure* blk) { | |
164 assert(obj->is_klass(),"must be a klass"); | |
165 assert(klassOop(obj)->klass_part()->oop_is_instance_slow(), "must be instance klass"); | |
166 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
167 // Get size before changing pointers. | |
168 // Don't call size() or oop_size() since that is a virtual call. | |
169 int size = ik->object_size(); | |
170 | |
171 ik->iterate_static_fields(blk); | |
172 ik->vtable()->oop_oop_iterate(blk); | |
173 ik->itable()->oop_oop_iterate(blk); | |
174 | |
175 blk->do_oop(ik->adr_array_klasses()); | |
176 blk->do_oop(ik->adr_methods()); | |
177 blk->do_oop(ik->adr_method_ordering()); | |
178 blk->do_oop(ik->adr_local_interfaces()); | |
179 blk->do_oop(ik->adr_transitive_interfaces()); | |
180 blk->do_oop(ik->adr_fields()); | |
181 blk->do_oop(ik->adr_constants()); | |
182 blk->do_oop(ik->adr_class_loader()); | |
183 blk->do_oop(ik->adr_protection_domain()); | |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
184 blk->do_oop(ik->adr_host_klass()); |
0 | 185 blk->do_oop(ik->adr_signers()); |
186 blk->do_oop(ik->adr_inner_classes()); | |
187 for (int i = 0; i < instanceKlass::implementors_limit; i++) { | |
188 blk->do_oop(&ik->adr_implementors()[i]); | |
189 } | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
665
diff
changeset
|
190 blk->do_oop(ik->adr_bootstrap_method()); |
0 | 191 blk->do_oop(ik->adr_class_annotations()); |
192 blk->do_oop(ik->adr_fields_annotations()); | |
193 blk->do_oop(ik->adr_methods_annotations()); | |
194 blk->do_oop(ik->adr_methods_parameter_annotations()); | |
195 blk->do_oop(ik->adr_methods_default_annotations()); | |
196 | |
197 klassKlass::oop_oop_iterate(obj, blk); | |
198 | |
199 if(ik->oop_map_cache() != NULL) ik->oop_map_cache()->oop_iterate(blk); | |
200 return size; | |
201 } | |
202 | |
203 int instanceKlassKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, | |
204 MemRegion mr) { | |
205 assert(obj->is_klass(),"must be a klass"); | |
206 assert(klassOop(obj)->klass_part()->oop_is_instance_slow(), "must be instance klass"); | |
207 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
208 // Get size before changing pointers. | |
209 // Don't call size() or oop_size() since that is a virtual call. | |
210 int size = ik->object_size(); | |
211 | |
212 ik->iterate_static_fields(blk, mr); | |
213 ik->vtable()->oop_oop_iterate_m(blk, mr); | |
214 ik->itable()->oop_oop_iterate_m(blk, mr); | |
215 | |
216 oop* adr; | |
217 adr = ik->adr_array_klasses(); | |
218 if (mr.contains(adr)) blk->do_oop(adr); | |
219 adr = ik->adr_methods(); | |
220 if (mr.contains(adr)) blk->do_oop(adr); | |
221 adr = ik->adr_method_ordering(); | |
222 if (mr.contains(adr)) blk->do_oop(adr); | |
223 adr = ik->adr_local_interfaces(); | |
224 if (mr.contains(adr)) blk->do_oop(adr); | |
225 adr = ik->adr_transitive_interfaces(); | |
226 if (mr.contains(adr)) blk->do_oop(adr); | |
227 adr = ik->adr_fields(); | |
228 if (mr.contains(adr)) blk->do_oop(adr); | |
229 adr = ik->adr_constants(); | |
230 if (mr.contains(adr)) blk->do_oop(adr); | |
231 adr = ik->adr_class_loader(); | |
232 if (mr.contains(adr)) blk->do_oop(adr); | |
233 adr = ik->adr_protection_domain(); | |
234 if (mr.contains(adr)) blk->do_oop(adr); | |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
235 adr = ik->adr_host_klass(); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
236 if (mr.contains(adr)) blk->do_oop(adr); |
0 | 237 adr = ik->adr_signers(); |
238 if (mr.contains(adr)) blk->do_oop(adr); | |
239 adr = ik->adr_inner_classes(); | |
240 if (mr.contains(adr)) blk->do_oop(adr); | |
241 adr = ik->adr_implementors(); | |
242 for (int i = 0; i < instanceKlass::implementors_limit; i++) { | |
243 if (mr.contains(&adr[i])) blk->do_oop(&adr[i]); | |
244 } | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
665
diff
changeset
|
245 adr = ik->adr_bootstrap_method(); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
665
diff
changeset
|
246 if (mr.contains(adr)) blk->do_oop(adr); |
0 | 247 adr = ik->adr_class_annotations(); |
248 if (mr.contains(adr)) blk->do_oop(adr); | |
249 adr = ik->adr_fields_annotations(); | |
250 if (mr.contains(adr)) blk->do_oop(adr); | |
251 adr = ik->adr_methods_annotations(); | |
252 if (mr.contains(adr)) blk->do_oop(adr); | |
253 adr = ik->adr_methods_parameter_annotations(); | |
254 if (mr.contains(adr)) blk->do_oop(adr); | |
255 adr = ik->adr_methods_default_annotations(); | |
256 if (mr.contains(adr)) blk->do_oop(adr); | |
257 | |
258 klassKlass::oop_oop_iterate_m(obj, blk, mr); | |
259 | |
260 if(ik->oop_map_cache() != NULL) ik->oop_map_cache()->oop_iterate(blk, mr); | |
261 return size; | |
262 } | |
263 | |
264 int instanceKlassKlass::oop_adjust_pointers(oop obj) { | |
265 assert(obj->is_klass(),"must be a klass"); | |
266 assert(klassOop(obj)->klass_part()->oop_is_instance_slow(), "must be instance klass"); | |
267 | |
268 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
269 ik->adjust_static_fields(); | |
270 ik->vtable()->oop_adjust_pointers(); | |
271 ik->itable()->oop_adjust_pointers(); | |
272 | |
273 MarkSweep::adjust_pointer(ik->adr_array_klasses()); | |
274 MarkSweep::adjust_pointer(ik->adr_methods()); | |
275 MarkSweep::adjust_pointer(ik->adr_method_ordering()); | |
276 MarkSweep::adjust_pointer(ik->adr_local_interfaces()); | |
277 MarkSweep::adjust_pointer(ik->adr_transitive_interfaces()); | |
278 MarkSweep::adjust_pointer(ik->adr_fields()); | |
279 MarkSweep::adjust_pointer(ik->adr_constants()); | |
280 MarkSweep::adjust_pointer(ik->adr_class_loader()); | |
281 MarkSweep::adjust_pointer(ik->adr_protection_domain()); | |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
282 MarkSweep::adjust_pointer(ik->adr_host_klass()); |
0 | 283 MarkSweep::adjust_pointer(ik->adr_signers()); |
284 MarkSweep::adjust_pointer(ik->adr_inner_classes()); | |
285 for (int i = 0; i < instanceKlass::implementors_limit; i++) { | |
286 MarkSweep::adjust_pointer(&ik->adr_implementors()[i]); | |
287 } | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
665
diff
changeset
|
288 MarkSweep::adjust_pointer(ik->adr_bootstrap_method()); |
0 | 289 MarkSweep::adjust_pointer(ik->adr_class_annotations()); |
290 MarkSweep::adjust_pointer(ik->adr_fields_annotations()); | |
291 MarkSweep::adjust_pointer(ik->adr_methods_annotations()); | |
292 MarkSweep::adjust_pointer(ik->adr_methods_parameter_annotations()); | |
293 MarkSweep::adjust_pointer(ik->adr_methods_default_annotations()); | |
294 | |
295 iterate_c_heap_oops(ik, &MarkSweep::adjust_root_pointer_closure); | |
296 | |
297 return klassKlass::oop_adjust_pointers(obj); | |
298 } | |
299 | |
300 #ifndef SERIALGC | |
301 void instanceKlassKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { | |
302 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
303 ik->push_static_fields(pm); | |
304 | |
305 oop* loader_addr = ik->adr_class_loader(); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
306 if (PSScavenge::should_scavenge(loader_addr)) { |
0 | 307 pm->claim_or_forward_depth(loader_addr); |
308 } | |
309 | |
310 oop* pd_addr = ik->adr_protection_domain(); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
311 if (PSScavenge::should_scavenge(pd_addr)) { |
0 | 312 pm->claim_or_forward_depth(pd_addr); |
313 } | |
314 | |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
315 oop* hk_addr = ik->adr_host_klass(); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
316 if (PSScavenge::should_scavenge(hk_addr)) { |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
317 pm->claim_or_forward_depth(hk_addr); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
318 } |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
319 |
0 | 320 oop* sg_addr = ik->adr_signers(); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
321 if (PSScavenge::should_scavenge(sg_addr)) { |
0 | 322 pm->claim_or_forward_depth(sg_addr); |
323 } | |
324 | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
975
diff
changeset
|
325 oop* bsm_addr = ik->adr_bootstrap_method(); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
975
diff
changeset
|
326 if (PSScavenge::should_scavenge(bsm_addr)) { |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
975
diff
changeset
|
327 pm->claim_or_forward_depth(bsm_addr); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
975
diff
changeset
|
328 } |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
975
diff
changeset
|
329 |
1706
9d7a8ab3736b
6962589: remove breadth first scanning code from parallel gc
tonyp
parents:
1552
diff
changeset
|
330 klassKlass::oop_push_contents(pm, obj); |
0 | 331 } |
332 | |
333 int instanceKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { | |
334 assert(obj->is_klass(),"must be a klass"); | |
335 assert(klassOop(obj)->klass_part()->oop_is_instance_slow(), | |
336 "must be instance klass"); | |
337 | |
338 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
339 ik->update_static_fields(); | |
340 ik->vtable()->oop_update_pointers(cm); | |
341 ik->itable()->oop_update_pointers(cm); | |
342 | |
343 oop* const beg_oop = ik->oop_block_beg(); | |
344 oop* const end_oop = ik->oop_block_end(); | |
345 for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) { | |
346 PSParallelCompact::adjust_pointer(cur_oop); | |
347 } | |
348 | |
349 OopClosure* closure = PSParallelCompact::adjust_root_pointer_closure(); | |
350 iterate_c_heap_oops(ik, closure); | |
351 | |
352 klassKlass::oop_update_pointers(cm, obj); | |
353 return ik->object_size(); | |
354 } | |
355 | |
356 int instanceKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj, | |
357 HeapWord* beg_addr, | |
358 HeapWord* end_addr) { | |
359 assert(obj->is_klass(),"must be a klass"); | |
360 assert(klassOop(obj)->klass_part()->oop_is_instance_slow(), | |
361 "must be instance klass"); | |
362 | |
363 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
364 ik->update_static_fields(beg_addr, end_addr); | |
365 ik->vtable()->oop_update_pointers(cm, beg_addr, end_addr); | |
366 ik->itable()->oop_update_pointers(cm, beg_addr, end_addr); | |
367 | |
368 oop* const beg_oop = MAX2((oop*)beg_addr, ik->oop_block_beg()); | |
369 oop* const end_oop = MIN2((oop*)end_addr, ik->oop_block_end()); | |
370 for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) { | |
371 PSParallelCompact::adjust_pointer(cur_oop); | |
372 } | |
373 | |
374 // The oop_map_cache, jni_ids and jni_id_map are allocated from the C heap, | |
375 // and so don't lie within any 'Chunk' boundaries. Update them when the | |
376 // lowest addressed oop in the instanceKlass 'oop_block' is updated. | |
377 if (beg_oop == ik->oop_block_beg()) { | |
378 OopClosure* closure = PSParallelCompact::adjust_root_pointer_closure(); | |
379 iterate_c_heap_oops(ik, closure); | |
380 } | |
381 | |
382 klassKlass::oop_update_pointers(cm, obj, beg_addr, end_addr); | |
383 return ik->object_size(); | |
384 } | |
385 #endif // SERIALGC | |
386 | |
938 | 387 klassOop |
388 instanceKlassKlass::allocate_instance_klass(int vtable_len, int itable_len, | |
389 int static_field_size, | |
939
9eebd3ac74cf
6845368: large objects cause a crash or unexpected exception
jcoomes
parents:
938
diff
changeset
|
390 unsigned nonstatic_oop_map_count, |
938 | 391 ReferenceType rt, TRAPS) { |
0 | 392 |
938 | 393 const int nonstatic_oop_map_size = |
394 instanceKlass::nonstatic_oop_map_size(nonstatic_oop_map_count); | |
0 | 395 int size = instanceKlass::object_size(align_object_offset(vtable_len) + align_object_offset(itable_len) + static_field_size + nonstatic_oop_map_size); |
396 | |
397 // Allocation | |
398 KlassHandle h_this_klass(THREAD, as_klassOop()); | |
399 KlassHandle k; | |
400 if (rt == REF_NONE) { | |
401 // regular klass | |
402 instanceKlass o; | |
403 k = base_create_klass(h_this_klass, size, o.vtbl_value(), CHECK_NULL); | |
404 } else { | |
405 // reference klass | |
406 instanceRefKlass o; | |
407 k = base_create_klass(h_this_klass, size, o.vtbl_value(), CHECK_NULL); | |
408 } | |
409 { | |
410 No_Safepoint_Verifier no_safepoint; // until k becomes parsable | |
411 instanceKlass* ik = (instanceKlass*) k()->klass_part(); | |
412 assert(!k()->is_parsable(), "not expecting parsability yet."); | |
413 | |
414 // The sizes of these these three variables are used for determining the | |
415 // size of the instanceKlassOop. It is critical that these are set to the right | |
416 // sizes before the first GC, i.e., when we allocate the mirror. | |
417 ik->set_vtable_length(vtable_len); | |
418 ik->set_itable_length(itable_len); | |
419 ik->set_static_field_size(static_field_size); | |
420 ik->set_nonstatic_oop_map_size(nonstatic_oop_map_size); | |
421 assert(k()->size() == size, "wrong size for object"); | |
422 | |
423 ik->set_array_klasses(NULL); | |
424 ik->set_methods(NULL); | |
425 ik->set_method_ordering(NULL); | |
426 ik->set_local_interfaces(NULL); | |
427 ik->set_transitive_interfaces(NULL); | |
428 ik->init_implementor(); | |
429 ik->set_fields(NULL); | |
430 ik->set_constants(NULL); | |
431 ik->set_class_loader(NULL); | |
432 ik->set_protection_domain(NULL); | |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
433 ik->set_host_klass(NULL); |
0 | 434 ik->set_signers(NULL); |
435 ik->set_source_file_name(NULL); | |
436 ik->set_source_debug_extension(NULL); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
437 ik->set_source_debug_extension(NULL); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
438 ik->set_array_name(NULL); |
0 | 439 ik->set_inner_classes(NULL); |
440 ik->set_static_oop_field_size(0); | |
441 ik->set_nonstatic_field_size(0); | |
975 | 442 ik->set_is_marked_dependent(false); |
0 | 443 ik->set_init_state(instanceKlass::allocated); |
444 ik->set_init_thread(NULL); | |
445 ik->set_reference_type(rt); | |
446 ik->set_oop_map_cache(NULL); | |
447 ik->set_jni_ids(NULL); | |
448 ik->set_osr_nmethods_head(NULL); | |
449 ik->set_breakpoints(NULL); | |
450 ik->init_previous_versions(); | |
451 ik->set_generic_signature(NULL); | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
665
diff
changeset
|
452 ik->set_bootstrap_method(NULL); |
0 | 453 ik->release_set_methods_jmethod_ids(NULL); |
454 ik->release_set_methods_cached_itable_indices(NULL); | |
455 ik->set_class_annotations(NULL); | |
456 ik->set_fields_annotations(NULL); | |
457 ik->set_methods_annotations(NULL); | |
458 ik->set_methods_parameter_annotations(NULL); | |
459 ik->set_methods_default_annotations(NULL); | |
460 ik->set_enclosing_method_indices(0, 0); | |
461 ik->set_jvmti_cached_class_field_map(NULL); | |
462 ik->set_initial_method_idnum(0); | |
463 assert(k()->is_parsable(), "should be parsable here."); | |
464 | |
465 // initialize the non-header words to zero | |
466 intptr_t* p = (intptr_t*)k(); | |
467 for (int index = instanceKlass::header_size(); index < size; index++) { | |
468 p[index] = NULL_WORD; | |
469 } | |
470 | |
471 // To get verify to work - must be set to partial loaded before first GC point. | |
472 k()->set_partially_loaded(); | |
473 } | |
474 | |
475 // GC can happen here | |
476 java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror | |
477 return k(); | |
478 } | |
479 | |
480 | |
481 | |
482 #ifndef PRODUCT | |
483 | |
484 // Printing | |
485 | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
486 #define BULLET " - " |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
487 |
0 | 488 static const char* state_names[] = { |
489 "unparseable_by_gc", "allocated", "loaded", "linked", "being_initialized", "fully_initialized", "initialization_error" | |
490 }; | |
491 | |
492 | |
493 void instanceKlassKlass::oop_print_on(oop obj, outputStream* st) { | |
494 assert(obj->is_klass(), "must be klass"); | |
495 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
496 klassKlass::oop_print_on(obj, st); | |
497 | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
498 st->print(BULLET"instance size: %d", ik->size_helper()); st->cr(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
499 st->print(BULLET"klass size: %d", ik->object_size()); st->cr(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
500 st->print(BULLET"access: "); ik->access_flags().print_on(st); st->cr(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
501 st->print(BULLET"state: "); st->print_cr(state_names[ik->_init_state]); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
502 st->print(BULLET"name: "); ik->name()->print_value_on(st); st->cr(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
503 st->print(BULLET"super: "); ik->super()->print_value_on(st); st->cr(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
504 st->print(BULLET"sub: "); |
0 | 505 Klass* sub = ik->subklass(); |
506 int n; | |
507 for (n = 0; sub != NULL; n++, sub = sub->next_sibling()) { | |
508 if (n < MaxSubklassPrintSize) { | |
509 sub->as_klassOop()->print_value_on(st); | |
510 st->print(" "); | |
511 } | |
512 } | |
513 if (n >= MaxSubklassPrintSize) st->print("(%d more klasses...)", n - MaxSubklassPrintSize); | |
514 st->cr(); | |
515 | |
516 if (ik->is_interface()) { | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
517 st->print_cr(BULLET"nof implementors: %d", ik->nof_implementors()); |
0 | 518 int print_impl = 0; |
519 for (int i = 0; i < instanceKlass::implementors_limit; i++) { | |
520 if (ik->implementor(i) != NULL) { | |
521 if (++print_impl == 1) | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
522 st->print_cr(BULLET"implementor: "); |
0 | 523 st->print(" "); |
524 ik->implementor(i)->print_value_on(st); | |
525 } | |
526 } | |
527 if (print_impl > 0) st->cr(); | |
528 } | |
529 | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
530 st->print(BULLET"arrays: "); ik->array_klasses()->print_value_on(st); st->cr(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
531 st->print(BULLET"methods: "); ik->methods()->print_value_on(st); st->cr(); |
0 | 532 if (Verbose) { |
533 objArrayOop methods = ik->methods(); | |
534 for(int i = 0; i < methods->length(); i++) { | |
535 tty->print("%d : ", i); methods->obj_at(i)->print_value(); tty->cr(); | |
536 } | |
537 } | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
538 st->print(BULLET"method ordering: "); ik->method_ordering()->print_value_on(st); st->cr(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
539 st->print(BULLET"local interfaces: "); ik->local_interfaces()->print_value_on(st); st->cr(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
540 st->print(BULLET"trans. interfaces: "); ik->transitive_interfaces()->print_value_on(st); st->cr(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
541 st->print(BULLET"constants: "); ik->constants()->print_value_on(st); st->cr(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
542 st->print(BULLET"class loader: "); ik->class_loader()->print_value_on(st); st->cr(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
543 st->print(BULLET"protection domain: "); ik->protection_domain()->print_value_on(st); st->cr(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
544 st->print(BULLET"host class: "); ik->host_klass()->print_value_on(st); st->cr(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
545 st->print(BULLET"signers: "); ik->signers()->print_value_on(st); st->cr(); |
0 | 546 if (ik->source_file_name() != NULL) { |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
547 st->print(BULLET"source file: "); |
0 | 548 ik->source_file_name()->print_value_on(st); |
549 st->cr(); | |
550 } | |
551 if (ik->source_debug_extension() != NULL) { | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
552 st->print(BULLET"source debug extension: "); |
0 | 553 ik->source_debug_extension()->print_value_on(st); |
554 st->cr(); | |
555 } | |
556 | |
557 { | |
558 ResourceMark rm; | |
559 // PreviousVersionInfo objects returned via PreviousVersionWalker | |
560 // contain a GrowableArray of handles. We have to clean up the | |
561 // GrowableArray _after_ the PreviousVersionWalker destructor | |
562 // has destroyed the handles. | |
563 { | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
564 bool have_pv = false; |
0 | 565 PreviousVersionWalker pvw(ik); |
566 for (PreviousVersionInfo * pv_info = pvw.next_previous_version(); | |
567 pv_info != NULL; pv_info = pvw.next_previous_version()) { | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
568 if (!have_pv) |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
569 st->print(BULLET"previous version: "); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
570 have_pv = true; |
0 | 571 pv_info->prev_constant_pool_handle()()->print_value_on(st); |
572 } | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
573 if (have_pv) st->cr(); |
0 | 574 } // pvw is cleaned up |
575 } // rm is cleaned up | |
576 | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
665
diff
changeset
|
577 if (ik->bootstrap_method() != NULL) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
665
diff
changeset
|
578 st->print(BULLET"bootstrap method: "); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
665
diff
changeset
|
579 ik->bootstrap_method()->print_value_on(st); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
665
diff
changeset
|
580 st->cr(); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
665
diff
changeset
|
581 } |
0 | 582 if (ik->generic_signature() != NULL) { |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
583 st->print(BULLET"generic signature: "); |
0 | 584 ik->generic_signature()->print_value_on(st); |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
585 st->cr(); |
0 | 586 } |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
587 st->print(BULLET"inner classes: "); ik->inner_classes()->print_value_on(st); st->cr(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
588 st->print(BULLET"java mirror: "); ik->java_mirror()->print_value_on(st); st->cr(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
589 st->print(BULLET"vtable length %d (start addr: " INTPTR_FORMAT ")", ik->vtable_length(), ik->start_of_vtable()); st->cr(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
590 st->print(BULLET"itable length %d (start addr: " INTPTR_FORMAT ")", ik->itable_length(), ik->start_of_itable()); st->cr(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
591 st->print_cr(BULLET"---- static fields (%d words):", ik->static_field_size()); |
0 | 592 FieldPrinter print_static_field(st); |
593 ik->do_local_static_fields(&print_static_field); | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
594 st->print_cr(BULLET"---- non-static fields (%d words):", ik->nonstatic_field_size()); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
595 FieldPrinter print_nonstatic_field(st); |
0 | 596 ik->do_nonstatic_fields(&print_nonstatic_field); |
597 | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
598 st->print(BULLET"static oop maps: "); |
0 | 599 if (ik->static_oop_field_size() > 0) { |
600 int first_offset = ik->offset_of_static_fields(); | |
601 st->print("%d-%d", first_offset, first_offset + ik->static_oop_field_size() - 1); | |
602 } | |
603 st->cr(); | |
604 | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
605 st->print(BULLET"non-static oop maps: "); |
0 | 606 OopMapBlock* map = ik->start_of_nonstatic_oop_maps(); |
938 | 607 OopMapBlock* end_map = map + ik->nonstatic_oop_map_count(); |
0 | 608 while (map < end_map) { |
938 | 609 st->print("%d-%d ", map->offset(), map->offset() + heapOopSize*(map->count() - 1)); |
0 | 610 map++; |
611 } | |
612 st->cr(); | |
613 } | |
614 | |
1155
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1059
diff
changeset
|
615 #endif //PRODUCT |
0 | 616 |
617 void instanceKlassKlass::oop_print_value_on(oop obj, outputStream* st) { | |
618 assert(obj->is_klass(), "must be klass"); | |
619 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
620 ik->name()->print_value_on(st); | |
621 } | |
622 | |
623 const char* instanceKlassKlass::internal_name() const { | |
624 return "{instance class}"; | |
625 } | |
626 | |
627 // Verification | |
628 | |
629 class VerifyFieldClosure: public OopClosure { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
630 protected: |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
631 template <class T> void do_oop_work(T* p) { |
0 | 632 guarantee(Universe::heap()->is_in(p), "should be in heap"); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
633 oop obj = oopDesc::load_decode_heap_oop(p); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
634 guarantee(obj->is_oop_or_null(), "should be in heap"); |
0 | 635 } |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
636 public: |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
637 virtual void do_oop(oop* p) { VerifyFieldClosure::do_oop_work(p); } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
638 virtual void do_oop(narrowOop* p) { VerifyFieldClosure::do_oop_work(p); } |
0 | 639 }; |
640 | |
641 void instanceKlassKlass::oop_verify_on(oop obj, outputStream* st) { | |
642 klassKlass::oop_verify_on(obj, st); | |
643 if (!obj->partially_loaded()) { | |
644 Thread *thread = Thread::current(); | |
645 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
646 | |
647 #ifndef PRODUCT | |
648 // Avoid redundant verifies | |
649 if (ik->_verify_count == Universe::verify_count()) return; | |
650 ik->_verify_count = Universe::verify_count(); | |
651 #endif | |
652 // Verify that klass is present in SystemDictionary | |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
653 if (ik->is_loaded() && !ik->is_anonymous()) { |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
654 Symbol* h_name = ik->name(); |
0 | 655 Handle h_loader (thread, ik->class_loader()); |
656 Handle h_obj(thread, obj); | |
657 SystemDictionary::verify_obj_klass_present(h_obj, h_name, h_loader); | |
658 } | |
659 | |
660 // Verify static fields | |
661 VerifyFieldClosure blk; | |
662 ik->iterate_static_fields(&blk); | |
663 | |
664 // Verify vtables | |
665 if (ik->is_linked()) { | |
666 ResourceMark rm(thread); | |
667 // $$$ This used to be done only for m/s collections. Doing it | |
668 // always seemed a valid generalization. (DLD -- 6/00) | |
669 ik->vtable()->verify(st); | |
670 } | |
671 | |
672 // Verify oop map cache | |
673 if (ik->oop_map_cache() != NULL) { | |
674 ik->oop_map_cache()->verify(); | |
675 } | |
676 | |
677 // Verify first subklass | |
678 if (ik->subklass_oop() != NULL) { | |
679 guarantee(ik->subklass_oop()->is_perm(), "should be in permspace"); | |
680 guarantee(ik->subklass_oop()->is_klass(), "should be klass"); | |
681 } | |
682 | |
683 // Verify siblings | |
684 klassOop super = ik->super(); | |
685 Klass* sib = ik->next_sibling(); | |
686 int sib_count = 0; | |
687 while (sib != NULL) { | |
688 if (sib == ik) { | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1155
diff
changeset
|
689 fatal(err_msg("subclass cycle of length %d", sib_count)); |
0 | 690 } |
691 if (sib_count >= 100000) { | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1155
diff
changeset
|
692 fatal(err_msg("suspiciously long subclass list %d", sib_count)); |
0 | 693 } |
694 guarantee(sib->as_klassOop()->is_klass(), "should be klass"); | |
695 guarantee(sib->as_klassOop()->is_perm(), "should be in permspace"); | |
696 guarantee(sib->super() == super, "siblings should have same superklass"); | |
697 sib = sib->next_sibling(); | |
698 } | |
699 | |
700 // Verify implementor fields | |
701 bool saw_null_impl = false; | |
702 for (int i = 0; i < instanceKlass::implementors_limit; i++) { | |
703 klassOop im = ik->implementor(i); | |
704 if (im == NULL) { saw_null_impl = true; continue; } | |
705 guarantee(!saw_null_impl, "non-nulls must preceded all nulls"); | |
706 guarantee(ik->is_interface(), "only interfaces should have implementor set"); | |
707 guarantee(i < ik->nof_implementors(), "should only have one implementor"); | |
708 guarantee(im->is_perm(), "should be in permspace"); | |
709 guarantee(im->is_klass(), "should be klass"); | |
710 guarantee(!Klass::cast(klassOop(im))->is_interface(), "implementors cannot be interfaces"); | |
711 } | |
712 | |
713 // Verify local interfaces | |
714 objArrayOop local_interfaces = ik->local_interfaces(); | |
715 guarantee(local_interfaces->is_perm(), "should be in permspace"); | |
716 guarantee(local_interfaces->is_objArray(), "should be obj array"); | |
717 int j; | |
718 for (j = 0; j < local_interfaces->length(); j++) { | |
719 oop e = local_interfaces->obj_at(j); | |
720 guarantee(e->is_klass() && Klass::cast(klassOop(e))->is_interface(), "invalid local interface"); | |
721 } | |
722 | |
723 // Verify transitive interfaces | |
724 objArrayOop transitive_interfaces = ik->transitive_interfaces(); | |
725 guarantee(transitive_interfaces->is_perm(), "should be in permspace"); | |
726 guarantee(transitive_interfaces->is_objArray(), "should be obj array"); | |
727 for (j = 0; j < transitive_interfaces->length(); j++) { | |
728 oop e = transitive_interfaces->obj_at(j); | |
729 guarantee(e->is_klass() && Klass::cast(klassOop(e))->is_interface(), "invalid transitive interface"); | |
730 } | |
731 | |
732 // Verify methods | |
733 objArrayOop methods = ik->methods(); | |
734 guarantee(methods->is_perm(), "should be in permspace"); | |
735 guarantee(methods->is_objArray(), "should be obj array"); | |
736 for (j = 0; j < methods->length(); j++) { | |
737 guarantee(methods->obj_at(j)->is_method(), "non-method in methods array"); | |
738 } | |
739 for (j = 0; j < methods->length() - 1; j++) { | |
740 methodOop m1 = methodOop(methods->obj_at(j)); | |
741 methodOop m2 = methodOop(methods->obj_at(j + 1)); | |
742 guarantee(m1->name()->fast_compare(m2->name()) <= 0, "methods not sorted correctly"); | |
743 } | |
744 | |
745 // Verify method ordering | |
746 typeArrayOop method_ordering = ik->method_ordering(); | |
747 guarantee(method_ordering->is_perm(), "should be in permspace"); | |
748 guarantee(method_ordering->is_typeArray(), "should be type array"); | |
749 int length = method_ordering->length(); | |
750 if (JvmtiExport::can_maintain_original_method_order()) { | |
751 guarantee(length == methods->length(), "invalid method ordering length"); | |
752 jlong sum = 0; | |
753 for (j = 0; j < length; j++) { | |
754 int original_index = method_ordering->int_at(j); | |
755 guarantee(original_index >= 0 && original_index < length, "invalid method ordering index"); | |
756 sum += original_index; | |
757 } | |
758 // Verify sum of indices 0,1,...,length-1 | |
759 guarantee(sum == ((jlong)length*(length-1))/2, "invalid method ordering sum"); | |
760 } else { | |
761 guarantee(length == 0, "invalid method ordering length"); | |
762 } | |
763 | |
764 // Verify JNI static field identifiers | |
765 if (ik->jni_ids() != NULL) { | |
766 ik->jni_ids()->verify(ik->as_klassOop()); | |
767 } | |
768 | |
769 // Verify other fields | |
770 if (ik->array_klasses() != NULL) { | |
771 guarantee(ik->array_klasses()->is_perm(), "should be in permspace"); | |
772 guarantee(ik->array_klasses()->is_klass(), "should be klass"); | |
773 } | |
774 guarantee(ik->fields()->is_perm(), "should be in permspace"); | |
775 guarantee(ik->fields()->is_typeArray(), "should be type array"); | |
776 guarantee(ik->constants()->is_perm(), "should be in permspace"); | |
777 guarantee(ik->constants()->is_constantPool(), "should be constant pool"); | |
778 guarantee(ik->inner_classes()->is_perm(), "should be in permspace"); | |
779 guarantee(ik->inner_classes()->is_typeArray(), "should be type array"); | |
780 if (ik->protection_domain() != NULL) { | |
781 guarantee(ik->protection_domain()->is_oop(), "should be oop"); | |
782 } | |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
783 if (ik->host_klass() != NULL) { |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
784 guarantee(ik->host_klass()->is_oop(), "should be oop"); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
785 } |
0 | 786 if (ik->signers() != NULL) { |
787 guarantee(ik->signers()->is_objArray(), "should be obj array"); | |
788 } | |
789 if (ik->class_annotations() != NULL) { | |
790 guarantee(ik->class_annotations()->is_typeArray(), "should be type array"); | |
791 } | |
792 if (ik->fields_annotations() != NULL) { | |
793 guarantee(ik->fields_annotations()->is_objArray(), "should be obj array"); | |
794 } | |
795 if (ik->methods_annotations() != NULL) { | |
796 guarantee(ik->methods_annotations()->is_objArray(), "should be obj array"); | |
797 } | |
798 if (ik->methods_parameter_annotations() != NULL) { | |
799 guarantee(ik->methods_parameter_annotations()->is_objArray(), "should be obj array"); | |
800 } | |
801 if (ik->methods_default_annotations() != NULL) { | |
802 guarantee(ik->methods_default_annotations()->is_objArray(), "should be obj array"); | |
803 } | |
804 } | |
805 } | |
806 | |
807 | |
808 bool instanceKlassKlass::oop_partially_loaded(oop obj) const { | |
809 assert(obj->is_klass(), "object must be klass"); | |
810 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
811 assert(ik->oop_is_instance(), "object must be instanceKlass"); | |
812 return ik->transitive_interfaces() == (objArrayOop) obj; // Check whether transitive_interfaces points to self | |
813 } | |
814 | |
815 | |
816 // The transitive_interfaces is the last field set when loading an object. | |
817 void instanceKlassKlass::oop_set_partially_loaded(oop obj) { | |
818 assert(obj->is_klass(), "object must be klass"); | |
819 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
820 // Set the layout helper to a place-holder value, until fuller initialization. | |
821 // (This allows asserts in oop_is_instance to succeed.) | |
822 ik->set_layout_helper(Klass::instance_layout_helper(0, true)); | |
823 assert(ik->oop_is_instance(), "object must be instanceKlass"); | |
824 assert(ik->transitive_interfaces() == NULL, "just checking"); | |
825 ik->set_transitive_interfaces((objArrayOop) obj); // Temporarily set transitive_interfaces to point to self | |
826 } |