8209802: Garbage collectors should register JFR types themselves to avoid build errors

Reviewed-by: kbarrett, tschatzl
This commit is contained in:
Stefan Johansson 2019-09-04 09:47:55 +02:00
parent bb63558420
commit f7d0ece0a1
8 changed files with 61 additions and 51 deletions

View File

@ -1567,6 +1567,7 @@ G1CollectedHeap::G1CollectedHeap() :
// Initialize the G1EvacuationFailureALot counters and flags.
NOT_PRODUCT(reset_evacuation_should_fail();)
_gc_tracer_stw->initialize();
guarantee(_task_queues != NULL, "task_queues allocation failure.");
}

View File

@ -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 @@ public:
}
};
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);
}
}

View File

@ -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);

View File

@ -48,6 +48,7 @@ class G1NewTracer : public YoungGCTracer {
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);

View File

@ -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 @@ TRACE_REQUEST_FUNC(ObjectCount) {
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

View File

@ -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 GCWhenConstant::serialize(JfrCheckpointWriter& writer) {
}
}
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 MetaspaceObjectTypeConstant::serialize(JfrCheckpointWriter& writer) {
}
}
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";

View File

@ -67,11 +67,6 @@ class GCWhenConstant : public JfrSerializer {
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 @@ class MetaspaceObjectTypeConstant : public JfrSerializer {
void serialize(JfrCheckpointWriter& writer);
};
class G1YCTypeConstant : public JfrSerializer {
public:
void serialize(JfrCheckpointWriter& writer);
};
class ReferenceTypeConstant : public JfrSerializer {
public:
void serialize(JfrCheckpointWriter& writer);

View File

@ -226,11 +226,9 @@ bool JfrTypeManager::initialize() {
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());