/* * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
double G1ConcurrentMarkThread::mmu_delay_end(G1Policy* policy, bool remark) { // There are 3 reasons to use SuspendibleThreadSetJoiner. // 1. To avoid concurrency problem. // - G1MMUTracker::add_pause(), when_sec() and when_max_gc_sec() can be called // concurrently from ConcurrentMarkThread and VMThread. // 2. If currently a gc is running, but it has not yet updated the MMU, // we will not forget to consider that pause in the MMU calculation. // 3. If currently a gc is running, ConcurrentMarkThread will wait it to be finished. // And then sleep for predicted amount of time by delay_to_keep_mmu().
SuspendibleThreadSetJoiner sts_join;
if (_state == FullMark) {
concurrent_mark_cycle_do();
} else {
assert(_state == UndoMark, "Must do undo mark but is %d", _state);
concurrent_undo_cycle_do();
}
void G1ConcurrentMarkThread::stop_service() { if (in_progress()) { // We are not allowed to abort the marking threads during root region scan. // Needs to be done separately.
_cm->root_regions()->abort();
_cm->root_regions()->wait_until_scan_finished();
// We have to ensure that we finish scanning the root regions // before the next GC takes place. To ensure this we have to // make sure that we do not join the STS until the root regions // have been scanned. If we did then it's possible that a // subsequent GC could block us from joining the STS and proceed // without the root regions have been scanned which would be a // correctness issue. // // So do not return before the scan root regions phase as a GC waits for a // notification from it. // // For the same reason ConcurrentGCBreakpoints (in the phase methods) before // here risk deadlock, because a young GC must wait for root region scanning. // // We can not easily abort before root region scan either because of the // reasons mentioned in G1CollectedHeap::abort_concurrent_cycle().
// Phase 1: Scan root regions. if (phase_scan_root_regions()) return;
// Phase 2: Actual mark loop. if (phase_mark_loop()) return;
// Phase 3: Rebuild remembered sets and scrub dead objects. if (phase_rebuild_and_scrub()) return;
// Phase 4: Wait for Cleanup. if (phase_delay_to_keep_mmu_before_cleanup()) return;
// Phase 5: Cleanup pause if (phase_cleanup()) return;
// Phase 6: Clear CLD claimed marks. if (phase_clear_cld_claimed_marks()) return;
// Phase 7: Clear bitmap for next mark.
phase_clear_bitmap_for_next_mark();
}
// We can (and should) abort if there has been a concurrent cycle abort for // some reason. if (_cm->has_aborted()) { return; }
_cm->flush_all_task_caches();
// Phase 1: Clear CLD claimed marks. if (phase_clear_cld_claimed_marks()) return;
// Phase 2: Clear bitmap for next mark.
phase_clear_bitmap_for_next_mark();
}
void G1ConcurrentMarkThread::concurrent_cycle_end(bool mark_cycle_completed) {
ConcurrentGCBreakpoints::at("BEFORE CLEANUP COMPLETED"); // Update the number of full collections that have been // completed. This will also notify the G1OldGCCount_lock in case a // Java thread is waiting for a full GC to happen (e.g., it // called System.gc() with +ExplicitGCInvokesConcurrent).
SuspendibleThreadSetJoiner sts_join;
G1CollectedHeap::heap()->increment_old_marking_cycles_completed(true/* concurrent */,
mark_cycle_completed /* heap_examined */);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.