src/hotspot/share/gc/g1/g1CollectorState.hpp
author coleenp
Wed, 14 Mar 2018 07:27:19 -0400
changeset 49392 2956d0ece7a9
parent 47216 71c04702a3d5
child 49607 acffe6ff3ae7
permissions -rw-r--r--
8199282: Remove ValueObj class for allocation subclassing for gc code Reviewed-by: stefank, kbarrett
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
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    31
// Various state variables that indicate
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    32
// the phase of the G1 collection.
49392
2956d0ece7a9 8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents: 47216
diff changeset
    33
class G1CollectorState {
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    34
  // Indicates whether we are in "full young" or "mixed" GC mode.
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    35
  bool _gcs_are_young;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    36
  // Was the last GC "young"?
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    37
  bool _last_gc_was_young;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    38
  // Is this the "last young GC" before we start doing mixed GCs?
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    39
  // Set after a concurrent mark has completed.
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    40
  bool _last_young_gc;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    41
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    42
  // If initiate_conc_mark_if_possible() is set at the beginning of a
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    43
  // 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
    44
  // 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
    45
  // 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
    46
  // 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
    47
  // 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
    48
  // 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
    49
  // 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
    50
  // initiation decision for the next pause. When we eventually decide
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    51
  // to start a cycle, we will set _during_initial_mark_pause which
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    52
  // will stay true until the end of the initial-mark pause and it's
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    53
  // the condition that indicates that a pause is doing the
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    54
  // initial-mark work.
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    55
  volatile bool _during_initial_mark_pause;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    56
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    57
  // 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
    58
  // whether we will start a marking cycle during the next pause. If
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    59
  // we decide that we want to do that, we will set this parameter to
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    60
  // true. So, this parameter will stay true between the end of a
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    61
  // pause and the beginning of a subsequent pause (not necessarily
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    62
  // the next one, see the comments on the next field) when we decide
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    63
  // that we will indeed start a marking cycle and do the initial-mark
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    64
  // work.
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    65
  volatile bool _initiate_conc_mark_if_possible;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    66
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    67
  // NOTE: if some of these are synonyms for others,
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    68
  // the redundant fields should be eliminated. XXX
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    69
  bool _during_marking;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    70
  bool _mark_in_progress;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    71
  bool _in_marking_window;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    72
  bool _in_marking_window_im;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    73
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    74
  bool _full_collection;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    75
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    76
  public:
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    77
    G1CollectorState() :
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    78
      _gcs_are_young(true),
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    79
      _last_gc_was_young(false),
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    80
      _last_young_gc(false),
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    81
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    82
      _during_initial_mark_pause(false),
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    83
      _initiate_conc_mark_if_possible(false),
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    84
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    85
      _during_marking(false),
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    86
      _mark_in_progress(false),
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    87
      _in_marking_window(false),
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    88
      _in_marking_window_im(false),
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    89
      _full_collection(false) {}
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    90
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    91
  // Setters
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    92
  void set_gcs_are_young(bool v) { _gcs_are_young = v; }
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    93
  void set_last_gc_was_young(bool v) { _last_gc_was_young = v; }
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    94
  void set_last_young_gc(bool v) { _last_young_gc = v; }
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    95
  void set_during_initial_mark_pause(bool v) { _during_initial_mark_pause = v; }
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    96
  void set_initiate_conc_mark_if_possible(bool v) { _initiate_conc_mark_if_possible = v; }
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    97
  void set_during_marking(bool v) { _during_marking = v; }
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    98
  void set_mark_in_progress(bool v) { _mark_in_progress = v; }
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    99
  void set_in_marking_window(bool v) { _in_marking_window = v; }
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   100
  void set_in_marking_window_im(bool v) { _in_marking_window_im = v; }
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   101
  void set_full_collection(bool v) { _full_collection = v; }
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   102
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   103
  // Getters
33130
a776072941e8 8138969: G1CollectorPolicy should use const for applicable methods
ehelin
parents: 31331
diff changeset
   104
  bool gcs_are_young() const { return _gcs_are_young; }
a776072941e8 8138969: G1CollectorPolicy should use const for applicable methods
ehelin
parents: 31331
diff changeset
   105
  bool last_gc_was_young() const { return _last_gc_was_young; }
a776072941e8 8138969: G1CollectorPolicy should use const for applicable methods
ehelin
parents: 31331
diff changeset
   106
  bool last_young_gc() const { return _last_young_gc; }
a776072941e8 8138969: G1CollectorPolicy should use const for applicable methods
ehelin
parents: 31331
diff changeset
   107
  bool during_initial_mark_pause() const { return _during_initial_mark_pause; }
a776072941e8 8138969: G1CollectorPolicy should use const for applicable methods
ehelin
parents: 31331
diff changeset
   108
  bool initiate_conc_mark_if_possible() const { return _initiate_conc_mark_if_possible; }
a776072941e8 8138969: G1CollectorPolicy should use const for applicable methods
ehelin
parents: 31331
diff changeset
   109
  bool during_marking() const { return _during_marking; }
a776072941e8 8138969: G1CollectorPolicy should use const for applicable methods
ehelin
parents: 31331
diff changeset
   110
  bool mark_in_progress() const { return _mark_in_progress; }
a776072941e8 8138969: G1CollectorPolicy should use const for applicable methods
ehelin
parents: 31331
diff changeset
   111
  bool in_marking_window() const { return _in_marking_window; }
a776072941e8 8138969: G1CollectorPolicy should use const for applicable methods
ehelin
parents: 31331
diff changeset
   112
  bool in_marking_window_im() const { return _in_marking_window_im; }
a776072941e8 8138969: G1CollectorPolicy should use const for applicable methods
ehelin
parents: 31331
diff changeset
   113
  bool full_collection() const { return _full_collection; }
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   114
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   115
  // Composite booleans (clients worry about flickering)
33130
a776072941e8 8138969: G1CollectorPolicy should use const for applicable methods
ehelin
parents: 31331
diff changeset
   116
  bool during_concurrent_mark() const {
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   117
    return (_in_marking_window && !_in_marking_window_im);
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   118
  }
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   119
33214
5a00fba36171 8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents: 33130
diff changeset
   120
  G1YCType yc_type() const {
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   121
    if (during_initial_mark_pause()) {
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   122
      return InitialMark;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   123
    } else if (mark_in_progress()) {
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   124
      return DuringMark;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   125
    } else if (gcs_are_young()) {
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   126
      return Normal;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   127
    } else {
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   128
      return Mixed;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   129
    }
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   130
  }
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   131
};
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   132
35191
da47979837b4 8145752: Fix include guards in GC code
tschatzl
parents: 33216
diff changeset
   133
#endif // SHARE_VM_GC_G1_G1COLLECTORSTATE_HPP