annotate src/share/vm/oops/instanceKlassKlass.cpp @ 431:a45484ea312d

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