@@ -2877,17 +2877,6 @@ void G1CollectedHeap::expand_heap_after_young_collection(){
2877
2877
}
2878
2878
}
2879
2879
2880
- void G1CollectedHeap::set_young_gc_name (char * young_gc_name) {
2881
- G1GCPauseType pause_type =
2882
- // The strings for all Concurrent Start pauses are the same, so the parameter
2883
- // does not matter here.
2884
- collector_state ()->young_gc_pause_type (false /* concurrent_operation_is_full_mark */ );
2885
- snprintf (young_gc_name,
2886
- MaxYoungGCNameLength,
2887
- " Pause Young (%s)" ,
2888
- G1GCPauseTypeHelper::to_string (pause_type));
2889
- }
2890
-
2891
2880
bool G1CollectedHeap::do_collection_pause_at_safepoint (double target_pause_time_ms) {
2892
2881
assert_at_safepoint_on_vm_thread ();
2893
2882
guarantee (!is_gc_active (), " collection is not reentrant" );
@@ -2915,6 +2904,46 @@ void G1CollectedHeap::gc_tracer_report_gc_end(bool concurrent_operation_is_full_
2915
2904
_gc_timer_stw->time_partitions ());
2916
2905
}
2917
2906
2907
+ // GCTraceTime wrapper that constructs the message according to GC pause type and
2908
+ // GC cause.
2909
+ // The code relies on the fact that GCTraceTimeWrapper stores the string passed
2910
+ // initially as a reference only, so that we can modify it as needed.
2911
+ class G1YoungGCTraceTime {
2912
+ G1GCPauseType _pause_type;
2913
+ GCCause::Cause _pause_cause;
2914
+
2915
+ static const uint MaxYoungGCNameLength = 128 ;
2916
+ char _young_gc_name_data[MaxYoungGCNameLength];
2917
+
2918
+ GCTraceTime (Info, gc) _tt;
2919
+
2920
+ const char * update_young_gc_name () {
2921
+ snprintf (_young_gc_name_data,
2922
+ MaxYoungGCNameLength,
2923
+ " Pause Young (%s) (%s)%s" ,
2924
+ G1GCPauseTypeHelper::to_string (_pause_type),
2925
+ GCCause::to_string (_pause_cause),
2926
+ G1CollectedHeap::heap ()->evacuation_failed () ? " (Evacuation Failure)" : " " );
2927
+ return _young_gc_name_data;
2928
+ }
2929
+
2930
+ public:
2931
+ G1YoungGCTraceTime (GCCause::Cause cause) :
2932
+ // Take snapshot of current pause type at start as it may be modified during gc.
2933
+ // The strings for all Concurrent Start pauses are the same, so the parameter
2934
+ // does not matter here.
2935
+ _pause_type (G1CollectedHeap::heap()->collector_state ()->young_gc_pause_type(false /* concurrent_operation_is_full_mark */ )),
2936
+ _pause_cause(cause),
2937
+ // Fake a "no cause" and manually add the correct string in update_young_gc_name()
2938
+ // to make the string look more natural.
2939
+ _tt(update_young_gc_name(), NULL, GCCause::_no_gc, true) {
2940
+ }
2941
+
2942
+ ~G1YoungGCTraceTime () {
2943
+ update_young_gc_name ();
2944
+ }
2945
+ };
2946
+
2918
2947
void G1CollectedHeap::do_collection_pause_at_safepoint_helper (double target_pause_time_ms) {
2919
2948
GCIdMark gc_id_mark;
2920
2949
@@ -2960,10 +2989,7 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus
2960
2989
2961
2990
GCTraceCPUTime tcpu;
2962
2991
2963
- char young_gc_name[MaxYoungGCNameLength];
2964
- set_young_gc_name (young_gc_name);
2965
-
2966
- GCTraceTime (Info, gc) tm (young_gc_name, NULL , gc_cause (), true );
2992
+ G1YoungGCTraceTime tm (gc_cause ());
2967
2993
2968
2994
uint active_workers = WorkerPolicy::calc_active_workers (workers ()->total_workers (),
2969
2995
workers ()->active_workers (),
@@ -3052,11 +3078,6 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus
3052
3078
gc_epilogue (false );
3053
3079
}
3054
3080
3055
- // Print the remainder of the GC log output.
3056
- if (evacuation_failed ()) {
3057
- log_info (gc)(" To-space exhausted" );
3058
- }
3059
-
3060
3081
policy ()->print_phases ();
3061
3082
heap_transition.print ();
3062
3083
0 commit comments