Missing object id in pool jdk.types.Symbol. All ids should reference object JEP-349-branch
authormgronlun
Sat, 21 Sep 2019 12:33:26 +0200
branchJEP-349-branch
changeset 58251 c4067538a0f2
parent 58250 5851f445c684
child 58253 67151bcd8b14
Missing object id in pool jdk.types.Symbol. All ids should reference object
src/hotspot/share/jfr/jfr.cpp
src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp
src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp
src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.hpp
src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp
src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.hpp
src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp
src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.hpp
src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSetUtils.cpp
src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSetUtils.hpp
--- a/src/hotspot/share/jfr/jfr.cpp	Sat Sep 21 12:31:40 2019 +0200
+++ b/src/hotspot/share/jfr/jfr.cpp	Sat Sep 21 12:33:26 2019 +0200
@@ -58,7 +58,7 @@
 }
 
 void Jfr::on_unloading_classes() {
-  if (JfrRecorder::is_created()) {
+  if (JfrRecorder::is_recording()) {
     JfrCheckpointManager::write_type_set_for_unloaded_classes();
   }
 }
--- a/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp	Sat Sep 21 12:31:40 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp	Sat Sep 21 12:33:26 2019 +0200
@@ -357,6 +357,7 @@
 
 typedef DiscardOp<DefaultDiscarder<JfrBuffer> > DiscardOperation;
 size_t JfrCheckpointManager::clear() {
+  JfrTypeManager::clear();
   DiscardOperation discarder(mutexed); // mutexed discard mode
   process_free_list(discarder, _free_list_mspace);
   process_free_list(discarder, _epoch_transition_mspace);
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp	Sat Sep 21 12:31:40 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp	Sat Sep 21 12:33:26 2019 +0200
@@ -303,6 +303,10 @@
 
 TypeSet::TypeSet(JfrCheckpointWriter* leakp_writer) : _leakp_writer(leakp_writer) {}
 
+void TypeSet::clear() {
+  JfrTypeSet::clear();
+}
+
 void TypeSet::serialize(JfrCheckpointWriter& writer) {
   assert(!SafepointSynchronize::is_at_safepoint(), "invariant");
   MutexLocker cld_lock(ClassLoaderDataGraph_lock);
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.hpp	Sat Sep 21 12:31:40 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.hpp	Sat Sep 21 12:33:26 2019 +0200
@@ -33,6 +33,7 @@
  public:
   explicit TypeSet(JfrCheckpointWriter* leakp_writer = NULL);
   void serialize(JfrCheckpointWriter& writer);
+  void clear();
 };
 
 class ClassUnloadTypeSet : public JfrSerializer {
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp	Sat Sep 21 12:31:40 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp	Sat Sep 21 12:33:26 2019 +0200
@@ -195,7 +195,7 @@
 typedef StopOnNullIterator<const List> Iterator;
 static List types;
 
-void JfrTypeManager::clear() {
+void JfrTypeManager::destroy() {
   SerializerRegistrationGuard guard;
   Iterator iter(types);
   JfrSerializerRegistration* registration;
@@ -206,6 +206,11 @@
   }
 }
 
+void JfrTypeManager::clear() {
+  TypeSet type_set;
+  type_set.clear();
+}
+
 void JfrTypeManager::on_rotation() {
   const Iterator iter(types);
   while (iter.has_next()) {
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.hpp	Sat Sep 21 12:31:40 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.hpp	Sat Sep 21 12:33:26 2019 +0200
@@ -32,6 +32,7 @@
 class JfrTypeManager : public AllStatic {
  public:
   static bool initialize();
+  static void destroy();
   static void clear();
   static void on_rotation();
   static void write_threads(JfrCheckpointWriter& writer);
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp	Sat Sep 21 12:31:40 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp	Sat Sep 21 12:33:26 2019 +0200
@@ -824,6 +824,12 @@
   _artifacts->tally(sw);
 }
 
+static bool clear_artifacts = false;
+
+void JfrTypeSet::clear() {
+  clear_artifacts = true;
+}
+
 typedef Wrapper<KlassPtr, ClearArtifact> ClearKlassBits;
 typedef Wrapper<MethodPtr, ClearArtifact> ClearMethodFlag;
 typedef MethodIteratorHost<ClearMethodFlag, ClearKlassBits, false> ClearKlassAndMethods;
@@ -835,7 +841,7 @@
     assert(_writer != NULL, "invariant");
     ClearKlassAndMethods clear(_writer);
     _artifacts->iterate_klasses(clear);
-    _artifacts->clear();
+    JfrTypeSet::clear();
     ++checkpoint_id;
   }
   return total_count;
@@ -849,7 +855,8 @@
   if (_artifacts == NULL) {
     _artifacts = new JfrArtifactSet(class_unload);
   } else {
-    _artifacts->initialize(class_unload);
+    _artifacts->initialize(class_unload, clear_artifacts);
+    clear_artifacts = false;
   }
   assert(_artifacts != NULL, "invariant");
   assert(!_artifacts->has_klass_entries(), "invariant");
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.hpp	Sat Sep 21 12:31:40 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.hpp	Sat Sep 21 12:33:26 2019 +0200
@@ -31,6 +31,7 @@
 
 class JfrTypeSet : AllStatic {
  public:
+  static void clear();
   static size_t serialize(JfrCheckpointWriter* writer, JfrCheckpointWriter* leakp_writer, bool class_unload, bool flushpoint);
 };
 
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSetUtils.cpp	Sat Sep 21 12:31:40 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSetUtils.cpp	Sat Sep 21 12:33:26 2019 +0200
@@ -68,7 +68,6 @@
   assert(!_cstring_table->has_entries(), "invariant");
 
   _sym_list = NULL;
-  _cstring_list = NULL;
   _symbol_id_counter = 1;
 
   _sym_query = NULL;
@@ -248,16 +247,19 @@
 }
 
 JfrArtifactSet::JfrArtifactSet(bool class_unload) : _symbol_id(new JfrSymbolId()),
-                                                     _klass_list(NULL),
-                                                     _total_count(0) {
+                                                    _klass_list(NULL),
+                                                    _total_count(0) {
   initialize(class_unload);
   assert(_klass_list != NULL, "invariant");
 }
 
 static const size_t initial_class_list_size = 200;
 
-void JfrArtifactSet::initialize(bool class_unload) {
+void JfrArtifactSet::initialize(bool class_unload, bool clear /* false */) {
   assert(_symbol_id != NULL, "invariant");
+  if (clear) {
+    _symbol_id->clear();
+  }
   _symbol_id->set_class_unload(class_unload);
   _total_count = 0;
   // resource allocation
@@ -265,12 +267,8 @@
 }
 
 JfrArtifactSet::~JfrArtifactSet() {
-  clear();
+  _symbol_id->clear();
   delete _symbol_id;
-}
-
-void JfrArtifactSet::clear() {
-  _symbol_id->clear();
   // _klass_list will be cleared by a ResourceMark
 }
 
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSetUtils.hpp	Sat Sep 21 12:31:40 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSetUtils.hpp	Sat Sep 21 12:33:26 2019 +0200
@@ -302,9 +302,7 @@
   ~JfrArtifactSet();
 
   // caller needs ResourceMark
-  void initialize(bool class_unload);
-  void clear();
-
+  void initialize(bool class_unload, bool clear = false);
 
   traceid mark(uintptr_t hash, const Symbol* sym, bool leakp);
   traceid mark(const Klass* klass, bool leakp);