8209802: Garbage collectors should register JFR types themselves to avoid build errors.
Reviewed-by: kbarrett, tschatzl
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp Wed Sep 04 09:47:51 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp Wed Sep 04 09:47:55 2019 +0200
@@ -1567,6 +1567,7 @@
// Initialize the G1EvacuationFailureALot counters and flags.
NOT_PRODUCT(reset_evacuation_should_fail();)
+ _gc_tracer_stw->initialize();
guarantee(_task_queues != NULL, "task_queues allocation failure.");
}
--- a/src/hotspot/share/gc/g1/g1HeapRegionEventSender.cpp Wed Sep 04 09:47:51 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1HeapRegionEventSender.cpp Wed Sep 04 09:47:55 2019 +0200
@@ -27,6 +27,7 @@
#include "gc/g1/heapRegion.hpp"
#include "g1HeapRegionEventSender.hpp"
#include "jfr/jfrEvents.hpp"
+#include "runtime/vmThread.hpp"
class DumpEventInfoClosure : public HeapRegionClosure {
public:
@@ -41,9 +42,17 @@
}
};
+class VM_G1SendHeapRegionInfoEvents : public VM_Operation {
+ virtual void doit() {
+ DumpEventInfoClosure c;
+ G1CollectedHeap::heap()->heap_region_iterate(&c);
+ }
+ virtual VMOp_Type type() const { return VMOp_HeapIterateOperation; }
+};
void G1HeapRegionEventSender::send_events() {
- DumpEventInfoClosure c;
-
- G1CollectedHeap::heap()->heap_region_iterate(&c);
+ if (UseG1GC) {
+ VM_G1SendHeapRegionInfoEvents op;
+ VMThread::execute(&op);
+ }
}
--- a/src/hotspot/share/gc/g1/g1Trace.cpp Wed Sep 04 09:47:51 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1Trace.cpp Wed Sep 04 09:47:55 2019 +0200
@@ -24,10 +24,53 @@
#include "precompiled.hpp"
#include "gc/g1/g1EvacuationInfo.hpp"
+#include "gc/g1/g1HeapRegionTraceType.hpp"
#include "gc/g1/g1Trace.hpp"
#include "gc/g1/g1YCTypes.hpp"
#include "gc/shared/gcHeapSummary.hpp"
#include "jfr/jfrEvents.hpp"
+#if INCLUDE_JFR
+#include "jfr/metadata/jfrSerializer.hpp"
+#endif
+
+#if INCLUDE_JFR
+class G1HeapRegionTypeConstant : public JfrSerializer {
+public:
+ void serialize(JfrCheckpointWriter& writer) {
+ static const u4 nof_entries = G1HeapRegionTraceType::G1HeapRegionTypeEndSentinel;
+ writer.write_count(nof_entries);
+ for (u4 i = 0; i < nof_entries; ++i) {
+ writer.write_key(i);
+ writer.write(G1HeapRegionTraceType::to_string((G1HeapRegionTraceType::Type)i));
+ }
+}
+};
+
+class G1YCTypeConstant : public JfrSerializer {
+public:
+ void serialize(JfrCheckpointWriter& writer) {
+ static const u4 nof_entries = G1YCTypeEndSentinel;
+ writer.write_count(nof_entries);
+ for (u4 i = 0; i < nof_entries; ++i) {
+ writer.write_key(i);
+ writer.write(G1YCTypeHelper::to_string((G1YCType)i));
+ }
+ }
+};
+
+static void register_jfr_type_constants() {
+ JfrSerializer::register_serializer(TYPE_G1HEAPREGIONTYPE, false, true,
+ new G1HeapRegionTypeConstant());
+
+ JfrSerializer::register_serializer(TYPE_G1YCTYPE, false, true,
+ new G1YCTypeConstant());
+}
+
+#endif
+
+void G1NewTracer::initialize() {
+ JFR_ONLY(register_jfr_type_constants());
+}
void G1NewTracer::report_yc_type(G1YCType type) {
_g1_young_gc_info.set_type(type);
--- a/src/hotspot/share/gc/g1/g1Trace.hpp Wed Sep 04 09:47:51 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1Trace.hpp Wed Sep 04 09:47:55 2019 +0200
@@ -48,6 +48,7 @@
public:
G1NewTracer() : YoungGCTracer(G1New) {}
+ void initialize();
void report_yc_type(G1YCType type);
void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions);
void report_evacuation_info(G1EvacuationInfo* info);
--- a/src/hotspot/share/jfr/periodic/jfrPeriodic.cpp Wed Sep 04 09:47:51 2019 +0200
+++ b/src/hotspot/share/jfr/periodic/jfrPeriodic.cpp Wed Sep 04 09:47:55 2019 +0200
@@ -32,7 +32,6 @@
#include "classfile/systemDictionary.hpp"
#include "code/codeCache.hpp"
#include "compiler/compileBroker.hpp"
-#include "gc/g1/g1HeapRegionEventSender.hpp"
#include "gc/shared/gcConfiguration.hpp"
#include "gc/shared/gcTrace.hpp"
#include "gc/shared/gcVMOperations.hpp"
@@ -65,6 +64,9 @@
#include "services/threadService.hpp"
#include "utilities/exceptions.hpp"
#include "utilities/globalDefinitions.hpp"
+#if INCLUDE_G1GC
+#include "gc/g1/g1HeapRegionEventSender.hpp"
+#endif
#if INCLUDE_SHENANDOAHGC
#include "gc/shenandoah/shenandoahJfrSupport.hpp"
#endif
@@ -323,18 +325,8 @@
VMThread::execute(&op);
}
-class VM_G1SendHeapRegionInfoEvents : public VM_Operation {
- virtual void doit() {
- G1HeapRegionEventSender::send_events();
- }
- virtual VMOp_Type type() const { return VMOp_HeapIterateOperation; }
-};
-
TRACE_REQUEST_FUNC(G1HeapRegionInformation) {
- if (UseG1GC) {
- VM_G1SendHeapRegionInfoEvents op;
- VMThread::execute(&op);
- }
+ G1GC_ONLY(G1HeapRegionEventSender::send_events());
}
// Java Mission Control (JMC) uses (Java) Long.MIN_VALUE to describe that a
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp Wed Sep 04 09:47:51 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp Wed Sep 04 09:47:55 2019 +0200
@@ -56,10 +56,6 @@
#include "opto/compile.hpp"
#include "opto/node.hpp"
#endif
-#if INCLUDE_G1GC
-#include "gc/g1/g1HeapRegionTraceType.hpp"
-#include "gc/g1/g1YCTypes.hpp"
-#endif
// Requires a ResourceMark for get_thread_name/as_utf8
class JfrCheckpointThreadClosure : public ThreadClosure {
@@ -188,15 +184,6 @@
}
}
-void G1HeapRegionTypeConstant::serialize(JfrCheckpointWriter& writer) {
- static const u4 nof_entries = G1HeapRegionTraceType::G1HeapRegionTypeEndSentinel;
- writer.write_count(nof_entries);
- for (u4 i = 0; i < nof_entries; ++i) {
- writer.write_key(i);
- writer.write(G1HeapRegionTraceType::to_string((G1HeapRegionTraceType::Type)i));
- }
-}
-
void GCThresholdUpdaterConstant::serialize(JfrCheckpointWriter& writer) {
static const u4 nof_entries = MetaspaceGCThresholdUpdater::Last;
writer.write_count(nof_entries);
@@ -224,17 +211,6 @@
}
}
-void G1YCTypeConstant::serialize(JfrCheckpointWriter& writer) {
-#if INCLUDE_G1GC
- static const u4 nof_entries = G1YCTypeEndSentinel;
- writer.write_count(nof_entries);
- for (u4 i = 0; i < nof_entries; ++i) {
- writer.write_key(i);
- writer.write(G1YCTypeHelper::to_string((G1YCType)i));
- }
-#endif
-}
-
static const char* reference_type_to_string(ReferenceType rt) {
switch (rt) {
case REF_NONE: return "None reference";
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.hpp Wed Sep 04 09:47:51 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.hpp Wed Sep 04 09:47:55 2019 +0200
@@ -67,11 +67,6 @@
void serialize(JfrCheckpointWriter& writer);
};
-class G1HeapRegionTypeConstant : public JfrSerializer {
- public:
- void serialize(JfrCheckpointWriter& writer);
-};
-
class GCThresholdUpdaterConstant : public JfrSerializer {
public:
void serialize(JfrCheckpointWriter& writer);
@@ -87,11 +82,6 @@
void serialize(JfrCheckpointWriter& writer);
};
-class G1YCTypeConstant : public JfrSerializer {
- public:
- void serialize(JfrCheckpointWriter& writer);
-};
-
class ReferenceTypeConstant : public JfrSerializer {
public:
void serialize(JfrCheckpointWriter& writer);
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp Wed Sep 04 09:47:51 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp Wed Sep 04 09:47:55 2019 +0200
@@ -226,11 +226,9 @@
register_type(TYPE_GCCAUSE, false, true, new GCCauseConstant());
register_type(TYPE_GCNAME, false, true, new GCNameConstant());
register_type(TYPE_GCWHEN, false, true, new GCWhenConstant());
- register_type(TYPE_G1HEAPREGIONTYPE, false, true, new G1HeapRegionTypeConstant());
register_type(TYPE_GCTHRESHOLDUPDATER, false, true, new GCThresholdUpdaterConstant());
register_type(TYPE_METADATATYPE, false, true, new MetadataTypeConstant());
register_type(TYPE_METASPACEOBJECTTYPE, false, true, new MetaspaceObjectTypeConstant());
- register_type(TYPE_G1YCTYPE, false, true, new G1YCTypeConstant());
register_type(TYPE_REFERENCETYPE, false, true, new ReferenceTypeConstant());
register_type(TYPE_NARROWOOPMODE, false, true, new NarrowOopModeConstant());
register_type(TYPE_COMPILERPHASETYPE, false, true, new CompilerPhaseTypeConstant());