@@ -2922,6 +2922,36 @@ class G1YoungGCTraceTime {
2922
2922
}
2923
2923
};
2924
2924
2925
+ class G1YoungGCVerifierMark : public StackObj {
2926
+ G1HeapVerifier::G1VerifyType _type;
2927
+
2928
+ static G1HeapVerifier::G1VerifyType young_collection_verify_type () {
2929
+ G1CollectorState* state = G1CollectedHeap::heap ()->collector_state ();
2930
+ if (state->in_concurrent_start_gc ()) {
2931
+ return G1HeapVerifier::G1VerifyConcurrentStart;
2932
+ } else if (state->in_young_only_phase ()) {
2933
+ return G1HeapVerifier::G1VerifyYoungNormal;
2934
+ } else {
2935
+ return G1HeapVerifier::G1VerifyMixed;
2936
+ }
2937
+ }
2938
+
2939
+ public:
2940
+ G1YoungGCVerifierMark () : _type(young_collection_verify_type()) {
2941
+ G1CollectedHeap::heap ()->verify_before_young_collection (_type);
2942
+ }
2943
+
2944
+ ~G1YoungGCVerifierMark () {
2945
+ G1CollectedHeap::heap ()->verify_after_young_collection (_type);
2946
+ }
2947
+ };
2948
+
2949
+ class G1YoungGCNotifyPauseMark : public StackObj {
2950
+ public:
2951
+ G1YoungGCNotifyPauseMark () { G1CollectedHeap::heap ()->policy ()->record_young_gc_pause_start (); }
2952
+ ~G1YoungGCNotifyPauseMark () { G1CollectedHeap::heap ()->policy ()->record_young_gc_pause_end (); }
2953
+ };
2954
+
2925
2955
G1HeapPrinterMark::G1HeapPrinterMark (G1CollectedHeap* g1h) : _g1h(g1h), _heap_transition(g1h) {
2926
2956
// This summary needs to be printed before incrementing total collections.
2927
2957
_g1h->rem_set ()->print_periodic_summary_info (" Before GC RS summary" , _g1h->total_collections ());
@@ -3053,8 +3083,8 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus
3053
3083
// determining collector state.
3054
3084
G1YoungGCTraceTime tm (gc_cause ());
3055
3085
3056
- // Young GC internal timing
3057
- policy ()-> note_gc_start () ;
3086
+ // Young GC internal pause timing
3087
+ G1YoungGCNotifyPauseMark npm ;
3058
3088
// JFR
3059
3089
G1YoungGCJFRTracerMark jtm (_gc_timer_stw, _gc_tracer_stw, gc_cause ());
3060
3090
// JStat/MXBeans
@@ -3069,15 +3099,14 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus
3069
3099
// just to do that).
3070
3100
wait_for_root_region_scanning ();
3071
3101
3072
- G1HeapVerifier::G1VerifyType verify_type = young_collection_verify_type ();
3073
- verify_before_young_collection (verify_type);
3102
+ G1YoungGCVerifierMark vm;
3074
3103
{
3075
3104
// Actual collection work starts and is executed (only) in this scope.
3076
3105
3077
- // The elapsed time induced by the start time below deliberately elides
3078
- // the possible verification above.
3079
- double sample_start_time_sec = os::elapsedTime ();
3080
- policy ()->record_collection_pause_start (sample_start_time_sec );
3106
+ // Young GC internal collection timing. The elapsed time recorded in the
3107
+ // policy for the collection deliberately elides verification (and some
3108
+ // other trivial setup above).
3109
+ policy ()->record_young_collection_start ( );
3081
3110
3082
3111
calculate_collection_set (jtm.evacuation_info (), target_pause_time_ms);
3083
3112
@@ -3106,14 +3135,8 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus
3106
3135
// modifies it to the next state.
3107
3136
jtm.report_pause_type (collector_state ()->young_gc_pause_type (concurrent_operation_is_full_mark));
3108
3137
3109
- double sample_end_time_sec = os::elapsedTime ();
3110
- double pause_time_ms = (sample_end_time_sec - sample_start_time_sec) * MILLIUNITS;
3111
- policy ()->record_collection_pause_end (pause_time_ms, concurrent_operation_is_full_mark);
3138
+ policy ()->record_young_collection_end (concurrent_operation_is_full_mark);
3112
3139
}
3113
- verify_after_young_collection (verify_type);
3114
-
3115
- policy ()->print_phases ();
3116
-
3117
3140
TASKQUEUE_STATS_ONLY (print_taskqueue_stats ());
3118
3141
TASKQUEUE_STATS_ONLY (reset_taskqueue_stats ());
3119
3142
}
@@ -3780,11 +3803,11 @@ void G1CollectedHeap::evacuate_next_optional_regions(G1ParScanThreadStateSet* pe
3780
3803
}
3781
3804
3782
3805
void G1CollectedHeap::evacuate_optional_collection_set (G1ParScanThreadStateSet* per_thread_states) {
3783
- const double gc_start_time_ms = phase_times ()->cur_collection_start_sec () * 1000.0 ;
3806
+ const double collection_start_time_ms = phase_times ()->cur_collection_start_sec () * 1000.0 ;
3784
3807
3785
3808
while (!evacuation_failed () && _collection_set.optional_region_length () > 0 ) {
3786
3809
3787
- double time_used_ms = os::elapsedTime () * 1000.0 - gc_start_time_ms ;
3810
+ double time_used_ms = os::elapsedTime () * 1000.0 - collection_start_time_ms ;
3788
3811
double time_left_ms = MaxGCPauseMillis - time_used_ms;
3789
3812
3790
3813
if (time_left_ms < 0 ||
0 commit comments