Path: blob/master/src/hotspot/share/gc/g1/g1CollectorState.hpp
40961 views
/*1* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_GC_G1_G1COLLECTORSTATE_HPP25#define SHARE_GC_G1_G1COLLECTORSTATE_HPP2627#include "gc/g1/g1GCPauseType.hpp"28#include "utilities/globalDefinitions.hpp"2930// State of the G1 collection.31class G1CollectorState {32// Indicates whether we are in the phase where we do partial gcs that only contain33// the young generation. Not set while _in_full_gc is set.34bool _in_young_only_phase;3536// Indicates whether we are in the last young gc before the mixed gc phase. This GC37// is required to keep pause time requirements.38bool _in_young_gc_before_mixed;3940// If _initiate_conc_mark_if_possible is set at the beginning of a41// pause, it is a suggestion that the pause should start a marking42// cycle by doing the concurrent start work. However, it is possible43// that the concurrent marking thread is still finishing up the44// previous marking cycle (e.g., clearing the next marking45// bitmap). If that is the case we cannot start a new cycle and46// we'll have to wait for the concurrent marking thread to finish47// what it is doing. In this case we will postpone the marking cycle48// initiation decision for the next pause. When we eventually decide49// to start a cycle, we will set _in_concurrent_start_gc which50// will stay true until the end of the concurrent start pause doing the51// concurrent start work.52volatile bool _in_concurrent_start_gc;5354// At the end of a pause we check the heap occupancy and we decide55// whether we will start a marking cycle during the next pause. If56// we decide that we want to do that, set this parameter. This parameter will57// stay set until the beginning of a subsequent pause (not necessarily58// the next one) when we decide that we will indeed start a marking cycle and59// do the concurrent start phase work.60volatile bool _initiate_conc_mark_if_possible;6162// Marking or rebuilding remembered set work is in progress. Set from the end63// of the concurrent start pause to the end of the Cleanup pause.64bool _mark_or_rebuild_in_progress;6566// The next bitmap is currently being cleared or about to be cleared. TAMS and bitmap67// may be out of sync.68bool _clearing_next_bitmap;6970// Set during a full gc pause.71bool _in_full_gc;7273public:74G1CollectorState() :75_in_young_only_phase(true),76_in_young_gc_before_mixed(false),7778_in_concurrent_start_gc(false),79_initiate_conc_mark_if_possible(false),8081_mark_or_rebuild_in_progress(false),82_clearing_next_bitmap(false),83_in_full_gc(false) { }8485// Phase setters86void set_in_young_only_phase(bool v) { _in_young_only_phase = v; }8788// Pause setters89void set_in_young_gc_before_mixed(bool v) { _in_young_gc_before_mixed = v; }90void set_in_concurrent_start_gc(bool v) { _in_concurrent_start_gc = v; }91void set_in_full_gc(bool v) { _in_full_gc = v; }9293void set_initiate_conc_mark_if_possible(bool v) { _initiate_conc_mark_if_possible = v; }9495void set_mark_or_rebuild_in_progress(bool v) { _mark_or_rebuild_in_progress = v; }96void set_clearing_next_bitmap(bool v) { _clearing_next_bitmap = v; }9798// Phase getters99bool in_young_only_phase() const { return _in_young_only_phase && !_in_full_gc; }100bool in_mixed_phase() const { return !in_young_only_phase() && !_in_full_gc; }101102// Specific pauses103bool in_young_gc_before_mixed() const { return _in_young_gc_before_mixed; }104bool in_full_gc() const { return _in_full_gc; }105bool in_concurrent_start_gc() const { return _in_concurrent_start_gc; }106107bool initiate_conc_mark_if_possible() const { return _initiate_conc_mark_if_possible; }108109bool mark_or_rebuild_in_progress() const { return _mark_or_rebuild_in_progress; }110bool clearing_next_bitmap() const { return _clearing_next_bitmap; }111112// Calculate GC Pause Type from internal state.113G1GCPauseType young_gc_pause_type(bool concurrent_operation_is_full_mark) const;114};115116#endif // SHARE_GC_G1_G1COLLECTORSTATE_HPP117118119