hotspot/src/share/vm/gc/g1/g1CollectorState.hpp
author kbarrett
Tue, 30 Aug 2016 23:48:16 -0400
changeset 40892 330a02d935ad
parent 37137 62fd3fb4b1b1
permissions -rw-r--r--
8156500: Move Reference pending list into VM to prevent deadlocks Summary: Move reference pending list and locking into VM Reviewed-by: coleenp, dholmes, dcubed, mchung, plevart Contributed-by: kim.barrett@oracle.com, per.liden@oracle.com
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
/*
37039
79f62b89a7a6 8151178: Move the collection set out of the G1 collector policy
mgerdin
parents: 35191
diff changeset
     2
 * Copyright (c) 2015, 2016, 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"
79f62b89a7a6 8151178: Move the collection set out of the G1 collector policy
mgerdin
parents: 35191
diff changeset
    29
#include "memory/allocation.hpp"
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    30
#include "utilities/globalDefinitions.hpp"
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    31
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    32
// Various state variables that indicate
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    33
// the phase of the G1 collection.
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    34
class G1CollectorState VALUE_OBJ_CLASS_SPEC {
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    35
  // 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
    36
  bool _gcs_are_young;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    37
  // Was the last GC "young"?
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    38
  bool _last_gc_was_young;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    39
  // 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
    40
  // Set after a concurrent mark has completed.
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    41
  bool _last_young_gc;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    42
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    43
  // 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
    44
  // 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
    45
  // 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
    46
  // 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
    47
  // 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
    48
  // 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
    49
  // 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
    50
  // 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
    51
  // 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
    52
  // 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
    53
  // 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
    54
  // 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
    55
  // initial-mark work.
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    56
  volatile bool _during_initial_mark_pause;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    57
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    58
  // 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
    59
  // 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
    60
  // 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
    61
  // 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
    62
  // 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
    63
  // 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
    64
  // 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
    65
  // work.
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    66
  volatile bool _initiate_conc_mark_if_possible;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    67
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    68
  // 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
    69
  // the redundant fields should be eliminated. XXX
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    70
  bool _during_marking;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    71
  bool _mark_in_progress;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    72
  bool _in_marking_window;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    73
  bool _in_marking_window_im;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    74
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    75
  bool _full_collection;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    76
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    77
  public:
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    78
    G1CollectorState() :
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    79
      _gcs_are_young(true),
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    80
      _last_gc_was_young(false),
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    81
      _last_young_gc(false),
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    82
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    83
      _during_initial_mark_pause(false),
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    84
      _initiate_conc_mark_if_possible(false),
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    85
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    86
      _during_marking(false),
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    87
      _mark_in_progress(false),
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    88
      _in_marking_window(false),
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    89
      _in_marking_window_im(false),
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    90
      _full_collection(false) {}
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    91
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    92
  // Setters
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
    93
  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
    94
  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
    95
  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
    96
  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
    97
  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
    98
  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
    99
  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
   100
  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
   101
  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
   102
  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
   103
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   104
  // Getters
33130
a776072941e8 8138969: G1CollectorPolicy should use const for applicable methods
ehelin
parents: 31331
diff changeset
   105
  bool gcs_are_young() const { return _gcs_are_young; }
a776072941e8 8138969: G1CollectorPolicy should use const for applicable methods
ehelin
parents: 31331
diff changeset
   106
  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
   107
  bool last_young_gc() const { return _last_young_gc; }
a776072941e8 8138969: G1CollectorPolicy should use const for applicable methods
ehelin
parents: 31331
diff changeset
   108
  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
   109
  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
   110
  bool during_marking() const { return _during_marking; }
a776072941e8 8138969: G1CollectorPolicy should use const for applicable methods
ehelin
parents: 31331
diff changeset
   111
  bool mark_in_progress() const { return _mark_in_progress; }
a776072941e8 8138969: G1CollectorPolicy should use const for applicable methods
ehelin
parents: 31331
diff changeset
   112
  bool in_marking_window() const { return _in_marking_window; }
a776072941e8 8138969: G1CollectorPolicy should use const for applicable methods
ehelin
parents: 31331
diff changeset
   113
  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
   114
  bool full_collection() const { return _full_collection; }
31331
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
  // Composite booleans (clients worry about flickering)
33130
a776072941e8 8138969: G1CollectorPolicy should use const for applicable methods
ehelin
parents: 31331
diff changeset
   117
  bool during_concurrent_mark() const {
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   118
    return (_in_marking_window && !_in_marking_window_im);
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   119
  }
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   120
33214
5a00fba36171 8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents: 33130
diff changeset
   121
  G1YCType yc_type() const {
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   122
    if (during_initial_mark_pause()) {
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   123
      return InitialMark;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   124
    } else if (mark_in_progress()) {
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   125
      return DuringMark;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   126
    } else if (gcs_are_young()) {
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   127
      return Normal;
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   128
    } else {
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   129
      return Mixed;
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
};
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff changeset
   133
35191
da47979837b4 8145752: Fix include guards in GC code
tschatzl
parents: 33216
diff changeset
   134
#endif // SHARE_VM_GC_G1_G1COLLECTORSTATE_HPP