src/hotspot/share/gc/g1/g1CollectorState.hpp
author tschatzl
Thu, 29 Mar 2018 14:07:59 +0200
changeset 49643 a3453bbd5418
parent 49632 64f9ebc85e67
child 49664 9a04cc89dde0
permissions -rw-r--r--
8199742: Clean up state flags in G1CollectorState Summary: Remove, merge and update naming of flags in G1CollectorState Reviewed-by: sangheki, sjohanss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
     1
/*
49392
2956d0ece7a9 8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents: 47216
diff changeset
     2
 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
     4
 *
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
     7
 * published by the Free Software Foundation.
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
     8
 *
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    13
 * accompanied this code).
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    14
 *
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    18
 *
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    21
 * questions.
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    22
 *
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    23
 */
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    24
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    25
#ifndef SHARE_VM_GC_G1_G1COLLECTORSTATE_HPP
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    26
#define SHARE_VM_GC_G1_G1COLLECTORSTATE_HPP
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    27
37039
79f62b89a7a6 8151178: Move the collection set out of the G1 collector policy
mgerdin
parents: 35191
diff changeset
    28
#include "gc/g1/g1YCTypes.hpp"
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    29
#include "utilities/globalDefinitions.hpp"
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    30
49643
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    31
// State of the G1 collection.
49392
2956d0ece7a9 8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents: 47216
diff changeset
    32
class G1CollectorState {
49643
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    33
  // Indicates whether we are in the phase where we do partial gcs that only contain
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    34
  // the young generation. Not set while _in_full_gc is set.
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    35
  bool _in_young_only_phase;
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    36
49643
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    37
  // Indicates whether we are in the last young gc before the mixed gc phase. This GC
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    38
  // is required to keep pause time requirements.
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    39
  bool _in_young_gc_before_mixed;
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    40
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    41
  // If _initiate_conc_mark_if_possible is set at the beginning of a
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    42
  // pause, it is a suggestion that the pause should start a marking
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    43
  // cycle by doing the initial-mark work. However, it is possible
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    44
  // that the concurrent marking thread is still finishing up the
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    45
  // previous marking cycle (e.g., clearing the next marking
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    46
  // bitmap). If that is the case we cannot start a new cycle and
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    47
  // we'll have to wait for the concurrent marking thread to finish
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    48
  // what it is doing. In this case we will postpone the marking cycle
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    49
  // initiation decision for the next pause. When we eventually decide
49643
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    50
  // to start a cycle, we will set _in_initial_mark_gc which
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    51
  // will stay true until the end of the initial-mark pause doing the
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    52
  // initial-mark work.
49643
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    53
  volatile bool _in_initial_mark_gc;
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    54
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    55
  // At the end of a pause we check the heap occupancy and we decide
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    56
  // whether we will start a marking cycle during the next pause. If
49643
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    57
  // we decide that we want to do that, set this parameter. This parameter will
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    58
  // stay set until the beginning of a subsequent pause (not necessarily
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    59
  // the next one) when we decide that we will indeed start a marking cycle and
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    60
  // do the initial-mark work.
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    61
  volatile bool _initiate_conc_mark_if_possible;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    62
49643
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    63
  // Marking or rebuilding remembered set work is in progress. Set from the end
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    64
  // of the initial mark pause to the end of the Cleanup pause.
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    65
  bool _mark_or_rebuild_in_progress;
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    66
49643
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    67
  // Set during a full gc pause.
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    68
  bool _in_full_gc;
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    69
49643
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    70
public:
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    71
  G1CollectorState() :
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    72
    _in_young_only_phase(true),
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    73
    _in_young_gc_before_mixed(false),
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    74
49643
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    75
    _in_initial_mark_gc(false),
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    76
    _initiate_conc_mark_if_possible(false),
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    77
49643
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    78
    _mark_or_rebuild_in_progress(false),
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    79
    _in_full_gc(false) { }
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    80
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    81
  // Phase setters
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    82
  void set_in_young_only_phase(bool v) { _in_young_only_phase = v; }
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    83
49643
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    84
  // Pause setters
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    85
  void set_in_young_gc_before_mixed(bool v) { _in_young_gc_before_mixed = v; }
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    86
  void set_in_initial_mark_gc(bool v) { _in_initial_mark_gc = v; }
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    87
  void set_in_full_gc(bool v) { _in_full_gc = v; }
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    88
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    89
  void set_initiate_conc_mark_if_possible(bool v) { _initiate_conc_mark_if_possible = v; }
49643
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    90
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    91
  void set_mark_or_rebuild_in_progress(bool v) { _mark_or_rebuild_in_progress = v; }
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    92
49643
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    93
  // Phase getters
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    94
  bool in_young_only_phase() const { return _in_young_only_phase && !_in_full_gc; }
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    95
  bool in_mixed_phase() const { return !in_young_only_phase() && !_in_full_gc; }
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    96
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    97
  // Specific pauses
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    98
  bool in_young_gc_before_mixed() const { return _in_young_gc_before_mixed; }
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
    99
  bool in_full_gc() const { return _in_full_gc; }
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
   100
  bool in_initial_mark_gc() const { return _in_initial_mark_gc; }
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
   101
33130
a776072941e8 8138969: G1CollectorPolicy should use const for applicable methods
ehelin
parents: 31331
diff changeset
   102
  bool initiate_conc_mark_if_possible() const { return _initiate_conc_mark_if_possible; }
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   103
49643
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
   104
  bool mark_or_rebuild_in_progress() const { return _mark_or_rebuild_in_progress; }
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   105
33214
5a00fba36171 8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents: 33130
diff changeset
   106
  G1YCType yc_type() const {
49643
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
   107
    if (in_initial_mark_gc()) {
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   108
      return InitialMark;
49643
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
   109
    } else if (mark_or_rebuild_in_progress()) {
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
   110
      return DuringMarkOrRebuild;
a3453bbd5418 8199742: Clean up state flags in G1CollectorState
tschatzl
parents: 49632
diff changeset
   111
    } else if (in_young_only_phase()) {
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   112
      return Normal;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   113
    } else {
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   114
      return Mixed;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   115
    }
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   116
  }
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   117
};
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   118
35191
da47979837b4 8145752: Fix include guards in GC code
tschatzl
parents: 33216
diff changeset
   119
#endif // SHARE_VM_GC_G1_G1COLLECTORSTATE_HPP