mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-18 11:53:17 +00:00
8202578: Revisit location for class unload events
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
This commit is contained in:
parent
12c27777c8
commit
eb51968f00
@ -76,11 +76,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
|
||||
|
||||
volatile size_t ClassLoaderDataGraph::_num_array_classes = 0;
|
||||
volatile size_t ClassLoaderDataGraph::_num_instance_classes = 0;
|
||||
@ -1316,29 +1311,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(bool do_cleaning) {
|
||||
@ -1382,10 +1354,6 @@ bool ClassLoaderDataGraph::do_unloading(bool do_cleaning) {
|
||||
_unloading = dead;
|
||||
}
|
||||
|
||||
if (seen_dead_loader) {
|
||||
JFR_ONLY(post_class_unload_events();)
|
||||
}
|
||||
|
||||
log_debug(class, loader, data)("do_unloading: loaders processed %u, loaders removed %u", loaders_processed, loaders_removed);
|
||||
|
||||
return seen_dead_loader;
|
||||
|
||||
@ -89,6 +89,9 @@
|
||||
#if INCLUDE_JVMCI
|
||||
#include "jvmci/jvmciRuntime.hpp"
|
||||
#endif
|
||||
#if INCLUDE_JFR
|
||||
#include "jfr/jfr.hpp"
|
||||
#endif
|
||||
|
||||
PlaceholderTable* SystemDictionary::_placeholders = NULL;
|
||||
Dictionary* SystemDictionary::_shared_dictionary = NULL;
|
||||
@ -1856,6 +1859,7 @@ bool SystemDictionary::do_unloading(GCTimer* gc_timer,
|
||||
// First, mark for unload all ClassLoaderData referencing a dead class loader.
|
||||
unloading_occurred = ClassLoaderDataGraph::do_unloading(do_cleaning);
|
||||
if (unloading_occurred) {
|
||||
JFR_ONLY(Jfr::on_unloading_classes();)
|
||||
ClassLoaderDataGraph::clean_module_and_package_info();
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,6 +80,10 @@
|
||||
#ifdef COMPILER1
|
||||
#include "c1/c1_Compiler.hpp"
|
||||
#endif
|
||||
#if INCLUDE_JFR
|
||||
#include "jfr/jfrEvents.hpp"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef DTRACE_ENABLED
|
||||
|
||||
@ -2423,6 +2427,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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user