Mercurial > hg > graal-compiler
annotate src/share/vm/oops/instanceKlassKlass.cpp @ 6231:7e5976e66c62
7182543: NMT ON: Aggregate a few NMT related bugs
Summary: 1) Fixed MemTrackWorker::generations_in_used() calculation 2) Ensured NMT not to leak memory recorders after shutdown 3) Used ThreadCritical to block safepoint safe threads
Reviewed-by: acorn, coleenp, dholmes, kvn
author | zgu |
---|---|
date | Thu, 19 Jul 2012 09:05:42 -0400 |
parents | 8bafad97cd26 |
children | 04ade88d9712 |
rev | line source |
---|---|
0 | 1 /* |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
5967
diff
changeset
|
2 * Copyright (c) 1997, 2012, 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" | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2227
diff
changeset
|
34 #include "oops/instanceMirrorKlass.hpp" |
1972 | 35 #include "oops/instanceKlassKlass.hpp" |
36 #include "oops/instanceRefKlass.hpp" | |
37 #include "oops/objArrayKlassKlass.hpp" | |
38 #include "oops/objArrayOop.hpp" | |
39 #include "oops/oop.inline.hpp" | |
40 #include "oops/oop.inline2.hpp" | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
41 #include "oops/symbol.hpp" |
1972 | 42 #include "oops/typeArrayOop.hpp" |
43 #include "prims/jvmtiExport.hpp" | |
44 #include "runtime/fieldDescriptor.hpp" | |
45 #ifndef SERIALGC | |
46 #include "gc_implementation/parNew/parOopClosures.inline.hpp" | |
47 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp" | |
48 #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp" | |
49 #include "memory/cardTableRS.hpp" | |
50 #include "oops/oop.pcgc.inline.hpp" | |
51 #endif | |
0 | 52 |
53 klassOop instanceKlassKlass::create_klass(TRAPS) { | |
54 instanceKlassKlass o; | |
55 KlassHandle h_this_klass(THREAD, Universe::klassKlassObj()); | |
56 KlassHandle k = base_create_klass(h_this_klass, header_size(), o.vtbl_value(), CHECK_NULL); | |
57 // Make sure size calculation is right | |
58 assert(k()->size() == align_object_size(header_size()), "wrong size for object"); | |
59 java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror | |
60 return k(); | |
61 } | |
62 | |
63 int instanceKlassKlass::oop_size(oop obj) const { | |
64 assert(obj->is_klass(), "must be klass"); | |
65 return instanceKlass::cast(klassOop(obj))->object_size(); | |
66 } | |
67 | |
68 bool instanceKlassKlass::oop_is_parsable(oop obj) const { | |
69 assert(obj->is_klass(), "must be klass"); | |
70 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
71 return (!ik->null_vtbl()) && ik->object_is_parsable(); | |
72 } | |
73 | |
74 void instanceKlassKlass::iterate_c_heap_oops(instanceKlass* ik, | |
75 OopClosure* closure) { | |
76 if (ik->oop_map_cache() != NULL) { | |
77 ik->oop_map_cache()->oop_iterate(closure); | |
78 } | |
79 | |
80 if (ik->jni_ids() != NULL) { | |
81 ik->jni_ids()->oops_do(closure); | |
82 } | |
83 } | |
84 | |
85 void instanceKlassKlass::oop_follow_contents(oop obj) { | |
86 assert(obj->is_klass(),"must be a klass"); | |
87 assert(klassOop(obj)->klass_part()->oop_is_instance_slow(), "must be instance klass"); | |
88 | |
89 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
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()); | |
6038
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
106 if (ik->adr_host_klass() != NULL) { |
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
107 MarkSweep::mark_and_push(ik->adr_host_klass()); |
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
108 } |
0 | 109 MarkSweep::mark_and_push(ik->adr_signers()); |
110 MarkSweep::mark_and_push(ik->adr_class_annotations()); | |
111 MarkSweep::mark_and_push(ik->adr_fields_annotations()); | |
112 MarkSweep::mark_and_push(ik->adr_methods_annotations()); | |
113 MarkSweep::mark_and_push(ik->adr_methods_parameter_annotations()); | |
114 MarkSweep::mark_and_push(ik->adr_methods_default_annotations()); | |
115 | |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
5967
diff
changeset
|
116 // We do not follow adr_implementor() here. It is followed later |
0 | 117 // in instanceKlass::follow_weak_klass_links() |
118 | |
119 klassKlass::oop_follow_contents(obj); | |
120 | |
121 iterate_c_heap_oops(ik, &MarkSweep::mark_and_push_closure); | |
122 } | |
123 | |
124 #ifndef SERIALGC | |
125 void instanceKlassKlass::oop_follow_contents(ParCompactionManager* cm, | |
126 oop obj) { | |
127 assert(obj->is_klass(),"must be a klass"); | |
128 assert(klassOop(obj)->klass_part()->oop_is_instance_slow(), "must be instance klass"); | |
129 | |
130 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
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()); | |
6038
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
144 if (ik->adr_host_klass() != NULL) { |
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
145 PSParallelCompact::mark_and_push(cm, ik->adr_host_klass()); |
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
146 } |
0 | 147 PSParallelCompact::mark_and_push(cm, ik->adr_signers()); |
148 PSParallelCompact::mark_and_push(cm, ik->adr_class_annotations()); | |
149 PSParallelCompact::mark_and_push(cm, ik->adr_fields_annotations()); | |
150 PSParallelCompact::mark_and_push(cm, ik->adr_methods_annotations()); | |
151 PSParallelCompact::mark_and_push(cm, ik->adr_methods_parameter_annotations()); | |
152 PSParallelCompact::mark_and_push(cm, ik->adr_methods_default_annotations()); | |
153 | |
154 // We do not follow adr_implementor() here. It is followed later | |
155 // in instanceKlass::follow_weak_klass_links() | |
156 | |
157 klassKlass::oop_follow_contents(cm, obj); | |
158 | |
159 PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm); | |
160 iterate_c_heap_oops(ik, &mark_and_push_closure); | |
161 } | |
162 #endif // SERIALGC | |
163 | |
164 int instanceKlassKlass::oop_oop_iterate(oop obj, OopClosure* blk) { | |
165 assert(obj->is_klass(),"must be a klass"); | |
166 assert(klassOop(obj)->klass_part()->oop_is_instance_slow(), "must be instance klass"); | |
167 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
168 // Get size before changing pointers. | |
169 // Don't call size() or oop_size() since that is a virtual call. | |
170 int size = ik->object_size(); | |
171 | |
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()); | |
6038
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
184 if (ik->adr_host_klass() != NULL) { |
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
185 blk->do_oop(ik->adr_host_klass()); |
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
186 } |
0 | 187 blk->do_oop(ik->adr_signers()); |
188 blk->do_oop(ik->adr_inner_classes()); | |
6038
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
189 if (ik->adr_implementor() != NULL) { |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
5967
diff
changeset
|
190 blk->do_oop(ik->adr_implementor()); |
0 | 191 } |
192 blk->do_oop(ik->adr_class_annotations()); | |
193 blk->do_oop(ik->adr_fields_annotations()); | |
194 blk->do_oop(ik->adr_methods_annotations()); | |
195 blk->do_oop(ik->adr_methods_parameter_annotations()); | |
196 blk->do_oop(ik->adr_methods_default_annotations()); | |
197 | |
198 klassKlass::oop_oop_iterate(obj, blk); | |
199 | |
200 if(ik->oop_map_cache() != NULL) ik->oop_map_cache()->oop_iterate(blk); | |
201 return size; | |
202 } | |
203 | |
204 int instanceKlassKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, | |
205 MemRegion mr) { | |
206 assert(obj->is_klass(),"must be a klass"); | |
207 assert(klassOop(obj)->klass_part()->oop_is_instance_slow(), "must be instance klass"); | |
208 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
209 // Get size before changing pointers. | |
210 // Don't call size() or oop_size() since that is a virtual call. | |
211 int size = ik->object_size(); | |
212 | |
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(); |
6038
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
236 if (adr != NULL && 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); | |
6038
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
241 adr = ik->adr_implementor(); |
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
242 if (adr != NULL && mr.contains(adr)) blk->do_oop(adr); |
0 | 243 adr = ik->adr_class_annotations(); |
244 if (mr.contains(adr)) blk->do_oop(adr); | |
245 adr = ik->adr_fields_annotations(); | |
246 if (mr.contains(adr)) blk->do_oop(adr); | |
247 adr = ik->adr_methods_annotations(); | |
248 if (mr.contains(adr)) blk->do_oop(adr); | |
249 adr = ik->adr_methods_parameter_annotations(); | |
250 if (mr.contains(adr)) blk->do_oop(adr); | |
251 adr = ik->adr_methods_default_annotations(); | |
252 if (mr.contains(adr)) blk->do_oop(adr); | |
253 | |
254 klassKlass::oop_oop_iterate_m(obj, blk, mr); | |
255 | |
256 if(ik->oop_map_cache() != NULL) ik->oop_map_cache()->oop_iterate(blk, mr); | |
257 return size; | |
258 } | |
259 | |
260 int instanceKlassKlass::oop_adjust_pointers(oop obj) { | |
261 assert(obj->is_klass(),"must be a klass"); | |
262 assert(klassOop(obj)->klass_part()->oop_is_instance_slow(), "must be instance klass"); | |
263 | |
264 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
265 ik->vtable()->oop_adjust_pointers(); | |
266 ik->itable()->oop_adjust_pointers(); | |
267 | |
268 MarkSweep::adjust_pointer(ik->adr_array_klasses()); | |
269 MarkSweep::adjust_pointer(ik->adr_methods()); | |
270 MarkSweep::adjust_pointer(ik->adr_method_ordering()); | |
271 MarkSweep::adjust_pointer(ik->adr_local_interfaces()); | |
272 MarkSweep::adjust_pointer(ik->adr_transitive_interfaces()); | |
273 MarkSweep::adjust_pointer(ik->adr_fields()); | |
274 MarkSweep::adjust_pointer(ik->adr_constants()); | |
275 MarkSweep::adjust_pointer(ik->adr_class_loader()); | |
276 MarkSweep::adjust_pointer(ik->adr_protection_domain()); | |
6038
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
277 if (ik->adr_host_klass() != NULL) { |
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
278 MarkSweep::adjust_pointer(ik->adr_host_klass()); |
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
279 } |
0 | 280 MarkSweep::adjust_pointer(ik->adr_signers()); |
281 MarkSweep::adjust_pointer(ik->adr_inner_classes()); | |
6038
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
282 if (ik->adr_implementor() != NULL) { |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
5967
diff
changeset
|
283 MarkSweep::adjust_pointer(ik->adr_implementor()); |
0 | 284 } |
285 MarkSweep::adjust_pointer(ik->adr_class_annotations()); | |
286 MarkSweep::adjust_pointer(ik->adr_fields_annotations()); | |
287 MarkSweep::adjust_pointer(ik->adr_methods_annotations()); | |
288 MarkSweep::adjust_pointer(ik->adr_methods_parameter_annotations()); | |
289 MarkSweep::adjust_pointer(ik->adr_methods_default_annotations()); | |
290 | |
291 iterate_c_heap_oops(ik, &MarkSweep::adjust_root_pointer_closure); | |
292 | |
293 return klassKlass::oop_adjust_pointers(obj); | |
294 } | |
295 | |
296 #ifndef SERIALGC | |
297 void instanceKlassKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { | |
298 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
299 | |
300 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
|
301 if (PSScavenge::should_scavenge(loader_addr)) { |
0 | 302 pm->claim_or_forward_depth(loader_addr); |
303 } | |
304 | |
305 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
|
306 if (PSScavenge::should_scavenge(pd_addr)) { |
0 | 307 pm->claim_or_forward_depth(pd_addr); |
308 } | |
309 | |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
310 oop* hk_addr = ik->adr_host_klass(); |
6038
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
311 if (hk_addr != NULL && PSScavenge::should_scavenge(hk_addr)) { |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
312 pm->claim_or_forward_depth(hk_addr); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
313 } |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
314 |
0 | 315 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
|
316 if (PSScavenge::should_scavenge(sg_addr)) { |
0 | 317 pm->claim_or_forward_depth(sg_addr); |
318 } | |
319 | |
1706
9d7a8ab3736b
6962589: remove breadth first scanning code from parallel gc
tonyp
parents:
1552
diff
changeset
|
320 klassKlass::oop_push_contents(pm, obj); |
0 | 321 } |
322 | |
323 int instanceKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { | |
324 assert(obj->is_klass(),"must be a klass"); | |
325 assert(klassOop(obj)->klass_part()->oop_is_instance_slow(), | |
326 "must be instance klass"); | |
327 | |
328 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
329 ik->vtable()->oop_update_pointers(cm); | |
330 ik->itable()->oop_update_pointers(cm); | |
331 | |
332 oop* const beg_oop = ik->oop_block_beg(); | |
333 oop* const end_oop = ik->oop_block_end(); | |
334 for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) { | |
335 PSParallelCompact::adjust_pointer(cur_oop); | |
336 } | |
6038
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
337 // embedded oops |
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
338 if (ik->adr_implementor() != NULL) { |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
5967
diff
changeset
|
339 PSParallelCompact::adjust_pointer(ik->adr_implementor()); |
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
5967
diff
changeset
|
340 } |
6038
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
341 if (ik->adr_host_klass() != NULL) { |
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
342 PSParallelCompact::adjust_pointer(ik->adr_host_klass()); |
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
343 } |
0 | 344 |
345 OopClosure* closure = PSParallelCompact::adjust_root_pointer_closure(); | |
346 iterate_c_heap_oops(ik, closure); | |
347 | |
348 klassKlass::oop_update_pointers(cm, obj); | |
349 return ik->object_size(); | |
350 } | |
351 | |
352 #endif // SERIALGC | |
353 | |
938 | 354 klassOop |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2227
diff
changeset
|
355 instanceKlassKlass::allocate_instance_klass(Symbol* name, int vtable_len, int itable_len, |
938 | 356 int static_field_size, |
939
9eebd3ac74cf
6845368: large objects cause a crash or unexpected exception
jcoomes
parents:
938
diff
changeset
|
357 unsigned nonstatic_oop_map_count, |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
5967
diff
changeset
|
358 AccessFlags access_flags, |
6038
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
359 ReferenceType rt, |
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
360 KlassHandle host_klass, TRAPS) { |
0 | 361 |
938 | 362 const int nonstatic_oop_map_size = |
363 instanceKlass::nonstatic_oop_map_size(nonstatic_oop_map_count); | |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
5967
diff
changeset
|
364 int size = align_object_offset(vtable_len) + align_object_offset(itable_len); |
6038
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
365 if (access_flags.is_interface() || !host_klass.is_null()) { |
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
366 size += align_object_offset(nonstatic_oop_map_size); |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
5967
diff
changeset
|
367 } else { |
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
5967
diff
changeset
|
368 size += nonstatic_oop_map_size; |
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
5967
diff
changeset
|
369 } |
6038
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
370 if (access_flags.is_interface()) { |
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
371 size += (int)sizeof(klassOop)/HeapWordSize; |
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
372 } |
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
373 if (!host_klass.is_null()) { |
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
374 size += (int)sizeof(klassOop)/HeapWordSize; |
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
375 } |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
5967
diff
changeset
|
376 size = instanceKlass::object_size(size); |
0 | 377 |
378 // Allocation | |
379 KlassHandle h_this_klass(THREAD, as_klassOop()); | |
380 KlassHandle k; | |
381 if (rt == REF_NONE) { | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2227
diff
changeset
|
382 if (name != vmSymbols::java_lang_Class()) { |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2227
diff
changeset
|
383 // regular klass |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2227
diff
changeset
|
384 instanceKlass o; |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2227
diff
changeset
|
385 k = base_create_klass(h_this_klass, size, o.vtbl_value(), CHECK_NULL); |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2227
diff
changeset
|
386 } else { |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2227
diff
changeset
|
387 // Class |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2227
diff
changeset
|
388 instanceMirrorKlass o; |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2227
diff
changeset
|
389 k = base_create_klass(h_this_klass, size, o.vtbl_value(), CHECK_NULL); |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2227
diff
changeset
|
390 } |
0 | 391 } else { |
392 // reference klass | |
393 instanceRefKlass o; | |
394 k = base_create_klass(h_this_klass, size, o.vtbl_value(), CHECK_NULL); | |
395 } | |
396 { | |
397 No_Safepoint_Verifier no_safepoint; // until k becomes parsable | |
398 instanceKlass* ik = (instanceKlass*) k()->klass_part(); | |
399 assert(!k()->is_parsable(), "not expecting parsability yet."); | |
400 | |
401 // The sizes of these these three variables are used for determining the | |
402 // size of the instanceKlassOop. It is critical that these are set to the right | |
403 // sizes before the first GC, i.e., when we allocate the mirror. | |
404 ik->set_vtable_length(vtable_len); | |
405 ik->set_itable_length(itable_len); | |
406 ik->set_static_field_size(static_field_size); | |
407 ik->set_nonstatic_oop_map_size(nonstatic_oop_map_size); | |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
5967
diff
changeset
|
408 ik->set_access_flags(access_flags); |
6038
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
409 ik->set_is_anonymous(!host_klass.is_null()); |
0 | 410 assert(k()->size() == size, "wrong size for object"); |
411 | |
412 ik->set_array_klasses(NULL); | |
413 ik->set_methods(NULL); | |
414 ik->set_method_ordering(NULL); | |
415 ik->set_local_interfaces(NULL); | |
416 ik->set_transitive_interfaces(NULL); | |
417 ik->init_implementor(); | |
3938 | 418 ik->set_fields(NULL, 0); |
0 | 419 ik->set_constants(NULL); |
420 ik->set_class_loader(NULL); | |
421 ik->set_protection_domain(NULL); | |
422 ik->set_signers(NULL); | |
423 ik->set_source_file_name(NULL); | |
424 ik->set_source_debug_extension(NULL); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
425 ik->set_source_debug_extension(NULL); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
426 ik->set_array_name(NULL); |
0 | 427 ik->set_inner_classes(NULL); |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2227
diff
changeset
|
428 ik->set_static_oop_field_count(0); |
0 | 429 ik->set_nonstatic_field_size(0); |
4772
8f8b94305aff
7129240: backout fix for 7102776 until 7128770 is resolved
dcubed
parents:
4737
diff
changeset
|
430 ik->set_is_marked_dependent(false); |
0 | 431 ik->set_init_state(instanceKlass::allocated); |
432 ik->set_init_thread(NULL); | |
433 ik->set_reference_type(rt); | |
434 ik->set_oop_map_cache(NULL); | |
435 ik->set_jni_ids(NULL); | |
436 ik->set_osr_nmethods_head(NULL); | |
437 ik->set_breakpoints(NULL); | |
438 ik->init_previous_versions(); | |
439 ik->set_generic_signature(NULL); | |
440 ik->release_set_methods_jmethod_ids(NULL); | |
441 ik->release_set_methods_cached_itable_indices(NULL); | |
442 ik->set_class_annotations(NULL); | |
443 ik->set_fields_annotations(NULL); | |
444 ik->set_methods_annotations(NULL); | |
445 ik->set_methods_parameter_annotations(NULL); | |
446 ik->set_methods_default_annotations(NULL); | |
447 ik->set_jvmti_cached_class_field_map(NULL); | |
448 ik->set_initial_method_idnum(0); | |
449 assert(k()->is_parsable(), "should be parsable here."); | |
450 | |
451 // initialize the non-header words to zero | |
452 intptr_t* p = (intptr_t*)k(); | |
453 for (int index = instanceKlass::header_size(); index < size; index++) { | |
454 p[index] = NULL_WORD; | |
455 } | |
456 | |
457 // To get verify to work - must be set to partial loaded before first GC point. | |
458 k()->set_partially_loaded(); | |
459 } | |
460 return k(); | |
461 } | |
462 | |
463 | |
464 | |
465 #ifndef PRODUCT | |
466 | |
467 // Printing | |
468 | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
469 #define BULLET " - " |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
470 |
0 | 471 static const char* state_names[] = { |
472 "unparseable_by_gc", "allocated", "loaded", "linked", "being_initialized", "fully_initialized", "initialization_error" | |
473 }; | |
474 | |
475 | |
476 void instanceKlassKlass::oop_print_on(oop obj, outputStream* st) { | |
477 assert(obj->is_klass(), "must be klass"); | |
478 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
479 klassKlass::oop_print_on(obj, st); | |
480 | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
481 st->print(BULLET"instance size: %d", ik->size_helper()); st->cr(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
482 st->print(BULLET"klass size: %d", ik->object_size()); st->cr(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
483 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
|
484 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
|
485 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
|
486 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
|
487 st->print(BULLET"sub: "); |
0 | 488 Klass* sub = ik->subklass(); |
489 int n; | |
490 for (n = 0; sub != NULL; n++, sub = sub->next_sibling()) { | |
491 if (n < MaxSubklassPrintSize) { | |
492 sub->as_klassOop()->print_value_on(st); | |
493 st->print(" "); | |
494 } | |
495 } | |
496 if (n >= MaxSubklassPrintSize) st->print("(%d more klasses...)", n - MaxSubklassPrintSize); | |
497 st->cr(); | |
498 | |
499 if (ik->is_interface()) { | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
500 st->print_cr(BULLET"nof implementors: %d", ik->nof_implementors()); |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
5967
diff
changeset
|
501 if (ik->nof_implementors() == 1) { |
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
5967
diff
changeset
|
502 st->print_cr(BULLET"implementor: "); |
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
5967
diff
changeset
|
503 st->print(" "); |
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
5967
diff
changeset
|
504 ik->implementor()->print_value_on(st); |
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
5967
diff
changeset
|
505 st->cr(); |
0 | 506 } |
507 } | |
508 | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
509 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
|
510 st->print(BULLET"methods: "); ik->methods()->print_value_on(st); st->cr(); |
0 | 511 if (Verbose) { |
512 objArrayOop methods = ik->methods(); | |
513 for(int i = 0; i < methods->length(); i++) { | |
514 tty->print("%d : ", i); methods->obj_at(i)->print_value(); tty->cr(); | |
515 } | |
516 } | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
517 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
|
518 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
|
519 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
|
520 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
|
521 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
|
522 st->print(BULLET"protection domain: "); ik->protection_domain()->print_value_on(st); st->cr(); |
6038
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
523 if (ik->host_klass() != NULL) { |
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
524 st->print(BULLET"host class: "); ik->host_klass()->print_value_on(st); st->cr(); |
8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
jiangli
parents:
5998
diff
changeset
|
525 } |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
526 st->print(BULLET"signers: "); ik->signers()->print_value_on(st); st->cr(); |
0 | 527 if (ik->source_file_name() != NULL) { |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
528 st->print(BULLET"source file: "); |
0 | 529 ik->source_file_name()->print_value_on(st); |
530 st->cr(); | |
531 } | |
532 if (ik->source_debug_extension() != NULL) { | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
533 st->print(BULLET"source debug extension: "); |
0 | 534 ik->source_debug_extension()->print_value_on(st); |
535 st->cr(); | |
536 } | |
537 | |
538 { | |
539 ResourceMark rm; | |
540 // PreviousVersionInfo objects returned via PreviousVersionWalker | |
541 // contain a GrowableArray of handles. We have to clean up the | |
542 // GrowableArray _after_ the PreviousVersionWalker destructor | |
543 // has destroyed the handles. | |
544 { | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
545 bool have_pv = false; |
0 | 546 PreviousVersionWalker pvw(ik); |
547 for (PreviousVersionInfo * pv_info = pvw.next_previous_version(); | |
548 pv_info != NULL; pv_info = pvw.next_previous_version()) { | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
549 if (!have_pv) |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
550 st->print(BULLET"previous version: "); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
551 have_pv = true; |
0 | 552 pv_info->prev_constant_pool_handle()()->print_value_on(st); |
553 } | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
554 if (have_pv) st->cr(); |
0 | 555 } // pvw is cleaned up |
556 } // rm is cleaned up | |
557 | |
558 if (ik->generic_signature() != NULL) { | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
559 st->print(BULLET"generic signature: "); |
0 | 560 ik->generic_signature()->print_value_on(st); |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
561 st->cr(); |
0 | 562 } |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
563 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
|
564 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
|
565 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
|
566 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
|
567 st->print_cr(BULLET"---- static fields (%d words):", ik->static_field_size()); |
0 | 568 FieldPrinter print_static_field(st); |
569 ik->do_local_static_fields(&print_static_field); | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
570 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
|
571 FieldPrinter print_nonstatic_field(st); |
0 | 572 ik->do_nonstatic_fields(&print_nonstatic_field); |
573 | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
431
diff
changeset
|
574 st->print(BULLET"non-static oop maps: "); |
0 | 575 OopMapBlock* map = ik->start_of_nonstatic_oop_maps(); |
938 | 576 OopMapBlock* end_map = map + ik->nonstatic_oop_map_count(); |
0 | 577 while (map < end_map) { |
938 | 578 st->print("%d-%d ", map->offset(), map->offset() + heapOopSize*(map->count() - 1)); |
0 | 579 map++; |
580 } | |
581 st->cr(); | |
582 } | |
583 | |
1155
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1059
diff
changeset
|
584 #endif //PRODUCT |
0 | 585 |
586 void instanceKlassKlass::oop_print_value_on(oop obj, outputStream* st) { | |
587 assert(obj->is_klass(), "must be klass"); | |
588 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
589 ik->name()->print_value_on(st); | |
590 } | |
591 | |
592 const char* instanceKlassKlass::internal_name() const { | |
593 return "{instance class}"; | |
594 } | |
595 | |
596 // Verification | |
597 | |
598 class VerifyFieldClosure: public OopClosure { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
599 protected: |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
600 template <class T> void do_oop_work(T* p) { |
0 | 601 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
|
602 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
|
603 guarantee(obj->is_oop_or_null(), "should be in heap"); |
0 | 604 } |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
605 public: |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
606 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
|
607 virtual void do_oop(narrowOop* p) { VerifyFieldClosure::do_oop_work(p); } |
0 | 608 }; |
609 | |
610 void instanceKlassKlass::oop_verify_on(oop obj, outputStream* st) { | |
611 klassKlass::oop_verify_on(obj, st); | |
612 if (!obj->partially_loaded()) { | |
613 Thread *thread = Thread::current(); | |
614 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
615 | |
616 #ifndef PRODUCT | |
617 // Avoid redundant verifies | |
618 if (ik->_verify_count == Universe::verify_count()) return; | |
619 ik->_verify_count = Universe::verify_count(); | |
620 #endif | |
621 // 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
|
622 if (ik->is_loaded() && !ik->is_anonymous()) { |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
623 Symbol* h_name = ik->name(); |
0 | 624 Handle h_loader (thread, ik->class_loader()); |
625 Handle h_obj(thread, obj); | |
626 SystemDictionary::verify_obj_klass_present(h_obj, h_name, h_loader); | |
627 } | |
628 | |
629 // Verify static fields | |
630 VerifyFieldClosure blk; | |
631 | |
632 // Verify vtables | |
633 if (ik->is_linked()) { | |
634 ResourceMark rm(thread); | |
635 // $$$ This used to be done only for m/s collections. Doing it | |
636 // always seemed a valid generalization. (DLD -- 6/00) | |
637 ik->vtable()->verify(st); | |
638 } | |
639 | |
640 // Verify oop map cache | |
641 if (ik->oop_map_cache() != NULL) { | |
642 ik->oop_map_cache()->verify(); | |
643 } | |
644 | |
645 // Verify first subklass | |
646 if (ik->subklass_oop() != NULL) { | |
647 guarantee(ik->subklass_oop()->is_perm(), "should be in permspace"); | |
648 guarantee(ik->subklass_oop()->is_klass(), "should be klass"); | |
649 } | |
650 | |
651 // Verify siblings | |
652 klassOop super = ik->super(); | |
653 Klass* sib = ik->next_sibling(); | |
654 int sib_count = 0; | |
655 while (sib != NULL) { | |
656 if (sib == ik) { | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1155
diff
changeset
|
657 fatal(err_msg("subclass cycle of length %d", sib_count)); |
0 | 658 } |
659 if (sib_count >= 100000) { | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1155
diff
changeset
|
660 fatal(err_msg("suspiciously long subclass list %d", sib_count)); |
0 | 661 } |
662 guarantee(sib->as_klassOop()->is_klass(), "should be klass"); | |
663 guarantee(sib->as_klassOop()->is_perm(), "should be in permspace"); | |
664 guarantee(sib->super() == super, "siblings should have same superklass"); | |
665 sib = sib->next_sibling(); | |
666 } | |
667 | |
668 // Verify implementor fields | |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
5967
diff
changeset
|
669 klassOop im = ik->implementor(); |
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
5967
diff
changeset
|
670 if (im != NULL) { |
0 | 671 guarantee(ik->is_interface(), "only interfaces should have implementor set"); |
672 guarantee(im->is_perm(), "should be in permspace"); | |
673 guarantee(im->is_klass(), "should be klass"); | |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
5967
diff
changeset
|
674 guarantee(!Klass::cast(klassOop(im))->is_interface() || im == ik->as_klassOop(), "implementors cannot be interfaces"); |
0 | 675 } |
676 | |
677 // Verify local interfaces | |
678 objArrayOop local_interfaces = ik->local_interfaces(); | |
679 guarantee(local_interfaces->is_perm(), "should be in permspace"); | |
680 guarantee(local_interfaces->is_objArray(), "should be obj array"); | |
681 int j; | |
682 for (j = 0; j < local_interfaces->length(); j++) { | |
683 oop e = local_interfaces->obj_at(j); | |
684 guarantee(e->is_klass() && Klass::cast(klassOop(e))->is_interface(), "invalid local interface"); | |
685 } | |
686 | |
687 // Verify transitive interfaces | |
688 objArrayOop transitive_interfaces = ik->transitive_interfaces(); | |
689 guarantee(transitive_interfaces->is_perm(), "should be in permspace"); | |
690 guarantee(transitive_interfaces->is_objArray(), "should be obj array"); | |
691 for (j = 0; j < transitive_interfaces->length(); j++) { | |
692 oop e = transitive_interfaces->obj_at(j); | |
693 guarantee(e->is_klass() && Klass::cast(klassOop(e))->is_interface(), "invalid transitive interface"); | |
694 } | |
695 | |
696 // Verify methods | |
697 objArrayOop methods = ik->methods(); | |
698 guarantee(methods->is_perm(), "should be in permspace"); | |
699 guarantee(methods->is_objArray(), "should be obj array"); | |
700 for (j = 0; j < methods->length(); j++) { | |
701 guarantee(methods->obj_at(j)->is_method(), "non-method in methods array"); | |
702 } | |
703 for (j = 0; j < methods->length() - 1; j++) { | |
704 methodOop m1 = methodOop(methods->obj_at(j)); | |
705 methodOop m2 = methodOop(methods->obj_at(j + 1)); | |
706 guarantee(m1->name()->fast_compare(m2->name()) <= 0, "methods not sorted correctly"); | |
707 } | |
708 | |
709 // Verify method ordering | |
710 typeArrayOop method_ordering = ik->method_ordering(); | |
711 guarantee(method_ordering->is_perm(), "should be in permspace"); | |
712 guarantee(method_ordering->is_typeArray(), "should be type array"); | |
713 int length = method_ordering->length(); | |
3245
8ce625481709
7032407: Crash in LinkResolver::runtime_resolve_virtual_method()
coleenp
parents:
2460
diff
changeset
|
714 if (JvmtiExport::can_maintain_original_method_order() || |
8ce625481709
7032407: Crash in LinkResolver::runtime_resolve_virtual_method()
coleenp
parents:
2460
diff
changeset
|
715 (UseSharedSpaces && length != 0)) { |
0 | 716 guarantee(length == methods->length(), "invalid method ordering length"); |
717 jlong sum = 0; | |
718 for (j = 0; j < length; j++) { | |
719 int original_index = method_ordering->int_at(j); | |
720 guarantee(original_index >= 0 && original_index < length, "invalid method ordering index"); | |
721 sum += original_index; | |
722 } | |
723 // Verify sum of indices 0,1,...,length-1 | |
724 guarantee(sum == ((jlong)length*(length-1))/2, "invalid method ordering sum"); | |
725 } else { | |
726 guarantee(length == 0, "invalid method ordering length"); | |
727 } | |
728 | |
729 // Verify JNI static field identifiers | |
730 if (ik->jni_ids() != NULL) { | |
731 ik->jni_ids()->verify(ik->as_klassOop()); | |
732 } | |
733 | |
734 // Verify other fields | |
735 if (ik->array_klasses() != NULL) { | |
736 guarantee(ik->array_klasses()->is_perm(), "should be in permspace"); | |
737 guarantee(ik->array_klasses()->is_klass(), "should be klass"); | |
738 } | |
739 guarantee(ik->fields()->is_perm(), "should be in permspace"); | |
740 guarantee(ik->fields()->is_typeArray(), "should be type array"); | |
741 guarantee(ik->constants()->is_perm(), "should be in permspace"); | |
742 guarantee(ik->constants()->is_constantPool(), "should be constant pool"); | |
743 guarantee(ik->inner_classes()->is_perm(), "should be in permspace"); | |
744 guarantee(ik->inner_classes()->is_typeArray(), "should be type array"); | |
745 if (ik->protection_domain() != NULL) { | |
746 guarantee(ik->protection_domain()->is_oop(), "should be oop"); | |
747 } | |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
748 if (ik->host_klass() != NULL) { |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
749 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
|
750 } |
0 | 751 if (ik->signers() != NULL) { |
752 guarantee(ik->signers()->is_objArray(), "should be obj array"); | |
753 } | |
754 if (ik->class_annotations() != NULL) { | |
755 guarantee(ik->class_annotations()->is_typeArray(), "should be type array"); | |
756 } | |
757 if (ik->fields_annotations() != NULL) { | |
758 guarantee(ik->fields_annotations()->is_objArray(), "should be obj array"); | |
759 } | |
760 if (ik->methods_annotations() != NULL) { | |
761 guarantee(ik->methods_annotations()->is_objArray(), "should be obj array"); | |
762 } | |
763 if (ik->methods_parameter_annotations() != NULL) { | |
764 guarantee(ik->methods_parameter_annotations()->is_objArray(), "should be obj array"); | |
765 } | |
766 if (ik->methods_default_annotations() != NULL) { | |
767 guarantee(ik->methods_default_annotations()->is_objArray(), "should be obj array"); | |
768 } | |
769 } | |
770 } | |
771 | |
772 | |
773 bool instanceKlassKlass::oop_partially_loaded(oop obj) const { | |
774 assert(obj->is_klass(), "object must be klass"); | |
775 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
776 assert(ik->oop_is_instance(), "object must be instanceKlass"); | |
777 return ik->transitive_interfaces() == (objArrayOop) obj; // Check whether transitive_interfaces points to self | |
778 } | |
779 | |
780 | |
781 // The transitive_interfaces is the last field set when loading an object. | |
782 void instanceKlassKlass::oop_set_partially_loaded(oop obj) { | |
783 assert(obj->is_klass(), "object must be klass"); | |
784 instanceKlass* ik = instanceKlass::cast(klassOop(obj)); | |
785 // Set the layout helper to a place-holder value, until fuller initialization. | |
786 // (This allows asserts in oop_is_instance to succeed.) | |
787 ik->set_layout_helper(Klass::instance_layout_helper(0, true)); | |
788 assert(ik->oop_is_instance(), "object must be instanceKlass"); | |
789 assert(ik->transitive_interfaces() == NULL, "just checking"); | |
790 ik->set_transitive_interfaces((objArrayOop) obj); // Temporarily set transitive_interfaces to point to self | |
791 } |