Mercurial > hg > graal-jvmci-8
comparison src/share/vm/oops/instanceKlass.cpp @ 8712:3efdfd6ddbf2
8003553: NPG: metaspace objects should be zeroed in constructors
Summary: Zero metadata in constructors, not in allocation (and some in constructors)
Reviewed-by: jmasa, sspitsyn
author | coleenp |
---|---|
date | Fri, 08 Mar 2013 11:47:57 -0500 |
parents | 927a311d00f9 |
children | 35ef86296a5d |
comparison
equal
deleted
inserted
replaced
8711:6b803ba47588 | 8712:3efdfd6ddbf2 |
---|---|
218 ReferenceType rt, | 218 ReferenceType rt, |
219 AccessFlags access_flags, | 219 AccessFlags access_flags, |
220 bool is_anonymous) { | 220 bool is_anonymous) { |
221 No_Safepoint_Verifier no_safepoint; // until k becomes parsable | 221 No_Safepoint_Verifier no_safepoint; // until k becomes parsable |
222 | 222 |
223 int size = InstanceKlass::size(vtable_len, itable_len, nonstatic_oop_map_size, | 223 int iksize = InstanceKlass::size(vtable_len, itable_len, nonstatic_oop_map_size, |
224 access_flags.is_interface(), is_anonymous); | 224 access_flags.is_interface(), is_anonymous); |
225 | 225 |
226 // The sizes of these these three variables are used for determining the | 226 // The sizes of these these three variables are used for determining the |
227 // size of the instanceKlassOop. It is critical that these are set to the right | 227 // size of the instanceKlassOop. It is critical that these are set to the right |
228 // sizes before the first GC, i.e., when we allocate the mirror. | 228 // sizes before the first GC, i.e., when we allocate the mirror. |
229 this->set_vtable_length(vtable_len); | 229 set_vtable_length(vtable_len); |
230 this->set_itable_length(itable_len); | 230 set_itable_length(itable_len); |
231 this->set_static_field_size(static_field_size); | 231 set_static_field_size(static_field_size); |
232 this->set_nonstatic_oop_map_size(nonstatic_oop_map_size); | 232 set_nonstatic_oop_map_size(nonstatic_oop_map_size); |
233 this->set_access_flags(access_flags); | 233 set_access_flags(access_flags); |
234 this->set_is_anonymous(is_anonymous); | 234 _misc_flags = 0; // initialize to zero |
235 assert(this->size() == size, "wrong size for object"); | 235 set_is_anonymous(is_anonymous); |
236 | 236 assert(size() == iksize, "wrong size for object"); |
237 this->set_array_klasses(NULL); | 237 |
238 this->set_methods(NULL); | 238 set_array_klasses(NULL); |
239 this->set_method_ordering(NULL); | 239 set_methods(NULL); |
240 this->set_local_interfaces(NULL); | 240 set_method_ordering(NULL); |
241 this->set_transitive_interfaces(NULL); | 241 set_local_interfaces(NULL); |
242 this->init_implementor(); | 242 set_transitive_interfaces(NULL); |
243 this->set_fields(NULL, 0); | 243 init_implementor(); |
244 this->set_constants(NULL); | 244 set_fields(NULL, 0); |
245 this->set_class_loader_data(NULL); | 245 set_constants(NULL); |
246 this->set_protection_domain(NULL); | 246 set_class_loader_data(NULL); |
247 this->set_signers(NULL); | 247 set_protection_domain(NULL); |
248 this->set_source_file_name(NULL); | 248 set_signers(NULL); |
249 this->set_source_debug_extension(NULL, 0); | 249 set_source_file_name(NULL); |
250 this->set_array_name(NULL); | 250 set_source_debug_extension(NULL, 0); |
251 this->set_inner_classes(NULL); | 251 set_array_name(NULL); |
252 this->set_static_oop_field_count(0); | 252 set_inner_classes(NULL); |
253 this->set_nonstatic_field_size(0); | 253 set_static_oop_field_count(0); |
254 this->set_is_marked_dependent(false); | 254 set_nonstatic_field_size(0); |
255 this->set_init_state(InstanceKlass::allocated); | 255 set_is_marked_dependent(false); |
256 this->set_init_thread(NULL); | 256 set_init_state(InstanceKlass::allocated); |
257 this->set_init_lock(NULL); | 257 set_init_thread(NULL); |
258 this->set_reference_type(rt); | 258 set_init_lock(NULL); |
259 this->set_oop_map_cache(NULL); | 259 set_reference_type(rt); |
260 this->set_jni_ids(NULL); | 260 set_oop_map_cache(NULL); |
261 this->set_osr_nmethods_head(NULL); | 261 set_jni_ids(NULL); |
262 this->set_breakpoints(NULL); | 262 set_osr_nmethods_head(NULL); |
263 this->init_previous_versions(); | 263 set_breakpoints(NULL); |
264 this->set_generic_signature(NULL); | 264 init_previous_versions(); |
265 this->release_set_methods_jmethod_ids(NULL); | 265 set_generic_signature(NULL); |
266 this->release_set_methods_cached_itable_indices(NULL); | 266 release_set_methods_jmethod_ids(NULL); |
267 this->set_annotations(NULL); | 267 release_set_methods_cached_itable_indices(NULL); |
268 this->set_jvmti_cached_class_field_map(NULL); | 268 set_annotations(NULL); |
269 this->set_initial_method_idnum(0); | 269 set_jvmti_cached_class_field_map(NULL); |
270 set_initial_method_idnum(0); | |
271 _dependencies = NULL; | |
272 set_jvmti_cached_class_field_map(NULL); | |
273 set_cached_class_file(NULL, 0); | |
274 set_initial_method_idnum(0); | |
275 set_minor_version(0); | |
276 set_major_version(0); | |
277 NOT_PRODUCT(_verify_count = 0;) | |
270 | 278 |
271 // initialize the non-header words to zero | 279 // initialize the non-header words to zero |
272 intptr_t* p = (intptr_t*)this; | 280 intptr_t* p = (intptr_t*)this; |
273 for (int index = InstanceKlass::header_size(); index < size; index++) { | 281 for (int index = InstanceKlass::header_size(); index < iksize; index++) { |
274 p[index] = NULL_WORD; | 282 p[index] = NULL_WORD; |
275 } | 283 } |
276 | 284 |
277 // Set temporary value until parseClassFile updates it with the real instance | 285 // Set temporary value until parseClassFile updates it with the real instance |
278 // size. | 286 // size. |
279 this->set_layout_helper(Klass::instance_layout_helper(0, true)); | 287 set_layout_helper(Klass::instance_layout_helper(0, true)); |
280 } | 288 } |
281 | 289 |
282 | 290 |
283 // This function deallocates the metadata and C heap pointers that the | 291 // This function deallocates the metadata and C heap pointers that the |
284 // InstanceKlass points to. | 292 // InstanceKlass points to. |
2779 st->cr(); | 2787 st->cr(); |
2780 } | 2788 } |
2781 st->print(BULLET"protection domain: "); ((InstanceKlass*)this)->protection_domain()->print_value_on(st); st->cr(); | 2789 st->print(BULLET"protection domain: "); ((InstanceKlass*)this)->protection_domain()->print_value_on(st); st->cr(); |
2782 st->print(BULLET"host class: "); host_klass()->print_value_on_maybe_null(st); st->cr(); | 2790 st->print(BULLET"host class: "); host_klass()->print_value_on_maybe_null(st); st->cr(); |
2783 st->print(BULLET"signers: "); signers()->print_value_on(st); st->cr(); | 2791 st->print(BULLET"signers: "); signers()->print_value_on(st); st->cr(); |
2784 st->print(BULLET"init_lock: "); ((oop)init_lock())->print_value_on(st); st->cr(); | 2792 st->print(BULLET"init_lock: "); ((oop)_init_lock)->print_value_on(st); st->cr(); |
2785 if (source_file_name() != NULL) { | 2793 if (source_file_name() != NULL) { |
2786 st->print(BULLET"source file: "); | 2794 st->print(BULLET"source file: "); |
2787 source_file_name()->print_value_on(st); | 2795 source_file_name()->print_value_on(st); |
2788 st->cr(); | 2796 st->cr(); |
2789 } | 2797 } |