--- old/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2019-09-02 16:46:22.077491335 +0200 +++ new/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2019-09-02 16:46:21.673489331 +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."); } --- old/src/hotspot/share/gc/g1/g1HeapRegionEventSender.cpp 2019-09-02 16:46:23.161496710 +0200 +++ new/src/hotspot/share/gc/g1/g1HeapRegionEventSender.cpp 2019-09-02 16:46:22.753494687 +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); + } } --- old/src/hotspot/share/gc/g1/g1Trace.cpp 2019-09-02 16:46:24.161501669 +0200 +++ new/src/hotspot/share/gc/g1/g1Trace.cpp 2019-09-02 16:46:23.761499685 +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); --- old/src/hotspot/share/gc/g1/g1Trace.hpp 2019-09-02 16:46:25.165506647 +0200 +++ new/src/hotspot/share/gc/g1/g1Trace.hpp 2019-09-02 16:46:24.757504624 +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); --- old/src/hotspot/share/jfr/periodic/jfrPeriodic.cpp 2019-09-02 16:46:26.169511626 +0200 +++ new/src/hotspot/share/jfr/periodic/jfrPeriodic.cpp 2019-09-02 16:46:25.765509622 +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 --- old/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp 2019-09-02 16:46:27.181516644 +0200 +++ new/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp 2019-09-02 16:46:26.773514621 +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"; --- old/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.hpp 2019-09-02 16:46:28.189521642 +0200 +++ new/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.hpp 2019-09-02 16:46:27.781519619 +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); @@ -86,11 +81,6 @@ public: void serialize(JfrCheckpointWriter& writer); }; - -class G1YCTypeConstant : public JfrSerializer { - public: - void serialize(JfrCheckpointWriter& writer); -}; class ReferenceTypeConstant : public JfrSerializer { public: --- old/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp 2019-09-02 16:46:29.173526522 +0200 +++ new/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp 2019-09-02 16:46:28.761524479 +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());