--- old/src/share/vm/classfile/classLoaderData.cpp 2017-04-10 16:51:56.679887470 -0400 +++ new/src/share/vm/classfile/classLoaderData.cpp 2017-04-10 16:51:56.294192119 -0400 @@ -247,7 +247,7 @@ void ClassLoaderData::methods_do(void f(Method*)) { // Lock-free access requires load_ptr_acquire for (Klass* k = load_ptr_acquire(&_klasses); k != NULL; k = k->next_link()) { - if (k->is_instance_klass()) { + if (k->is_instance_klass() && InstanceKlass::cast(k)->is_loaded()) { InstanceKlass::cast(k)->methods_do(f); } } --- old/src/share/vm/classfile/classLoaderData.hpp 2017-04-10 16:52:05.750542877 -0400 +++ new/src/share/vm/classfile/classLoaderData.hpp 2017-04-10 16:52:05.505399772 -0400 @@ -94,6 +94,10 @@ static void keep_alive_cld_do(CLDClosure* cl); static void always_strong_cld_do(CLDClosure* cl); // klass do + // Walking classes through the ClassLoaderDataGraph include array classes. It also includes + // classes that are allocated but not loaded, classes that have errors, and scratch classes + // for redefinition. These classes are removed during the next class unloading. + // Walking the ClassLoaderDataGraph also includes anonymous classes. static void classes_do(KlassClosure* klass_closure); static void classes_do(void f(Klass* const)); static void methods_do(void f(Method*)); --- old/src/share/vm/classfile/dictionary.cpp 2017-04-10 16:52:13.754188176 -0400 +++ new/src/share/vm/classfile/dictionary.cpp 2017-04-10 16:52:13.508137638 -0400 @@ -177,6 +177,11 @@ // the loader must be an initiating loader (rather than the // defining loader). Remove this entry. if (k_def_class_loader_data->is_unloading()) { + ResourceMark rm; + tty->print_cr("loader data %s loads class %s in loader data %s", + loader_data->loader_name(), + ik->name()->as_C_string(), k_def_class_loader_data->loader_name()); + ShouldNotReachHere(); // isn't there a dependency created? or k_loader_data is parent of loader_data?? // If we get here, the class_loader_data must not be the defining // loader, it must be an initiating one. assert(k_def_class_loader_data != loader_data, @@ -266,23 +271,6 @@ _pd_cache_table->always_strong_oops_do(blk); } - -void Dictionary::always_strong_classes_do(KlassClosure* closure) { - // Follow all system classes and temporary placeholders in dictionary - for (int index = 0; index < table_size(); index++) { - for (DictionaryEntry* probe = bucket(index); - probe != NULL; - probe = probe->next()) { - Klass* e = probe->klass(); - ClassLoaderData* loader_data = probe->loader_data(); - if (is_strongly_reachable(loader_data, e)) { - closure->do_klass(e); - } - } - } -} - - // Just the classes from defining class loaders void Dictionary::classes_do(void f(Klass*)) { for (int index = 0; index < table_size(); index++) { @@ -331,20 +319,6 @@ _pd_cache_table->oops_do(f); } -void Dictionary::methods_do(void f(Method*)) { - for (int index = 0; index < table_size(); index++) { - for (DictionaryEntry* probe = bucket(index); - probe != NULL; - probe = probe->next()) { - Klass* k = probe->klass(); - if (probe->loader_data() == k->class_loader_data()) { - // only take klass is we have the entry with the defining class loader - InstanceKlass::cast(k)->methods_do(f); - } - } - } -} - void Dictionary::unlink(BoolObjectClosure* is_alive) { // Only the protection domain cache table may contain references to the heap // that need to be unlinked. @@ -651,25 +625,6 @@ return p; } -void ProtectionDomainCacheTable::free(ProtectionDomainCacheEntry* to_delete) { - unsigned int hash = compute_hash(Handle(Thread::current(), to_delete->protection_domain())); - int index = hash_to_index(hash); - - ProtectionDomainCacheEntry** p = bucket_addr(index); - ProtectionDomainCacheEntry* entry = bucket(index); - while (true) { - assert(entry != NULL, "sanity"); - - if (entry == to_delete) { - *p = entry->next(); - Hashtable::free_entry(entry); - break; - } else { - p = entry->next_addr(); - entry = *p; - } - } -} SymbolPropertyTable::SymbolPropertyTable(int table_size) : Hashtable(table_size, sizeof(SymbolPropertyEntry)) --- old/src/share/vm/classfile/dictionary.hpp 2017-04-10 16:52:21.764869209 -0400 +++ new/src/share/vm/classfile/dictionary.hpp 2017-04-10 16:52:21.473805524 -0400 @@ -75,8 +75,6 @@ DictionaryEntry* new_entry(unsigned int hash, InstanceKlass* klass, ClassLoaderData* loader_data); - DictionaryEntry* new_entry(); - void free_entry(DictionaryEntry* entry); void add_klass(Symbol* class_name, ClassLoaderData* loader_data, InstanceKlass* obj); @@ -94,14 +92,10 @@ void always_strong_oops_do(OopClosure* blk); void roots_oops_do(OopClosure* strong, OopClosure* weak); - void always_strong_classes_do(KlassClosure* closure); - void classes_do(void f(Klass*)); void classes_do(void f(Klass*, TRAPS), TRAPS); void classes_do(void f(Klass*, ClassLoaderData*)); - void methods_do(void f(Method*)); - void unlink(BoolObjectClosure* is_alive); void remove_classes_in_error_state(); @@ -211,7 +205,6 @@ ProtectionDomainCacheTable(int table_size); ProtectionDomainCacheEntry* get(Handle protection_domain); - void free(ProtectionDomainCacheEntry* entry); void unlink(BoolObjectClosure* cl); @@ -278,7 +271,6 @@ void add_protection_domain(Dictionary* dict, Handle protection_domain); InstanceKlass* klass() const { return (InstanceKlass*)literal(); } - InstanceKlass** klass_addr() { return (InstanceKlass**)literal_addr(); } DictionaryEntry* next() const { return (DictionaryEntry*)HashtableEntry::next(); @@ -294,8 +286,6 @@ ProtectionDomainEntry* pd_set() const { return _pd_set; } void set_pd_set(ProtectionDomainEntry* pd_set) { _pd_set = pd_set; } - bool has_protection_domain() { return _pd_set != NULL; } - // Tells whether the initiating class' protection can access the this _klass bool is_valid_protection_domain(Handle protection_domain) { if (!ProtectionDomainVerification) return true; --- old/src/share/vm/classfile/loaderConstraints.cpp 2017-04-10 16:52:30.449717247 -0400 +++ new/src/share/vm/classfile/loaderConstraints.cpp 2017-04-10 16:52:30.204040713 -0400 @@ -57,19 +57,6 @@ Hashtable::free_entry(entry); } -// Enhanced Class Redefinition support -void LoaderConstraintTable::classes_do(KlassClosure* f) { - for (int index = 0; index < table_size(); index++) { - for (LoaderConstraintEntry* probe = bucket(index); - probe != NULL; - probe = probe->next()) { - if (probe->klass() != NULL) { - f->do_klass(probe->klass()); - } - } - } - } - // The loaderConstraintTable must always be accessed with the // SystemDictionary lock held. This is true even for readers as // entries in the table could be being dynamically resized. --- old/src/share/vm/classfile/loaderConstraints.hpp 2017-04-10 16:52:38.442506669 -0400 +++ new/src/share/vm/classfile/loaderConstraints.hpp 2017-04-10 16:52:38.196863627 -0400 @@ -61,9 +61,6 @@ return (LoaderConstraintEntry**)Hashtable::bucket_addr(i); } - // Enhanced Class Redefinition support - void classes_do(KlassClosure* f); - // Check class loader constraints bool add_entry(Symbol* name, InstanceKlass* klass1, Handle loader1, InstanceKlass* klass2, Handle loader2); --- old/src/share/vm/classfile/placeholders.cpp 2017-04-10 16:52:46.389313457 -0400 +++ new/src/share/vm/classfile/placeholders.cpp 2017-04-10 16:52:46.144652658 -0400 @@ -175,37 +175,6 @@ : TwoOopHashtable(table_size, sizeof(PlaceholderEntry)) { } - -void PlaceholderTable::classes_do(KlassClosure* f) { - for (int index = 0; index < table_size(); index++) { - for (PlaceholderEntry* probe = bucket(index); - probe != NULL; - probe = probe->next()) { - probe->classes_do(f); - } - } -} - - -void PlaceholderEntry::classes_do(KlassClosure* closure) { - assert(klassname() != NULL, "should have a non-null klass"); - if (_instanceKlass != NULL) { - closure->do_klass(instance_klass()); - } -} - -// do all entries in the placeholder table -void PlaceholderTable::entries_do(void f(Symbol*)) { - for (int index = 0; index < table_size(); index++) { - for (PlaceholderEntry* probe = bucket(index); - probe != NULL; - probe = probe->next()) { - f(probe->klassname()); - } - } -} - - #ifndef PRODUCT // Note, doesn't append a cr void PlaceholderEntry::print() const { --- old/src/share/vm/classfile/placeholders.hpp 2017-04-10 16:52:54.356434868 -0400 +++ new/src/share/vm/classfile/placeholders.hpp 2017-04-10 16:52:54.110713719 -0400 @@ -98,12 +98,6 @@ Symbol* name, ClassLoaderData* loader_data, classloadAction action, Thread* thread); - // GC support. - void classes_do(KlassClosure* f); - - // JVMTI support - void entries_do(void f(Symbol*)); - #ifndef PRODUCT void print(); #endif @@ -329,10 +323,6 @@ return (actionToQueue(action) == NULL); } - // GC support - // Applies "f->do_oop" to all root oops in the placeholder table. - void classes_do(KlassClosure* closure); - // Print method doesn't append a cr void print() const PRODUCT_RETURN; void verify() const; --- old/src/share/vm/classfile/systemDictionary.cpp 2017-04-10 16:53:02.727796157 -0400 +++ new/src/share/vm/classfile/systemDictionary.cpp 2017-04-10 16:53:02.429538301 -0400 @@ -1885,14 +1885,6 @@ roots_oops_do(blk, NULL); } -void SystemDictionary::always_strong_classes_do(KlassClosure* closure) { - // Follow all system classes and temporary placeholders in dictionary - dictionary()->always_strong_classes_do(closure); - - // Placeholders. These represent classes we're actively loading. - placeholders()->classes_do(closure); -} - // Calculate a "good" systemdictionary size based // on predicted or current loaded classes count int SystemDictionary::calculate_systemdictionary_size(int classcount) { @@ -1974,31 +1966,6 @@ invoke_method_table()->oops_do(f); } -// Extended Class redefinition support. -// If one of these classes is replaced, we need to replace it in these places. -// KlassClosure::do_klass should take the address of a class but we can -// change that later. -void SystemDictionary::preloaded_classes_do(KlassClosure* f) { - for (int k = (int)FIRST_WKID; k < (int)WKID_LIMIT; k++) { - f->do_klass(_well_known_klasses[k]); - } - - { - for (int i = 0; i < T_VOID+1; i++) { - if (_box_klasses[i] != NULL) { - assert(i >= T_BOOLEAN, "checking"); - f->do_klass(_box_klasses[i]); - } - } - } - - FilteredFieldsMap::classes_do(f); -} - -void SystemDictionary::lazily_loaded_classes_do(KlassClosure* f) { - f->do_klass(_abstract_ownable_synchronizer_klass); -} - // Just the classes from defining class loaders // Don't iterate over placeholders void SystemDictionary::classes_do(void f(Klass*)) { @@ -2018,12 +1985,10 @@ dictionary()->classes_do(f); } -void SystemDictionary::placeholders_do(void f(Symbol*)) { - placeholders()->entries_do(f); -} - void SystemDictionary::methods_do(void f(Method*)) { - dictionary()->methods_do(f); + // Walk methods in loaded classes + ClassLoaderDataGraph::methods_do(f); + // Walk method handle intrinsics invoke_method_table()->methods_do(f); } --- old/src/share/vm/classfile/systemDictionary.hpp 2017-04-10 16:53:10.796152777 -0400 +++ new/src/share/vm/classfile/systemDictionary.hpp 2017-04-10 16:53:10.548679813 -0400 @@ -347,16 +347,14 @@ TRAPS); // Iterate over all klasses in dictionary - // Just the classes from defining class loaders + // Just the classes from defining class loaders static void classes_do(void f(Klass*)); // Added for initialize_itable_for_klass to handle exceptions static void classes_do(void f(Klass*, TRAPS), TRAPS); - // All classes, and their class loaders + // All classes, and their class loaders, including initiating class loaders static void classes_do(void f(Klass*, ClassLoaderData*)); - static void placeholders_do(void f(Symbol*)); - - // Iterate over all methods in all klasses in dictionary + // Iterate over all methods in all klasses static void methods_do(void f(Method*)); // Garbage collection support @@ -364,7 +362,6 @@ // This method applies "blk->do_oop" to all the pointers to "system" // classes and loaders. static void always_strong_oops_do(OopClosure* blk); - static void always_strong_classes_do(KlassClosure* closure); // Unload (that is, break root links to) all unmarked classes and // loaders. Returns "true" iff something was unloaded. @@ -383,10 +380,6 @@ // System loader lock static oop system_loader_lock() { return _system_loader_lock_obj; } -protected: - // Extended Redefine classes support (tbi) - static void preloaded_classes_do(KlassClosure* f); - static void lazily_loaded_classes_do(KlassClosure* f); public: // Sharing support. static void reorder_dictionary(); --- old/src/share/vm/memory/universe.hpp 2017-04-10 16:53:19.034566119 -0400 +++ new/src/share/vm/memory/universe.hpp 2017-04-10 16:53:18.649771047 -0400 @@ -62,11 +62,6 @@ Method* get_method(); - // Enhanced Class Redefinition support - void classes_do(void f(Klass*)) { - f(_klass); - } - // CDS support. Replace the klass in this with the archive version // could use this for Enhanced Class Redefinition also. void serialize(SerializeClosure* f) { --- old/src/share/vm/prims/jvmtiGetLoadedClasses.cpp 2017-04-10 16:53:27.828204234 -0400 +++ new/src/share/vm/prims/jvmtiGetLoadedClasses.cpp 2017-04-10 16:53:27.489606895 -0400 @@ -213,14 +213,6 @@ } } - static void prim_array_increment_with_loader(Klass* array, ClassLoaderData* loader_data) { - JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this(); - oop class_loader = loader_data->class_loader(); - if (class_loader == JNIHandles::resolve(that->get_initiatingLoader())) { - that->set_count(that->get_count() + 1); - } - } - static void add_with_loader(Klass* k, ClassLoaderData* loader_data) { JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this(); if (that->available()) { --- old/src/share/vm/prims/privilegedStack.cpp 2017-04-10 16:53:35.862752923 -0400 +++ new/src/share/vm/prims/privilegedStack.cpp 2017-04-10 16:53:35.616329464 -0400 @@ -51,14 +51,6 @@ } while(cur != NULL); } -void PrivilegedElement::classes_do(KlassClosure* f) { - PrivilegedElement *cur = this; - do { - f->do_klass(cur->_klass); - cur = cur->_next; - } while(cur != NULL); -} - //------------------------------------------------------------------------------- #ifndef PRODUCT --- old/src/share/vm/prims/privilegedStack.hpp 2017-04-10 16:53:43.816446522 -0400 +++ new/src/share/vm/prims/privilegedStack.hpp 2017-04-10 16:53:43.571808712 -0400 @@ -39,7 +39,6 @@ public: void initialize(vframeStream* vf, oop context, PrivilegedElement* next, TRAPS); void oops_do(OopClosure* f); - void classes_do(KlassClosure* f); intptr_t* frame_id() const { return _frame_id; } oop privileged_context() const { return _privileged_context; } oop class_loader() const { return InstanceKlass::cast(_klass)->class_loader(); } --- old/src/share/vm/runtime/java.cpp 2017-04-10 16:53:52.131866298 -0400 +++ new/src/share/vm/runtime/java.cpp 2017-04-10 16:53:51.792222174 -0400 @@ -112,7 +112,7 @@ ResourceMark rm; HandleMark hm; collected_profiled_methods = new GrowableArray(1024); - ClassLoaderDataGraph::methods_do(collect_profiled_methods); + SystemDictionary::methods_do(collect_profiled_methods); collected_profiled_methods->sort(&compare_methods); int count = collected_profiled_methods->length(); @@ -163,7 +163,7 @@ collected_invoked_methods->sort(&compare_methods); // tty->cr(); - tty->print_cr("Histogram Over MethodOop Invocation Counters (cutoff = " INTX_FORMAT "):", MethodHistogramCutoff); + tty->print_cr("Histogram Over Method Invocation Counters (cutoff = " INTX_FORMAT "):", MethodHistogramCutoff); tty->cr(); tty->print_cr("____Count_(I+C)____Method________________________Module_________________"); unsigned total = 0, int_total = 0, comp_total = 0, static_total = 0, final_total = 0, --- old/src/share/vm/runtime/reflectionUtils.hpp 2017-04-10 16:54:00.232723465 -0400 +++ new/src/share/vm/runtime/reflectionUtils.hpp 2017-04-10 16:53:59.983672606 -0400 @@ -196,12 +196,6 @@ } return nflds; } - // Enhance Class Redefinition Support - static void classes_do(KlassClosure* f) { - for (int i = 0; i < _filtered_fields->length(); i++) { - f->do_klass(_filtered_fields->at(i)->klass()); - } - } }; --- old/src/share/vm/services/heapDumper.cpp 2017-04-10 16:54:08.562721622 -0400 +++ new/src/share/vm/services/heapDumper.cpp 2017-04-10 16:54:08.223072152 -0400 @@ -1824,8 +1824,10 @@ check_segment_length(); // HPROF_GC_ROOT_STICKY_CLASS + // These should be classes in the NULL class loader data, and not all classes + // if !ClassUnloading StickyClassDumper class_dumper(writer()); - SystemDictionary::always_strong_classes_do(&class_dumper); + ClassLoaderData::the_null_class_loader_data()->classes_do(&class_dumper); // fixes up the length of the dump record and writes the HPROF_HEAP_DUMP_END record. DumperSupport::end_of_dump(writer());