author | stefank |
Tue, 08 Feb 2011 12:33:19 +0100 | |
changeset 8297 | f05d10c1c4b8 |
parent 8076 | 96d498ec7ae1 |
child 8725 | 8c1e3dd5fe1b |
permissions | -rw-r--r-- |
1 | 1 |
/* |
8297 | 2 |
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5403
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5403
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5403
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 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" |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
40 |
#include "oops/symbol.hpp" |
7397 | 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 |
|
1 | 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()); |
|
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
106 |
MarkSweep::mark_and_push(ik->adr_host_klass()); |
1 | 107 |
MarkSweep::mark_and_push(ik->adr_signers()); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2332
diff
changeset
|
108 |
MarkSweep::mark_and_push(ik->adr_bootstrap_method()); |
1 | 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()); |
|
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
144 |
PSParallelCompact::mark_and_push(cm, ik->adr_host_klass()); |
1 | 145 |
PSParallelCompact::mark_and_push(cm, ik->adr_signers()); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2332
diff
changeset
|
146 |
PSParallelCompact::mark_and_push(cm, ik->adr_bootstrap_method()); |
1 | 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()); |
|
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
184 |
blk->do_oop(ik->adr_host_klass()); |
1 | 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 |
} |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2332
diff
changeset
|
190 |
blk->do_oop(ik->adr_bootstrap_method()); |
1 | 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); |
|
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
235 |
adr = ik->adr_host_klass(); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
236 |
if (mr.contains(adr)) blk->do_oop(adr); |
1 | 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 |
} |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2332
diff
changeset
|
245 |
adr = ik->adr_bootstrap_method(); |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2332
diff
changeset
|
246 |
if (mr.contains(adr)) blk->do_oop(adr); |
1 | 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()); |
|
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
282 |
MarkSweep::adjust_pointer(ik->adr_host_klass()); |
1 | 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 |
} |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2332
diff
changeset
|
288 |
MarkSweep::adjust_pointer(ik->adr_bootstrap_method()); |
1 | 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(); |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
306 |
if (PSScavenge::should_scavenge(loader_addr)) { |
1 | 307 |
pm->claim_or_forward_depth(loader_addr); |
308 |
} |
|
309 |
||
310 |
oop* pd_addr = ik->adr_protection_domain(); |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
311 |
if (PSScavenge::should_scavenge(pd_addr)) { |
1 | 312 |
pm->claim_or_forward_depth(pd_addr); |
313 |
} |
|
314 |
||
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
315 |
oop* hk_addr = ik->adr_host_klass(); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
316 |
if (PSScavenge::should_scavenge(hk_addr)) { |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
317 |
pm->claim_or_forward_depth(hk_addr); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
318 |
} |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
319 |
|
1 | 320 |
oop* sg_addr = ik->adr_signers(); |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
321 |
if (PSScavenge::should_scavenge(sg_addr)) { |
1 | 322 |
pm->claim_or_forward_depth(sg_addr); |
323 |
} |
|
324 |
||
4429
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
3822
diff
changeset
|
325 |
oop* bsm_addr = ik->adr_bootstrap_method(); |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
3822
diff
changeset
|
326 |
if (PSScavenge::should_scavenge(bsm_addr)) { |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
3822
diff
changeset
|
327 |
pm->claim_or_forward_depth(bsm_addr); |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
3822
diff
changeset
|
328 |
} |
d7eb4e2099aa
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
3822
diff
changeset
|
329 |
|
6248
2e661807cef0
6962589: remove breadth first scanning code from parallel gc
tonyp
parents:
5547
diff
changeset
|
330 |
klassKlass::oop_push_contents(pm, obj); |
1 | 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 |
#endif // SERIALGC |
|
357 |
||
3693 | 358 |
klassOop |
359 |
instanceKlassKlass::allocate_instance_klass(int vtable_len, int itable_len, |
|
360 |
int static_field_size, |
|
3694
942b7bc7f28c
6845368: large objects cause a crash or unexpected exception
jcoomes
parents:
3693
diff
changeset
|
361 |
unsigned nonstatic_oop_map_count, |
3693 | 362 |
ReferenceType rt, TRAPS) { |
1 | 363 |
|
3693 | 364 |
const int nonstatic_oop_map_size = |
365 |
instanceKlass::nonstatic_oop_map_size(nonstatic_oop_map_count); |
|
1 | 366 |
int size = instanceKlass::object_size(align_object_offset(vtable_len) + align_object_offset(itable_len) + static_field_size + nonstatic_oop_map_size); |
367 |
||
368 |
// Allocation |
|
369 |
KlassHandle h_this_klass(THREAD, as_klassOop()); |
|
370 |
KlassHandle k; |
|
371 |
if (rt == REF_NONE) { |
|
372 |
// regular klass |
|
373 |
instanceKlass o; |
|
374 |
k = base_create_klass(h_this_klass, size, o.vtbl_value(), CHECK_NULL); |
|
375 |
} else { |
|
376 |
// reference klass |
|
377 |
instanceRefKlass o; |
|
378 |
k = base_create_klass(h_this_klass, size, o.vtbl_value(), CHECK_NULL); |
|
379 |
} |
|
380 |
{ |
|
381 |
No_Safepoint_Verifier no_safepoint; // until k becomes parsable |
|
382 |
instanceKlass* ik = (instanceKlass*) k()->klass_part(); |
|
383 |
assert(!k()->is_parsable(), "not expecting parsability yet."); |
|
384 |
||
385 |
// The sizes of these these three variables are used for determining the |
|
386 |
// size of the instanceKlassOop. It is critical that these are set to the right |
|
387 |
// sizes before the first GC, i.e., when we allocate the mirror. |
|
388 |
ik->set_vtable_length(vtable_len); |
|
389 |
ik->set_itable_length(itable_len); |
|
390 |
ik->set_static_field_size(static_field_size); |
|
391 |
ik->set_nonstatic_oop_map_size(nonstatic_oop_map_size); |
|
392 |
assert(k()->size() == size, "wrong size for object"); |
|
393 |
||
394 |
ik->set_array_klasses(NULL); |
|
395 |
ik->set_methods(NULL); |
|
396 |
ik->set_method_ordering(NULL); |
|
397 |
ik->set_local_interfaces(NULL); |
|
398 |
ik->set_transitive_interfaces(NULL); |
|
399 |
ik->init_implementor(); |
|
400 |
ik->set_fields(NULL); |
|
401 |
ik->set_constants(NULL); |
|
402 |
ik->set_class_loader(NULL); |
|
403 |
ik->set_protection_domain(NULL); |
|
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
404 |
ik->set_host_klass(NULL); |
1 | 405 |
ik->set_signers(NULL); |
406 |
ik->set_source_file_name(NULL); |
|
407 |
ik->set_source_debug_extension(NULL); |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
408 |
ik->set_source_debug_extension(NULL); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
409 |
ik->set_array_name(NULL); |
1 | 410 |
ik->set_inner_classes(NULL); |
411 |
ik->set_static_oop_field_size(0); |
|
412 |
ik->set_nonstatic_field_size(0); |
|
3822 | 413 |
ik->set_is_marked_dependent(false); |
1 | 414 |
ik->set_init_state(instanceKlass::allocated); |
415 |
ik->set_init_thread(NULL); |
|
416 |
ik->set_reference_type(rt); |
|
417 |
ik->set_oop_map_cache(NULL); |
|
418 |
ik->set_jni_ids(NULL); |
|
419 |
ik->set_osr_nmethods_head(NULL); |
|
420 |
ik->set_breakpoints(NULL); |
|
421 |
ik->init_previous_versions(); |
|
422 |
ik->set_generic_signature(NULL); |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2332
diff
changeset
|
423 |
ik->set_bootstrap_method(NULL); |
1 | 424 |
ik->release_set_methods_jmethod_ids(NULL); |
425 |
ik->release_set_methods_cached_itable_indices(NULL); |
|
426 |
ik->set_class_annotations(NULL); |
|
427 |
ik->set_fields_annotations(NULL); |
|
428 |
ik->set_methods_annotations(NULL); |
|
429 |
ik->set_methods_parameter_annotations(NULL); |
|
430 |
ik->set_methods_default_annotations(NULL); |
|
431 |
ik->set_enclosing_method_indices(0, 0); |
|
432 |
ik->set_jvmti_cached_class_field_map(NULL); |
|
433 |
ik->set_initial_method_idnum(0); |
|
434 |
assert(k()->is_parsable(), "should be parsable here."); |
|
435 |
||
436 |
// initialize the non-header words to zero |
|
437 |
intptr_t* p = (intptr_t*)k(); |
|
438 |
for (int index = instanceKlass::header_size(); index < size; index++) { |
|
439 |
p[index] = NULL_WORD; |
|
440 |
} |
|
441 |
||
442 |
// To get verify to work - must be set to partial loaded before first GC point. |
|
443 |
k()->set_partially_loaded(); |
|
444 |
} |
|
445 |
||
446 |
// GC can happen here |
|
447 |
java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror |
|
448 |
return k(); |
|
449 |
} |
|
450 |
||
451 |
||
452 |
||
453 |
#ifndef PRODUCT |
|
454 |
||
455 |
// Printing |
|
456 |
||
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
457 |
#define BULLET " - " |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
458 |
|
1 | 459 |
static const char* state_names[] = { |
460 |
"unparseable_by_gc", "allocated", "loaded", "linked", "being_initialized", "fully_initialized", "initialization_error" |
|
461 |
}; |
|
462 |
||
463 |
||
464 |
void instanceKlassKlass::oop_print_on(oop obj, outputStream* st) { |
|
465 |
assert(obj->is_klass(), "must be klass"); |
|
466 |
instanceKlass* ik = instanceKlass::cast(klassOop(obj)); |
|
467 |
klassKlass::oop_print_on(obj, st); |
|
468 |
||
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
469 |
st->print(BULLET"instance size: %d", ik->size_helper()); st->cr(); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
470 |
st->print(BULLET"klass size: %d", ik->object_size()); st->cr(); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
471 |
st->print(BULLET"access: "); ik->access_flags().print_on(st); st->cr(); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
472 |
st->print(BULLET"state: "); st->print_cr(state_names[ik->_init_state]); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
473 |
st->print(BULLET"name: "); ik->name()->print_value_on(st); st->cr(); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
474 |
st->print(BULLET"super: "); ik->super()->print_value_on(st); st->cr(); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
475 |
st->print(BULLET"sub: "); |
1 | 476 |
Klass* sub = ik->subklass(); |
477 |
int n; |
|
478 |
for (n = 0; sub != NULL; n++, sub = sub->next_sibling()) { |
|
479 |
if (n < MaxSubklassPrintSize) { |
|
480 |
sub->as_klassOop()->print_value_on(st); |
|
481 |
st->print(" "); |
|
482 |
} |
|
483 |
} |
|
484 |
if (n >= MaxSubklassPrintSize) st->print("(%d more klasses...)", n - MaxSubklassPrintSize); |
|
485 |
st->cr(); |
|
486 |
||
487 |
if (ik->is_interface()) { |
|
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
488 |
st->print_cr(BULLET"nof implementors: %d", ik->nof_implementors()); |
1 | 489 |
int print_impl = 0; |
490 |
for (int i = 0; i < instanceKlass::implementors_limit; i++) { |
|
491 |
if (ik->implementor(i) != NULL) { |
|
492 |
if (++print_impl == 1) |
|
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
493 |
st->print_cr(BULLET"implementor: "); |
1 | 494 |
st->print(" "); |
495 |
ik->implementor(i)->print_value_on(st); |
|
496 |
} |
|
497 |
} |
|
498 |
if (print_impl > 0) st->cr(); |
|
499 |
} |
|
500 |
||
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
501 |
st->print(BULLET"arrays: "); ik->array_klasses()->print_value_on(st); st->cr(); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
502 |
st->print(BULLET"methods: "); ik->methods()->print_value_on(st); st->cr(); |
1 | 503 |
if (Verbose) { |
504 |
objArrayOop methods = ik->methods(); |
|
505 |
for(int i = 0; i < methods->length(); i++) { |
|
506 |
tty->print("%d : ", i); methods->obj_at(i)->print_value(); tty->cr(); |
|
507 |
} |
|
508 |
} |
|
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
509 |
st->print(BULLET"method ordering: "); ik->method_ordering()->print_value_on(st); st->cr(); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
510 |
st->print(BULLET"local interfaces: "); ik->local_interfaces()->print_value_on(st); st->cr(); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
511 |
st->print(BULLET"trans. interfaces: "); ik->transitive_interfaces()->print_value_on(st); st->cr(); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
512 |
st->print(BULLET"constants: "); ik->constants()->print_value_on(st); st->cr(); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
513 |
st->print(BULLET"class loader: "); ik->class_loader()->print_value_on(st); st->cr(); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
514 |
st->print(BULLET"protection domain: "); ik->protection_domain()->print_value_on(st); st->cr(); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
515 |
st->print(BULLET"host class: "); ik->host_klass()->print_value_on(st); st->cr(); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
516 |
st->print(BULLET"signers: "); ik->signers()->print_value_on(st); st->cr(); |
1 | 517 |
if (ik->source_file_name() != NULL) { |
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
518 |
st->print(BULLET"source file: "); |
1 | 519 |
ik->source_file_name()->print_value_on(st); |
520 |
st->cr(); |
|
521 |
} |
|
522 |
if (ik->source_debug_extension() != NULL) { |
|
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
523 |
st->print(BULLET"source debug extension: "); |
1 | 524 |
ik->source_debug_extension()->print_value_on(st); |
525 |
st->cr(); |
|
526 |
} |
|
527 |
||
528 |
{ |
|
529 |
ResourceMark rm; |
|
530 |
// PreviousVersionInfo objects returned via PreviousVersionWalker |
|
531 |
// contain a GrowableArray of handles. We have to clean up the |
|
532 |
// GrowableArray _after_ the PreviousVersionWalker destructor |
|
533 |
// has destroyed the handles. |
|
534 |
{ |
|
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
535 |
bool have_pv = false; |
1 | 536 |
PreviousVersionWalker pvw(ik); |
537 |
for (PreviousVersionInfo * pv_info = pvw.next_previous_version(); |
|
538 |
pv_info != NULL; pv_info = pvw.next_previous_version()) { |
|
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
539 |
if (!have_pv) |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
540 |
st->print(BULLET"previous version: "); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
541 |
have_pv = true; |
1 | 542 |
pv_info->prev_constant_pool_handle()()->print_value_on(st); |
543 |
} |
|
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
544 |
if (have_pv) st->cr(); |
1 | 545 |
} // pvw is cleaned up |
546 |
} // rm is cleaned up |
|
547 |
||
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2332
diff
changeset
|
548 |
if (ik->bootstrap_method() != NULL) { |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2332
diff
changeset
|
549 |
st->print(BULLET"bootstrap method: "); |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2332
diff
changeset
|
550 |
ik->bootstrap_method()->print_value_on(st); |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2332
diff
changeset
|
551 |
st->cr(); |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2332
diff
changeset
|
552 |
} |
1 | 553 |
if (ik->generic_signature() != NULL) { |
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
554 |
st->print(BULLET"generic signature: "); |
1 | 555 |
ik->generic_signature()->print_value_on(st); |
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
556 |
st->cr(); |
1 | 557 |
} |
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
558 |
st->print(BULLET"inner classes: "); ik->inner_classes()->print_value_on(st); st->cr(); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
559 |
st->print(BULLET"java mirror: "); ik->java_mirror()->print_value_on(st); st->cr(); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
560 |
st->print(BULLET"vtable length %d (start addr: " INTPTR_FORMAT ")", ik->vtable_length(), ik->start_of_vtable()); st->cr(); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
561 |
st->print(BULLET"itable length %d (start addr: " INTPTR_FORMAT ")", ik->itable_length(), ik->start_of_itable()); st->cr(); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
562 |
st->print_cr(BULLET"---- static fields (%d words):", ik->static_field_size()); |
1 | 563 |
FieldPrinter print_static_field(st); |
564 |
ik->do_local_static_fields(&print_static_field); |
|
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
565 |
st->print_cr(BULLET"---- non-static fields (%d words):", ik->nonstatic_field_size()); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
566 |
FieldPrinter print_nonstatic_field(st); |
1 | 567 |
ik->do_nonstatic_fields(&print_nonstatic_field); |
568 |
||
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
569 |
st->print(BULLET"static oop maps: "); |
1 | 570 |
if (ik->static_oop_field_size() > 0) { |
571 |
int first_offset = ik->offset_of_static_fields(); |
|
572 |
st->print("%d-%d", first_offset, first_offset + ik->static_oop_field_size() - 1); |
|
573 |
} |
|
574 |
st->cr(); |
|
575 |
||
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1550
diff
changeset
|
576 |
st->print(BULLET"non-static oop maps: "); |
1 | 577 |
OopMapBlock* map = ik->start_of_nonstatic_oop_maps(); |
3693 | 578 |
OopMapBlock* end_map = map + ik->nonstatic_oop_map_count(); |
1 | 579 |
while (map < end_map) { |
3693 | 580 |
st->print("%d-%d ", map->offset(), map->offset() + heapOopSize*(map->count() - 1)); |
1 | 581 |
map++; |
582 |
} |
|
583 |
st->cr(); |
|
584 |
} |
|
585 |
||
4584
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
4429
diff
changeset
|
586 |
#endif //PRODUCT |
1 | 587 |
|
588 |
void instanceKlassKlass::oop_print_value_on(oop obj, outputStream* st) { |
|
589 |
assert(obj->is_klass(), "must be klass"); |
|
590 |
instanceKlass* ik = instanceKlass::cast(klassOop(obj)); |
|
591 |
ik->name()->print_value_on(st); |
|
592 |
} |
|
593 |
||
594 |
const char* instanceKlassKlass::internal_name() const { |
|
595 |
return "{instance class}"; |
|
596 |
} |
|
597 |
||
598 |
// Verification |
|
599 |
||
600 |
class VerifyFieldClosure: public OopClosure { |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
601 |
protected: |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
602 |
template <class T> void do_oop_work(T* p) { |
1 | 603 |
guarantee(Universe::heap()->is_in(p), "should be in heap"); |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
604 |
oop obj = oopDesc::load_decode_heap_oop(p); |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
605 |
guarantee(obj->is_oop_or_null(), "should be in heap"); |
1 | 606 |
} |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
607 |
public: |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
608 |
virtual void do_oop(oop* p) { VerifyFieldClosure::do_oop_work(p); } |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
609 |
virtual void do_oop(narrowOop* p) { VerifyFieldClosure::do_oop_work(p); } |
1 | 610 |
}; |
611 |
||
612 |
void instanceKlassKlass::oop_verify_on(oop obj, outputStream* st) { |
|
613 |
klassKlass::oop_verify_on(obj, st); |
|
614 |
if (!obj->partially_loaded()) { |
|
615 |
Thread *thread = Thread::current(); |
|
616 |
instanceKlass* ik = instanceKlass::cast(klassOop(obj)); |
|
617 |
||
618 |
#ifndef PRODUCT |
|
619 |
// Avoid redundant verifies |
|
620 |
if (ik->_verify_count == Universe::verify_count()) return; |
|
621 |
ik->_verify_count = Universe::verify_count(); |
|
622 |
#endif |
|
623 |
// Verify that klass is present in SystemDictionary |
|
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
624 |
if (ik->is_loaded() && !ik->is_anonymous()) { |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
625 |
Symbol* h_name = ik->name(); |
1 | 626 |
Handle h_loader (thread, ik->class_loader()); |
627 |
Handle h_obj(thread, obj); |
|
628 |
SystemDictionary::verify_obj_klass_present(h_obj, h_name, h_loader); |
|
629 |
} |
|
630 |
||
631 |
// Verify static fields |
|
632 |
VerifyFieldClosure blk; |
|
633 |
ik->iterate_static_fields(&blk); |
|
634 |
||
635 |
// Verify vtables |
|
636 |
if (ik->is_linked()) { |
|
637 |
ResourceMark rm(thread); |
|
638 |
// $$$ This used to be done only for m/s collections. Doing it |
|
639 |
// always seemed a valid generalization. (DLD -- 6/00) |
|
640 |
ik->vtable()->verify(st); |
|
641 |
} |
|
642 |
||
643 |
// Verify oop map cache |
|
644 |
if (ik->oop_map_cache() != NULL) { |
|
645 |
ik->oop_map_cache()->verify(); |
|
646 |
} |
|
647 |
||
648 |
// Verify first subklass |
|
649 |
if (ik->subklass_oop() != NULL) { |
|
650 |
guarantee(ik->subklass_oop()->is_perm(), "should be in permspace"); |
|
651 |
guarantee(ik->subklass_oop()->is_klass(), "should be klass"); |
|
652 |
} |
|
653 |
||
654 |
// Verify siblings |
|
655 |
klassOop super = ik->super(); |
|
656 |
Klass* sib = ik->next_sibling(); |
|
657 |
int sib_count = 0; |
|
658 |
while (sib != NULL) { |
|
659 |
if (sib == ik) { |
|
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
4584
diff
changeset
|
660 |
fatal(err_msg("subclass cycle of length %d", sib_count)); |
1 | 661 |
} |
662 |
if (sib_count >= 100000) { |
|
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
4584
diff
changeset
|
663 |
fatal(err_msg("suspiciously long subclass list %d", sib_count)); |
1 | 664 |
} |
665 |
guarantee(sib->as_klassOop()->is_klass(), "should be klass"); |
|
666 |
guarantee(sib->as_klassOop()->is_perm(), "should be in permspace"); |
|
667 |
guarantee(sib->super() == super, "siblings should have same superklass"); |
|
668 |
sib = sib->next_sibling(); |
|
669 |
} |
|
670 |
||
671 |
// Verify implementor fields |
|
672 |
bool saw_null_impl = false; |
|
673 |
for (int i = 0; i < instanceKlass::implementors_limit; i++) { |
|
674 |
klassOop im = ik->implementor(i); |
|
675 |
if (im == NULL) { saw_null_impl = true; continue; } |
|
676 |
guarantee(!saw_null_impl, "non-nulls must preceded all nulls"); |
|
677 |
guarantee(ik->is_interface(), "only interfaces should have implementor set"); |
|
678 |
guarantee(i < ik->nof_implementors(), "should only have one implementor"); |
|
679 |
guarantee(im->is_perm(), "should be in permspace"); |
|
680 |
guarantee(im->is_klass(), "should be klass"); |
|
681 |
guarantee(!Klass::cast(klassOop(im))->is_interface(), "implementors cannot be interfaces"); |
|
682 |
} |
|
683 |
||
684 |
// Verify local interfaces |
|
685 |
objArrayOop local_interfaces = ik->local_interfaces(); |
|
686 |
guarantee(local_interfaces->is_perm(), "should be in permspace"); |
|
687 |
guarantee(local_interfaces->is_objArray(), "should be obj array"); |
|
688 |
int j; |
|
689 |
for (j = 0; j < local_interfaces->length(); j++) { |
|
690 |
oop e = local_interfaces->obj_at(j); |
|
691 |
guarantee(e->is_klass() && Klass::cast(klassOop(e))->is_interface(), "invalid local interface"); |
|
692 |
} |
|
693 |
||
694 |
// Verify transitive interfaces |
|
695 |
objArrayOop transitive_interfaces = ik->transitive_interfaces(); |
|
696 |
guarantee(transitive_interfaces->is_perm(), "should be in permspace"); |
|
697 |
guarantee(transitive_interfaces->is_objArray(), "should be obj array"); |
|
698 |
for (j = 0; j < transitive_interfaces->length(); j++) { |
|
699 |
oop e = transitive_interfaces->obj_at(j); |
|
700 |
guarantee(e->is_klass() && Klass::cast(klassOop(e))->is_interface(), "invalid transitive interface"); |
|
701 |
} |
|
702 |
||
703 |
// Verify methods |
|
704 |
objArrayOop methods = ik->methods(); |
|
705 |
guarantee(methods->is_perm(), "should be in permspace"); |
|
706 |
guarantee(methods->is_objArray(), "should be obj array"); |
|
707 |
for (j = 0; j < methods->length(); j++) { |
|
708 |
guarantee(methods->obj_at(j)->is_method(), "non-method in methods array"); |
|
709 |
} |
|
710 |
for (j = 0; j < methods->length() - 1; j++) { |
|
711 |
methodOop m1 = methodOop(methods->obj_at(j)); |
|
712 |
methodOop m2 = methodOop(methods->obj_at(j + 1)); |
|
713 |
guarantee(m1->name()->fast_compare(m2->name()) <= 0, "methods not sorted correctly"); |
|
714 |
} |
|
715 |
||
716 |
// Verify method ordering |
|
717 |
typeArrayOop method_ordering = ik->method_ordering(); |
|
718 |
guarantee(method_ordering->is_perm(), "should be in permspace"); |
|
719 |
guarantee(method_ordering->is_typeArray(), "should be type array"); |
|
720 |
int length = method_ordering->length(); |
|
721 |
if (JvmtiExport::can_maintain_original_method_order()) { |
|
722 |
guarantee(length == methods->length(), "invalid method ordering length"); |
|
723 |
jlong sum = 0; |
|
724 |
for (j = 0; j < length; j++) { |
|
725 |
int original_index = method_ordering->int_at(j); |
|
726 |
guarantee(original_index >= 0 && original_index < length, "invalid method ordering index"); |
|
727 |
sum += original_index; |
|
728 |
} |
|
729 |
// Verify sum of indices 0,1,...,length-1 |
|
730 |
guarantee(sum == ((jlong)length*(length-1))/2, "invalid method ordering sum"); |
|
731 |
} else { |
|
732 |
guarantee(length == 0, "invalid method ordering length"); |
|
733 |
} |
|
734 |
||
735 |
// Verify JNI static field identifiers |
|
736 |
if (ik->jni_ids() != NULL) { |
|
737 |
ik->jni_ids()->verify(ik->as_klassOop()); |
|
738 |
} |
|
739 |
||
740 |
// Verify other fields |
|
741 |
if (ik->array_klasses() != NULL) { |
|
742 |
guarantee(ik->array_klasses()->is_perm(), "should be in permspace"); |
|
743 |
guarantee(ik->array_klasses()->is_klass(), "should be klass"); |
|
744 |
} |
|
745 |
guarantee(ik->fields()->is_perm(), "should be in permspace"); |
|
746 |
guarantee(ik->fields()->is_typeArray(), "should be type array"); |
|
747 |
guarantee(ik->constants()->is_perm(), "should be in permspace"); |
|
748 |
guarantee(ik->constants()->is_constantPool(), "should be constant pool"); |
|
749 |
guarantee(ik->inner_classes()->is_perm(), "should be in permspace"); |
|
750 |
guarantee(ik->inner_classes()->is_typeArray(), "should be type array"); |
|
751 |
if (ik->protection_domain() != NULL) { |
|
752 |
guarantee(ik->protection_domain()->is_oop(), "should be oop"); |
|
753 |
} |
|
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
754 |
if (ik->host_klass() != NULL) { |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
755 |
guarantee(ik->host_klass()->is_oop(), "should be oop"); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
670
diff
changeset
|
756 |
} |
1 | 757 |
if (ik->signers() != NULL) { |
758 |
guarantee(ik->signers()->is_objArray(), "should be obj array"); |
|
759 |
} |
|
760 |
if (ik->class_annotations() != NULL) { |
|
761 |
guarantee(ik->class_annotations()->is_typeArray(), "should be type array"); |
|
762 |
} |
|
763 |
if (ik->fields_annotations() != NULL) { |
|
764 |
guarantee(ik->fields_annotations()->is_objArray(), "should be obj array"); |
|
765 |
} |
|
766 |
if (ik->methods_annotations() != NULL) { |
|
767 |
guarantee(ik->methods_annotations()->is_objArray(), "should be obj array"); |
|
768 |
} |
|
769 |
if (ik->methods_parameter_annotations() != NULL) { |
|
770 |
guarantee(ik->methods_parameter_annotations()->is_objArray(), "should be obj array"); |
|
771 |
} |
|
772 |
if (ik->methods_default_annotations() != NULL) { |
|
773 |
guarantee(ik->methods_default_annotations()->is_objArray(), "should be obj array"); |
|
774 |
} |
|
775 |
} |
|
776 |
} |
|
777 |
||
778 |
||
779 |
bool instanceKlassKlass::oop_partially_loaded(oop obj) const { |
|
780 |
assert(obj->is_klass(), "object must be klass"); |
|
781 |
instanceKlass* ik = instanceKlass::cast(klassOop(obj)); |
|
782 |
assert(ik->oop_is_instance(), "object must be instanceKlass"); |
|
783 |
return ik->transitive_interfaces() == (objArrayOop) obj; // Check whether transitive_interfaces points to self |
|
784 |
} |
|
785 |
||
786 |
||
787 |
// The transitive_interfaces is the last field set when loading an object. |
|
788 |
void instanceKlassKlass::oop_set_partially_loaded(oop obj) { |
|
789 |
assert(obj->is_klass(), "object must be klass"); |
|
790 |
instanceKlass* ik = instanceKlass::cast(klassOop(obj)); |
|
791 |
// Set the layout helper to a place-holder value, until fuller initialization. |
|
792 |
// (This allows asserts in oop_is_instance to succeed.) |
|
793 |
ik->set_layout_helper(Klass::instance_layout_helper(0, true)); |
|
794 |
assert(ik->oop_is_instance(), "object must be instanceKlass"); |
|
795 |
assert(ik->transitive_interfaces() == NULL, "just checking"); |
|
796 |
ik->set_transitive_interfaces((objArrayOop) obj); // Temporarily set transitive_interfaces to point to self |
|
797 |
} |