src/share/vm/classfile/classLoaderData.cpp

changeset 9866
41515291559a
parent 9858
b985cbb00e68
child 9931
fd44df5e3bc3
equal deleted inserted replaced
9865:5a83b7215107 9866:41515291559a
62 #include "runtime/safepoint.hpp" 62 #include "runtime/safepoint.hpp"
63 #include "runtime/synchronizer.hpp" 63 #include "runtime/synchronizer.hpp"
64 #include "utilities/growableArray.hpp" 64 #include "utilities/growableArray.hpp"
65 #include "utilities/macros.hpp" 65 #include "utilities/macros.hpp"
66 #include "utilities/ostream.hpp" 66 #include "utilities/ostream.hpp"
67 #include "utilities/ticks.hpp"
68 #if INCLUDE_JFR
69 #include "jfr/jfr.hpp"
70 #include "jfr/jfrEvents.hpp"
71 #endif
72 67
73 ClassLoaderData * ClassLoaderData::_the_null_class_loader_data = NULL; 68 ClassLoaderData * ClassLoaderData::_the_null_class_loader_data = NULL;
74 69
75 ClassLoaderData::ClassLoaderData(Handle h_class_loader, bool is_anonymous, Dependencies dependencies) : 70 ClassLoaderData::ClassLoaderData(Handle h_class_loader, bool is_anonymous, Dependencies dependencies) :
76 _class_loader(h_class_loader()), 71 _class_loader(h_class_loader()),
751 746
752 return false; 747 return false;
753 } 748 }
754 #endif // PRODUCT 749 #endif // PRODUCT
755 750
756 #if INCLUDE_JFR
757 static Ticks class_unload_time;
758 static void post_class_unload_event(Klass* const k) {
759 assert(k != NULL, "invariant");
760 EventClassUnload event(UNTIMED);
761 event.set_endtime(class_unload_time);
762 event.set_unloadedClass(k);
763 event.set_definingClassLoader(k->class_loader_data());
764 event.commit();
765 }
766
767 static void post_class_unload_events() {
768 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
769 if (Jfr::is_enabled()) {
770 if (EventClassUnload::is_enabled()) {
771 class_unload_time = Ticks::now();
772 ClassLoaderDataGraph::classes_unloading_do(&post_class_unload_event);
773 }
774 Jfr::on_unloading_classes();
775 }
776 }
777 #endif // INCLUDE_JFR
778
779 // Move class loader data from main list to the unloaded list for unloading 751 // Move class loader data from main list to the unloaded list for unloading
780 // and deallocation later. 752 // and deallocation later.
781 bool ClassLoaderDataGraph::do_unloading(BoolObjectClosure* is_alive_closure, bool clean_alive) { 753 bool ClassLoaderDataGraph::do_unloading(BoolObjectClosure* is_alive_closure, bool clean_alive) {
782 ClassLoaderData* data = _head; 754 ClassLoaderData* data = _head;
783 ClassLoaderData* prev = NULL; 755 ClassLoaderData* prev = NULL;
813 if (clean_alive) { 785 if (clean_alive) {
814 // Clean previous versions and the deallocate list. 786 // Clean previous versions and the deallocate list.
815 ClassLoaderDataGraph::clean_metaspaces(); 787 ClassLoaderDataGraph::clean_metaspaces();
816 } 788 }
817 789
818 if (seen_dead_loader) {
819 JFR_ONLY(post_class_unload_events();)
820 }
821
822 return seen_dead_loader; 790 return seen_dead_loader;
823 } 791 }
824 792
825 void ClassLoaderDataGraph::clean_metaspaces() { 793 void ClassLoaderDataGraph::clean_metaspaces() {
826 // mark metadata seen on the stack and code cache so we can delete unneeded entries. 794 // mark metadata seen on the stack and code cache so we can delete unneeded entries.

mercurial