changeset 51383:41a5b2de5ad3

8205405: ZGC: Decouple JFR type registration Reviewed-by: stefank, mgronlun
author pliden
date Mon, 25 Jun 2018 10:54:55 +0200
parents d46700d64e9c
children 45511dcfed3f
files src/hotspot/share/gc/z/zTracer.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
diffstat 4 files changed, 40 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/gc/z/zTracer.cpp	Mon Jun 25 10:41:03 2018 +0200
+++ b/src/hotspot/share/gc/z/zTracer.cpp	Mon Jun 25 10:54:55 2018 +0200
@@ -28,6 +28,44 @@
 #include "gc/shared/gcLocker.hpp"
 #include "jfr/jfrEvents.hpp"
 #include "runtime/safepointVerifiers.hpp"
+#if INCLUDE_JFR
+#include "jfr/metadata/jfrSerializer.hpp"
+#endif
+
+#if INCLUDE_JFR
+class ZStatisticsCounterTypeConstant : public JfrSerializer {
+public:
+  virtual void serialize(JfrCheckpointWriter& writer) {
+    writer.write_count(ZStatCounter::count());
+    for (ZStatCounter* counter = ZStatCounter::first(); counter != NULL; counter = counter->next()) {
+      writer.write_key(counter->id());
+      writer.write(counter->name());
+    }
+  }
+};
+
+class ZStatisticsSamplerTypeConstant : public JfrSerializer {
+public:
+  virtual void serialize(JfrCheckpointWriter& writer) {
+    writer.write_count(ZStatSampler::count());
+    for (ZStatSampler* sampler = ZStatSampler::first(); sampler != NULL; sampler = sampler->next()) {
+      writer.write_key(sampler->id());
+      writer.write(sampler->name());
+    }
+  }
+};
+
+static void register_jfr_type_serializers() {
+  JfrSerializer::register_serializer(TYPE_ZSTATISTICSCOUNTERTYPE,
+                                     false /* require_safepoint */,
+                                     true /* permit_cache */,
+                                     new ZStatisticsCounterTypeConstant());
+  JfrSerializer::register_serializer(TYPE_ZSTATISTICSSAMPLERTYPE,
+                                     false /* require_safepoint */,
+                                     true /* permit_cache */,
+                                     new ZStatisticsSamplerTypeConstant());
+}
+#endif
 
 ZTracer* ZTracer::_tracer = NULL;
 
@@ -35,7 +73,9 @@
     GCTracer(Z) {}
 
 void ZTracer::initialize() {
+  assert(_tracer == NULL, "Already initialized");
   _tracer = new (ResourceObj::C_HEAP, mtGC) ZTracer();
+  JFR_ONLY(register_jfr_type_serializers());
 }
 
 void ZTracer::send_stat_counter(uint32_t counter_id, uint64_t increment, uint64_t value) {
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp	Mon Jun 25 10:41:03 2018 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp	Mon Jun 25 10:54:55 2018 +0200
@@ -59,9 +59,6 @@
 #include "gc/g1/g1HeapRegionTraceType.hpp"
 #include "gc/g1/g1YCTypes.hpp"
 #endif
-#if INCLUDE_ZGC
-#include "gc/z/zStat.hpp"
-#endif
 
 class JfrCheckpointThreadCountClosure : public ThreadClosure {
 private:
@@ -343,23 +340,3 @@
   writer.write(thread_group_id);
   JfrThreadGroup::serialize(&writer, thread_group_id);
 }
-
-void ZStatisticsCounterTypeConstant::serialize(JfrCheckpointWriter& writer) {
-#if INCLUDE_ZGC
-  writer.write_count(ZStatCounter::count());
-  for (ZStatCounter* counter = ZStatCounter::first(); counter != NULL; counter = counter->next()) {
-    writer.write_key(counter->id());
-    writer.write(counter->name());
-  }
-#endif
-}
-
-void ZStatisticsSamplerTypeConstant::serialize(JfrCheckpointWriter& writer) {
-#if INCLUDE_ZGC
-  writer.write_count(ZStatSampler::count());
-  for (ZStatSampler* sampler = ZStatSampler::first(); sampler != NULL; sampler = sampler->next()) {
-    writer.write_key(sampler->id());
-    writer.write(sampler->name());
-  }
-#endif
-}
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.hpp	Mon Jun 25 10:41:03 2018 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.hpp	Mon Jun 25 10:54:55 2018 +0200
@@ -135,14 +135,4 @@
   void serialize(JfrCheckpointWriter& writer);
 };
 
-class ZStatisticsCounterTypeConstant : public JfrSerializer {
- public:
-  void serialize(JfrCheckpointWriter& writer);
-};
-
-class ZStatisticsSamplerTypeConstant : public JfrSerializer {
- public:
-  void serialize(JfrCheckpointWriter& writer);
-};
-
 #endif // SHARE_VM_JFR_CHECKPOINT_CONSTANT_JFRCONSTANT_HPP
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp	Mon Jun 25 10:41:03 2018 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp	Mon Jun 25 10:54:55 2018 +0200
@@ -236,8 +236,6 @@
   register_type(TYPE_CODEBLOBTYPE, false, true, new CodeBlobTypeConstant());
   register_type(TYPE_VMOPERATIONTYPE, false, true, new VMOperationTypeConstant());
   register_type(TYPE_THREADSTATE, false, true, new ThreadStateConstant());
-  register_type(TYPE_ZSTATISTICSCOUNTERTYPE, false, true, new ZStatisticsCounterTypeConstant());
-  register_type(TYPE_ZSTATISTICSSAMPLERTYPE, false, true, new ZStatisticsSamplerTypeConstant());
 
   // register safepointing type serialization
   register_type(TYPE_THREADGROUP, true, false, new JfrThreadGroupConstant());