1149 }
1150
1151 bool G1CollectedHeap::do_collection(bool explicit_gc,
1152 bool clear_all_soft_refs,
1153 size_t word_size) {
1154 assert_at_safepoint(true /* should_be_vm_thread */);
1155
1156 if (GC_locker::check_active_before_gc()) {
1157 return false;
1158 }
1159
1160 STWGCTimer* gc_timer = G1MarkSweep::gc_timer();
1161 gc_timer->register_gc_start();
1162
1163 SerialOldTracer* gc_tracer = G1MarkSweep::gc_tracer();
1164 gc_tracer->report_gc_start(gc_cause(), gc_timer->gc_start());
1165
1166 SvcGCMarker sgcm(SvcGCMarker::FULL);
1167 ResourceMark rm;
1168
1169 print_heap_before_gc();
1170 trace_heap_before_gc(gc_tracer);
1171
1172 size_t metadata_prev_used = MetaspaceAux::used_bytes();
1173
1174 verify_region_sets_optional();
1175
1176 const bool do_clear_all_soft_refs = clear_all_soft_refs ||
1177 collector_policy()->should_clear_all_soft_refs();
1178
1179 ClearedAllSoftRefs casr(do_clear_all_soft_refs, collector_policy());
1180
1181 {
1182 IsGCActiveMark x;
1183
1184 // Timing
1185 assert(gc_cause() != GCCause::_java_lang_system_gc || explicit_gc, "invariant");
1186 TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty);
1187
1188 {
3631 }
3632 gclog_or_tty->flush();
3633 }
3634
3635 bool
3636 G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) {
3637 assert_at_safepoint(true /* should_be_vm_thread */);
3638 guarantee(!is_gc_active(), "collection is not reentrant");
3639
3640 if (GC_locker::check_active_before_gc()) {
3641 return false;
3642 }
3643
3644 _gc_timer_stw->register_gc_start();
3645
3646 _gc_tracer_stw->report_gc_start(gc_cause(), _gc_timer_stw->gc_start());
3647
3648 SvcGCMarker sgcm(SvcGCMarker::MINOR);
3649 ResourceMark rm;
3650
3651 print_heap_before_gc();
3652 trace_heap_before_gc(_gc_tracer_stw);
3653
3654 verify_region_sets_optional();
3655 verify_dirty_young_regions();
3656
3657 // This call will decide whether this pause is an initial-mark
3658 // pause. If it is, during_initial_mark_pause() will return true
3659 // for the duration of this pause.
3660 g1_policy()->decide_on_conc_mark_initiation();
3661
3662 // We do not allow initial-mark to be piggy-backed on a mixed GC.
3663 assert(!g1_policy()->during_initial_mark_pause() ||
3664 g1_policy()->gcs_are_young(), "sanity");
3665
3666 // We also do not allow mixed GCs during marking.
3667 assert(!mark_in_progress() || g1_policy()->gcs_are_young(), "sanity");
3668
3669 // Record whether this pause is an initial mark. When the current
3670 // thread has completed its logging output and it's safe to signal
|
1149 }
1150
1151 bool G1CollectedHeap::do_collection(bool explicit_gc,
1152 bool clear_all_soft_refs,
1153 size_t word_size) {
1154 assert_at_safepoint(true /* should_be_vm_thread */);
1155
1156 if (GC_locker::check_active_before_gc()) {
1157 return false;
1158 }
1159
1160 STWGCTimer* gc_timer = G1MarkSweep::gc_timer();
1161 gc_timer->register_gc_start();
1162
1163 SerialOldTracer* gc_tracer = G1MarkSweep::gc_tracer();
1164 gc_tracer->report_gc_start(gc_cause(), gc_timer->gc_start());
1165
1166 SvcGCMarker sgcm(SvcGCMarker::FULL);
1167 ResourceMark rm;
1168
1169 G1Log::update_level();
1170 print_heap_before_gc();
1171 trace_heap_before_gc(gc_tracer);
1172
1173 size_t metadata_prev_used = MetaspaceAux::used_bytes();
1174
1175 verify_region_sets_optional();
1176
1177 const bool do_clear_all_soft_refs = clear_all_soft_refs ||
1178 collector_policy()->should_clear_all_soft_refs();
1179
1180 ClearedAllSoftRefs casr(do_clear_all_soft_refs, collector_policy());
1181
1182 {
1183 IsGCActiveMark x;
1184
1185 // Timing
1186 assert(gc_cause() != GCCause::_java_lang_system_gc || explicit_gc, "invariant");
1187 TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty);
1188
1189 {
3632 }
3633 gclog_or_tty->flush();
3634 }
3635
3636 bool
3637 G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) {
3638 assert_at_safepoint(true /* should_be_vm_thread */);
3639 guarantee(!is_gc_active(), "collection is not reentrant");
3640
3641 if (GC_locker::check_active_before_gc()) {
3642 return false;
3643 }
3644
3645 _gc_timer_stw->register_gc_start();
3646
3647 _gc_tracer_stw->report_gc_start(gc_cause(), _gc_timer_stw->gc_start());
3648
3649 SvcGCMarker sgcm(SvcGCMarker::MINOR);
3650 ResourceMark rm;
3651
3652 G1Log::update_level();
3653 print_heap_before_gc();
3654 trace_heap_before_gc(_gc_tracer_stw);
3655
3656 verify_region_sets_optional();
3657 verify_dirty_young_regions();
3658
3659 // This call will decide whether this pause is an initial-mark
3660 // pause. If it is, during_initial_mark_pause() will return true
3661 // for the duration of this pause.
3662 g1_policy()->decide_on_conc_mark_initiation();
3663
3664 // We do not allow initial-mark to be piggy-backed on a mixed GC.
3665 assert(!g1_policy()->during_initial_mark_pause() ||
3666 g1_policy()->gcs_are_young(), "sanity");
3667
3668 // We also do not allow mixed GCs during marking.
3669 assert(!mark_in_progress() || g1_policy()->gcs_are_young(), "sanity");
3670
3671 // Record whether this pause is an initial mark. When the current
3672 // thread has completed its logging output and it's safe to signal
|