1.1 --- a/src/share/vm/oops/instanceKlass.cpp Fri Aug 31 16:39:35 2012 -0700 1.2 +++ b/src/share/vm/oops/instanceKlass.cpp Sat Sep 01 13:25:18 2012 -0400 1.3 @@ -34,14 +34,15 @@ 1.4 #include "interpreter/rewriter.hpp" 1.5 #include "jvmtifiles/jvmti.h" 1.6 #include "memory/genOopClosures.inline.hpp" 1.7 +#include "memory/metadataFactory.hpp" 1.8 #include "memory/oopFactory.hpp" 1.9 -#include "memory/permGen.hpp" 1.10 #include "oops/fieldStreams.hpp" 1.11 +#include "oops/instanceClassLoaderKlass.hpp" 1.12 #include "oops/instanceKlass.hpp" 1.13 #include "oops/instanceMirrorKlass.hpp" 1.14 #include "oops/instanceOop.hpp" 1.15 -#include "oops/methodOop.hpp" 1.16 -#include "oops/objArrayKlassKlass.hpp" 1.17 +#include "oops/klass.inline.hpp" 1.18 +#include "oops/method.hpp" 1.19 #include "oops/oop.inline.hpp" 1.20 #include "oops/symbol.hpp" 1.21 #include "prims/jvmtiExport.hpp" 1.22 @@ -65,11 +66,13 @@ 1.23 # include "thread_bsd.inline.hpp" 1.24 #endif 1.25 #ifndef SERIALGC 1.26 +#include "gc_implementation/concurrentMarkSweep/cmsOopClosures.inline.hpp" 1.27 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" 1.28 #include "gc_implementation/g1/g1OopClosures.inline.hpp" 1.29 #include "gc_implementation/g1/g1RemSet.inline.hpp" 1.30 #include "gc_implementation/g1/heapRegionSeq.inline.hpp" 1.31 #include "gc_implementation/parNew/parOopClosures.inline.hpp" 1.32 +#include "gc_implementation/parallelScavenge/parallelScavengeHeap.inline.hpp" 1.33 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp" 1.34 #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp" 1.35 #include "oops/oop.pcgc.inline.hpp" 1.36 @@ -168,19 +171,242 @@ 1.37 1.38 #endif // ndef DTRACE_ENABLED 1.39 1.40 -bool instanceKlass::should_be_initialized() const { 1.41 +Klass* InstanceKlass::allocate_instance_klass(ClassLoaderData* loader_data, 1.42 + int vtable_len, 1.43 + int itable_len, 1.44 + int static_field_size, 1.45 + int nonstatic_oop_map_size, 1.46 + ReferenceType rt, 1.47 + AccessFlags access_flags, 1.48 + Symbol* name, 1.49 + Klass* super_klass, 1.50 + KlassHandle host_klass, 1.51 + TRAPS) { 1.52 + 1.53 + int size = InstanceKlass::size(vtable_len, itable_len, nonstatic_oop_map_size, 1.54 + access_flags.is_interface(), 1.55 + !host_klass.is_null()); 1.56 + 1.57 + // Allocation 1.58 + InstanceKlass* ik; 1.59 + if (rt == REF_NONE) { 1.60 + if (name == vmSymbols::java_lang_Class()) { 1.61 + ik = new (loader_data, size, THREAD) instanceMirrorKlass( 1.62 + vtable_len, itable_len, static_field_size, nonstatic_oop_map_size, rt, 1.63 + access_flags, !host_klass.is_null()); 1.64 + } else if (name == vmSymbols::java_lang_ClassLoader() || 1.65 + (SystemDictionary::ClassLoader_klass_loaded() && 1.66 + super_klass != NULL && 1.67 + super_klass->is_subtype_of(SystemDictionary::ClassLoader_klass()))) { 1.68 + ik = new (loader_data, size, THREAD) instanceClassLoaderKlass( 1.69 + vtable_len, itable_len, static_field_size, nonstatic_oop_map_size, rt, 1.70 + access_flags, !host_klass.is_null()); 1.71 + } else { 1.72 + // normal class 1.73 + ik = new (loader_data, size, THREAD) InstanceKlass( 1.74 + vtable_len, itable_len, static_field_size, nonstatic_oop_map_size, rt, 1.75 + access_flags, !host_klass.is_null()); 1.76 + } 1.77 + } else { 1.78 + // reference klass 1.79 + ik = new (loader_data, size, THREAD) instanceRefKlass( 1.80 + vtable_len, itable_len, static_field_size, nonstatic_oop_map_size, rt, 1.81 + access_flags, !host_klass.is_null()); 1.82 + } 1.83 + 1.84 + return ik; 1.85 +} 1.86 + 1.87 +InstanceKlass::InstanceKlass(int vtable_len, 1.88 + int itable_len, 1.89 + int static_field_size, 1.90 + int nonstatic_oop_map_size, 1.91 + ReferenceType rt, 1.92 + AccessFlags access_flags, 1.93 + bool is_anonymous) { 1.94 + No_Safepoint_Verifier no_safepoint; // until k becomes parsable 1.95 + 1.96 + int size = InstanceKlass::size(vtable_len, itable_len, nonstatic_oop_map_size, 1.97 + access_flags.is_interface(), is_anonymous); 1.98 + 1.99 + // The sizes of these these three variables are used for determining the 1.100 + // size of the instanceKlassOop. It is critical that these are set to the right 1.101 + // sizes before the first GC, i.e., when we allocate the mirror. 1.102 + this->set_vtable_length(vtable_len); 1.103 + this->set_itable_length(itable_len); 1.104 + this->set_static_field_size(static_field_size); 1.105 + this->set_nonstatic_oop_map_size(nonstatic_oop_map_size); 1.106 + this->set_access_flags(access_flags); 1.107 + this->set_is_anonymous(is_anonymous); 1.108 + assert(this->size() == size, "wrong size for object"); 1.109 + 1.110 + this->set_array_klasses(NULL); 1.111 + this->set_methods(NULL); 1.112 + this->set_method_ordering(NULL); 1.113 + this->set_local_interfaces(NULL); 1.114 + this->set_transitive_interfaces(NULL); 1.115 + this->init_implementor(); 1.116 + this->set_fields(NULL, 0); 1.117 + this->set_constants(NULL); 1.118 + this->set_class_loader_data(NULL); 1.119 + this->set_protection_domain(NULL); 1.120 + this->set_signers(NULL); 1.121 + this->set_source_file_name(NULL); 1.122 + this->set_source_debug_extension(NULL, 0); 1.123 + this->set_array_name(NULL); 1.124 + this->set_inner_classes(NULL); 1.125 + this->set_static_oop_field_count(0); 1.126 + this->set_nonstatic_field_size(0); 1.127 + this->set_is_marked_dependent(false); 1.128 + this->set_init_state(InstanceKlass::allocated); 1.129 + this->set_init_thread(NULL); 1.130 + this->set_init_lock(NULL); 1.131 + this->set_reference_type(rt); 1.132 + this->set_oop_map_cache(NULL); 1.133 + this->set_jni_ids(NULL); 1.134 + this->set_osr_nmethods_head(NULL); 1.135 + this->set_breakpoints(NULL); 1.136 + this->init_previous_versions(); 1.137 + this->set_generic_signature(NULL); 1.138 + this->release_set_methods_jmethod_ids(NULL); 1.139 + this->release_set_methods_cached_itable_indices(NULL); 1.140 + this->set_annotations(NULL); 1.141 + this->set_jvmti_cached_class_field_map(NULL); 1.142 + this->set_initial_method_idnum(0); 1.143 + 1.144 + // initialize the non-header words to zero 1.145 + intptr_t* p = (intptr_t*)this; 1.146 + for (int index = InstanceKlass::header_size(); index < size; index++) { 1.147 + p[index] = NULL_WORD; 1.148 + } 1.149 + 1.150 + // Set temporary value until parseClassFile updates it with the real instance 1.151 + // size. 1.152 + this->set_layout_helper(Klass::instance_layout_helper(0, true)); 1.153 +} 1.154 + 1.155 + 1.156 +// This function deallocates the metadata and C heap pointers that the 1.157 +// InstanceKlass points to. 1.158 +void InstanceKlass::deallocate_contents(ClassLoaderData* loader_data) { 1.159 + 1.160 + // Orphan the mirror first, CMS thinks it's still live. 1.161 + java_lang_Class::set_klass(java_mirror(), NULL); 1.162 + 1.163 + // Need to take this class off the class loader data list. 1.164 + loader_data->remove_class(this); 1.165 + 1.166 + // The array_klass for this class is created later, after error handling. 1.167 + // For class redefinition, we keep the original class so this scratch class 1.168 + // doesn't have an array class. Either way, assert that there is nothing 1.169 + // to deallocate. 1.170 + assert(array_klasses() == NULL, "array classes shouldn't be created for this class yet"); 1.171 + 1.172 + // Release C heap allocated data that this might point to, which includes 1.173 + // reference counting symbol names. 1.174 + release_C_heap_structures(); 1.175 + 1.176 + Array<Method*>* ms = methods(); 1.177 + if (ms != Universe::the_empty_method_array()) { 1.178 + for (int i = 0; i <= methods()->length() -1 ; i++) { 1.179 + Method* method = methods()->at(i); 1.180 + // Only want to delete methods that are not executing for RedefineClasses. 1.181 + // The previous version will point to them so they're not totally dangling 1.182 + assert (!method->on_stack(), "shouldn't be called with methods on stack"); 1.183 + MetadataFactory::free_metadata(loader_data, method); 1.184 + } 1.185 + MetadataFactory::free_array<Method*>(loader_data, methods()); 1.186 + } 1.187 + set_methods(NULL); 1.188 + 1.189 + if (method_ordering() != Universe::the_empty_int_array()) { 1.190 + MetadataFactory::free_array<int>(loader_data, method_ordering()); 1.191 + } 1.192 + set_method_ordering(NULL); 1.193 + 1.194 + // This array is in Klass, but remove it with the InstanceKlass since 1.195 + // this place would be the only caller and it can share memory with transitive 1.196 + // interfaces. 1.197 + if (secondary_supers() != Universe::the_empty_klass_array() && 1.198 + secondary_supers() != transitive_interfaces()) { 1.199 + MetadataFactory::free_array<Klass*>(loader_data, secondary_supers()); 1.200 + } 1.201 + set_secondary_supers(NULL); 1.202 + 1.203 + // Only deallocate transitive interfaces if not empty, same as super class 1.204 + // or same as local interfaces. See code in parseClassFile. 1.205 + Array<Klass*>* ti = transitive_interfaces(); 1.206 + if (ti != Universe::the_empty_klass_array() && ti != local_interfaces()) { 1.207 + // check that the interfaces don't come from super class 1.208 + Array<Klass*>* sti = (super() == NULL) ? NULL : 1.209 + InstanceKlass::cast(super())->transitive_interfaces(); 1.210 + if (ti != sti) { 1.211 + MetadataFactory::free_array<Klass*>(loader_data, ti); 1.212 + } 1.213 + } 1.214 + set_transitive_interfaces(NULL); 1.215 + 1.216 + // local interfaces can be empty 1.217 + Array<Klass*>* li = local_interfaces(); 1.218 + if (li != Universe::the_empty_klass_array()) { 1.219 + MetadataFactory::free_array<Klass*>(loader_data, li); 1.220 + } 1.221 + set_local_interfaces(NULL); 1.222 + 1.223 + MetadataFactory::free_array<jushort>(loader_data, fields()); 1.224 + set_fields(NULL, 0); 1.225 + 1.226 + // If a method from a redefined class is using this constant pool, don't 1.227 + // delete it, yet. The new class's previous version will point to this. 1.228 + assert (!constants()->on_stack(), "shouldn't be called if anything is onstack"); 1.229 + MetadataFactory::free_metadata(loader_data, constants()); 1.230 + set_constants(NULL); 1.231 + 1.232 + if (inner_classes() != Universe::the_empty_short_array()) { 1.233 + MetadataFactory::free_array<jushort>(loader_data, inner_classes()); 1.234 + } 1.235 + set_inner_classes(NULL); 1.236 + 1.237 + // Null out Java heap objects, although these won't be walked to keep 1.238 + // alive once this InstanceKlass is deallocated. 1.239 + set_protection_domain(NULL); 1.240 + set_signers(NULL); 1.241 + set_init_lock(NULL); 1.242 + set_annotations(NULL); 1.243 +} 1.244 + 1.245 +volatile oop InstanceKlass::init_lock() const { 1.246 + volatile oop lock = _init_lock; // read once 1.247 + assert((oop)lock != NULL || !is_not_initialized(), // initialized or in_error state 1.248 + "only fully initialized state can have a null lock"); 1.249 + return lock; 1.250 +} 1.251 + 1.252 +// Set the initialization lock to null so the object can be GC'ed. Any racing 1.253 +// threads to get this lock will see a null lock and will not lock. 1.254 +// That's okay because they all check for initialized state after getting 1.255 +// the lock and return. 1.256 +void InstanceKlass::fence_and_clear_init_lock() { 1.257 + // make sure previous stores are all done, notably the init_state. 1.258 + OrderAccess::storestore(); 1.259 + klass_oop_store(&_init_lock, NULL); 1.260 + assert(!is_not_initialized(), "class must be initialized now"); 1.261 +} 1.262 + 1.263 + 1.264 +bool InstanceKlass::should_be_initialized() const { 1.265 return !is_initialized(); 1.266 } 1.267 1.268 -klassVtable* instanceKlass::vtable() const { 1.269 - return new klassVtable(as_klassOop(), start_of_vtable(), vtable_length() / vtableEntry::size()); 1.270 +klassVtable* InstanceKlass::vtable() const { 1.271 + return new klassVtable(this, start_of_vtable(), vtable_length() / vtableEntry::size()); 1.272 } 1.273 1.274 -klassItable* instanceKlass::itable() const { 1.275 - return new klassItable(as_klassOop()); 1.276 +klassItable* InstanceKlass::itable() const { 1.277 + return new klassItable(instanceKlassHandle(this)); 1.278 } 1.279 1.280 -void instanceKlass::eager_initialize(Thread *thread) { 1.281 +void InstanceKlass::eager_initialize(Thread *thread) { 1.282 if (!EagerInitialization) return; 1.283 1.284 if (this->is_not_initialized()) { 1.285 @@ -188,22 +414,23 @@ 1.286 if (this->class_initializer() != NULL) return; 1.287 1.288 // abort if it is java.lang.Object (initialization is handled in genesis) 1.289 - klassOop super = this->super(); 1.290 + Klass* super = this->super(); 1.291 if (super == NULL) return; 1.292 1.293 // abort if the super class should be initialized 1.294 - if (!instanceKlass::cast(super)->is_initialized()) return; 1.295 + if (!InstanceKlass::cast(super)->is_initialized()) return; 1.296 1.297 // call body to expose the this pointer 1.298 - instanceKlassHandle this_oop(thread, this->as_klassOop()); 1.299 + instanceKlassHandle this_oop(thread, this); 1.300 eager_initialize_impl(this_oop); 1.301 } 1.302 } 1.303 1.304 1.305 -void instanceKlass::eager_initialize_impl(instanceKlassHandle this_oop) { 1.306 +void InstanceKlass::eager_initialize_impl(instanceKlassHandle this_oop) { 1.307 EXCEPTION_MARK; 1.308 - ObjectLocker ol(this_oop, THREAD); 1.309 + volatile oop init_lock = this_oop->init_lock(); 1.310 + ObjectLocker ol(init_lock, THREAD, init_lock != NULL); 1.311 1.312 // abort if someone beat us to the initialization 1.313 if (!this_oop->is_not_initialized()) return; // note: not equivalent to is_initialized() 1.314 @@ -222,6 +449,7 @@ 1.315 } else { 1.316 // linking successfull, mark class as initialized 1.317 this_oop->set_init_state (fully_initialized); 1.318 + this_oop->fence_and_clear_init_lock(); 1.319 // trace 1.320 if (TraceClassInitialization) { 1.321 ResourceMark rm(THREAD); 1.322 @@ -234,10 +462,10 @@ 1.323 // See "The Virtual Machine Specification" section 2.16.5 for a detailed explanation of the class initialization 1.324 // process. The step comments refers to the procedure described in that section. 1.325 // Note: implementation moved to static method to expose the this pointer. 1.326 -void instanceKlass::initialize(TRAPS) { 1.327 +void InstanceKlass::initialize(TRAPS) { 1.328 if (this->should_be_initialized()) { 1.329 HandleMark hm(THREAD); 1.330 - instanceKlassHandle this_oop(THREAD, this->as_klassOop()); 1.331 + instanceKlassHandle this_oop(THREAD, this); 1.332 initialize_impl(this_oop, CHECK); 1.333 // Note: at this point the class may be initialized 1.334 // OR it may be in the state of being initialized 1.335 @@ -248,7 +476,7 @@ 1.336 } 1.337 1.338 1.339 -bool instanceKlass::verify_code( 1.340 +bool InstanceKlass::verify_code( 1.341 instanceKlassHandle this_oop, bool throw_verifyerror, TRAPS) { 1.342 // 1) Verify the bytecodes 1.343 Verifier::Mode mode = 1.344 @@ -260,31 +488,33 @@ 1.345 // Used exclusively by the shared spaces dump mechanism to prevent 1.346 // classes mapped into the shared regions in new VMs from appearing linked. 1.347 1.348 -void instanceKlass::unlink_class() { 1.349 +void InstanceKlass::unlink_class() { 1.350 assert(is_linked(), "must be linked"); 1.351 _init_state = loaded; 1.352 } 1.353 1.354 -void instanceKlass::link_class(TRAPS) { 1.355 +void InstanceKlass::link_class(TRAPS) { 1.356 assert(is_loaded(), "must be loaded"); 1.357 if (!is_linked()) { 1.358 - instanceKlassHandle this_oop(THREAD, this->as_klassOop()); 1.359 + HandleMark hm(THREAD); 1.360 + instanceKlassHandle this_oop(THREAD, this); 1.361 link_class_impl(this_oop, true, CHECK); 1.362 } 1.363 } 1.364 1.365 // Called to verify that a class can link during initialization, without 1.366 // throwing a VerifyError. 1.367 -bool instanceKlass::link_class_or_fail(TRAPS) { 1.368 +bool InstanceKlass::link_class_or_fail(TRAPS) { 1.369 assert(is_loaded(), "must be loaded"); 1.370 if (!is_linked()) { 1.371 - instanceKlassHandle this_oop(THREAD, this->as_klassOop()); 1.372 + HandleMark hm(THREAD); 1.373 + instanceKlassHandle this_oop(THREAD, this); 1.374 link_class_impl(this_oop, false, CHECK_false); 1.375 } 1.376 return is_linked(); 1.377 } 1.378 1.379 -bool instanceKlass::link_class_impl( 1.380 +bool InstanceKlass::link_class_impl( 1.381 instanceKlassHandle this_oop, bool throw_verifyerror, TRAPS) { 1.382 // check for error state 1.383 if (this_oop->is_in_error_state()) { 1.384 @@ -321,11 +551,11 @@ 1.385 } 1.386 1.387 // link all interfaces implemented by this class before linking this class 1.388 - objArrayHandle interfaces (THREAD, this_oop->local_interfaces()); 1.389 + Array<Klass*>* interfaces = this_oop->local_interfaces(); 1.390 int num_interfaces = interfaces->length(); 1.391 for (int index = 0; index < num_interfaces; index++) { 1.392 HandleMark hm(THREAD); 1.393 - instanceKlassHandle ih(THREAD, klassOop(interfaces->obj_at(index))); 1.394 + instanceKlassHandle ih(THREAD, interfaces->at(index)); 1.395 link_class_impl(ih, throw_verifyerror, CHECK_false); 1.396 } 1.397 1.398 @@ -345,10 +575,12 @@ 1.399 1.400 // verification & rewriting 1.401 { 1.402 - ObjectLocker ol(this_oop, THREAD); 1.403 + volatile oop init_lock = this_oop->init_lock(); 1.404 + ObjectLocker ol(init_lock, THREAD, init_lock != NULL); 1.405 // rewritten will have been set if loader constraint error found 1.406 // on an earlier link attempt 1.407 // don't verify or rewrite if already rewritten 1.408 + 1.409 if (!this_oop->is_linked()) { 1.410 if (!this_oop->is_rewritten()) { 1.411 { 1.412 @@ -382,7 +614,7 @@ 1.413 1.414 // Initialize the vtable and interface table after 1.415 // methods have been rewritten since rewrite may 1.416 - // fabricate new methodOops. 1.417 + // fabricate new Method*s. 1.418 // also does loader constraint checking 1.419 if (!this_oop()->is_shared()) { 1.420 ResourceMark rm(THREAD); 1.421 @@ -412,9 +644,9 @@ 1.422 // Rewrite the byte codes of all of the methods of a class. 1.423 // The rewriter must be called exactly once. Rewriting must happen after 1.424 // verification but before the first method of the class is executed. 1.425 -void instanceKlass::rewrite_class(TRAPS) { 1.426 +void InstanceKlass::rewrite_class(TRAPS) { 1.427 assert(is_loaded(), "must be loaded"); 1.428 - instanceKlassHandle this_oop(THREAD, this->as_klassOop()); 1.429 + instanceKlassHandle this_oop(THREAD, this); 1.430 if (this_oop->is_rewritten()) { 1.431 assert(this_oop()->is_shared(), "rewriting an unshared class?"); 1.432 return; 1.433 @@ -426,25 +658,27 @@ 1.434 // Now relocate and link method entry points after class is rewritten. 1.435 // This is outside is_rewritten flag. In case of an exception, it can be 1.436 // executed more than once. 1.437 -void instanceKlass::relocate_and_link_methods(TRAPS) { 1.438 +void InstanceKlass::relocate_and_link_methods(TRAPS) { 1.439 assert(is_loaded(), "must be loaded"); 1.440 - instanceKlassHandle this_oop(THREAD, this->as_klassOop()); 1.441 + instanceKlassHandle this_oop(THREAD, this); 1.442 Rewriter::relocate_and_link(this_oop, CHECK); 1.443 } 1.444 1.445 1.446 -void instanceKlass::initialize_impl(instanceKlassHandle this_oop, TRAPS) { 1.447 +void InstanceKlass::initialize_impl(instanceKlassHandle this_oop, TRAPS) { 1.448 // Make sure klass is linked (verified) before initialization 1.449 // A class could already be verified, since it has been reflected upon. 1.450 this_oop->link_class(CHECK); 1.451 1.452 - DTRACE_CLASSINIT_PROBE(required, instanceKlass::cast(this_oop()), -1); 1.453 + DTRACE_CLASSINIT_PROBE(required, InstanceKlass::cast(this_oop()), -1); 1.454 1.455 bool wait = false; 1.456 1.457 // refer to the JVM book page 47 for description of steps 1.458 // Step 1 1.459 - { ObjectLocker ol(this_oop, THREAD); 1.460 + { 1.461 + volatile oop init_lock = this_oop->init_lock(); 1.462 + ObjectLocker ol(init_lock, THREAD, init_lock != NULL); 1.463 1.464 Thread *self = THREAD; // it's passed the current thread 1.465 1.466 @@ -459,19 +693,19 @@ 1.467 1.468 // Step 3 1.469 if (this_oop->is_being_initialized() && this_oop->is_reentrant_initialization(self)) { 1.470 - DTRACE_CLASSINIT_PROBE_WAIT(recursive, instanceKlass::cast(this_oop()), -1,wait); 1.471 + DTRACE_CLASSINIT_PROBE_WAIT(recursive, InstanceKlass::cast(this_oop()), -1,wait); 1.472 return; 1.473 } 1.474 1.475 // Step 4 1.476 if (this_oop->is_initialized()) { 1.477 - DTRACE_CLASSINIT_PROBE_WAIT(concurrent, instanceKlass::cast(this_oop()), -1,wait); 1.478 + DTRACE_CLASSINIT_PROBE_WAIT(concurrent, InstanceKlass::cast(this_oop()), -1,wait); 1.479 return; 1.480 } 1.481 1.482 // Step 5 1.483 if (this_oop->is_in_error_state()) { 1.484 - DTRACE_CLASSINIT_PROBE_WAIT(erroneous, instanceKlass::cast(this_oop()), -1,wait); 1.485 + DTRACE_CLASSINIT_PROBE_WAIT(erroneous, InstanceKlass::cast(this_oop()), -1,wait); 1.486 ResourceMark rm(THREAD); 1.487 const char* desc = "Could not initialize class "; 1.488 const char* className = this_oop->external_name(); 1.489 @@ -492,7 +726,7 @@ 1.490 } 1.491 1.492 // Step 7 1.493 - klassOop super_klass = this_oop->super(); 1.494 + Klass* super_klass = this_oop->super(); 1.495 if (super_klass != NULL && !this_oop->is_interface() && Klass::cast(super_klass)->should_be_initialized()) { 1.496 Klass::cast(super_klass)->initialize(THREAD); 1.497 1.498 @@ -504,7 +738,7 @@ 1.499 this_oop->set_initialization_state_and_notify(initialization_error, THREAD); // Locks object, set state, and notify all waiting threads 1.500 CLEAR_PENDING_EXCEPTION; // ignore any exception thrown, superclass initialization error is thrown below 1.501 } 1.502 - DTRACE_CLASSINIT_PROBE_WAIT(super__failed, instanceKlass::cast(this_oop()), -1,wait); 1.503 + DTRACE_CLASSINIT_PROBE_WAIT(super__failed, InstanceKlass::cast(this_oop()), -1,wait); 1.504 THROW_OOP(e()); 1.505 } 1.506 } 1.507 @@ -513,7 +747,7 @@ 1.508 { 1.509 assert(THREAD->is_Java_thread(), "non-JavaThread in initialize_impl"); 1.510 JavaThread* jt = (JavaThread*)THREAD; 1.511 - DTRACE_CLASSINIT_PROBE_WAIT(clinit, instanceKlass::cast(this_oop()), -1,wait); 1.512 + DTRACE_CLASSINIT_PROBE_WAIT(clinit, InstanceKlass::cast(this_oop()), -1,wait); 1.513 // Timer includes any side effects of class initialization (resolution, 1.514 // etc), but not recursive entry into call_class_initializer(). 1.515 PerfClassTraceTime timer(ClassLoader::perf_class_init_time(), 1.516 @@ -541,7 +775,7 @@ 1.517 this_oop->set_initialization_state_and_notify(initialization_error, THREAD); 1.518 CLEAR_PENDING_EXCEPTION; // ignore any exception thrown, class initialization error is thrown below 1.519 } 1.520 - DTRACE_CLASSINIT_PROBE_WAIT(error, instanceKlass::cast(this_oop()), -1,wait); 1.521 + DTRACE_CLASSINIT_PROBE_WAIT(error, InstanceKlass::cast(this_oop()), -1,wait); 1.522 if (e->is_a(SystemDictionary::Error_klass())) { 1.523 THROW_OOP(e()); 1.524 } else { 1.525 @@ -551,108 +785,116 @@ 1.526 &args); 1.527 } 1.528 } 1.529 - DTRACE_CLASSINIT_PROBE_WAIT(end, instanceKlass::cast(this_oop()), -1,wait); 1.530 + DTRACE_CLASSINIT_PROBE_WAIT(end, InstanceKlass::cast(this_oop()), -1,wait); 1.531 } 1.532 1.533 1.534 // Note: implementation moved to static method to expose the this pointer. 1.535 -void instanceKlass::set_initialization_state_and_notify(ClassState state, TRAPS) { 1.536 - instanceKlassHandle kh(THREAD, this->as_klassOop()); 1.537 +void InstanceKlass::set_initialization_state_and_notify(ClassState state, TRAPS) { 1.538 + instanceKlassHandle kh(THREAD, this); 1.539 set_initialization_state_and_notify_impl(kh, state, CHECK); 1.540 } 1.541 1.542 -void instanceKlass::set_initialization_state_and_notify_impl(instanceKlassHandle this_oop, ClassState state, TRAPS) { 1.543 - ObjectLocker ol(this_oop, THREAD); 1.544 +void InstanceKlass::set_initialization_state_and_notify_impl(instanceKlassHandle this_oop, ClassState state, TRAPS) { 1.545 + volatile oop init_lock = this_oop->init_lock(); 1.546 + ObjectLocker ol(init_lock, THREAD, init_lock != NULL); 1.547 this_oop->set_init_state(state); 1.548 + this_oop->fence_and_clear_init_lock(); 1.549 ol.notify_all(CHECK); 1.550 } 1.551 1.552 // The embedded _implementor field can only record one implementor. 1.553 // When there are more than one implementors, the _implementor field 1.554 -// is set to the interface klassOop itself. Following are the possible 1.555 +// is set to the interface Klass* itself. Following are the possible 1.556 // values for the _implementor field: 1.557 // NULL - no implementor 1.558 -// implementor klassOop - one implementor 1.559 +// implementor Klass* - one implementor 1.560 // self - more than one implementor 1.561 // 1.562 // The _implementor field only exists for interfaces. 1.563 -void instanceKlass::add_implementor(klassOop k) { 1.564 +void InstanceKlass::add_implementor(Klass* k) { 1.565 assert(Compile_lock->owned_by_self(), ""); 1.566 assert(is_interface(), "not interface"); 1.567 // Filter out my subinterfaces. 1.568 // (Note: Interfaces are never on the subklass list.) 1.569 - if (instanceKlass::cast(k)->is_interface()) return; 1.570 + if (InstanceKlass::cast(k)->is_interface()) return; 1.571 1.572 // Filter out subclasses whose supers already implement me. 1.573 // (Note: CHA must walk subclasses of direct implementors 1.574 // in order to locate indirect implementors.) 1.575 - klassOop sk = instanceKlass::cast(k)->super(); 1.576 - if (sk != NULL && instanceKlass::cast(sk)->implements_interface(as_klassOop())) 1.577 + Klass* sk = InstanceKlass::cast(k)->super(); 1.578 + if (sk != NULL && InstanceKlass::cast(sk)->implements_interface(this)) 1.579 // We only need to check one immediate superclass, since the 1.580 // implements_interface query looks at transitive_interfaces. 1.581 // Any supers of the super have the same (or fewer) transitive_interfaces. 1.582 return; 1.583 1.584 - klassOop ik = implementor(); 1.585 + Klass* ik = implementor(); 1.586 if (ik == NULL) { 1.587 set_implementor(k); 1.588 - } else if (ik != this->as_klassOop()) { 1.589 + } else if (ik != this) { 1.590 // There is already an implementor. Use itself as an indicator of 1.591 // more than one implementors. 1.592 - set_implementor(this->as_klassOop()); 1.593 + set_implementor(this); 1.594 } 1.595 1.596 // The implementor also implements the transitive_interfaces 1.597 for (int index = 0; index < local_interfaces()->length(); index++) { 1.598 - instanceKlass::cast(klassOop(local_interfaces()->obj_at(index)))->add_implementor(k); 1.599 + InstanceKlass::cast(local_interfaces()->at(index))->add_implementor(k); 1.600 } 1.601 } 1.602 1.603 -void instanceKlass::init_implementor() { 1.604 +void InstanceKlass::init_implementor() { 1.605 if (is_interface()) { 1.606 set_implementor(NULL); 1.607 } 1.608 } 1.609 1.610 1.611 -void instanceKlass::process_interfaces(Thread *thread) { 1.612 +void InstanceKlass::process_interfaces(Thread *thread) { 1.613 // link this class into the implementors list of every interface it implements 1.614 - KlassHandle this_as_oop (thread, this->as_klassOop()); 1.615 + Klass* this_as_klass_oop = this; 1.616 for (int i = local_interfaces()->length() - 1; i >= 0; i--) { 1.617 - assert(local_interfaces()->obj_at(i)->is_klass(), "must be a klass"); 1.618 - instanceKlass* interf = instanceKlass::cast(klassOop(local_interfaces()->obj_at(i))); 1.619 + assert(local_interfaces()->at(i)->is_klass(), "must be a klass"); 1.620 + InstanceKlass* interf = InstanceKlass::cast(local_interfaces()->at(i)); 1.621 assert(interf->is_interface(), "expected interface"); 1.622 - interf->add_implementor(this_as_oop()); 1.623 + interf->add_implementor(this_as_klass_oop); 1.624 } 1.625 } 1.626 1.627 -bool instanceKlass::can_be_primary_super_slow() const { 1.628 +bool InstanceKlass::can_be_primary_super_slow() const { 1.629 if (is_interface()) 1.630 return false; 1.631 else 1.632 return Klass::can_be_primary_super_slow(); 1.633 } 1.634 1.635 -objArrayOop instanceKlass::compute_secondary_supers(int num_extra_slots, TRAPS) { 1.636 +GrowableArray<Klass*>* InstanceKlass::compute_secondary_supers(int num_extra_slots) { 1.637 // The secondaries are the implemented interfaces. 1.638 - instanceKlass* ik = instanceKlass::cast(as_klassOop()); 1.639 - objArrayHandle interfaces (THREAD, ik->transitive_interfaces()); 1.640 + InstanceKlass* ik = InstanceKlass::cast(this); 1.641 + Array<Klass*>* interfaces = ik->transitive_interfaces(); 1.642 int num_secondaries = num_extra_slots + interfaces->length(); 1.643 if (num_secondaries == 0) { 1.644 - return Universe::the_empty_system_obj_array(); 1.645 + // Must share this for correct bootstrapping! 1.646 + set_secondary_supers(Universe::the_empty_klass_array()); 1.647 + return NULL; 1.648 } else if (num_extra_slots == 0) { 1.649 - return interfaces(); 1.650 + // The secondary super list is exactly the same as the transitive interfaces. 1.651 + // Redefine classes has to be careful not to delete this! 1.652 + set_secondary_supers(interfaces); 1.653 + return NULL; 1.654 } else { 1.655 - // a mix of both 1.656 - objArrayOop secondaries = oopFactory::new_system_objArray(num_secondaries, CHECK_NULL); 1.657 + // Copy transitive interfaces to a temporary growable array to be constructed 1.658 + // into the secondary super list with extra slots. 1.659 + GrowableArray<Klass*>* secondaries = new GrowableArray<Klass*>(interfaces->length()); 1.660 for (int i = 0; i < interfaces->length(); i++) { 1.661 - secondaries->obj_at_put(num_extra_slots+i, interfaces->obj_at(i)); 1.662 + secondaries->push(interfaces->at(i)); 1.663 } 1.664 return secondaries; 1.665 } 1.666 } 1.667 1.668 -bool instanceKlass::compute_is_subtype_of(klassOop k) { 1.669 +bool InstanceKlass::compute_is_subtype_of(Klass* k) { 1.670 if (Klass::cast(k)->is_interface()) { 1.671 return implements_interface(k); 1.672 } else { 1.673 @@ -660,18 +902,18 @@ 1.674 } 1.675 } 1.676 1.677 -bool instanceKlass::implements_interface(klassOop k) const { 1.678 - if (as_klassOop() == k) return true; 1.679 +bool InstanceKlass::implements_interface(Klass* k) const { 1.680 + if (this == k) return true; 1.681 assert(Klass::cast(k)->is_interface(), "should be an interface class"); 1.682 for (int i = 0; i < transitive_interfaces()->length(); i++) { 1.683 - if (transitive_interfaces()->obj_at(i) == k) { 1.684 + if (transitive_interfaces()->at(i) == k) { 1.685 return true; 1.686 } 1.687 } 1.688 return false; 1.689 } 1.690 1.691 -objArrayOop instanceKlass::allocate_objArray(int n, int length, TRAPS) { 1.692 +objArrayOop InstanceKlass::allocate_objArray(int n, int length, TRAPS) { 1.693 if (length < 0) THROW_0(vmSymbols::java_lang_NegativeArraySizeException()); 1.694 if (length > arrayOopDesc::max_array_length(T_OBJECT)) { 1.695 report_java_out_of_memory("Requested array size exceeds VM limit"); 1.696 @@ -679,14 +921,14 @@ 1.697 THROW_OOP_0(Universe::out_of_memory_error_array_size()); 1.698 } 1.699 int size = objArrayOopDesc::object_size(length); 1.700 - klassOop ak = array_klass(n, CHECK_NULL); 1.701 + Klass* ak = array_klass(n, CHECK_NULL); 1.702 KlassHandle h_ak (THREAD, ak); 1.703 objArrayOop o = 1.704 (objArrayOop)CollectedHeap::array_allocate(h_ak, size, length, CHECK_NULL); 1.705 return o; 1.706 } 1.707 1.708 -instanceOop instanceKlass::register_finalizer(instanceOop i, TRAPS) { 1.709 +instanceOop InstanceKlass::register_finalizer(instanceOop i, TRAPS) { 1.710 if (TraceFinalizerRegistration) { 1.711 tty->print("Registered "); 1.712 i->print_value_on(tty); 1.713 @@ -701,12 +943,11 @@ 1.714 return h_i(); 1.715 } 1.716 1.717 -instanceOop instanceKlass::allocate_instance(TRAPS) { 1.718 - assert(!oop_is_instanceMirror(), "wrong allocation path"); 1.719 +instanceOop InstanceKlass::allocate_instance(TRAPS) { 1.720 bool has_finalizer_flag = has_finalizer(); // Query before possible GC 1.721 int size = size_helper(); // Query before forming handle. 1.722 1.723 - KlassHandle h_k(THREAD, as_klassOop()); 1.724 + KlassHandle h_k(THREAD, this); 1.725 1.726 instanceOop i; 1.727 1.728 @@ -717,39 +958,25 @@ 1.729 return i; 1.730 } 1.731 1.732 -instanceOop instanceKlass::allocate_permanent_instance(TRAPS) { 1.733 - // Finalizer registration occurs in the Object.<init> constructor 1.734 - // and constructors normally aren't run when allocating perm 1.735 - // instances so simply disallow finalizable perm objects. This can 1.736 - // be relaxed if a need for it is found. 1.737 - assert(!has_finalizer(), "perm objects not allowed to have finalizers"); 1.738 - assert(!oop_is_instanceMirror(), "wrong allocation path"); 1.739 - int size = size_helper(); // Query before forming handle. 1.740 - KlassHandle h_k(THREAD, as_klassOop()); 1.741 - instanceOop i = (instanceOop) 1.742 - CollectedHeap::permanent_obj_allocate(h_k, size, CHECK_NULL); 1.743 - return i; 1.744 -} 1.745 - 1.746 -void instanceKlass::check_valid_for_instantiation(bool throwError, TRAPS) { 1.747 +void InstanceKlass::check_valid_for_instantiation(bool throwError, TRAPS) { 1.748 if (is_interface() || is_abstract()) { 1.749 ResourceMark rm(THREAD); 1.750 THROW_MSG(throwError ? vmSymbols::java_lang_InstantiationError() 1.751 : vmSymbols::java_lang_InstantiationException(), external_name()); 1.752 } 1.753 - if (as_klassOop() == SystemDictionary::Class_klass()) { 1.754 + if (this == SystemDictionary::Class_klass()) { 1.755 ResourceMark rm(THREAD); 1.756 THROW_MSG(throwError ? vmSymbols::java_lang_IllegalAccessError() 1.757 : vmSymbols::java_lang_IllegalAccessException(), external_name()); 1.758 } 1.759 } 1.760 1.761 -klassOop instanceKlass::array_klass_impl(bool or_null, int n, TRAPS) { 1.762 - instanceKlassHandle this_oop(THREAD, as_klassOop()); 1.763 +Klass* InstanceKlass::array_klass_impl(bool or_null, int n, TRAPS) { 1.764 + instanceKlassHandle this_oop(THREAD, this); 1.765 return array_klass_impl(this_oop, or_null, n, THREAD); 1.766 } 1.767 1.768 -klassOop instanceKlass::array_klass_impl(instanceKlassHandle this_oop, bool or_null, int n, TRAPS) { 1.769 +Klass* InstanceKlass::array_klass_impl(instanceKlassHandle this_oop, bool or_null, int n, TRAPS) { 1.770 if (this_oop->array_klasses() == NULL) { 1.771 if (or_null) return NULL; 1.772 1.773 @@ -762,35 +989,32 @@ 1.774 1.775 // Check if update has already taken place 1.776 if (this_oop->array_klasses() == NULL) { 1.777 - objArrayKlassKlass* oakk = 1.778 - (objArrayKlassKlass*)Universe::objArrayKlassKlassObj()->klass_part(); 1.779 - 1.780 - klassOop k = oakk->allocate_objArray_klass(1, this_oop, CHECK_NULL); 1.781 + Klass* k = objArrayKlass::allocate_objArray_klass(this_oop->class_loader_data(), 1, this_oop, CHECK_NULL); 1.782 this_oop->set_array_klasses(k); 1.783 } 1.784 } 1.785 } 1.786 // _this will always be set at this point 1.787 - objArrayKlass* oak = (objArrayKlass*)this_oop->array_klasses()->klass_part(); 1.788 + objArrayKlass* oak = (objArrayKlass*)this_oop->array_klasses(); 1.789 if (or_null) { 1.790 return oak->array_klass_or_null(n); 1.791 } 1.792 return oak->array_klass(n, CHECK_NULL); 1.793 } 1.794 1.795 -klassOop instanceKlass::array_klass_impl(bool or_null, TRAPS) { 1.796 +Klass* InstanceKlass::array_klass_impl(bool or_null, TRAPS) { 1.797 return array_klass_impl(or_null, 1, THREAD); 1.798 } 1.799 1.800 -void instanceKlass::call_class_initializer(TRAPS) { 1.801 - instanceKlassHandle ik (THREAD, as_klassOop()); 1.802 +void InstanceKlass::call_class_initializer(TRAPS) { 1.803 + instanceKlassHandle ik (THREAD, this); 1.804 call_class_initializer_impl(ik, THREAD); 1.805 } 1.806 1.807 static int call_class_initializer_impl_counter = 0; // for debugging 1.808 1.809 -methodOop instanceKlass::class_initializer() { 1.810 - methodOop clinit = find_method( 1.811 +Method* InstanceKlass::class_initializer() { 1.812 + Method* clinit = find_method( 1.813 vmSymbols::class_initializer_name(), vmSymbols::void_method_signature()); 1.814 if (clinit != NULL && clinit->has_valid_initializer_flags()) { 1.815 return clinit; 1.816 @@ -798,7 +1022,7 @@ 1.817 return NULL; 1.818 } 1.819 1.820 -void instanceKlass::call_class_initializer_impl(instanceKlassHandle this_oop, TRAPS) { 1.821 +void InstanceKlass::call_class_initializer_impl(instanceKlassHandle this_oop, TRAPS) { 1.822 methodHandle h_method(THREAD, this_oop->class_initializer()); 1.823 assert(!this_oop->is_initialized(), "we cannot initialize twice"); 1.824 if (TraceClassInitialization) { 1.825 @@ -814,7 +1038,7 @@ 1.826 } 1.827 1.828 1.829 -void instanceKlass::mask_for(methodHandle method, int bci, 1.830 +void InstanceKlass::mask_for(methodHandle method, int bci, 1.831 InterpreterOopMap* entry_for) { 1.832 // Dirty read, then double-check under a lock. 1.833 if (_oop_map_cache == NULL) { 1.834 @@ -830,12 +1054,12 @@ 1.835 } 1.836 1.837 1.838 -bool instanceKlass::find_local_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const { 1.839 - for (JavaFieldStream fs(as_klassOop()); !fs.done(); fs.next()) { 1.840 +bool InstanceKlass::find_local_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const { 1.841 + for (JavaFieldStream fs(this); !fs.done(); fs.next()) { 1.842 Symbol* f_name = fs.name(); 1.843 Symbol* f_sig = fs.signature(); 1.844 if (f_name == name && f_sig == sig) { 1.845 - fd->initialize(as_klassOop(), fs.index()); 1.846 + fd->initialize(const_cast<InstanceKlass*>(this), fs.index()); 1.847 return true; 1.848 } 1.849 } 1.850 @@ -843,32 +1067,18 @@ 1.851 } 1.852 1.853 1.854 -void instanceKlass::shared_symbols_iterate(SymbolClosure* closure) { 1.855 - Klass::shared_symbols_iterate(closure); 1.856 - closure->do_symbol(&_generic_signature); 1.857 - closure->do_symbol(&_source_file_name); 1.858 - 1.859 - for (JavaFieldStream fs(this); !fs.done(); fs.next()) { 1.860 - int name_index = fs.name_index(); 1.861 - closure->do_symbol(constants()->symbol_at_addr(name_index)); 1.862 - int sig_index = fs.signature_index(); 1.863 - closure->do_symbol(constants()->symbol_at_addr(sig_index)); 1.864 - } 1.865 -} 1.866 - 1.867 - 1.868 -klassOop instanceKlass::find_interface_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const { 1.869 +Klass* InstanceKlass::find_interface_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const { 1.870 const int n = local_interfaces()->length(); 1.871 for (int i = 0; i < n; i++) { 1.872 - klassOop intf1 = klassOop(local_interfaces()->obj_at(i)); 1.873 + Klass* intf1 = local_interfaces()->at(i); 1.874 assert(Klass::cast(intf1)->is_interface(), "just checking type"); 1.875 // search for field in current interface 1.876 - if (instanceKlass::cast(intf1)->find_local_field(name, sig, fd)) { 1.877 + if (InstanceKlass::cast(intf1)->find_local_field(name, sig, fd)) { 1.878 assert(fd->is_static(), "interface field must be static"); 1.879 return intf1; 1.880 } 1.881 // search for field in direct superinterfaces 1.882 - klassOop intf2 = instanceKlass::cast(intf1)->find_interface_field(name, sig, fd); 1.883 + Klass* intf2 = InstanceKlass::cast(intf1)->find_interface_field(name, sig, fd); 1.884 if (intf2 != NULL) return intf2; 1.885 } 1.886 // otherwise field lookup fails 1.887 @@ -876,49 +1086,49 @@ 1.888 } 1.889 1.890 1.891 -klassOop instanceKlass::find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const { 1.892 +Klass* InstanceKlass::find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const { 1.893 // search order according to newest JVM spec (5.4.3.2, p.167). 1.894 // 1) search for field in current klass 1.895 if (find_local_field(name, sig, fd)) { 1.896 - return as_klassOop(); 1.897 + return const_cast<InstanceKlass*>(this); 1.898 } 1.899 // 2) search for field recursively in direct superinterfaces 1.900 - { klassOop intf = find_interface_field(name, sig, fd); 1.901 + { Klass* intf = find_interface_field(name, sig, fd); 1.902 if (intf != NULL) return intf; 1.903 } 1.904 // 3) apply field lookup recursively if superclass exists 1.905 - { klassOop supr = super(); 1.906 - if (supr != NULL) return instanceKlass::cast(supr)->find_field(name, sig, fd); 1.907 + { Klass* supr = super(); 1.908 + if (supr != NULL) return InstanceKlass::cast(supr)->find_field(name, sig, fd); 1.909 } 1.910 // 4) otherwise field lookup fails 1.911 return NULL; 1.912 } 1.913 1.914 1.915 -klassOop instanceKlass::find_field(Symbol* name, Symbol* sig, bool is_static, fieldDescriptor* fd) const { 1.916 +Klass* InstanceKlass::find_field(Symbol* name, Symbol* sig, bool is_static, fieldDescriptor* fd) const { 1.917 // search order according to newest JVM spec (5.4.3.2, p.167). 1.918 // 1) search for field in current klass 1.919 if (find_local_field(name, sig, fd)) { 1.920 - if (fd->is_static() == is_static) return as_klassOop(); 1.921 + if (fd->is_static() == is_static) return const_cast<InstanceKlass*>(this); 1.922 } 1.923 // 2) search for field recursively in direct superinterfaces 1.924 if (is_static) { 1.925 - klassOop intf = find_interface_field(name, sig, fd); 1.926 + Klass* intf = find_interface_field(name, sig, fd); 1.927 if (intf != NULL) return intf; 1.928 } 1.929 // 3) apply field lookup recursively if superclass exists 1.930 - { klassOop supr = super(); 1.931 - if (supr != NULL) return instanceKlass::cast(supr)->find_field(name, sig, is_static, fd); 1.932 + { Klass* supr = super(); 1.933 + if (supr != NULL) return InstanceKlass::cast(supr)->find_field(name, sig, is_static, fd); 1.934 } 1.935 // 4) otherwise field lookup fails 1.936 return NULL; 1.937 } 1.938 1.939 1.940 -bool instanceKlass::find_local_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const { 1.941 - for (JavaFieldStream fs(as_klassOop()); !fs.done(); fs.next()) { 1.942 +bool InstanceKlass::find_local_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const { 1.943 + for (JavaFieldStream fs(this); !fs.done(); fs.next()) { 1.944 if (fs.offset() == offset) { 1.945 - fd->initialize(as_klassOop(), fs.index()); 1.946 + fd->initialize(const_cast<InstanceKlass*>(this), fs.index()); 1.947 if (fd->is_static() == is_static) return true; 1.948 } 1.949 } 1.950 @@ -926,10 +1136,10 @@ 1.951 } 1.952 1.953 1.954 -bool instanceKlass::find_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const { 1.955 - klassOop klass = as_klassOop(); 1.956 +bool InstanceKlass::find_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const { 1.957 + Klass* klass = const_cast<InstanceKlass*>(this); 1.958 while (klass != NULL) { 1.959 - if (instanceKlass::cast(klass)->find_local_field_from_offset(offset, is_static, fd)) { 1.960 + if (InstanceKlass::cast(klass)->find_local_field_from_offset(offset, is_static, fd)) { 1.961 return true; 1.962 } 1.963 klass = Klass::cast(klass)->super(); 1.964 @@ -938,34 +1148,34 @@ 1.965 } 1.966 1.967 1.968 -void instanceKlass::methods_do(void f(methodOop method)) { 1.969 +void InstanceKlass::methods_do(void f(Method* method)) { 1.970 int len = methods()->length(); 1.971 for (int index = 0; index < len; index++) { 1.972 - methodOop m = methodOop(methods()->obj_at(index)); 1.973 + Method* m = methods()->at(index); 1.974 assert(m->is_method(), "must be method"); 1.975 f(m); 1.976 } 1.977 } 1.978 1.979 1.980 -void instanceKlass::do_local_static_fields(FieldClosure* cl) { 1.981 +void InstanceKlass::do_local_static_fields(FieldClosure* cl) { 1.982 for (JavaFieldStream fs(this); !fs.done(); fs.next()) { 1.983 if (fs.access_flags().is_static()) { 1.984 fieldDescriptor fd; 1.985 - fd.initialize(as_klassOop(), fs.index()); 1.986 + fd.initialize(this, fs.index()); 1.987 cl->do_field(&fd); 1.988 } 1.989 } 1.990 } 1.991 1.992 1.993 -void instanceKlass::do_local_static_fields(void f(fieldDescriptor*, TRAPS), TRAPS) { 1.994 - instanceKlassHandle h_this(THREAD, as_klassOop()); 1.995 +void InstanceKlass::do_local_static_fields(void f(fieldDescriptor*, TRAPS), TRAPS) { 1.996 + instanceKlassHandle h_this(THREAD, this); 1.997 do_local_static_fields_impl(h_this, f, CHECK); 1.998 } 1.999 1.1000 1.1001 -void instanceKlass::do_local_static_fields_impl(instanceKlassHandle this_oop, void f(fieldDescriptor* fd, TRAPS), TRAPS) { 1.1002 +void InstanceKlass::do_local_static_fields_impl(instanceKlassHandle this_oop, void f(fieldDescriptor* fd, TRAPS), TRAPS) { 1.1003 for (JavaFieldStream fs(this_oop()); !fs.done(); fs.next()) { 1.1004 if (fs.access_flags().is_static()) { 1.1005 fieldDescriptor fd; 1.1006 @@ -980,8 +1190,8 @@ 1.1007 return a[0] - b[0]; 1.1008 } 1.1009 1.1010 -void instanceKlass::do_nonstatic_fields(FieldClosure* cl) { 1.1011 - instanceKlass* super = superklass(); 1.1012 +void InstanceKlass::do_nonstatic_fields(FieldClosure* cl) { 1.1013 + InstanceKlass* super = superklass(); 1.1014 if (super != NULL) { 1.1015 super->do_nonstatic_fields(cl); 1.1016 } 1.1017 @@ -991,7 +1201,7 @@ 1.1018 int* fields_sorted = NEW_C_HEAP_ARRAY(int, 2*(length+1), mtClass); 1.1019 int j = 0; 1.1020 for (int i = 0; i < length; i += 1) { 1.1021 - fd.initialize(as_klassOop(), i); 1.1022 + fd.initialize(this, i); 1.1023 if (!fd.is_static()) { 1.1024 fields_sorted[j + 0] = fd.offset(); 1.1025 fields_sorted[j + 1] = i; 1.1026 @@ -1003,7 +1213,7 @@ 1.1027 // _sort_Fn is defined in growableArray.hpp. 1.1028 qsort(fields_sorted, length/2, 2*sizeof(int), (_sort_Fn)compare_fields_by_offset); 1.1029 for (int i = 0; i < length; i += 2) { 1.1030 - fd.initialize(as_klassOop(), fields_sorted[i + 1]); 1.1031 + fd.initialize(this, fields_sorted[i + 1]); 1.1032 assert(!fd.is_static() && fd.offset() == fields_sorted[i], "only nonstatic fields"); 1.1033 cl->do_field(&fd); 1.1034 } 1.1035 @@ -1012,22 +1222,27 @@ 1.1036 } 1.1037 1.1038 1.1039 -void instanceKlass::array_klasses_do(void f(klassOop k)) { 1.1040 +void InstanceKlass::array_klasses_do(void f(Klass* k, TRAPS), TRAPS) { 1.1041 + if (array_klasses() != NULL) 1.1042 + arrayKlass::cast(array_klasses())->array_klasses_do(f, THREAD); 1.1043 +} 1.1044 + 1.1045 +void InstanceKlass::array_klasses_do(void f(Klass* k)) { 1.1046 if (array_klasses() != NULL) 1.1047 arrayKlass::cast(array_klasses())->array_klasses_do(f); 1.1048 } 1.1049 1.1050 1.1051 -void instanceKlass::with_array_klasses_do(void f(klassOop k)) { 1.1052 - f(as_klassOop()); 1.1053 +void InstanceKlass::with_array_klasses_do(void f(Klass* k)) { 1.1054 + f(this); 1.1055 array_klasses_do(f); 1.1056 } 1.1057 1.1058 #ifdef ASSERT 1.1059 -static int linear_search(objArrayOop methods, Symbol* name, Symbol* signature) { 1.1060 +static int linear_search(Array<Method*>* methods, Symbol* name, Symbol* signature) { 1.1061 int len = methods->length(); 1.1062 for (int index = 0; index < len; index++) { 1.1063 - methodOop m = (methodOop)(methods->obj_at(index)); 1.1064 + Method* m = methods->at(index); 1.1065 assert(m->is_method(), "must be method"); 1.1066 if (m->signature() == signature && m->name() == name) { 1.1067 return index; 1.1068 @@ -1037,18 +1252,18 @@ 1.1069 } 1.1070 #endif 1.1071 1.1072 -methodOop instanceKlass::find_method(Symbol* name, Symbol* signature) const { 1.1073 - return instanceKlass::find_method(methods(), name, signature); 1.1074 +Method* InstanceKlass::find_method(Symbol* name, Symbol* signature) const { 1.1075 + return InstanceKlass::find_method(methods(), name, signature); 1.1076 } 1.1077 1.1078 -methodOop instanceKlass::find_method(objArrayOop methods, Symbol* name, Symbol* signature) { 1.1079 +Method* InstanceKlass::find_method(Array<Method*>* methods, Symbol* name, Symbol* signature) { 1.1080 int len = methods->length(); 1.1081 // methods are sorted, so do binary search 1.1082 int l = 0; 1.1083 int h = len - 1; 1.1084 while (l <= h) { 1.1085 int mid = (l + h) >> 1; 1.1086 - methodOop m = (methodOop)methods->obj_at(mid); 1.1087 + Method* m = methods->at(mid); 1.1088 assert(m->is_method(), "must be method"); 1.1089 int res = m->name()->fast_compare(name); 1.1090 if (res == 0) { 1.1091 @@ -1058,14 +1273,14 @@ 1.1092 // search downwards through overloaded methods 1.1093 int i; 1.1094 for (i = mid - 1; i >= l; i--) { 1.1095 - methodOop m = (methodOop)methods->obj_at(i); 1.1096 + Method* m = methods->at(i); 1.1097 assert(m->is_method(), "must be method"); 1.1098 if (m->name() != name) break; 1.1099 if (m->signature() == signature) return m; 1.1100 } 1.1101 // search upwards 1.1102 for (i = mid + 1; i <= h; i++) { 1.1103 - methodOop m = (methodOop)methods->obj_at(i); 1.1104 + Method* m = methods->at(i); 1.1105 assert(m->is_method(), "must be method"); 1.1106 if (m->name() != name) break; 1.1107 if (m->signature() == signature) return m; 1.1108 @@ -1089,25 +1304,25 @@ 1.1109 return NULL; 1.1110 } 1.1111 1.1112 -methodOop instanceKlass::uncached_lookup_method(Symbol* name, Symbol* signature) const { 1.1113 - klassOop klass = as_klassOop(); 1.1114 +Method* InstanceKlass::uncached_lookup_method(Symbol* name, Symbol* signature) const { 1.1115 + Klass* klass = const_cast<InstanceKlass*>(this); 1.1116 while (klass != NULL) { 1.1117 - methodOop method = instanceKlass::cast(klass)->find_method(name, signature); 1.1118 + Method* method = InstanceKlass::cast(klass)->find_method(name, signature); 1.1119 if (method != NULL) return method; 1.1120 - klass = instanceKlass::cast(klass)->super(); 1.1121 + klass = InstanceKlass::cast(klass)->super(); 1.1122 } 1.1123 return NULL; 1.1124 } 1.1125 1.1126 // lookup a method in all the interfaces that this class implements 1.1127 -methodOop instanceKlass::lookup_method_in_all_interfaces(Symbol* name, 1.1128 +Method* InstanceKlass::lookup_method_in_all_interfaces(Symbol* name, 1.1129 Symbol* signature) const { 1.1130 - objArrayOop all_ifs = instanceKlass::cast(as_klassOop())->transitive_interfaces(); 1.1131 + Array<Klass*>* all_ifs = transitive_interfaces(); 1.1132 int num_ifs = all_ifs->length(); 1.1133 - instanceKlass *ik = NULL; 1.1134 + InstanceKlass *ik = NULL; 1.1135 for (int i = 0; i < num_ifs; i++) { 1.1136 - ik = instanceKlass::cast(klassOop(all_ifs->obj_at(i))); 1.1137 - methodOop m = ik->lookup_method(name, signature); 1.1138 + ik = InstanceKlass::cast(all_ifs->at(i)); 1.1139 + Method* m = ik->lookup_method(name, signature); 1.1140 if (m != NULL) { 1.1141 return m; 1.1142 } 1.1143 @@ -1116,13 +1331,13 @@ 1.1144 } 1.1145 1.1146 /* jni_id_for_impl for jfieldIds only */ 1.1147 -JNIid* instanceKlass::jni_id_for_impl(instanceKlassHandle this_oop, int offset) { 1.1148 +JNIid* InstanceKlass::jni_id_for_impl(instanceKlassHandle this_oop, int offset) { 1.1149 MutexLocker ml(JfieldIdCreation_lock); 1.1150 // Retry lookup after we got the lock 1.1151 JNIid* probe = this_oop->jni_ids() == NULL ? NULL : this_oop->jni_ids()->find(offset); 1.1152 if (probe == NULL) { 1.1153 // Slow case, allocate new static field identifier 1.1154 - probe = new JNIid(this_oop->as_klassOop(), offset, this_oop->jni_ids()); 1.1155 + probe = new JNIid(this_oop(), offset, this_oop->jni_ids()); 1.1156 this_oop->set_jni_ids(probe); 1.1157 } 1.1158 return probe; 1.1159 @@ -1130,16 +1345,16 @@ 1.1160 1.1161 1.1162 /* jni_id_for for jfieldIds only */ 1.1163 -JNIid* instanceKlass::jni_id_for(int offset) { 1.1164 +JNIid* InstanceKlass::jni_id_for(int offset) { 1.1165 JNIid* probe = jni_ids() == NULL ? NULL : jni_ids()->find(offset); 1.1166 if (probe == NULL) { 1.1167 - probe = jni_id_for_impl(this->as_klassOop(), offset); 1.1168 + probe = jni_id_for_impl(this, offset); 1.1169 } 1.1170 return probe; 1.1171 } 1.1172 1.1173 -u2 instanceKlass::enclosing_method_data(int offset) { 1.1174 - typeArrayOop inner_class_list = inner_classes(); 1.1175 +u2 InstanceKlass::enclosing_method_data(int offset) { 1.1176 + Array<jushort>* inner_class_list = inner_classes(); 1.1177 if (inner_class_list == NULL) { 1.1178 return 0; 1.1179 } 1.1180 @@ -1148,23 +1363,21 @@ 1.1181 return 0; 1.1182 } else { 1.1183 int index = length - enclosing_method_attribute_size; 1.1184 - typeArrayHandle inner_class_list_h(inner_class_list); 1.1185 assert(offset < enclosing_method_attribute_size, "invalid offset"); 1.1186 - return inner_class_list_h->ushort_at(index + offset); 1.1187 + return inner_class_list->at(index + offset); 1.1188 } 1.1189 } 1.1190 1.1191 -void instanceKlass::set_enclosing_method_indices(u2 class_index, 1.1192 +void InstanceKlass::set_enclosing_method_indices(u2 class_index, 1.1193 u2 method_index) { 1.1194 - typeArrayOop inner_class_list = inner_classes(); 1.1195 + Array<jushort>* inner_class_list = inner_classes(); 1.1196 assert (inner_class_list != NULL, "_inner_classes list is not set up"); 1.1197 int length = inner_class_list->length(); 1.1198 if (length % inner_class_next_offset == enclosing_method_attribute_size) { 1.1199 int index = length - enclosing_method_attribute_size; 1.1200 - typeArrayHandle inner_class_list_h(inner_class_list); 1.1201 - inner_class_list_h->ushort_at_put( 1.1202 + inner_class_list->at_put( 1.1203 index + enclosing_method_class_index_offset, class_index); 1.1204 - inner_class_list_h->ushort_at_put( 1.1205 + inner_class_list->at_put( 1.1206 index + enclosing_method_method_index_offset, method_index); 1.1207 } 1.1208 } 1.1209 @@ -1174,7 +1387,7 @@ 1.1210 // locking has to be done very carefully to avoid deadlocks 1.1211 // and/or other cache consistency problems. 1.1212 // 1.1213 -jmethodID instanceKlass::get_jmethod_id(instanceKlassHandle ik_h, methodHandle method_h) { 1.1214 +jmethodID InstanceKlass::get_jmethod_id(instanceKlassHandle ik_h, methodHandle method_h) { 1.1215 size_t idnum = (size_t)method_h->method_idnum(); 1.1216 jmethodID* jmeths = ik_h->methods_jmethod_ids_acquire(); 1.1217 size_t length = 0; 1.1218 @@ -1245,14 +1458,13 @@ 1.1219 jmethodID new_id = NULL; 1.1220 if (method_h->is_old() && !method_h->is_obsolete()) { 1.1221 // The method passed in is old (but not obsolete), we need to use the current version 1.1222 - methodOop current_method = ik_h->method_with_idnum((int)idnum); 1.1223 + Method* current_method = ik_h->method_with_idnum((int)idnum); 1.1224 assert(current_method != NULL, "old and but not obsolete, so should exist"); 1.1225 - methodHandle current_method_h(current_method == NULL? method_h() : current_method); 1.1226 - new_id = JNIHandles::make_jmethod_id(current_method_h); 1.1227 + new_id = Method::make_jmethod_id(ik_h->class_loader_data(), current_method); 1.1228 } else { 1.1229 // It is the current version of the method or an obsolete method, 1.1230 // use the version passed in 1.1231 - new_id = JNIHandles::make_jmethod_id(method_h); 1.1232 + new_id = Method::make_jmethod_id(ik_h->class_loader_data(), method_h()); 1.1233 } 1.1234 1.1235 if (Threads::number_of_threads() == 0 || 1.1236 @@ -1273,7 +1485,7 @@ 1.1237 } 1.1238 // free up the new ID since it wasn't needed 1.1239 if (to_dealloc_id != NULL) { 1.1240 - JNIHandles::destroy_jmethod_id(to_dealloc_id); 1.1241 + Method::destroy_jmethod_id(ik_h->class_loader_data(), to_dealloc_id); 1.1242 } 1.1243 } 1.1244 return id; 1.1245 @@ -1285,7 +1497,7 @@ 1.1246 // that causes the caller to go to a safepoint or we can deadlock with 1.1247 // the VMThread or have cache consistency issues. 1.1248 // 1.1249 -jmethodID instanceKlass::get_jmethod_id_fetch_or_update( 1.1250 +jmethodID InstanceKlass::get_jmethod_id_fetch_or_update( 1.1251 instanceKlassHandle ik_h, size_t idnum, jmethodID new_id, 1.1252 jmethodID* new_jmeths, jmethodID* to_dealloc_id_p, 1.1253 jmethodID** to_dealloc_jmeths_p) { 1.1254 @@ -1337,7 +1549,7 @@ 1.1255 // Common code to get the jmethodID cache length and the jmethodID 1.1256 // value at index idnum if there is one. 1.1257 // 1.1258 -void instanceKlass::get_jmethod_id_length_value(jmethodID* cache, 1.1259 +void InstanceKlass::get_jmethod_id_length_value(jmethodID* cache, 1.1260 size_t idnum, size_t *length_p, jmethodID* id_p) { 1.1261 assert(cache != NULL, "sanity check"); 1.1262 assert(length_p != NULL, "sanity check"); 1.1263 @@ -1354,7 +1566,7 @@ 1.1264 1.1265 1.1266 // Lookup a jmethodID, NULL if not found. Do no blocking, no allocations, no handles 1.1267 -jmethodID instanceKlass::jmethod_id_or_null(methodOop method) { 1.1268 +jmethodID InstanceKlass::jmethod_id_or_null(Method* method) { 1.1269 size_t idnum = (size_t)method->method_idnum(); 1.1270 jmethodID* jmeths = methods_jmethod_ids_acquire(); 1.1271 size_t length; // length assigned as debugging crumb 1.1272 @@ -1368,7 +1580,7 @@ 1.1273 1.1274 1.1275 // Cache an itable index 1.1276 -void instanceKlass::set_cached_itable_index(size_t idnum, int index) { 1.1277 +void InstanceKlass::set_cached_itable_index(size_t idnum, int index) { 1.1278 int* indices = methods_cached_itable_indices_acquire(); 1.1279 int* to_dealloc_indices = NULL; 1.1280 1.1281 @@ -1438,7 +1650,7 @@ 1.1282 1.1283 1.1284 // Retrieve a cached itable index 1.1285 -int instanceKlass::cached_itable_index(size_t idnum) { 1.1286 +int InstanceKlass::cached_itable_index(size_t idnum) { 1.1287 int* indices = methods_cached_itable_indices_acquire(); 1.1288 if (indices != NULL && ((size_t)indices[0]) > idnum) { 1.1289 // indices exist and are long enough, retrieve possible cached 1.1290 @@ -1453,7 +1665,7 @@ 1.1291 // are dependent on the changes that were passed in and mark them for 1.1292 // deoptimization. Returns the number of nmethods found. 1.1293 // 1.1294 -int instanceKlass::mark_dependent_nmethods(DepChange& changes) { 1.1295 +int InstanceKlass::mark_dependent_nmethods(DepChange& changes) { 1.1296 assert_locked_or_safepoint(CodeCache_lock); 1.1297 int found = 0; 1.1298 nmethodBucket* b = _dependencies; 1.1299 @@ -1485,7 +1697,7 @@ 1.1300 // so a count is kept for each bucket to guarantee that creation and 1.1301 // deletion of dependencies is consistent. 1.1302 // 1.1303 -void instanceKlass::add_dependent_nmethod(nmethod* nm) { 1.1304 +void InstanceKlass::add_dependent_nmethod(nmethod* nm) { 1.1305 assert_locked_or_safepoint(CodeCache_lock); 1.1306 nmethodBucket* b = _dependencies; 1.1307 nmethodBucket* last = NULL; 1.1308 @@ -1506,7 +1718,7 @@ 1.1309 // find a corresponding bucket otherwise there's a bug in the 1.1310 // recording of dependecies. 1.1311 // 1.1312 -void instanceKlass::remove_dependent_nmethod(nmethod* nm) { 1.1313 +void InstanceKlass::remove_dependent_nmethod(nmethod* nm) { 1.1314 assert_locked_or_safepoint(CodeCache_lock); 1.1315 nmethodBucket* b = _dependencies; 1.1316 nmethodBucket* last = NULL; 1.1317 @@ -1534,7 +1746,7 @@ 1.1318 1.1319 1.1320 #ifndef PRODUCT 1.1321 -void instanceKlass::print_dependent_nmethods(bool verbose) { 1.1322 +void InstanceKlass::print_dependent_nmethods(bool verbose) { 1.1323 nmethodBucket* b = _dependencies; 1.1324 int idx = 0; 1.1325 while (b != NULL) { 1.1326 @@ -1553,7 +1765,7 @@ 1.1327 } 1.1328 1.1329 1.1330 -bool instanceKlass::is_dependent_nmethod(nmethod* nm) { 1.1331 +bool InstanceKlass::is_dependent_nmethod(nmethod* nm) { 1.1332 nmethodBucket* b = _dependencies; 1.1333 while (b != NULL) { 1.1334 if (nm == b->get_nmethod()) { 1.1335 @@ -1566,6 +1778,18 @@ 1.1336 #endif //PRODUCT 1.1337 1.1338 1.1339 +// Garbage collection 1.1340 + 1.1341 +void InstanceKlass::oops_do(OopClosure* cl) { 1.1342 + Klass::oops_do(cl); 1.1343 + 1.1344 + cl->do_oop(adr_protection_domain()); 1.1345 + cl->do_oop(adr_signers()); 1.1346 + cl->do_oop(adr_init_lock()); 1.1347 + 1.1348 + // Don't walk the arrays since they are walked from the ClassLoaderData objects. 1.1349 +} 1.1350 + 1.1351 #ifdef ASSERT 1.1352 template <class T> void assert_is_in(T *p) { 1.1353 T heap_oop = oopDesc::load_heap_oop(p); 1.1354 @@ -1578,7 +1802,8 @@ 1.1355 T heap_oop = oopDesc::load_heap_oop(p); 1.1356 if (!oopDesc::is_null(heap_oop)) { 1.1357 oop o = oopDesc::decode_heap_oop_not_null(heap_oop); 1.1358 - assert(Universe::heap()->is_in_closed_subset(o), "should be in closed"); 1.1359 + assert(Universe::heap()->is_in_closed_subset(o), 1.1360 + err_msg("should be in closed *p " INTPTR_FORMAT " " INTPTR_FORMAT, (address)p, (address)o)); 1.1361 } 1.1362 } 1.1363 template <class T> void assert_is_in_reserved(T *p) { 1.1364 @@ -1732,9 +1957,9 @@ 1.1365 } \ 1.1366 } 1.1367 1.1368 -void instanceKlass::oop_follow_contents(oop obj) { 1.1369 +void InstanceKlass::oop_follow_contents(oop obj) { 1.1370 assert(obj != NULL, "can't follow the content of NULL object"); 1.1371 - obj->follow_header(); 1.1372 + MarkSweep::follow_klass(obj->klass()); 1.1373 InstanceKlass_OOP_MAP_ITERATE( \ 1.1374 obj, \ 1.1375 MarkSweep::mark_and_push(p), \ 1.1376 @@ -1742,10 +1967,12 @@ 1.1377 } 1.1378 1.1379 #ifndef SERIALGC 1.1380 -void instanceKlass::oop_follow_contents(ParCompactionManager* cm, 1.1381 +void InstanceKlass::oop_follow_contents(ParCompactionManager* cm, 1.1382 oop obj) { 1.1383 assert(obj != NULL, "can't follow the content of NULL object"); 1.1384 - obj->follow_header(cm); 1.1385 + PSParallelCompact::follow_klass(cm, obj->klass()); 1.1386 + // Only mark the header and let the scan of the meta-data mark 1.1387 + // everything else. 1.1388 InstanceKlass_OOP_MAP_ITERATE( \ 1.1389 obj, \ 1.1390 PSParallelCompact::mark_and_push(cm, p), \ 1.1391 @@ -1753,16 +1980,22 @@ 1.1392 } 1.1393 #endif // SERIALGC 1.1394 1.1395 -// closure's do_header() method dicates whether the given closure should be 1.1396 +// closure's do_metadata() method dictates whether the given closure should be 1.1397 // applied to the klass ptr in the object header. 1.1398 1.1399 +#define if_do_metadata_checked(closure, nv_suffix) \ 1.1400 + /* Make sure the non-virtual and the virtual versions match. */ \ 1.1401 + assert(closure->do_metadata##nv_suffix() == closure->do_metadata(), \ 1.1402 + "Inconsistency in do_metadata"); \ 1.1403 + if (closure->do_metadata##nv_suffix()) 1.1404 + 1.1405 #define InstanceKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \ 1.1406 \ 1.1407 -int instanceKlass::oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) { \ 1.1408 +int InstanceKlass::oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) { \ 1.1409 SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::ik);\ 1.1410 /* header */ \ 1.1411 - if (closure->do_header()) { \ 1.1412 - obj->oop_iterate_header(closure); \ 1.1413 + if_do_metadata_checked(closure, nv_suffix) { \ 1.1414 + closure->do_klass##nv_suffix(obj->klass()); \ 1.1415 } \ 1.1416 InstanceKlass_OOP_MAP_ITERATE( \ 1.1417 obj, \ 1.1418 @@ -1776,12 +2009,12 @@ 1.1419 #ifndef SERIALGC 1.1420 #define InstanceKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix) \ 1.1421 \ 1.1422 -int instanceKlass::oop_oop_iterate_backwards##nv_suffix(oop obj, \ 1.1423 +int InstanceKlass::oop_oop_iterate_backwards##nv_suffix(oop obj, \ 1.1424 OopClosureType* closure) { \ 1.1425 SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::ik); \ 1.1426 /* header */ \ 1.1427 - if (closure->do_header()) { \ 1.1428 - obj->oop_iterate_header(closure); \ 1.1429 + if_do_metadata_checked(closure, nv_suffix) { \ 1.1430 + closure->do_klass##nv_suffix(obj->klass()); \ 1.1431 } \ 1.1432 /* instance variables */ \ 1.1433 InstanceKlass_OOP_MAP_REVERSE_ITERATE( \ 1.1434 @@ -1795,12 +2028,14 @@ 1.1435 1.1436 #define InstanceKlass_OOP_OOP_ITERATE_DEFN_m(OopClosureType, nv_suffix) \ 1.1437 \ 1.1438 -int instanceKlass::oop_oop_iterate##nv_suffix##_m(oop obj, \ 1.1439 +int InstanceKlass::oop_oop_iterate##nv_suffix##_m(oop obj, \ 1.1440 OopClosureType* closure, \ 1.1441 MemRegion mr) { \ 1.1442 SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::ik);\ 1.1443 - if (closure->do_header()) { \ 1.1444 - obj->oop_iterate_header(closure, mr); \ 1.1445 + if_do_metadata_checked(closure, nv_suffix) { \ 1.1446 + if (mr.contains(obj)) { \ 1.1447 + closure->do_klass##nv_suffix(obj->klass()); \ 1.1448 + } \ 1.1449 } \ 1.1450 InstanceKlass_BOUNDED_OOP_MAP_ITERATE( \ 1.1451 obj, mr.start(), mr.end(), \ 1.1452 @@ -1818,18 +2053,18 @@ 1.1453 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN) 1.1454 #endif // !SERIALGC 1.1455 1.1456 -int instanceKlass::oop_adjust_pointers(oop obj) { 1.1457 +int InstanceKlass::oop_adjust_pointers(oop obj) { 1.1458 int size = size_helper(); 1.1459 InstanceKlass_OOP_MAP_ITERATE( \ 1.1460 obj, \ 1.1461 MarkSweep::adjust_pointer(p), \ 1.1462 assert_is_in) 1.1463 - obj->adjust_header(); 1.1464 + MarkSweep::adjust_klass(obj->klass()); 1.1465 return size; 1.1466 } 1.1467 1.1468 #ifndef SERIALGC 1.1469 -void instanceKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { 1.1470 +void InstanceKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { 1.1471 InstanceKlass_OOP_MAP_REVERSE_ITERATE( \ 1.1472 obj, \ 1.1473 if (PSScavenge::should_scavenge(p)) { \ 1.1474 @@ -1838,51 +2073,128 @@ 1.1475 assert_nothing ) 1.1476 } 1.1477 1.1478 -int instanceKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { 1.1479 +int InstanceKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { 1.1480 + int size = size_helper(); 1.1481 InstanceKlass_OOP_MAP_ITERATE( \ 1.1482 obj, \ 1.1483 PSParallelCompact::adjust_pointer(p), \ 1.1484 - assert_nothing) 1.1485 - return size_helper(); 1.1486 + assert_is_in) 1.1487 + obj->update_header(cm); 1.1488 + return size; 1.1489 } 1.1490 1.1491 #endif // SERIALGC 1.1492 1.1493 -// This klass is alive but the implementor link is not followed/updated. 1.1494 -// Subklass and sibling links are handled by Klass::follow_weak_klass_links 1.1495 - 1.1496 -void instanceKlass::follow_weak_klass_links( 1.1497 - BoolObjectClosure* is_alive, OopClosure* keep_alive) { 1.1498 - assert(is_alive->do_object_b(as_klassOop()), "this oop should be live"); 1.1499 - 1.1500 +void InstanceKlass::clean_implementors_list(BoolObjectClosure* is_alive) { 1.1501 + assert(is_loader_alive(is_alive), "this klass should be live"); 1.1502 if (is_interface()) { 1.1503 if (ClassUnloading) { 1.1504 - klassOop impl = implementor(); 1.1505 + Klass* impl = implementor(); 1.1506 if (impl != NULL) { 1.1507 - if (!is_alive->do_object_b(impl)) { 1.1508 + if (!impl->is_loader_alive(is_alive)) { 1.1509 // remove this guy 1.1510 *adr_implementor() = NULL; 1.1511 } 1.1512 } 1.1513 - } else { 1.1514 - assert(adr_implementor() != NULL, "just checking"); 1.1515 - keep_alive->do_oop(adr_implementor()); 1.1516 } 1.1517 } 1.1518 - 1.1519 - Klass::follow_weak_klass_links(is_alive, keep_alive); 1.1520 } 1.1521 1.1522 -void instanceKlass::remove_unshareable_info() { 1.1523 +void InstanceKlass::clean_method_data(BoolObjectClosure* is_alive) { 1.1524 +#ifdef COMPILER2 1.1525 + // Currently only used by C2. 1.1526 + for (int m = 0; m < methods()->length(); m++) { 1.1527 + MethodData* mdo = methods()->at(m)->method_data(); 1.1528 + if (mdo != NULL) { 1.1529 + for (ProfileData* data = mdo->first_data(); 1.1530 + mdo->is_valid(data); 1.1531 + data = mdo->next_data(data)) { 1.1532 + data->clean_weak_klass_links(is_alive); 1.1533 + } 1.1534 + } 1.1535 + } 1.1536 +#else 1.1537 +#ifdef ASSERT 1.1538 + // Verify that we haven't started to use MDOs for C1. 1.1539 + for (int m = 0; m < methods()->length(); m++) { 1.1540 + MethodData* mdo = methods()->at(m)->method_data(); 1.1541 + assert(mdo == NULL, "Didn't expect C1 to use MDOs"); 1.1542 + } 1.1543 +#endif // ASSERT 1.1544 +#endif // !COMPILER2 1.1545 +} 1.1546 + 1.1547 + 1.1548 +static void remove_unshareable_in_class(Klass* k) { 1.1549 + // remove klass's unshareable info 1.1550 + k->remove_unshareable_info(); 1.1551 +} 1.1552 + 1.1553 +void InstanceKlass::remove_unshareable_info() { 1.1554 Klass::remove_unshareable_info(); 1.1555 + // Unlink the class 1.1556 + if (is_linked()) { 1.1557 + unlink_class(); 1.1558 + } 1.1559 init_implementor(); 1.1560 + 1.1561 + constants()->remove_unshareable_info(); 1.1562 + 1.1563 + for (int i = 0; i < methods()->length(); i++) { 1.1564 + Method* m = methods()->at(i); 1.1565 + m->remove_unshareable_info(); 1.1566 + } 1.1567 + 1.1568 + // Need to reinstate when reading back the class. 1.1569 + set_init_lock(NULL); 1.1570 + 1.1571 + // do array classes also. 1.1572 + array_klasses_do(remove_unshareable_in_class); 1.1573 } 1.1574 1.1575 -static void clear_all_breakpoints(methodOop m) { 1.1576 +void restore_unshareable_in_class(Klass* k, TRAPS) { 1.1577 + k->restore_unshareable_info(CHECK); 1.1578 +} 1.1579 + 1.1580 +void InstanceKlass::restore_unshareable_info(TRAPS) { 1.1581 + Klass::restore_unshareable_info(CHECK); 1.1582 + instanceKlassHandle ik(THREAD, this); 1.1583 + 1.1584 + Array<Method*>* methods = ik->methods(); 1.1585 + int num_methods = methods->length(); 1.1586 + for (int index2 = 0; index2 < num_methods; ++index2) { 1.1587 + methodHandle m(THREAD, methods->at(index2)); 1.1588 + m()->link_method(m, CHECK); 1.1589 + } 1.1590 + if (JvmtiExport::has_redefined_a_class()) { 1.1591 + // Reinitialize vtable because RedefineClasses may have changed some 1.1592 + // entries in this vtable for super classes so the CDS vtable might 1.1593 + // point to old or obsolete entries. RedefineClasses doesn't fix up 1.1594 + // vtables in the shared system dictionary, only the main one. 1.1595 + // It also redefines the itable too so fix that too. 1.1596 + ResourceMark rm(THREAD); 1.1597 + ik->vtable()->initialize_vtable(false, CHECK); 1.1598 + ik->itable()->initialize_itable(false, CHECK); 1.1599 + } 1.1600 + 1.1601 + // Allocate a simple java object for a lock. 1.1602 + // This needs to be a java object because during class initialization 1.1603 + // it can be held across a java call. 1.1604 + typeArrayOop r = oopFactory::new_typeArray(T_INT, 0, CHECK); 1.1605 + Handle h(THREAD, (oop)r); 1.1606 + ik->set_init_lock(h()); 1.1607 + 1.1608 + // restore constant pool resolved references 1.1609 + ik->constants()->restore_unshareable_info(CHECK); 1.1610 + 1.1611 + ik->array_klasses_do(restore_unshareable_in_class, CHECK); 1.1612 +} 1.1613 + 1.1614 +static void clear_all_breakpoints(Method* m) { 1.1615 m->clear_all_breakpoints(); 1.1616 } 1.1617 1.1618 -void instanceKlass::release_C_heap_structures() { 1.1619 +void InstanceKlass::release_C_heap_structures() { 1.1620 // Deallocate oop map cache 1.1621 if (_oop_map_cache != NULL) { 1.1622 delete _oop_map_cache; 1.1623 @@ -1943,18 +2255,15 @@ 1.1624 // class can't be referenced anymore). 1.1625 if (_array_name != NULL) _array_name->decrement_refcount(); 1.1626 if (_source_file_name != NULL) _source_file_name->decrement_refcount(); 1.1627 - // walk constant pool and decrement symbol reference counts 1.1628 - _constants->unreference_symbols(); 1.1629 - 1.1630 if (_source_debug_extension != NULL) FREE_C_HEAP_ARRAY(char, _source_debug_extension, mtClass); 1.1631 } 1.1632 1.1633 -void instanceKlass::set_source_file_name(Symbol* n) { 1.1634 +void InstanceKlass::set_source_file_name(Symbol* n) { 1.1635 _source_file_name = n; 1.1636 if (_source_file_name != NULL) _source_file_name->increment_refcount(); 1.1637 } 1.1638 1.1639 -void instanceKlass::set_source_debug_extension(char* array, int length) { 1.1640 +void InstanceKlass::set_source_debug_extension(char* array, int length) { 1.1641 if (array == NULL) { 1.1642 _source_debug_extension = NULL; 1.1643 } else { 1.1644 @@ -1972,12 +2281,12 @@ 1.1645 } 1.1646 } 1.1647 1.1648 -address instanceKlass::static_field_addr(int offset) { 1.1649 +address InstanceKlass::static_field_addr(int offset) { 1.1650 return (address)(offset + instanceMirrorKlass::offset_of_static_fields() + (intptr_t)java_mirror()); 1.1651 } 1.1652 1.1653 1.1654 -const char* instanceKlass::signature_name() const { 1.1655 +const char* InstanceKlass::signature_name() const { 1.1656 const char* src = (const char*) (name()->as_C_string()); 1.1657 const int src_length = (int)strlen(src); 1.1658 char* dest = NEW_RESOURCE_ARRAY(char, src_length + 3); 1.1659 @@ -1993,9 +2302,9 @@ 1.1660 } 1.1661 1.1662 // different verisons of is_same_class_package 1.1663 -bool instanceKlass::is_same_class_package(klassOop class2) { 1.1664 - klassOop class1 = as_klassOop(); 1.1665 - oop classloader1 = instanceKlass::cast(class1)->class_loader(); 1.1666 +bool InstanceKlass::is_same_class_package(Klass* class2) { 1.1667 + Klass* class1 = this; 1.1668 + oop classloader1 = InstanceKlass::cast(class1)->class_loader(); 1.1669 Symbol* classname1 = Klass::cast(class1)->name(); 1.1670 1.1671 if (Klass::cast(class2)->oop_is_objArray()) { 1.1672 @@ -2003,29 +2312,29 @@ 1.1673 } 1.1674 oop classloader2; 1.1675 if (Klass::cast(class2)->oop_is_instance()) { 1.1676 - classloader2 = instanceKlass::cast(class2)->class_loader(); 1.1677 + classloader2 = InstanceKlass::cast(class2)->class_loader(); 1.1678 } else { 1.1679 assert(Klass::cast(class2)->oop_is_typeArray(), "should be type array"); 1.1680 classloader2 = NULL; 1.1681 } 1.1682 Symbol* classname2 = Klass::cast(class2)->name(); 1.1683 1.1684 - return instanceKlass::is_same_class_package(classloader1, classname1, 1.1685 + return InstanceKlass::is_same_class_package(classloader1, classname1, 1.1686 classloader2, classname2); 1.1687 } 1.1688 1.1689 -bool instanceKlass::is_same_class_package(oop classloader2, Symbol* classname2) { 1.1690 - klassOop class1 = as_klassOop(); 1.1691 - oop classloader1 = instanceKlass::cast(class1)->class_loader(); 1.1692 +bool InstanceKlass::is_same_class_package(oop classloader2, Symbol* classname2) { 1.1693 + Klass* class1 = this; 1.1694 + oop classloader1 = InstanceKlass::cast(class1)->class_loader(); 1.1695 Symbol* classname1 = Klass::cast(class1)->name(); 1.1696 1.1697 - return instanceKlass::is_same_class_package(classloader1, classname1, 1.1698 + return InstanceKlass::is_same_class_package(classloader1, classname1, 1.1699 classloader2, classname2); 1.1700 } 1.1701 1.1702 // return true if two classes are in the same package, classloader 1.1703 // and classname information is enough to determine a class's package 1.1704 -bool instanceKlass::is_same_class_package(oop class_loader1, Symbol* class_name1, 1.1705 +bool InstanceKlass::is_same_class_package(oop class_loader1, Symbol* class_name1, 1.1706 oop class_loader2, Symbol* class_name2) { 1.1707 if (class_loader1 != class_loader2) { 1.1708 return false; 1.1709 @@ -2080,9 +2389,9 @@ 1.1710 // Returns true iff super_method can be overridden by a method in targetclassname 1.1711 // See JSL 3rd edition 8.4.6.1 1.1712 // Assumes name-signature match 1.1713 -// "this" is instanceKlass of super_method which must exist 1.1714 -// note that the instanceKlass of the method in the targetclassname has not always been created yet 1.1715 -bool instanceKlass::is_override(methodHandle super_method, Handle targetclassloader, Symbol* targetclassname, TRAPS) { 1.1716 +// "this" is InstanceKlass of super_method which must exist 1.1717 +// note that the InstanceKlass of the method in the targetclassname has not always been created yet 1.1718 +bool InstanceKlass::is_override(methodHandle super_method, Handle targetclassloader, Symbol* targetclassname, TRAPS) { 1.1719 // Private methods can not be overridden 1.1720 if (super_method->is_private()) { 1.1721 return false; 1.1722 @@ -2098,16 +2407,16 @@ 1.1723 } 1.1724 1.1725 /* defined for now in jvm.cpp, for historical reasons *-- 1.1726 -klassOop instanceKlass::compute_enclosing_class_impl(instanceKlassHandle self, 1.1727 +Klass* InstanceKlass::compute_enclosing_class_impl(instanceKlassHandle self, 1.1728 Symbol*& simple_name_result, TRAPS) { 1.1729 ... 1.1730 } 1.1731 */ 1.1732 1.1733 // tell if two classes have the same enclosing class (at package level) 1.1734 -bool instanceKlass::is_same_package_member_impl(instanceKlassHandle class1, 1.1735 - klassOop class2_oop, TRAPS) { 1.1736 - if (class2_oop == class1->as_klassOop()) return true; 1.1737 +bool InstanceKlass::is_same_package_member_impl(instanceKlassHandle class1, 1.1738 + Klass* class2_oop, TRAPS) { 1.1739 + if (class2_oop == class1()) return true; 1.1740 if (!Klass::cast(class2_oop)->oop_is_instance()) return false; 1.1741 instanceKlassHandle class2(THREAD, class2_oop); 1.1742 1.1743 @@ -2123,7 +2432,7 @@ 1.1744 // Eventually, the walks will terminate as outer1 stops 1.1745 // at the top-level class around the original class. 1.1746 bool ignore_inner_is_member; 1.1747 - klassOop next = outer1->compute_enclosing_class(&ignore_inner_is_member, 1.1748 + Klass* next = outer1->compute_enclosing_class(&ignore_inner_is_member, 1.1749 CHECK_false); 1.1750 if (next == NULL) break; 1.1751 if (next == class2()) return true; 1.1752 @@ -2134,7 +2443,7 @@ 1.1753 instanceKlassHandle outer2 = class2; 1.1754 for (;;) { 1.1755 bool ignore_inner_is_member; 1.1756 - klassOop next = outer2->compute_enclosing_class(&ignore_inner_is_member, 1.1757 + Klass* next = outer2->compute_enclosing_class(&ignore_inner_is_member, 1.1758 CHECK_false); 1.1759 if (next == NULL) break; 1.1760 // Might as well check the new outer against all available values. 1.1761 @@ -2149,12 +2458,11 @@ 1.1762 } 1.1763 1.1764 1.1765 -jint instanceKlass::compute_modifier_flags(TRAPS) const { 1.1766 - klassOop k = as_klassOop(); 1.1767 +jint InstanceKlass::compute_modifier_flags(TRAPS) const { 1.1768 jint access = access_flags().as_int(); 1.1769 1.1770 // But check if it happens to be member class. 1.1771 - instanceKlassHandle ik(THREAD, k); 1.1772 + instanceKlassHandle ik(THREAD, this); 1.1773 InnerClassesIterator iter(ik); 1.1774 for (; !iter.done(); iter.next()) { 1.1775 int ioff = iter.inner_class_info_index(); 1.1776 @@ -2175,7 +2483,7 @@ 1.1777 return (access & (~JVM_ACC_SUPER)) & JVM_ACC_WRITTEN_FLAGS; 1.1778 } 1.1779 1.1780 -jint instanceKlass::jvmti_class_status() const { 1.1781 +jint InstanceKlass::jvmti_class_status() const { 1.1782 jint result = 0; 1.1783 1.1784 if (is_linked()) { 1.1785 @@ -2192,7 +2500,7 @@ 1.1786 return result; 1.1787 } 1.1788 1.1789 -methodOop instanceKlass::method_at_itable(klassOop holder, int index, TRAPS) { 1.1790 +Method* InstanceKlass::method_at_itable(Klass* holder, int index, TRAPS) { 1.1791 itableOffsetEntry* ioe = (itableOffsetEntry*)start_of_itable(); 1.1792 int method_table_offset_in_words = ioe->offset()/wordSize; 1.1793 int nof_interfaces = (method_table_offset_in_words - itable_offset_in_words()) 1.1794 @@ -2202,23 +2510,23 @@ 1.1795 // If the interface isn't implemented by the receiver class, 1.1796 // the VM should throw IncompatibleClassChangeError. 1.1797 if (cnt >= nof_interfaces) { 1.1798 - THROW_0(vmSymbols::java_lang_IncompatibleClassChangeError()); 1.1799 + THROW_NULL(vmSymbols::java_lang_IncompatibleClassChangeError()); 1.1800 } 1.1801 1.1802 - klassOop ik = ioe->interface_klass(); 1.1803 + Klass* ik = ioe->interface_klass(); 1.1804 if (ik == holder) break; 1.1805 } 1.1806 1.1807 - itableMethodEntry* ime = ioe->first_method_entry(as_klassOop()); 1.1808 - methodOop m = ime[index].method(); 1.1809 + itableMethodEntry* ime = ioe->first_method_entry(this); 1.1810 + Method* m = ime[index].method(); 1.1811 if (m == NULL) { 1.1812 - THROW_0(vmSymbols::java_lang_AbstractMethodError()); 1.1813 + THROW_NULL(vmSymbols::java_lang_AbstractMethodError()); 1.1814 } 1.1815 return m; 1.1816 } 1.1817 1.1818 // On-stack replacement stuff 1.1819 -void instanceKlass::add_osr_nmethod(nmethod* n) { 1.1820 +void InstanceKlass::add_osr_nmethod(nmethod* n) { 1.1821 // only one compilation can be active 1.1822 NEEDS_CLEANUP 1.1823 // This is a short non-blocking critical region, so the no safepoint check is ok. 1.1824 @@ -2228,7 +2536,7 @@ 1.1825 set_osr_nmethods_head(n); 1.1826 // Raise the highest osr level if necessary 1.1827 if (TieredCompilation) { 1.1828 - methodOop m = n->method(); 1.1829 + Method* m = n->method(); 1.1830 m->set_highest_osr_comp_level(MAX2(m->highest_osr_comp_level(), n->comp_level())); 1.1831 } 1.1832 // Remember to unlock again 1.1833 @@ -2246,14 +2554,14 @@ 1.1834 } 1.1835 1.1836 1.1837 -void instanceKlass::remove_osr_nmethod(nmethod* n) { 1.1838 +void InstanceKlass::remove_osr_nmethod(nmethod* n) { 1.1839 // This is a short non-blocking critical region, so the no safepoint check is ok. 1.1840 OsrList_lock->lock_without_safepoint_check(); 1.1841 assert(n->is_osr_method(), "wrong kind of nmethod"); 1.1842 nmethod* last = NULL; 1.1843 nmethod* cur = osr_nmethods_head(); 1.1844 int max_level = CompLevel_none; // Find the max comp level excluding n 1.1845 - methodOop m = n->method(); 1.1846 + Method* m = n->method(); 1.1847 // Search for match 1.1848 while(cur != NULL && cur != n) { 1.1849 if (TieredCompilation) { 1.1850 @@ -2287,7 +2595,7 @@ 1.1851 OsrList_lock->unlock(); 1.1852 } 1.1853 1.1854 -nmethod* instanceKlass::lookup_osr_nmethod(const methodOop m, int bci, int comp_level, bool match_level) const { 1.1855 +nmethod* InstanceKlass::lookup_osr_nmethod(Method* const m, int bci, int comp_level, bool match_level) const { 1.1856 // This is a short non-blocking critical region, so the no safepoint check is ok. 1.1857 OsrList_lock->lock_without_safepoint_check(); 1.1858 nmethod* osr = osr_nmethods_head(); 1.1859 @@ -2329,12 +2637,135 @@ 1.1860 } 1.1861 1.1862 // ----------------------------------------------------------------------------------------------------- 1.1863 +// Printing 1.1864 + 1.1865 #ifndef PRODUCT 1.1866 1.1867 -// Printing 1.1868 - 1.1869 #define BULLET " - " 1.1870 1.1871 +static const char* state_names[] = { 1.1872 + "allocated", "loaded", "linked", "being_initialized", "fully_initialized", "initialization_error" 1.1873 +}; 1.1874 + 1.1875 +void InstanceKlass::print_on(outputStream* st) const { 1.1876 + assert(is_klass(), "must be klass"); 1.1877 + Klass::print_on(st); 1.1878 + 1.1879 + st->print(BULLET"instance size: %d", size_helper()); st->cr(); 1.1880 + st->print(BULLET"klass size: %d", size()); st->cr(); 1.1881 + st->print(BULLET"access: "); access_flags().print_on(st); st->cr(); 1.1882 + st->print(BULLET"state: "); st->print_cr(state_names[_init_state]); 1.1883 + st->print(BULLET"name: "); name()->print_value_on(st); st->cr(); 1.1884 + st->print(BULLET"super: "); super()->print_value_on_maybe_null(st); st->cr(); 1.1885 + st->print(BULLET"sub: "); 1.1886 + Klass* sub = subklass(); 1.1887 + int n; 1.1888 + for (n = 0; sub != NULL; n++, sub = sub->next_sibling()) { 1.1889 + if (n < MaxSubklassPrintSize) { 1.1890 + sub->print_value_on(st); 1.1891 + st->print(" "); 1.1892 + } 1.1893 + } 1.1894 + if (n >= MaxSubklassPrintSize) st->print("(%d more klasses...)", n - MaxSubklassPrintSize); 1.1895 + st->cr(); 1.1896 + 1.1897 + if (is_interface()) { 1.1898 + st->print_cr(BULLET"nof implementors: %d", nof_implementors()); 1.1899 + if (nof_implementors() == 1) { 1.1900 + st->print_cr(BULLET"implementor: "); 1.1901 + st->print(" "); 1.1902 + implementor()->print_value_on(st); 1.1903 + st->cr(); 1.1904 + } 1.1905 + } 1.1906 + 1.1907 + st->print(BULLET"arrays: "); array_klasses()->print_value_on_maybe_null(st); st->cr(); 1.1908 + st->print(BULLET"methods: "); methods()->print_value_on(st); st->cr(); 1.1909 + if (Verbose) { 1.1910 + Array<Method*>* method_array = methods(); 1.1911 + for(int i = 0; i < method_array->length(); i++) { 1.1912 + st->print("%d : ", i); method_array->at(i)->print_value(); st->cr(); 1.1913 + } 1.1914 + } 1.1915 + st->print(BULLET"method ordering: "); method_ordering()->print_value_on(st); st->cr(); 1.1916 + st->print(BULLET"local interfaces: "); local_interfaces()->print_value_on(st); st->cr(); 1.1917 + st->print(BULLET"trans. interfaces: "); transitive_interfaces()->print_value_on(st); st->cr(); 1.1918 + st->print(BULLET"constants: "); constants()->print_value_on(st); st->cr(); 1.1919 + if (class_loader_data() != NULL) { 1.1920 + st->print(BULLET"class loader data: "); 1.1921 + class_loader_data()->print_value_on(st); 1.1922 + st->cr(); 1.1923 + } 1.1924 + st->print(BULLET"protection domain: "); ((InstanceKlass*)this)->protection_domain()->print_value_on(st); st->cr(); 1.1925 + st->print(BULLET"host class: "); host_klass()->print_value_on_maybe_null(st); st->cr(); 1.1926 + st->print(BULLET"signers: "); signers()->print_value_on(st); st->cr(); 1.1927 + st->print(BULLET"init_lock: "); ((oop)init_lock())->print_value_on(st); st->cr(); 1.1928 + if (source_file_name() != NULL) { 1.1929 + st->print(BULLET"source file: "); 1.1930 + source_file_name()->print_value_on(st); 1.1931 + st->cr(); 1.1932 + } 1.1933 + if (source_debug_extension() != NULL) { 1.1934 + st->print(BULLET"source debug extension: "); 1.1935 + st->print("%s", source_debug_extension()); 1.1936 + st->cr(); 1.1937 + } 1.1938 + st->print(BULLET"annotations: "); annotations()->print_value_on(st); st->cr(); 1.1939 + { 1.1940 + ResourceMark rm; 1.1941 + // PreviousVersionInfo objects returned via PreviousVersionWalker 1.1942 + // contain a GrowableArray of handles. We have to clean up the 1.1943 + // GrowableArray _after_ the PreviousVersionWalker destructor 1.1944 + // has destroyed the handles. 1.1945 + { 1.1946 + bool have_pv = false; 1.1947 + PreviousVersionWalker pvw((InstanceKlass*)this); 1.1948 + for (PreviousVersionInfo * pv_info = pvw.next_previous_version(); 1.1949 + pv_info != NULL; pv_info = pvw.next_previous_version()) { 1.1950 + if (!have_pv) 1.1951 + st->print(BULLET"previous version: "); 1.1952 + have_pv = true; 1.1953 + pv_info->prev_constant_pool_handle()()->print_value_on(st); 1.1954 + } 1.1955 + if (have_pv) st->cr(); 1.1956 + } // pvw is cleaned up 1.1957 + } // rm is cleaned up 1.1958 + 1.1959 + if (generic_signature() != NULL) { 1.1960 + st->print(BULLET"generic signature: "); 1.1961 + generic_signature()->print_value_on(st); 1.1962 + st->cr(); 1.1963 + } 1.1964 + st->print(BULLET"inner classes: "); inner_classes()->print_value_on(st); st->cr(); 1.1965 + st->print(BULLET"java mirror: "); java_mirror()->print_value_on(st); st->cr(); 1.1966 + st->print(BULLET"vtable length %d (start addr: " INTPTR_FORMAT ")", vtable_length(), start_of_vtable()); st->cr(); 1.1967 + st->print(BULLET"itable length %d (start addr: " INTPTR_FORMAT ")", itable_length(), start_of_itable()); st->cr(); 1.1968 + st->print_cr(BULLET"---- static fields (%d words):", static_field_size()); 1.1969 + FieldPrinter print_static_field(st); 1.1970 + ((InstanceKlass*)this)->do_local_static_fields(&print_static_field); 1.1971 + st->print_cr(BULLET"---- non-static fields (%d words):", nonstatic_field_size()); 1.1972 + FieldPrinter print_nonstatic_field(st); 1.1973 + ((InstanceKlass*)this)->do_nonstatic_fields(&print_nonstatic_field); 1.1974 + 1.1975 + st->print(BULLET"non-static oop maps: "); 1.1976 + OopMapBlock* map = start_of_nonstatic_oop_maps(); 1.1977 + OopMapBlock* end_map = map + nonstatic_oop_map_count(); 1.1978 + while (map < end_map) { 1.1979 + st->print("%d-%d ", map->offset(), map->offset() + heapOopSize*(map->count() - 1)); 1.1980 + map++; 1.1981 + } 1.1982 + st->cr(); 1.1983 +} 1.1984 + 1.1985 +#endif //PRODUCT 1.1986 + 1.1987 +void InstanceKlass::print_value_on(outputStream* st) const { 1.1988 + assert(is_klass(), "must be klass"); 1.1989 + name()->print_value_on(st); 1.1990 +} 1.1991 + 1.1992 +#ifndef PRODUCT 1.1993 + 1.1994 void FieldPrinter::do_field(fieldDescriptor* fd) { 1.1995 _st->print(BULLET); 1.1996 if (_obj == NULL) { 1.1997 @@ -2347,10 +2778,10 @@ 1.1998 } 1.1999 1.2000 1.2001 -void instanceKlass::oop_print_on(oop obj, outputStream* st) { 1.2002 +void InstanceKlass::oop_print_on(oop obj, outputStream* st) { 1.2003 Klass::oop_print_on(obj, st); 1.2004 1.2005 - if (as_klassOop() == SystemDictionary::String_klass()) { 1.2006 + if (this == SystemDictionary::String_klass()) { 1.2007 typeArrayOop value = java_lang_String::value(obj); 1.2008 juint offset = java_lang_String::offset(obj); 1.2009 juint length = java_lang_String::length(obj); 1.2010 @@ -2370,29 +2801,29 @@ 1.2011 FieldPrinter print_field(st, obj); 1.2012 do_nonstatic_fields(&print_field); 1.2013 1.2014 - if (as_klassOop() == SystemDictionary::Class_klass()) { 1.2015 + if (this == SystemDictionary::Class_klass()) { 1.2016 st->print(BULLET"signature: "); 1.2017 java_lang_Class::print_signature(obj, st); 1.2018 st->cr(); 1.2019 - klassOop mirrored_klass = java_lang_Class::as_klassOop(obj); 1.2020 + Klass* mirrored_klass = java_lang_Class::as_Klass(obj); 1.2021 st->print(BULLET"fake entry for mirror: "); 1.2022 - mirrored_klass->print_value_on(st); 1.2023 + mirrored_klass->print_value_on_maybe_null(st); 1.2024 st->cr(); 1.2025 st->print(BULLET"fake entry resolved_constructor: "); 1.2026 - methodOop ctor = java_lang_Class::resolved_constructor(obj); 1.2027 - ctor->print_value_on(st); 1.2028 - klassOop array_klass = java_lang_Class::array_klass(obj); 1.2029 + Method* ctor = java_lang_Class::resolved_constructor(obj); 1.2030 + ctor->print_value_on_maybe_null(st); 1.2031 + Klass* array_klass = java_lang_Class::array_klass(obj); 1.2032 st->cr(); 1.2033 st->print(BULLET"fake entry for array: "); 1.2034 - array_klass->print_value_on(st); 1.2035 + array_klass->print_value_on_maybe_null(st); 1.2036 st->cr(); 1.2037 st->print_cr(BULLET"fake entry for oop_size: %d", java_lang_Class::oop_size(obj)); 1.2038 st->print_cr(BULLET"fake entry for static_oop_field_count: %d", java_lang_Class::static_oop_field_count(obj)); 1.2039 - klassOop real_klass = java_lang_Class::as_klassOop(obj); 1.2040 - if (real_klass != NULL && real_klass->klass_part()->oop_is_instance()) { 1.2041 - instanceKlass::cast(real_klass)->do_local_static_fields(&print_field); 1.2042 + Klass* real_klass = java_lang_Class::as_Klass(obj); 1.2043 + if (real_klass != NULL && real_klass->oop_is_instance()) { 1.2044 + InstanceKlass::cast(real_klass)->do_local_static_fields(&print_field); 1.2045 } 1.2046 - } else if (as_klassOop() == SystemDictionary::MethodType_klass()) { 1.2047 + } else if (this == SystemDictionary::MethodType_klass()) { 1.2048 st->print(BULLET"signature: "); 1.2049 java_lang_invoke_MethodType::print_signature(obj, st); 1.2050 st->cr(); 1.2051 @@ -2401,11 +2832,11 @@ 1.2052 1.2053 #endif //PRODUCT 1.2054 1.2055 -void instanceKlass::oop_print_value_on(oop obj, outputStream* st) { 1.2056 +void InstanceKlass::oop_print_value_on(oop obj, outputStream* st) { 1.2057 st->print("a "); 1.2058 name()->print_value_on(st); 1.2059 obj->print_address_on(st); 1.2060 - if (as_klassOop() == SystemDictionary::String_klass() 1.2061 + if (this == SystemDictionary::String_klass() 1.2062 && java_lang_String::value(obj) != NULL) { 1.2063 ResourceMark rm; 1.2064 int len = java_lang_String::length(obj); 1.2065 @@ -2414,8 +2845,8 @@ 1.2066 st->print(" = \"%s\"", str); 1.2067 if (len > plen) 1.2068 st->print("...[%d]", len); 1.2069 - } else if (as_klassOop() == SystemDictionary::Class_klass()) { 1.2070 - klassOop k = java_lang_Class::as_klassOop(obj); 1.2071 + } else if (this == SystemDictionary::Class_klass()) { 1.2072 + Klass* k = java_lang_Class::as_Klass(obj); 1.2073 st->print(" = "); 1.2074 if (k != NULL) { 1.2075 k->print_value_on(st); 1.2076 @@ -2423,20 +2854,20 @@ 1.2077 const char* tname = type2name(java_lang_Class::primitive_type(obj)); 1.2078 st->print("%s", tname ? tname : "type?"); 1.2079 } 1.2080 - } else if (as_klassOop() == SystemDictionary::MethodType_klass()) { 1.2081 + } else if (this == SystemDictionary::MethodType_klass()) { 1.2082 st->print(" = "); 1.2083 java_lang_invoke_MethodType::print_signature(obj, st); 1.2084 } else if (java_lang_boxing_object::is_instance(obj)) { 1.2085 st->print(" = "); 1.2086 java_lang_boxing_object::print(obj, st); 1.2087 - } else if (as_klassOop() == SystemDictionary::LambdaForm_klass()) { 1.2088 + } else if (this == SystemDictionary::LambdaForm_klass()) { 1.2089 oop vmentry = java_lang_invoke_LambdaForm::vmentry(obj); 1.2090 if (vmentry != NULL) { 1.2091 st->print(" => "); 1.2092 vmentry->print_value_on(st); 1.2093 } 1.2094 - } else if (as_klassOop() == SystemDictionary::MemberName_klass()) { 1.2095 - oop vmtarget = java_lang_invoke_MemberName::vmtarget(obj); 1.2096 + } else if (this == SystemDictionary::MemberName_klass()) { 1.2097 + Metadata* vmtarget = java_lang_invoke_MemberName::vmtarget(obj); 1.2098 if (vmtarget != NULL) { 1.2099 st->print(" = "); 1.2100 vmtarget->print_value_on(st); 1.2101 @@ -2448,7 +2879,7 @@ 1.2102 } 1.2103 } 1.2104 1.2105 -const char* instanceKlass::internal_name() const { 1.2106 +const char* InstanceKlass::internal_name() const { 1.2107 return external_name(); 1.2108 } 1.2109 1.2110 @@ -2457,7 +2888,6 @@ 1.2111 class VerifyFieldClosure: public OopClosure { 1.2112 protected: 1.2113 template <class T> void do_oop_work(T* p) { 1.2114 - guarantee(Universe::heap()->is_in_closed_subset(p), "should be in heap"); 1.2115 oop obj = oopDesc::load_decode_heap_oop(p); 1.2116 if (!obj->is_oop_or_null()) { 1.2117 tty->print_cr("Failed: " PTR_FORMAT " -> " PTR_FORMAT, p, (address)obj); 1.2118 @@ -2470,17 +2900,151 @@ 1.2119 virtual void do_oop(narrowOop* p) { VerifyFieldClosure::do_oop_work(p); } 1.2120 }; 1.2121 1.2122 -void instanceKlass::oop_verify_on(oop obj, outputStream* st) { 1.2123 +void InstanceKlass::verify_on(outputStream* st) { 1.2124 + Klass::verify_on(st); 1.2125 + Thread *thread = Thread::current(); 1.2126 + 1.2127 +#ifndef PRODUCT 1.2128 + // Avoid redundant verifies 1.2129 + if (_verify_count == Universe::verify_count()) return; 1.2130 + _verify_count = Universe::verify_count(); 1.2131 +#endif 1.2132 + // Verify that klass is present in SystemDictionary 1.2133 + if (is_loaded() && !is_anonymous()) { 1.2134 + Symbol* h_name = name(); 1.2135 + SystemDictionary::verify_obj_klass_present(h_name, class_loader_data()); 1.2136 + } 1.2137 + 1.2138 + // Verify static fields 1.2139 + VerifyFieldClosure blk; 1.2140 + 1.2141 + // Verify vtables 1.2142 + if (is_linked()) { 1.2143 + ResourceMark rm(thread); 1.2144 + // $$$ This used to be done only for m/s collections. Doing it 1.2145 + // always seemed a valid generalization. (DLD -- 6/00) 1.2146 + vtable()->verify(st); 1.2147 + } 1.2148 + 1.2149 + // Verify first subklass 1.2150 + if (subklass_oop() != NULL) { 1.2151 + guarantee(subklass_oop()->is_metadata(), "should be in metaspace"); 1.2152 + guarantee(subklass_oop()->is_klass(), "should be klass"); 1.2153 + } 1.2154 + 1.2155 + // Verify siblings 1.2156 + Klass* super = this->super(); 1.2157 + Klass* sib = next_sibling(); 1.2158 + if (sib != NULL) { 1.2159 + if (sib == this) { 1.2160 + fatal(err_msg("subclass points to itself " PTR_FORMAT, sib)); 1.2161 + } 1.2162 + 1.2163 + guarantee(sib->is_metadata(), "should be in metaspace"); 1.2164 + guarantee(sib->is_klass(), "should be klass"); 1.2165 + guarantee(sib->super() == super, "siblings should have same superklass"); 1.2166 + } 1.2167 + 1.2168 + // Verify implementor fields 1.2169 + Klass* im = implementor(); 1.2170 + if (im != NULL) { 1.2171 + guarantee(is_interface(), "only interfaces should have implementor set"); 1.2172 + guarantee(im->is_klass(), "should be klass"); 1.2173 + guarantee(!Klass::cast(im)->is_interface() || im == this, 1.2174 + "implementors cannot be interfaces"); 1.2175 + } 1.2176 + 1.2177 + // Verify local interfaces 1.2178 + if (local_interfaces()) { 1.2179 + Array<Klass*>* local_interfaces = this->local_interfaces(); 1.2180 + for (int j = 0; j < local_interfaces->length(); j++) { 1.2181 + Klass* e = local_interfaces->at(j); 1.2182 + guarantee(e->is_klass() && Klass::cast(e)->is_interface(), "invalid local interface"); 1.2183 + } 1.2184 + } 1.2185 + 1.2186 + // Verify transitive interfaces 1.2187 + if (transitive_interfaces() != NULL) { 1.2188 + Array<Klass*>* transitive_interfaces = this->transitive_interfaces(); 1.2189 + for (int j = 0; j < transitive_interfaces->length(); j++) { 1.2190 + Klass* e = transitive_interfaces->at(j); 1.2191 + guarantee(e->is_klass() && Klass::cast(e)->is_interface(), "invalid transitive interface"); 1.2192 + } 1.2193 + } 1.2194 + 1.2195 + // Verify methods 1.2196 + if (methods() != NULL) { 1.2197 + Array<Method*>* methods = this->methods(); 1.2198 + for (int j = 0; j < methods->length(); j++) { 1.2199 + guarantee(methods->at(j)->is_metadata(), "should be in metaspace"); 1.2200 + guarantee(methods->at(j)->is_method(), "non-method in methods array"); 1.2201 + } 1.2202 + for (int j = 0; j < methods->length() - 1; j++) { 1.2203 + Method* m1 = methods->at(j); 1.2204 + Method* m2 = methods->at(j + 1); 1.2205 + guarantee(m1->name()->fast_compare(m2->name()) <= 0, "methods not sorted correctly"); 1.2206 + } 1.2207 + } 1.2208 + 1.2209 + // Verify method ordering 1.2210 + if (method_ordering() != NULL) { 1.2211 + Array<int>* method_ordering = this->method_ordering(); 1.2212 + int length = method_ordering->length(); 1.2213 + if (JvmtiExport::can_maintain_original_method_order() || 1.2214 + (UseSharedSpaces && length != 0)) { 1.2215 + guarantee(length == methods()->length(), "invalid method ordering length"); 1.2216 + jlong sum = 0; 1.2217 + for (int j = 0; j < length; j++) { 1.2218 + int original_index = method_ordering->at(j); 1.2219 + guarantee(original_index >= 0, "invalid method ordering index"); 1.2220 + guarantee(original_index < length, "invalid method ordering index"); 1.2221 + sum += original_index; 1.2222 + } 1.2223 + // Verify sum of indices 0,1,...,length-1 1.2224 + guarantee(sum == ((jlong)length*(length-1))/2, "invalid method ordering sum"); 1.2225 + } else { 1.2226 + guarantee(length == 0, "invalid method ordering length"); 1.2227 + } 1.2228 + } 1.2229 + 1.2230 + // Verify JNI static field identifiers 1.2231 + if (jni_ids() != NULL) { 1.2232 + jni_ids()->verify(this); 1.2233 + } 1.2234 + 1.2235 + // Verify other fields 1.2236 + if (array_klasses() != NULL) { 1.2237 + guarantee(array_klasses()->is_metadata(), "should be in metaspace"); 1.2238 + guarantee(array_klasses()->is_klass(), "should be klass"); 1.2239 + } 1.2240 + if (constants() != NULL) { 1.2241 + guarantee(constants()->is_metadata(), "should be in metaspace"); 1.2242 + guarantee(constants()->is_constantPool(), "should be constant pool"); 1.2243 + } 1.2244 + if (protection_domain() != NULL) { 1.2245 + guarantee(protection_domain()->is_oop(), "should be oop"); 1.2246 + } 1.2247 + if (host_klass() != NULL) { 1.2248 + guarantee(host_klass()->is_metadata(), "should be in metaspace"); 1.2249 + guarantee(host_klass()->is_klass(), "should be klass"); 1.2250 + } 1.2251 + if (signers() != NULL) { 1.2252 + guarantee(signers()->is_objArray(), "should be obj array"); 1.2253 + } 1.2254 +} 1.2255 + 1.2256 +void InstanceKlass::oop_verify_on(oop obj, outputStream* st) { 1.2257 Klass::oop_verify_on(obj, st); 1.2258 VerifyFieldClosure blk; 1.2259 - oop_oop_iterate(obj, &blk); 1.2260 + obj->oop_iterate_no_header(&blk); 1.2261 } 1.2262 1.2263 + 1.2264 // JNIid class for jfieldIDs only 1.2265 // Note to reviewers: 1.2266 // These JNI functions are just moved over to column 1 and not changed 1.2267 // in the compressed oops workspace. 1.2268 -JNIid::JNIid(klassOop holder, int offset, JNIid* next) { 1.2269 +JNIid::JNIid(Klass* holder, int offset, JNIid* next) { 1.2270 _holder = holder; 1.2271 _offset = offset; 1.2272 _next = next; 1.2273 @@ -2497,12 +3061,6 @@ 1.2274 return NULL; 1.2275 } 1.2276 1.2277 -void JNIid::oops_do(OopClosure* f) { 1.2278 - for (JNIid* cur = this; cur != NULL; cur = cur->next()) { 1.2279 - f->do_oop(cur->holder_addr()); 1.2280 - } 1.2281 -} 1.2282 - 1.2283 void JNIid::deallocate(JNIid* current) { 1.2284 while (current != NULL) { 1.2285 JNIid* next = current->next(); 1.2286 @@ -2512,10 +3070,10 @@ 1.2287 } 1.2288 1.2289 1.2290 -void JNIid::verify(klassOop holder) { 1.2291 +void JNIid::verify(Klass* holder) { 1.2292 int first_field_offset = instanceMirrorKlass::offset_of_static_fields(); 1.2293 int end_field_offset; 1.2294 - end_field_offset = first_field_offset + (instanceKlass::cast(holder)->static_field_size() * wordSize); 1.2295 + end_field_offset = first_field_offset + (InstanceKlass::cast(holder)->static_field_size() * wordSize); 1.2296 1.2297 JNIid* current = this; 1.2298 while (current != NULL) { 1.2299 @@ -2532,8 +3090,8 @@ 1.2300 1.2301 1.2302 #ifdef ASSERT 1.2303 -void instanceKlass::set_init_state(ClassState state) { 1.2304 - bool good_state = as_klassOop()->is_shared() ? (_init_state <= state) 1.2305 +void InstanceKlass::set_init_state(ClassState state) { 1.2306 + bool good_state = is_shared() ? (_init_state <= state) 1.2307 : (_init_state < state); 1.2308 assert(good_state || state == allocated, "illegal state transition"); 1.2309 _init_state = (u1)state; 1.2310 @@ -2543,14 +3101,105 @@ 1.2311 1.2312 // RedefineClasses() support for previous versions: 1.2313 1.2314 -// Add an information node that contains weak references to the 1.2315 +// Purge previous versions 1.2316 +static void purge_previous_versions_internal(InstanceKlass* ik, int emcp_method_count) { 1.2317 + if (ik->previous_versions() != NULL) { 1.2318 + // This klass has previous versions so see what we can cleanup 1.2319 + // while it is safe to do so. 1.2320 + 1.2321 + int deleted_count = 0; // leave debugging breadcrumbs 1.2322 + int live_count = 0; 1.2323 + ClassLoaderData* loader_data = ik->class_loader_data() == NULL ? 1.2324 + ClassLoaderData::the_null_class_loader_data() : 1.2325 + ik->class_loader_data(); 1.2326 + 1.2327 + // RC_TRACE macro has an embedded ResourceMark 1.2328 + RC_TRACE(0x00000200, ("purge: %s: previous version length=%d", 1.2329 + ik->external_name(), ik->previous_versions()->length())); 1.2330 + 1.2331 + for (int i = ik->previous_versions()->length() - 1; i >= 0; i--) { 1.2332 + // check the previous versions array 1.2333 + PreviousVersionNode * pv_node = ik->previous_versions()->at(i); 1.2334 + ConstantPool* cp_ref = pv_node->prev_constant_pool(); 1.2335 + assert(cp_ref != NULL, "cp ref was unexpectedly cleared"); 1.2336 + 1.2337 + ConstantPool* pvcp = cp_ref; 1.2338 + if (!pvcp->on_stack()) { 1.2339 + // If the constant pool isn't on stack, none of the methods 1.2340 + // are executing. Delete all the methods, the constant pool and 1.2341 + // and this previous version node. 1.2342 + GrowableArray<Method*>* method_refs = pv_node->prev_EMCP_methods(); 1.2343 + if (method_refs != NULL) { 1.2344 + for (int j = method_refs->length() - 1; j >= 0; j--) { 1.2345 + Method* method = method_refs->at(j); 1.2346 + assert(method != NULL, "method ref was unexpectedly cleared"); 1.2347 + method_refs->remove_at(j); 1.2348 + // method will be freed with associated class. 1.2349 + } 1.2350 + } 1.2351 + // Remove the constant pool 1.2352 + delete pv_node; 1.2353 + // Since we are traversing the array backwards, we don't have to 1.2354 + // do anything special with the index. 1.2355 + ik->previous_versions()->remove_at(i); 1.2356 + deleted_count++; 1.2357 + continue; 1.2358 + } else { 1.2359 + RC_TRACE(0x00000200, ("purge: previous version @%d is alive", i)); 1.2360 + assert(pvcp->pool_holder() != NULL, "Constant pool with no holder"); 1.2361 + guarantee (!loader_data->is_unloading(), "unloaded classes can't be on the stack"); 1.2362 + live_count++; 1.2363 + } 1.2364 + 1.2365 + // At least one method is live in this previous version, clean out 1.2366 + // the others or mark them as obsolete. 1.2367 + GrowableArray<Method*>* method_refs = pv_node->prev_EMCP_methods(); 1.2368 + if (method_refs != NULL) { 1.2369 + RC_TRACE(0x00000200, ("purge: previous methods length=%d", 1.2370 + method_refs->length())); 1.2371 + for (int j = method_refs->length() - 1; j >= 0; j--) { 1.2372 + Method* method = method_refs->at(j); 1.2373 + assert(method != NULL, "method ref was unexpectedly cleared"); 1.2374 + 1.2375 + // Remove the emcp method if it's not executing 1.2376 + // If it's been made obsolete by a redefinition of a non-emcp 1.2377 + // method, mark it as obsolete but leave it to clean up later. 1.2378 + if (!method->on_stack()) { 1.2379 + method_refs->remove_at(j); 1.2380 + } else if (emcp_method_count == 0) { 1.2381 + method->set_is_obsolete(); 1.2382 + } else { 1.2383 + // RC_TRACE macro has an embedded ResourceMark 1.2384 + RC_TRACE(0x00000200, 1.2385 + ("purge: %s(%s): prev method @%d in version @%d is alive", 1.2386 + method->name()->as_C_string(), 1.2387 + method->signature()->as_C_string(), j, i)); 1.2388 + } 1.2389 + } 1.2390 + } 1.2391 + } 1.2392 + assert(ik->previous_versions()->length() == live_count, "sanity check"); 1.2393 + RC_TRACE(0x00000200, 1.2394 + ("purge: previous version stats: live=%d, deleted=%d", live_count, 1.2395 + deleted_count)); 1.2396 + } 1.2397 +} 1.2398 + 1.2399 +// External interface for use during class unloading. 1.2400 +void InstanceKlass::purge_previous_versions(InstanceKlass* ik) { 1.2401 + // Call with >0 emcp methods since they are not currently being redefined. 1.2402 + purge_previous_versions_internal(ik, 1); 1.2403 +} 1.2404 + 1.2405 + 1.2406 +// Potentially add an information node that contains pointers to the 1.2407 // interesting parts of the previous version of the_class. 1.2408 -// This is also where we clean out any unused weak references. 1.2409 +// This is also where we clean out any unused references. 1.2410 // Note that while we delete nodes from the _previous_versions 1.2411 // array, we never delete the array itself until the klass is 1.2412 // unloaded. The has_been_redefined() query depends on that fact. 1.2413 // 1.2414 -void instanceKlass::add_previous_version(instanceKlassHandle ikh, 1.2415 +void InstanceKlass::add_previous_version(instanceKlassHandle ikh, 1.2416 BitMap* emcp_methods, int emcp_method_count) { 1.2417 assert(Thread::current()->is_VM_thread(), 1.2418 "only VMThread can add previous versions"); 1.2419 @@ -2563,155 +3212,81 @@ 1.2420 GrowableArray<PreviousVersionNode *>(2, true); 1.2421 } 1.2422 1.2423 + ConstantPool* cp_ref = ikh->constants(); 1.2424 + 1.2425 // RC_TRACE macro has an embedded ResourceMark 1.2426 - RC_TRACE(0x00000100, ("adding previous version ref for %s @%d, EMCP_cnt=%d", 1.2427 - ikh->external_name(), _previous_versions->length(), emcp_method_count)); 1.2428 - constantPoolHandle cp_h(ikh->constants()); 1.2429 - jobject cp_ref; 1.2430 - if (cp_h->is_shared()) { 1.2431 - // a shared ConstantPool requires a regular reference; a weak 1.2432 - // reference would be collectible 1.2433 - cp_ref = JNIHandles::make_global(cp_h); 1.2434 - } else { 1.2435 - cp_ref = JNIHandles::make_weak_global(cp_h); 1.2436 - } 1.2437 + RC_TRACE(0x00000400, ("adding previous version ref for %s @%d, EMCP_cnt=%d " 1.2438 + "on_stack=%d", 1.2439 + ikh->external_name(), _previous_versions->length(), emcp_method_count, 1.2440 + cp_ref->on_stack())); 1.2441 + 1.2442 + // If the constant pool for this previous version of the class 1.2443 + // is not marked as being on the stack, then none of the methods 1.2444 + // in this previous version of the class are on the stack so 1.2445 + // we don't need to create a new PreviousVersionNode. However, 1.2446 + // we still need to examine older previous versions below. 1.2447 + Array<Method*>* old_methods = ikh->methods(); 1.2448 + 1.2449 + if (cp_ref->on_stack()) { 1.2450 PreviousVersionNode * pv_node = NULL; 1.2451 - objArrayOop old_methods = ikh->methods(); 1.2452 - 1.2453 if (emcp_method_count == 0) { 1.2454 - // non-shared ConstantPool gets a weak reference 1.2455 - pv_node = new PreviousVersionNode(cp_ref, !cp_h->is_shared(), NULL); 1.2456 + // non-shared ConstantPool gets a reference 1.2457 + pv_node = new PreviousVersionNode(cp_ref, !cp_ref->is_shared(), NULL); 1.2458 RC_TRACE(0x00000400, 1.2459 - ("add: all methods are obsolete; flushing any EMCP weak refs")); 1.2460 + ("add: all methods are obsolete; flushing any EMCP refs")); 1.2461 } else { 1.2462 int local_count = 0; 1.2463 - GrowableArray<jweak>* method_refs = new (ResourceObj::C_HEAP, mtClass) 1.2464 - GrowableArray<jweak>(emcp_method_count, true); 1.2465 + GrowableArray<Method*>* method_refs = new (ResourceObj::C_HEAP, mtClass) 1.2466 + GrowableArray<Method*>(emcp_method_count, true); 1.2467 for (int i = 0; i < old_methods->length(); i++) { 1.2468 if (emcp_methods->at(i)) { 1.2469 - // this old method is EMCP so save a weak ref 1.2470 - methodOop old_method = (methodOop) old_methods->obj_at(i); 1.2471 - methodHandle old_method_h(old_method); 1.2472 - jweak method_ref = JNIHandles::make_weak_global(old_method_h); 1.2473 - method_refs->append(method_ref); 1.2474 + // this old method is EMCP. Save it only if it's on the stack 1.2475 + Method* old_method = old_methods->at(i); 1.2476 + if (old_method->on_stack()) { 1.2477 + method_refs->append(old_method); 1.2478 + } 1.2479 if (++local_count >= emcp_method_count) { 1.2480 // no more EMCP methods so bail out now 1.2481 break; 1.2482 } 1.2483 } 1.2484 } 1.2485 - // non-shared ConstantPool gets a weak reference 1.2486 - pv_node = new PreviousVersionNode(cp_ref, !cp_h->is_shared(), method_refs); 1.2487 + // non-shared ConstantPool gets a reference 1.2488 + pv_node = new PreviousVersionNode(cp_ref, !cp_ref->is_shared(), method_refs); 1.2489 + } 1.2490 + // append new previous version. 1.2491 + _previous_versions->append(pv_node); 1.2492 } 1.2493 1.2494 - _previous_versions->append(pv_node); 1.2495 - 1.2496 - // Using weak references allows the interesting parts of previous 1.2497 - // classes to be GC'ed when they are no longer needed. Since the 1.2498 - // caller is the VMThread and we are at a safepoint, this is a good 1.2499 - // time to clear out unused weak references. 1.2500 + // Since the caller is the VMThread and we are at a safepoint, this 1.2501 + // is a good time to clear out unused references. 1.2502 1.2503 RC_TRACE(0x00000400, ("add: previous version length=%d", 1.2504 _previous_versions->length())); 1.2505 1.2506 - // skip the last entry since we just added it 1.2507 - for (int i = _previous_versions->length() - 2; i >= 0; i--) { 1.2508 - // check the previous versions array for a GC'ed weak refs 1.2509 - pv_node = _previous_versions->at(i); 1.2510 - cp_ref = pv_node->prev_constant_pool(); 1.2511 - assert(cp_ref != NULL, "cp ref was unexpectedly cleared"); 1.2512 - if (cp_ref == NULL) { 1.2513 - delete pv_node; 1.2514 - _previous_versions->remove_at(i); 1.2515 - // Since we are traversing the array backwards, we don't have to 1.2516 - // do anything special with the index. 1.2517 - continue; // robustness 1.2518 - } 1.2519 - 1.2520 - constantPoolOop cp = (constantPoolOop)JNIHandles::resolve(cp_ref); 1.2521 - if (cp == NULL) { 1.2522 - // this entry has been GC'ed so remove it 1.2523 - delete pv_node; 1.2524 - _previous_versions->remove_at(i); 1.2525 - // Since we are traversing the array backwards, we don't have to 1.2526 - // do anything special with the index. 1.2527 - continue; 1.2528 - } else { 1.2529 - RC_TRACE(0x00000400, ("add: previous version @%d is alive", i)); 1.2530 - } 1.2531 - 1.2532 - GrowableArray<jweak>* method_refs = pv_node->prev_EMCP_methods(); 1.2533 - if (method_refs != NULL) { 1.2534 - RC_TRACE(0x00000400, ("add: previous methods length=%d", 1.2535 - method_refs->length())); 1.2536 - for (int j = method_refs->length() - 1; j >= 0; j--) { 1.2537 - jweak method_ref = method_refs->at(j); 1.2538 - assert(method_ref != NULL, "weak method ref was unexpectedly cleared"); 1.2539 - if (method_ref == NULL) { 1.2540 - method_refs->remove_at(j); 1.2541 - // Since we are traversing the array backwards, we don't have to 1.2542 - // do anything special with the index. 1.2543 - continue; // robustness 1.2544 - } 1.2545 - 1.2546 - methodOop method = (methodOop)JNIHandles::resolve(method_ref); 1.2547 - if (method == NULL || emcp_method_count == 0) { 1.2548 - // This method entry has been GC'ed or the current 1.2549 - // RedefineClasses() call has made all methods obsolete 1.2550 - // so remove it. 1.2551 - JNIHandles::destroy_weak_global(method_ref); 1.2552 - method_refs->remove_at(j); 1.2553 - } else { 1.2554 - // RC_TRACE macro has an embedded ResourceMark 1.2555 - RC_TRACE(0x00000400, 1.2556 - ("add: %s(%s): previous method @%d in version @%d is alive", 1.2557 - method->name()->as_C_string(), method->signature()->as_C_string(), 1.2558 - j, i)); 1.2559 - } 1.2560 - } 1.2561 - } 1.2562 - } 1.2563 + // Purge previous versions not executing on the stack 1.2564 + purge_previous_versions_internal(this, emcp_method_count); 1.2565 1.2566 int obsolete_method_count = old_methods->length() - emcp_method_count; 1.2567 1.2568 if (emcp_method_count != 0 && obsolete_method_count != 0 && 1.2569 - _previous_versions->length() > 1) { 1.2570 - // We have a mix of obsolete and EMCP methods. If there is more 1.2571 - // than the previous version that we just added, then we have to 1.2572 + _previous_versions->length() > 0) { 1.2573 + // We have a mix of obsolete and EMCP methods so we have to 1.2574 // clear out any matching EMCP method entries the hard way. 1.2575 int local_count = 0; 1.2576 for (int i = 0; i < old_methods->length(); i++) { 1.2577 if (!emcp_methods->at(i)) { 1.2578 // only obsolete methods are interesting 1.2579 - methodOop old_method = (methodOop) old_methods->obj_at(i); 1.2580 + Method* old_method = old_methods->at(i); 1.2581 Symbol* m_name = old_method->name(); 1.2582 Symbol* m_signature = old_method->signature(); 1.2583 1.2584 - // skip the last entry since we just added it 1.2585 - for (int j = _previous_versions->length() - 2; j >= 0; j--) { 1.2586 - // check the previous versions array for a GC'ed weak refs 1.2587 - pv_node = _previous_versions->at(j); 1.2588 - cp_ref = pv_node->prev_constant_pool(); 1.2589 - assert(cp_ref != NULL, "cp ref was unexpectedly cleared"); 1.2590 - if (cp_ref == NULL) { 1.2591 - delete pv_node; 1.2592 - _previous_versions->remove_at(j); 1.2593 - // Since we are traversing the array backwards, we don't have to 1.2594 - // do anything special with the index. 1.2595 - continue; // robustness 1.2596 - } 1.2597 - 1.2598 - constantPoolOop cp = (constantPoolOop)JNIHandles::resolve(cp_ref); 1.2599 - if (cp == NULL) { 1.2600 - // this entry has been GC'ed so remove it 1.2601 - delete pv_node; 1.2602 - _previous_versions->remove_at(j); 1.2603 - // Since we are traversing the array backwards, we don't have to 1.2604 - // do anything special with the index. 1.2605 - continue; 1.2606 - } 1.2607 - 1.2608 - GrowableArray<jweak>* method_refs = pv_node->prev_EMCP_methods(); 1.2609 + // we might not have added the last entry 1.2610 + for (int j = _previous_versions->length() - 1; j >= 0; j--) { 1.2611 + // check the previous versions array for non executing obsolete methods 1.2612 + PreviousVersionNode * pv_node = _previous_versions->at(j); 1.2613 + 1.2614 + GrowableArray<Method*>* method_refs = pv_node->prev_EMCP_methods(); 1.2615 if (method_refs == NULL) { 1.2616 // We have run into a PreviousVersion generation where 1.2617 // all methods were made obsolete during that generation's 1.2618 @@ -2726,36 +3301,21 @@ 1.2619 } 1.2620 1.2621 for (int k = method_refs->length() - 1; k >= 0; k--) { 1.2622 - jweak method_ref = method_refs->at(k); 1.2623 - assert(method_ref != NULL, 1.2624 - "weak method ref was unexpectedly cleared"); 1.2625 - if (method_ref == NULL) { 1.2626 - method_refs->remove_at(k); 1.2627 - // Since we are traversing the array backwards, we don't 1.2628 - // have to do anything special with the index. 1.2629 - continue; // robustness 1.2630 - } 1.2631 - 1.2632 - methodOop method = (methodOop)JNIHandles::resolve(method_ref); 1.2633 - if (method == NULL) { 1.2634 - // this method entry has been GC'ed so skip it 1.2635 - JNIHandles::destroy_weak_global(method_ref); 1.2636 - method_refs->remove_at(k); 1.2637 - continue; 1.2638 - } 1.2639 - 1.2640 - if (method->name() == m_name && 1.2641 + Method* method = method_refs->at(k); 1.2642 + 1.2643 + if (!method->is_obsolete() && 1.2644 + method->name() == m_name && 1.2645 method->signature() == m_signature) { 1.2646 // The current RedefineClasses() call has made all EMCP 1.2647 // versions of this method obsolete so mark it as obsolete 1.2648 - // and remove the weak ref. 1.2649 + // and remove the reference. 1.2650 RC_TRACE(0x00000400, 1.2651 ("add: %s(%s): flush obsolete method @%d in version @%d", 1.2652 m_name->as_C_string(), m_signature->as_C_string(), k, j)); 1.2653 1.2654 method->set_is_obsolete(); 1.2655 - JNIHandles::destroy_weak_global(method_ref); 1.2656 - method_refs->remove_at(k); 1.2657 + // Leave obsolete methods on the previous version list to 1.2658 + // clean up later. 1.2659 break; 1.2660 } 1.2661 } 1.2662 @@ -2763,9 +3323,9 @@ 1.2663 // The previous loop may not find a matching EMCP method, but 1.2664 // that doesn't mean that we can optimize and not go any 1.2665 // further back in the PreviousVersion generations. The EMCP 1.2666 - // method for this generation could have already been GC'ed, 1.2667 + // method for this generation could have already been deleted, 1.2668 // but there still may be an older EMCP method that has not 1.2669 - // been GC'ed. 1.2670 + // been deleted. 1.2671 } 1.2672 1.2673 if (++local_count >= obsolete_method_count) { 1.2674 @@ -2778,46 +3338,20 @@ 1.2675 } // end add_previous_version() 1.2676 1.2677 1.2678 -// Determine if instanceKlass has a previous version. 1.2679 -bool instanceKlass::has_previous_version() const { 1.2680 - if (_previous_versions == NULL) { 1.2681 - // no previous versions array so answer is easy 1.2682 - return false; 1.2683 - } 1.2684 - 1.2685 - for (int i = _previous_versions->length() - 1; i >= 0; i--) { 1.2686 - // Check the previous versions array for an info node that hasn't 1.2687 - // been GC'ed 1.2688 - PreviousVersionNode * pv_node = _previous_versions->at(i); 1.2689 - 1.2690 - jobject cp_ref = pv_node->prev_constant_pool(); 1.2691 - assert(cp_ref != NULL, "cp reference was unexpectedly cleared"); 1.2692 - if (cp_ref == NULL) { 1.2693 - continue; // robustness 1.2694 - } 1.2695 - 1.2696 - constantPoolOop cp = (constantPoolOop)JNIHandles::resolve(cp_ref); 1.2697 - if (cp != NULL) { 1.2698 - // we have at least one previous version 1.2699 - return true; 1.2700 - } 1.2701 - 1.2702 - // We don't have to check the method refs. If the constant pool has 1.2703 - // been GC'ed then so have the methods. 1.2704 - } 1.2705 - 1.2706 - // all of the underlying nodes' info has been GC'ed 1.2707 - return false; 1.2708 +// Determine if InstanceKlass has a previous version. 1.2709 +bool InstanceKlass::has_previous_version() const { 1.2710 + return (_previous_versions != NULL && _previous_versions->length() > 0); 1.2711 } // end has_previous_version() 1.2712 1.2713 -methodOop instanceKlass::method_with_idnum(int idnum) { 1.2714 - methodOop m = NULL; 1.2715 + 1.2716 +Method* InstanceKlass::method_with_idnum(int idnum) { 1.2717 + Method* m = NULL; 1.2718 if (idnum < methods()->length()) { 1.2719 - m = (methodOop) methods()->obj_at(idnum); 1.2720 + m = methods()->at(idnum); 1.2721 } 1.2722 if (m == NULL || m->method_idnum() != idnum) { 1.2723 for (int index = 0; index < methods()->length(); ++index) { 1.2724 - m = (methodOop) methods()->obj_at(index); 1.2725 + m = methods()->at(index); 1.2726 if (m->method_idnum() == idnum) { 1.2727 return m; 1.2728 } 1.2729 @@ -2827,32 +3361,10 @@ 1.2730 } 1.2731 1.2732 1.2733 -// Set the annotation at 'idnum' to 'anno'. 1.2734 -// We don't want to create or extend the array if 'anno' is NULL, since that is the 1.2735 -// default value. However, if the array exists and is long enough, we must set NULL values. 1.2736 -void instanceKlass::set_methods_annotations_of(int idnum, typeArrayOop anno, objArrayOop* md_p) { 1.2737 - objArrayOop md = *md_p; 1.2738 - if (md != NULL && md->length() > idnum) { 1.2739 - md->obj_at_put(idnum, anno); 1.2740 - } else if (anno != NULL) { 1.2741 - // create the array 1.2742 - int length = MAX2(idnum+1, (int)_idnum_allocated_count); 1.2743 - md = oopFactory::new_system_objArray(length, Thread::current()); 1.2744 - if (*md_p != NULL) { 1.2745 - // copy the existing entries 1.2746 - for (int index = 0; index < (*md_p)->length(); index++) { 1.2747 - md->obj_at_put(index, (*md_p)->obj_at(index)); 1.2748 - } 1.2749 - } 1.2750 - set_annotations(md, md_p); 1.2751 - md->obj_at_put(idnum, anno); 1.2752 - } // if no array and idnum isn't included there is nothing to do 1.2753 -} 1.2754 - 1.2755 // Construct a PreviousVersionNode entry for the array hung off 1.2756 -// the instanceKlass. 1.2757 -PreviousVersionNode::PreviousVersionNode(jobject prev_constant_pool, 1.2758 - bool prev_cp_is_weak, GrowableArray<jweak>* prev_EMCP_methods) { 1.2759 +// the InstanceKlass. 1.2760 +PreviousVersionNode::PreviousVersionNode(ConstantPool* prev_constant_pool, 1.2761 + bool prev_cp_is_weak, GrowableArray<Method*>* prev_EMCP_methods) { 1.2762 1.2763 _prev_constant_pool = prev_constant_pool; 1.2764 _prev_cp_is_weak = prev_cp_is_weak; 1.2765 @@ -2863,20 +3375,10 @@ 1.2766 // Destroy a PreviousVersionNode 1.2767 PreviousVersionNode::~PreviousVersionNode() { 1.2768 if (_prev_constant_pool != NULL) { 1.2769 - if (_prev_cp_is_weak) { 1.2770 - JNIHandles::destroy_weak_global(_prev_constant_pool); 1.2771 - } else { 1.2772 - JNIHandles::destroy_global(_prev_constant_pool); 1.2773 - } 1.2774 + _prev_constant_pool = NULL; 1.2775 } 1.2776 1.2777 if (_prev_EMCP_methods != NULL) { 1.2778 - for (int i = _prev_EMCP_methods->length() - 1; i >= 0; i--) { 1.2779 - jweak method_ref = _prev_EMCP_methods->at(i); 1.2780 - if (method_ref != NULL) { 1.2781 - JNIHandles::destroy_weak_global(method_ref); 1.2782 - } 1.2783 - } 1.2784 delete _prev_EMCP_methods; 1.2785 } 1.2786 } 1.2787 @@ -2887,45 +3389,31 @@ 1.2788 _prev_constant_pool_handle = constantPoolHandle(); // NULL handle 1.2789 _prev_EMCP_method_handles = NULL; 1.2790 1.2791 - jobject cp_ref = pv_node->prev_constant_pool(); 1.2792 - assert(cp_ref != NULL, "constant pool ref was unexpectedly cleared"); 1.2793 - if (cp_ref == NULL) { 1.2794 + ConstantPool* cp = pv_node->prev_constant_pool(); 1.2795 + assert(cp != NULL, "constant pool ref was unexpectedly cleared"); 1.2796 + if (cp == NULL) { 1.2797 return; // robustness 1.2798 } 1.2799 1.2800 - constantPoolOop cp = (constantPoolOop)JNIHandles::resolve(cp_ref); 1.2801 - if (cp == NULL) { 1.2802 - // Weak reference has been GC'ed. Since the constant pool has been 1.2803 - // GC'ed, the methods have also been GC'ed. 1.2804 + // make the ConstantPool* safe to return 1.2805 + _prev_constant_pool_handle = constantPoolHandle(cp); 1.2806 + 1.2807 + GrowableArray<Method*>* method_refs = pv_node->prev_EMCP_methods(); 1.2808 + if (method_refs == NULL) { 1.2809 + // the InstanceKlass did not have any EMCP methods 1.2810 return; 1.2811 } 1.2812 1.2813 - // make the constantPoolOop safe to return 1.2814 - _prev_constant_pool_handle = constantPoolHandle(cp); 1.2815 - 1.2816 - GrowableArray<jweak>* method_refs = pv_node->prev_EMCP_methods(); 1.2817 - if (method_refs == NULL) { 1.2818 - // the instanceKlass did not have any EMCP methods 1.2819 - return; 1.2820 - } 1.2821 - 1.2822 _prev_EMCP_method_handles = new GrowableArray<methodHandle>(10); 1.2823 1.2824 int n_methods = method_refs->length(); 1.2825 for (int i = 0; i < n_methods; i++) { 1.2826 - jweak method_ref = method_refs->at(i); 1.2827 - assert(method_ref != NULL, "weak method ref was unexpectedly cleared"); 1.2828 - if (method_ref == NULL) { 1.2829 + Method* method = method_refs->at(i); 1.2830 + assert (method != NULL, "method has been cleared"); 1.2831 + if (method == NULL) { 1.2832 continue; // robustness 1.2833 } 1.2834 - 1.2835 - methodOop method = (methodOop)JNIHandles::resolve(method_ref); 1.2836 - if (method == NULL) { 1.2837 - // this entry has been GC'ed so skip it 1.2838 - continue; 1.2839 - } 1.2840 - 1.2841 - // make the methodOop safe to return 1.2842 + // make the Method* safe to return 1.2843 _prev_EMCP_method_handles->append(methodHandle(method)); 1.2844 } 1.2845 } 1.2846 @@ -2939,7 +3427,7 @@ 1.2847 1.2848 1.2849 // Construct a helper for walking the previous versions array 1.2850 -PreviousVersionWalker::PreviousVersionWalker(instanceKlass *ik) { 1.2851 +PreviousVersionWalker::PreviousVersionWalker(InstanceKlass *ik) { 1.2852 _previous_versions = ik->previous_versions(); 1.2853 _current_index = 0; 1.2854 // _hm needs no initialization 1.2855 @@ -2981,21 +3469,13 @@ 1.2856 PreviousVersionInfo(pv_node); 1.2857 1.2858 constantPoolHandle cp_h = pv_info->prev_constant_pool_handle(); 1.2859 - if (cp_h.is_null()) { 1.2860 - delete pv_info; 1.2861 - 1.2862 - // The underlying node's info has been GC'ed so try the next one. 1.2863 - // We don't have to check the methods. If the constant pool has 1.2864 - // GC'ed then so have the methods. 1.2865 - continue; 1.2866 - } 1.2867 - 1.2868 - // Found a node with non GC'ed info so return it. The caller will 1.2869 - // need to delete pv_info when they are done with it. 1.2870 + assert (!cp_h.is_null(), "null cp found in previous version"); 1.2871 + 1.2872 + // The caller will need to delete pv_info when they are done with it. 1.2873 _current_p = pv_info; 1.2874 return pv_info; 1.2875 } 1.2876 1.2877 - // all of the underlying nodes' info has been GC'ed 1.2878 + // all of the underlying nodes' info has been deleted 1.2879 return NULL; 1.2880 } // end next_previous_version()