better leak predicate JEP-349-branch
authormgronlun
Wed, 18 Sep 2019 12:17:27 +0200
branchJEP-349-branch
changeset 58206 87436c6f681f
parent 58205 9a078d4cf8a4
child 58207 704387b7f5b9
better leak predicate
src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp	Wed Sep 18 11:40:01 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp	Wed Sep 18 12:17:27 2019 +0200
@@ -204,9 +204,14 @@
   return write_klass(writer, klass, true);
 }
 
+static bool is_implied(const Klass* klass) {
+  assert(klass != NULL, "invariant");
+  return klass->is_subclass_of(SystemDictionary::ClassLoader_klass()) || klass == SystemDictionary::Object_klass();
+}
+
 static void do_implied(Klass* klass) {
   assert(klass != NULL, "invariant");
-  if (klass->is_subclass_of(SystemDictionary::ClassLoader_klass()) || klass == SystemDictionary::Object_klass()) {
+  if (is_implied(klass)) {
     if (_leakp_writer != NULL) {
       SET_LEAKP(klass);
     }
@@ -259,6 +264,16 @@
 typedef CompositeFunctor<KlassPtr, KlassWriter, KlassArtifactRegistrator> KlassWriterRegistration;
 typedef JfrArtifactCallbackHost<KlassPtr, KlassWriterRegistration> KlassCallback;
 
+template <>
+class LeakPredicate<const Klass*> {
+public:
+  LeakPredicate(bool class_unload) {}
+  bool operator()(const Klass* klass) {
+    assert(klass != NULL, "invariant");
+    return IS_LEAKP(klass) || is_implied(klass);
+  }
+};
+
 typedef LeakPredicate<KlassPtr> LeakKlassPredicate;
 typedef JfrPredicatedTypeWriterImplHost<KlassPtr, LeakKlassPredicate, write__klass__leakp> LeakKlassWriterImpl;
 typedef JfrTypeWriterHost<LeakKlassWriterImpl, TYPE_CLASS> LeakKlassWriter;