@@ -979,7 +979,11 @@ class PostCompactionPrinterClosure: public HeapRegionClosure {
979979 : _hr_printer(hr_printer) { }
980980};
981981
982- void G1CollectedHeap::print_hrm_post_compaction () {
982+ void G1CollectedHeap::print_heap_after_full_collection () {
983+ // Post collection region logging.
984+ // We should do this after we potentially resize the heap so
985+ // that all the COMMIT / UNCOMMIT events are generated before
986+ // the compaction events.
983987 if (_hr_printer.is_active ()) {
984988 PostCompactionPrinterClosure cl (hr_printer ());
985989 heap_region_iterate (&cl);
@@ -1091,17 +1095,6 @@ void G1CollectedHeap::verify_after_full_collection() {
10911095 _ref_processor_cm->verify_no_references_recorded ();
10921096}
10931097
1094- void G1CollectedHeap::print_heap_after_full_collection (G1HeapTransition* heap_transition) {
1095- // Post collection logging.
1096- // We should do this after we potentially resize the heap so
1097- // that all the COMMIT / UNCOMMIT events are generated before
1098- // the compaction events.
1099- print_hrm_post_compaction ();
1100- heap_transition->print ();
1101- print_heap_after_gc ();
1102- print_heap_regions ();
1103- }
1104-
11051098bool G1CollectedHeap::do_full_collection (bool explicit_gc,
11061099 bool clear_all_soft_refs,
11071100 bool do_maximum_compaction) {
@@ -2566,9 +2559,6 @@ void G1CollectedHeap::trace_heap(GCWhen::Type when, const GCTracer* gc_tracer) {
25662559void G1CollectedHeap::gc_prologue (bool full) {
25672560 assert (InlineCacheBuffer::is_empty (), " should have cleaned up ICBuffer" );
25682561
2569- // This summary needs to be printed before incrementing total collections.
2570- rem_set ()->print_periodic_summary_info (" Before GC RS summary" , total_collections ());
2571-
25722562 // Update common counters.
25732563 increment_total_collections (full /* full gc */ );
25742564 if (full || collector_state ()->in_concurrent_start_gc ()) {
@@ -2601,9 +2591,6 @@ void G1CollectedHeap::gc_epilogue(bool full) {
26012591 increment_old_marking_cycles_completed (false /* concurrent */ , true /* liveness_completed */ );
26022592 }
26032593
2604- // We are at the end of the GC. Total collections has already been increased.
2605- rem_set ()->print_periodic_summary_info (" After GC RS summary" , total_collections () - 1 );
2606-
26072594#if COMPILER2_OR_JVMCI
26082595 assert (DerivedPointerTable::is_empty (), " derived pointer present" );
26092596#endif
@@ -2617,9 +2604,6 @@ void G1CollectedHeap::gc_epilogue(bool full) {
26172604 // policy with the new heap occupancy
26182605 Universe::heap ()->update_capacity_and_used_at_gc ();
26192606
2620- // Print NUMA statistics.
2621- _numa->print_statistics ();
2622-
26232607 _collection_pause_end = Ticks::now ();
26242608}
26252609
@@ -2805,10 +2789,10 @@ void G1CollectedHeap::start_new_collection_set() {
28052789 phase_times ()->record_start_new_cset_time_ms ((os::elapsedTime () - start) * 1000.0 );
28062790}
28072791
2808- void G1CollectedHeap::calculate_collection_set (G1EvacuationInfo& evacuation_info, double target_pause_time_ms) {
2792+ void G1CollectedHeap::calculate_collection_set (G1EvacuationInfo* evacuation_info, double target_pause_time_ms) {
28092793
28102794 _collection_set.finalize_initial_collection_set (target_pause_time_ms, &_survivor);
2811- evacuation_info. set_collectionset_regions (collection_set ()->region_length () +
2795+ evacuation_info-> set_collectionset_regions (collection_set ()->region_length () +
28122796 collection_set ()->optional_region_length ());
28132797
28142798 _cm->verify_no_collection_set_oops ();
@@ -2903,6 +2887,64 @@ void G1CollectedHeap::gc_tracer_report_gc_end(bool concurrent_operation_is_full_
29032887 _gc_timer_stw->time_partitions ());
29042888}
29052889
2890+ G1HeapPrinterMark::G1HeapPrinterMark (G1CollectedHeap* g1h) : _g1h(g1h), _heap_transition(g1h) {
2891+ // This summary needs to be printed before incrementing total collections.
2892+ _g1h->rem_set ()->print_periodic_summary_info (" Before GC RS summary" , _g1h->total_collections ());
2893+ _g1h->print_heap_before_gc ();
2894+ _g1h->print_heap_regions ();
2895+ }
2896+
2897+ G1HeapPrinterMark::~G1HeapPrinterMark () {
2898+ _g1h->policy ()->print_age_table ();
2899+ // not (yet) in 17u: _g1h->rem_set()->print_coarsen_stats();
2900+ // We are at the end of the GC. Total collections has already been increased.
2901+ _g1h->rem_set ()->print_periodic_summary_info (" After GC RS summary" , _g1h->total_collections () - 1 );
2902+
2903+ _heap_transition.print ();
2904+ _g1h->print_heap_regions ();
2905+ _g1h->print_heap_after_gc ();
2906+ // Print NUMA statistics.
2907+ _g1h->numa ()->print_statistics ();
2908+ }
2909+
2910+ G1JFRTracerMark::G1JFRTracerMark (STWGCTimer* timer, GCTracer* tracer) :
2911+ _timer(timer), _tracer(tracer) {
2912+
2913+ _timer->register_gc_start ();
2914+ _tracer->report_gc_start (G1CollectedHeap::heap ()->gc_cause (), _timer->gc_start ());
2915+ G1CollectedHeap::heap ()->trace_heap_before_gc (_tracer);
2916+ }
2917+
2918+ G1JFRTracerMark::~G1JFRTracerMark () {
2919+ G1CollectedHeap::heap ()->trace_heap_after_gc (_tracer);
2920+ _timer->register_gc_end ();
2921+ _tracer->report_gc_end (_timer->gc_end (), _timer->time_partitions ());
2922+ }
2923+
2924+ class G1YoungGCJFRTracerMark : public G1JFRTracerMark {
2925+ G1EvacuationInfo _evacuation_info;
2926+
2927+ G1NewTracer* tracer () const { return (G1NewTracer*)_tracer; }
2928+
2929+ public:
2930+
2931+ G1EvacuationInfo* evacuation_info () { return &_evacuation_info; }
2932+
2933+ G1YoungGCJFRTracerMark (STWGCTimer* gc_timer_stw, G1NewTracer* gc_tracer_stw, GCCause::Cause cause) :
2934+ G1JFRTracerMark (gc_timer_stw, gc_tracer_stw), _evacuation_info() { }
2935+
2936+ void report_pause_type (G1GCPauseType type) {
2937+ tracer ()->report_young_gc_pause (type);
2938+ }
2939+
2940+ ~G1YoungGCJFRTracerMark () {
2941+ G1CollectedHeap* g1h = G1CollectedHeap::heap ();
2942+
2943+ tracer ()->report_evacuation_info (&_evacuation_info);
2944+ tracer ()->report_tenuring_threshold (g1h->policy ()->tenuring_threshold ());
2945+ }
2946+ };
2947+
29062948void G1CollectedHeap::do_collection_pause_at_safepoint_helper (double target_pause_time_ms) {
29072949 GCIdMark gc_id_mark;
29082950
@@ -2911,14 +2953,8 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus
29112953
29122954 policy ()->note_gc_start ();
29132955
2914- gc_tracer_report_gc_start ();
2915-
29162956 wait_for_root_region_scanning ();
29172957
2918- print_heap_before_gc ();
2919- print_heap_regions ();
2920- trace_heap_before_gc (_gc_tracer_stw);
2921-
29222958 _verifier->verify_region_sets_optional ();
29232959 _verifier->verify_dirty_young_regions ();
29242960
@@ -2944,8 +2980,6 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus
29442980
29452981 // Inner scope for scope based logging, timers, and stats collection
29462982 {
2947- G1EvacuationInfo evacuation_info;
2948-
29492983 GCTraceCPUTime tcpu;
29502984
29512985 char young_gc_name[MaxYoungGCNameLength];
@@ -2959,11 +2993,13 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus
29592993 active_workers = workers ()->update_active_workers (active_workers);
29602994 log_info (gc,task)(" Using %u workers of %u for evacuation" , active_workers, workers ()->total_workers ());
29612995
2996+ // JFR
2997+ G1YoungGCJFRTracerMark jtm (_gc_timer_stw, _gc_tracer_stw, gc_cause ());
29622998 G1MonitoringScope ms (g1mm (),
29632999 false /* full_gc */ ,
29643000 collector_state ()->in_mixed_phase () /* all_memory_pools_affected */ );
29653001
2966- G1HeapTransition heap_transition (this );
3002+ G1HeapPrinterMark hpm (this );
29673003
29683004 {
29693005 IsGCActiveMark x;
@@ -2995,15 +3031,15 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus
29953031 // of the collection set!).
29963032 _allocator->release_mutator_alloc_regions ();
29973033
2998- calculate_collection_set (evacuation_info, target_pause_time_ms);
3034+ calculate_collection_set (jtm. evacuation_info () , target_pause_time_ms);
29993035
30003036 G1RedirtyCardsQueueSet rdcqs (G1BarrierSet::dirty_card_queue_set ().allocator ());
30013037 G1ParScanThreadStateSet per_thread_states (this ,
30023038 &rdcqs,
30033039 workers ()->active_workers (),
30043040 collection_set ()->young_region_length (),
30053041 collection_set ()->optional_region_length ());
3006- pre_evacuate_collection_set (evacuation_info, &per_thread_states);
3042+ pre_evacuate_collection_set (jtm. evacuation_info () , &per_thread_states);
30073043
30083044 bool may_do_optional_evacuation = _collection_set.optional_region_length () != 0 ;
30093045 // Actually do the work...
@@ -3012,7 +3048,7 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus
30123048 if (may_do_optional_evacuation) {
30133049 evacuate_optional_collection_set (&per_thread_states);
30143050 }
3015- post_evacuate_collection_set (evacuation_info, &rdcqs, &per_thread_states);
3051+ post_evacuate_collection_set (jtm. evacuation_info () , &rdcqs, &per_thread_states);
30163052
30173053 start_new_collection_set ();
30183054
@@ -3031,7 +3067,7 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus
30313067
30323068 // Need to report the collection pause now since record_collection_pause_end()
30333069 // modifies it to the next state.
3034- _gc_tracer_stw-> report_young_gc_pause (collector_state ()->young_gc_pause_type (concurrent_operation_is_full_mark));
3070+ jtm. report_pause_type (collector_state ()->young_gc_pause_type (concurrent_operation_is_full_mark));
30353071
30363072 double sample_end_time_sec = os::elapsedTime ();
30373073 double pause_time_ms = (sample_end_time_sec - sample_start_time_sec) * MILLIUNITS;
@@ -3049,25 +3085,18 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus
30493085 }
30503086
30513087 policy ()->print_phases ();
3052- heap_transition.print ();
30533088
30543089 _hrm.verify_optional ();
30553090 _verifier->verify_region_sets_optional ();
30563091
30573092 TASKQUEUE_STATS_ONLY (print_taskqueue_stats ());
30583093 TASKQUEUE_STATS_ONLY (reset_taskqueue_stats ());
30593094
3060- print_heap_after_gc ();
3061- print_heap_regions ();
3062- trace_heap_after_gc (_gc_tracer_stw);
3063-
30643095 // We must call G1MonitoringSupport::update_sizes() in the same scoping level
30653096 // as an active TraceMemoryManagerStats object (i.e. before the destructor for the
30663097 // TraceMemoryManagerStats is called) so that the G1 memory pools are updated
30673098 // before any GC notifications are raised.
30683099 g1mm ()->update_sizes ();
3069-
3070- gc_tracer_report_gc_end (concurrent_operation_is_full_mark, evacuation_info);
30713100 }
30723101 // It should now be safe to tell the concurrent mark thread to start
30733102 // without its logging output interfering with the logging output
@@ -3490,7 +3519,7 @@ class G1PrepareEvacuationTask : public AbstractGangTask {
34903519 }
34913520};
34923521
3493- void G1CollectedHeap::pre_evacuate_collection_set (G1EvacuationInfo& evacuation_info, G1ParScanThreadStateSet* per_thread_states) {
3522+ void G1CollectedHeap::pre_evacuate_collection_set (G1EvacuationInfo* evacuation_info, G1ParScanThreadStateSet* per_thread_states) {
34943523 _bytes_used_during_gc = 0 ;
34953524
34963525 _expand_heap_after_alloc_failure = true ;
@@ -3756,7 +3785,7 @@ void G1CollectedHeap::evacuate_optional_collection_set(G1ParScanThreadStateSet*
37563785 _collection_set.abandon_optional_collection_set (per_thread_states);
37573786}
37583787
3759- void G1CollectedHeap::post_evacuate_collection_set (G1EvacuationInfo& evacuation_info,
3788+ void G1CollectedHeap::post_evacuate_collection_set (G1EvacuationInfo* evacuation_info,
37603789 G1RedirtyCardsQueueSet* rdcqs,
37613790 G1ParScanThreadStateSet* per_thread_states) {
37623791 G1GCPhaseTimes* p = phase_times ();
@@ -3777,18 +3806,16 @@ void G1CollectedHeap::post_evacuate_collection_set(G1EvacuationInfo& evacuation_
37773806
37783807 post_evacuate_cleanup_1 (per_thread_states, rdcqs);
37793808
3780- post_evacuate_cleanup_2 (&_preserved_marks_set, rdcqs, & evacuation_info, per_thread_states->surviving_young_words ());
3809+ post_evacuate_cleanup_2 (&_preserved_marks_set, rdcqs, evacuation_info, per_thread_states->surviving_young_words ());
37813810
37823811 assert_used_and_recalculate_used_equal (this );
37833812
37843813 rebuild_free_region_list ();
37853814
37863815 record_obj_copy_mem_stats ();
37873816
3788- evacuation_info.set_collectionset_used_before (collection_set ()->bytes_used_before ());
3789- evacuation_info.set_bytes_used (_bytes_used_during_gc);
3790-
3791- policy ()->print_age_table ();
3817+ evacuation_info->set_collectionset_used_before (collection_set ()->bytes_used_before ());
3818+ evacuation_info->set_bytes_used (_bytes_used_during_gc);
37923819}
37933820
37943821void G1CollectedHeap::record_obj_copy_mem_stats () {
0 commit comments