comparison src/share/vm/classfile/classLoaderData.cpp @ 20770:02c7eebe5f52

Merge
author asaha
date Wed, 19 Nov 2014 12:52:56 -0800
parents b12a2a9b05ca
children 82d3e7b5277a
comparison
equal deleted inserted replaced
20769:fc1348524f65 20770:02c7eebe5f52
745 #endif // PRODUCT 745 #endif // PRODUCT
746 746
747 747
748 // Move class loader data from main list to the unloaded list for unloading 748 // Move class loader data from main list to the unloaded list for unloading
749 // and deallocation later. 749 // and deallocation later.
750 bool ClassLoaderDataGraph::do_unloading(BoolObjectClosure* is_alive_closure) { 750 bool ClassLoaderDataGraph::do_unloading(BoolObjectClosure* is_alive_closure, bool clean_alive) {
751 ClassLoaderData* data = _head; 751 ClassLoaderData* data = _head;
752 ClassLoaderData* prev = NULL; 752 ClassLoaderData* prev = NULL;
753 bool seen_dead_loader = false; 753 bool seen_dead_loader = false;
754 754
755 // Save previous _unloading pointer for CMS which may add to unloading list before 755 // Save previous _unloading pointer for CMS which may add to unloading list before
756 // purging and we don't want to rewalk the previously unloaded class loader data. 756 // purging and we don't want to rewalk the previously unloaded class loader data.
757 _saved_unloading = _unloading; 757 _saved_unloading = _unloading;
758 758
759 // mark metadata seen on the stack and code cache so we can delete
760 // unneeded entries.
761 bool has_redefined_a_class = JvmtiExport::has_redefined_a_class();
762 MetadataOnStackMark md_on_stack;
763 while (data != NULL) { 759 while (data != NULL) {
764 if (data->is_alive(is_alive_closure)) { 760 if (data->is_alive(is_alive_closure)) {
765 if (has_redefined_a_class) {
766 data->classes_do(InstanceKlass::purge_previous_versions);
767 }
768 data->free_deallocate_list();
769 prev = data; 761 prev = data;
770 data = data->next(); 762 data = data->next();
771 continue; 763 continue;
772 } 764 }
773 seen_dead_loader = true; 765 seen_dead_loader = true;
785 } 777 }
786 dead->set_next(_unloading); 778 dead->set_next(_unloading);
787 _unloading = dead; 779 _unloading = dead;
788 } 780 }
789 781
782 if (clean_alive) {
783 // Clean previous versions and the deallocate list.
784 ClassLoaderDataGraph::clean_metaspaces();
785 }
786
790 if (seen_dead_loader) { 787 if (seen_dead_loader) {
791 post_class_unload_events(); 788 post_class_unload_events();
792 } 789 }
793 790
794 return seen_dead_loader; 791 return seen_dead_loader;
792 }
793
794 void ClassLoaderDataGraph::clean_metaspaces() {
795 // mark metadata seen on the stack and code cache so we can delete unneeded entries.
796 bool has_redefined_a_class = JvmtiExport::has_redefined_a_class();
797 MetadataOnStackMark md_on_stack(has_redefined_a_class);
798
799 if (has_redefined_a_class) {
800 // purge_previous_versions also cleans weak method links. Because
801 // one method's MDO can reference another method from another
802 // class loader, we need to first clean weak method links for all
803 // class loaders here. Below, we can then free redefined methods
804 // for all class loaders.
805 for (ClassLoaderData* data = _head; data != NULL; data = data->next()) {
806 data->classes_do(InstanceKlass::purge_previous_versions);
807 }
808 }
809
810 // Need to purge the previous version before deallocating.
811 free_deallocate_lists();
795 } 812 }
796 813
797 void ClassLoaderDataGraph::purge() { 814 void ClassLoaderDataGraph::purge() {
798 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!"); 815 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
799 ClassLoaderData* list = _unloading; 816 ClassLoaderData* list = _unloading;
817 classes_unloading_do(&class_unload_event); 834 classes_unloading_do(&class_unload_event);
818 } 835 }
819 Tracing::on_unloading_classes(); 836 Tracing::on_unloading_classes();
820 } 837 }
821 #endif 838 #endif
839 }
840
841 void ClassLoaderDataGraph::free_deallocate_lists() {
842 for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
843 // We need to keep this data until InstanceKlass::purge_previous_version has been
844 // called on all alive classes. See the comment in ClassLoaderDataGraph::clean_metaspaces.
845 cld->free_deallocate_list();
846 }
822 } 847 }
823 848
824 // CDS support 849 // CDS support
825 850
826 // Global metaspaces for writing information to the shared archive. When 851 // Global metaspaces for writing information to the shared archive. When