8202578: Revisit location for class unload events

Tue, 28 Aug 2018 10:10:11 -0400

author
hseigel
date
Tue, 28 Aug 2018 10:10:11 -0400
changeset 9866
41515291559a
parent 9865
5a83b7215107
child 9867
150ab470bf7f

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 file | annotate | diff | comparison | revisions
src/share/vm/classfile/systemDictionary.cpp file | annotate | diff | comparison | revisions
src/share/vm/oops/instanceKlass.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/classfile/classLoaderData.cpp	Wed Dec 12 18:35:26 2018 +0100
     1.2 +++ b/src/share/vm/classfile/classLoaderData.cpp	Tue Aug 28 10:10:11 2018 -0400
     1.3 @@ -64,11 +64,6 @@
     1.4  #include "utilities/growableArray.hpp"
     1.5  #include "utilities/macros.hpp"
     1.6  #include "utilities/ostream.hpp"
     1.7 -#include "utilities/ticks.hpp"
     1.8 -#if INCLUDE_JFR
     1.9 -#include "jfr/jfr.hpp"
    1.10 -#include "jfr/jfrEvents.hpp"
    1.11 -#endif
    1.12  
    1.13  ClassLoaderData * ClassLoaderData::_the_null_class_loader_data = NULL;
    1.14  
    1.15 @@ -753,29 +748,6 @@
    1.16  }
    1.17  #endif // PRODUCT
    1.18  
    1.19 -#if INCLUDE_JFR
    1.20 -static Ticks class_unload_time;
    1.21 -static void post_class_unload_event(Klass* const k) {
    1.22 -  assert(k != NULL, "invariant");
    1.23 -  EventClassUnload event(UNTIMED);
    1.24 -  event.set_endtime(class_unload_time);
    1.25 -  event.set_unloadedClass(k);
    1.26 -  event.set_definingClassLoader(k->class_loader_data());
    1.27 -  event.commit();
    1.28 -}
    1.29 -
    1.30 -static void post_class_unload_events() {
    1.31 -  assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
    1.32 -  if (Jfr::is_enabled()) {
    1.33 -    if (EventClassUnload::is_enabled()) {
    1.34 -      class_unload_time = Ticks::now();
    1.35 -      ClassLoaderDataGraph::classes_unloading_do(&post_class_unload_event);
    1.36 -    }
    1.37 -    Jfr::on_unloading_classes();
    1.38 -  }
    1.39 -}
    1.40 -#endif // INCLUDE_JFR
    1.41 -
    1.42  // Move class loader data from main list to the unloaded list for unloading
    1.43  // and deallocation later.
    1.44  bool ClassLoaderDataGraph::do_unloading(BoolObjectClosure* is_alive_closure, bool clean_alive) {
    1.45 @@ -815,10 +787,6 @@
    1.46      ClassLoaderDataGraph::clean_metaspaces();
    1.47    }
    1.48  
    1.49 -  if (seen_dead_loader) {
    1.50 -    JFR_ONLY(post_class_unload_events();)
    1.51 -  }
    1.52 -
    1.53    return seen_dead_loader;
    1.54  }
    1.55  
     2.1 --- a/src/share/vm/classfile/systemDictionary.cpp	Wed Dec 12 18:35:26 2018 +0100
     2.2 +++ b/src/share/vm/classfile/systemDictionary.cpp	Tue Aug 28 10:10:11 2018 -0400
     2.3 @@ -139,6 +139,9 @@
     2.4  }
     2.5  
     2.6  #endif
     2.7 +#if INCLUDE_JFR
     2.8 +#include "jfr/jfr.hpp"
     2.9 +#endif
    2.10  
    2.11  // ----------------------------------------------------------------------------
    2.12  // Parallel class loading check
    2.13 @@ -1749,6 +1752,7 @@
    2.14    // First, mark for unload all ClassLoaderData referencing a dead class loader.
    2.15    bool unloading_occurred = ClassLoaderDataGraph::do_unloading(is_alive, clean_alive);
    2.16    if (unloading_occurred) {
    2.17 +    JFR_ONLY(Jfr::on_unloading_classes();)
    2.18      dictionary()->do_unloading();
    2.19      constraints()->purge_loader_constraints();
    2.20      resolution_errors()->purge_resolution_errors();
     3.1 --- a/src/share/vm/oops/instanceKlass.cpp	Wed Dec 12 18:35:26 2018 +0100
     3.2 +++ b/src/share/vm/oops/instanceKlass.cpp	Tue Aug 28 10:10:11 2018 -0400
     3.3 @@ -78,6 +78,10 @@
     3.4  #ifdef COMPILER1
     3.5  #include "c1/c1_Compiler.hpp"
     3.6  #endif
     3.7 +#if INCLUDE_JFR
     3.8 +#include "jfr/jfrEvents.hpp"
     3.9 +#endif
    3.10 +
    3.11  
    3.12  PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
    3.13  
    3.14 @@ -2526,6 +2530,14 @@
    3.15  
    3.16    // notify ClassLoadingService of class unload
    3.17    ClassLoadingService::notify_class_unloaded(ik);
    3.18 +
    3.19 +#if INCLUDE_JFR
    3.20 +  assert(ik != NULL, "invariant");
    3.21 +  EventClassUnload event;
    3.22 +  event.set_unloadedClass(ik);
    3.23 +  event.set_definingClassLoader(ik->class_loader_data());
    3.24 +  event.commit();
    3.25 +#endif
    3.26  }
    3.27  
    3.28  void InstanceKlass::release_C_heap_structures(InstanceKlass* ik) {

mercurial