提交 ca4e51bc 编写于 作者: H hseigel

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
上级 77e715a0
...@@ -64,11 +64,6 @@ ...@@ -64,11 +64,6 @@
#include "utilities/growableArray.hpp" #include "utilities/growableArray.hpp"
#include "utilities/macros.hpp" #include "utilities/macros.hpp"
#include "utilities/ostream.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; ClassLoaderData * ClassLoaderData::_the_null_class_loader_data = NULL;
...@@ -753,29 +748,6 @@ bool ClassLoaderDataGraph::contains_loader_data(ClassLoaderData* loader_data) { ...@@ -753,29 +748,6 @@ bool ClassLoaderDataGraph::contains_loader_data(ClassLoaderData* loader_data) {
} }
#endif // PRODUCT #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 // Move class loader data from main list to the unloaded list for unloading
// and deallocation later. // and deallocation later.
bool ClassLoaderDataGraph::do_unloading(BoolObjectClosure* is_alive_closure, bool clean_alive) { bool ClassLoaderDataGraph::do_unloading(BoolObjectClosure* is_alive_closure, bool clean_alive) {
...@@ -815,10 +787,6 @@ bool ClassLoaderDataGraph::do_unloading(BoolObjectClosure* is_alive_closure, boo ...@@ -815,10 +787,6 @@ bool ClassLoaderDataGraph::do_unloading(BoolObjectClosure* is_alive_closure, boo
ClassLoaderDataGraph::clean_metaspaces(); ClassLoaderDataGraph::clean_metaspaces();
} }
if (seen_dead_loader) {
JFR_ONLY(post_class_unload_events();)
}
return seen_dead_loader; return seen_dead_loader;
} }
......
...@@ -138,6 +138,9 @@ bool SystemDictionary::is_internal_format(Symbol* class_name) { ...@@ -138,6 +138,9 @@ bool SystemDictionary::is_internal_format(Symbol* class_name) {
} }
} }
#endif
#if INCLUDE_JFR
#include "jfr/jfr.hpp"
#endif #endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
...@@ -1749,6 +1752,7 @@ bool SystemDictionary::do_unloading(BoolObjectClosure* is_alive, bool clean_aliv ...@@ -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. // First, mark for unload all ClassLoaderData referencing a dead class loader.
bool unloading_occurred = ClassLoaderDataGraph::do_unloading(is_alive, clean_alive); bool unloading_occurred = ClassLoaderDataGraph::do_unloading(is_alive, clean_alive);
if (unloading_occurred) { if (unloading_occurred) {
JFR_ONLY(Jfr::on_unloading_classes();)
dictionary()->do_unloading(); dictionary()->do_unloading();
constraints()->purge_loader_constraints(); constraints()->purge_loader_constraints();
resolution_errors()->purge_resolution_errors(); resolution_errors()->purge_resolution_errors();
......
...@@ -78,6 +78,10 @@ ...@@ -78,6 +78,10 @@
#ifdef COMPILER1 #ifdef COMPILER1
#include "c1/c1_Compiler.hpp" #include "c1/c1_Compiler.hpp"
#endif #endif
#if INCLUDE_JFR
#include "jfr/jfrEvents.hpp"
#endif
PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
...@@ -2526,6 +2530,14 @@ void InstanceKlass::notify_unload_class(InstanceKlass* ik) { ...@@ -2526,6 +2530,14 @@ void InstanceKlass::notify_unload_class(InstanceKlass* ik) {
// notify ClassLoadingService of class unload // notify ClassLoadingService of class unload
ClassLoadingService::notify_class_unloaded(ik); 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) { void InstanceKlass::release_C_heap_structures(InstanceKlass* ik) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册