From ca4e51bcd144652a17cf91a2363ca0baef709bb5 Mon Sep 17 00:00:00 2001 From: hseigel Date: Tue, 28 Aug 2018 10:10:11 -0400 Subject: [PATCH] 8202578: Revisit location for class unload events Summary: Use notify_unload_class() to post JFR class unload events instead of doing a separate traversal of the class loader data graph Reviewed-by: lfoltan, coleenp, mgronlun, egahlin --- src/share/vm/classfile/classLoaderData.cpp | 32 --------------------- src/share/vm/classfile/systemDictionary.cpp | 4 +++ src/share/vm/oops/instanceKlass.cpp | 12 ++++++++ 3 files changed, 16 insertions(+), 32 deletions(-) diff --git a/src/share/vm/classfile/classLoaderData.cpp b/src/share/vm/classfile/classLoaderData.cpp index 693eee08c..12b7e5036 100644 --- a/src/share/vm/classfile/classLoaderData.cpp +++ b/src/share/vm/classfile/classLoaderData.cpp @@ -64,11 +64,6 @@ #include "utilities/growableArray.hpp" #include "utilities/macros.hpp" #include "utilities/ostream.hpp" -#include "utilities/ticks.hpp" -#if INCLUDE_JFR -#include "jfr/jfr.hpp" -#include "jfr/jfrEvents.hpp" -#endif ClassLoaderData * ClassLoaderData::_the_null_class_loader_data = NULL; @@ -753,29 +748,6 @@ bool ClassLoaderDataGraph::contains_loader_data(ClassLoaderData* loader_data) { } #endif // PRODUCT -#if INCLUDE_JFR -static Ticks class_unload_time; -static void post_class_unload_event(Klass* const k) { - assert(k != NULL, "invariant"); - EventClassUnload event(UNTIMED); - event.set_endtime(class_unload_time); - event.set_unloadedClass(k); - event.set_definingClassLoader(k->class_loader_data()); - event.commit(); -} - -static void post_class_unload_events() { - assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!"); - if (Jfr::is_enabled()) { - if (EventClassUnload::is_enabled()) { - class_unload_time = Ticks::now(); - ClassLoaderDataGraph::classes_unloading_do(&post_class_unload_event); - } - Jfr::on_unloading_classes(); - } -} -#endif // INCLUDE_JFR - // Move class loader data from main list to the unloaded list for unloading // and deallocation later. bool ClassLoaderDataGraph::do_unloading(BoolObjectClosure* is_alive_closure, bool clean_alive) { @@ -815,10 +787,6 @@ bool ClassLoaderDataGraph::do_unloading(BoolObjectClosure* is_alive_closure, boo ClassLoaderDataGraph::clean_metaspaces(); } - if (seen_dead_loader) { - JFR_ONLY(post_class_unload_events();) - } - return seen_dead_loader; } diff --git a/src/share/vm/classfile/systemDictionary.cpp b/src/share/vm/classfile/systemDictionary.cpp index 04026bd33..6f1fc3d30 100644 --- a/src/share/vm/classfile/systemDictionary.cpp +++ b/src/share/vm/classfile/systemDictionary.cpp @@ -138,6 +138,9 @@ bool SystemDictionary::is_internal_format(Symbol* class_name) { } } +#endif +#if INCLUDE_JFR +#include "jfr/jfr.hpp" #endif // ---------------------------------------------------------------------------- @@ -1749,6 +1752,7 @@ bool SystemDictionary::do_unloading(BoolObjectClosure* is_alive, bool clean_aliv // First, mark for unload all ClassLoaderData referencing a dead class loader. bool unloading_occurred = ClassLoaderDataGraph::do_unloading(is_alive, clean_alive); if (unloading_occurred) { + JFR_ONLY(Jfr::on_unloading_classes();) dictionary()->do_unloading(); constraints()->purge_loader_constraints(); resolution_errors()->purge_resolution_errors(); diff --git a/src/share/vm/oops/instanceKlass.cpp b/src/share/vm/oops/instanceKlass.cpp index 0204188ad..c9bc0bab1 100644 --- a/src/share/vm/oops/instanceKlass.cpp +++ b/src/share/vm/oops/instanceKlass.cpp @@ -78,6 +78,10 @@ #ifdef COMPILER1 #include "c1/c1_Compiler.hpp" #endif +#if INCLUDE_JFR +#include "jfr/jfrEvents.hpp" +#endif + PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC @@ -2526,6 +2530,14 @@ void InstanceKlass::notify_unload_class(InstanceKlass* ik) { // notify ClassLoadingService of class unload ClassLoadingService::notify_class_unloaded(ik); + +#if INCLUDE_JFR + assert(ik != NULL, "invariant"); + EventClassUnload event; + event.set_unloadedClass(ik); + event.set_definingClassLoader(ik->class_loader_data()); + event.commit(); +#endif } void InstanceKlass::release_C_heap_structures(InstanceKlass* ik) { -- GitLab