author | tschatzl |
Wed, 17 Jul 2019 16:33:19 +0200 | |
changeset 55722 | 5ee183a90e65 |
parent 53244 | 9807daeb47c4 |
permissions | -rw-r--r-- |
31331
a7c714b6cfb3
7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff
changeset
|
1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
49664
diff
changeset
|
2 |
* Copyright (c) 2015, 2019, 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 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
49664
diff
changeset
|
25 |
#ifndef SHARE_GC_G1_G1COLLECTORSTATE_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
49664
diff
changeset
|
26 |
#define SHARE_GC_G1_G1COLLECTORSTATE_HPP |
31331
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 |
|
49664 | 67 |
// The next bitmap is currently being cleared or about to be cleared. TAMS and bitmap |
68 |
// may be out of sync. |
|
69 |
bool _clearing_next_bitmap; |
|
70 |
||
49643
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
71 |
// Set during a full gc pause. |
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
72 |
bool _in_full_gc; |
31331
a7c714b6cfb3
7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff
changeset
|
73 |
|
49643
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
74 |
public: |
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
75 |
G1CollectorState() : |
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
76 |
_in_young_only_phase(true), |
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
77 |
_in_young_gc_before_mixed(false), |
31331
a7c714b6cfb3
7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff
changeset
|
78 |
|
49643
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
79 |
_in_initial_mark_gc(false), |
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
80 |
_initiate_conc_mark_if_possible(false), |
31331
a7c714b6cfb3
7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff
changeset
|
81 |
|
49643
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
82 |
_mark_or_rebuild_in_progress(false), |
49664 | 83 |
_clearing_next_bitmap(false), |
49643
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
84 |
_in_full_gc(false) { } |
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
85 |
|
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
86 |
// Phase setters |
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
87 |
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
|
88 |
|
49643
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
89 |
// Pause setters |
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
90 |
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
|
91 |
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
|
92 |
void set_in_full_gc(bool v) { _in_full_gc = v; } |
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
93 |
|
31331
a7c714b6cfb3
7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff
changeset
|
94 |
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
|
95 |
|
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
96 |
void set_mark_or_rebuild_in_progress(bool v) { _mark_or_rebuild_in_progress = v; } |
49664 | 97 |
void set_clearing_next_bitmap(bool v) { _clearing_next_bitmap = v; } |
31331
a7c714b6cfb3
7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff
changeset
|
98 |
|
49643
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
99 |
// Phase getters |
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
100 |
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
|
101 |
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
|
102 |
|
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
103 |
// Specific pauses |
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
104 |
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
|
105 |
bool in_full_gc() const { return _in_full_gc; } |
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
106 |
bool in_initial_mark_gc() const { return _in_initial_mark_gc; } |
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
107 |
|
33130
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; } |
31331
a7c714b6cfb3
7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff
changeset
|
109 |
|
49643
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
110 |
bool mark_or_rebuild_in_progress() const { return _mark_or_rebuild_in_progress; } |
49664 | 111 |
bool clearing_next_bitmap() const { return _clearing_next_bitmap; } |
31331
a7c714b6cfb3
7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff
changeset
|
112 |
|
33214
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
33130
diff
changeset
|
113 |
G1YCType yc_type() const { |
49643
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
114 |
if (in_initial_mark_gc()) { |
31331
a7c714b6cfb3
7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff
changeset
|
115 |
return InitialMark; |
49643
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
116 |
} else if (mark_or_rebuild_in_progress()) { |
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
117 |
return DuringMarkOrRebuild; |
a3453bbd5418
8199742: Clean up state flags in G1CollectorState
tschatzl
parents:
49632
diff
changeset
|
118 |
} else if (in_young_only_phase()) { |
31331
a7c714b6cfb3
7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff
changeset
|
119 |
return Normal; |
a7c714b6cfb3
7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff
changeset
|
120 |
} else { |
a7c714b6cfb3
7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff
changeset
|
121 |
return Mixed; |
a7c714b6cfb3
7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff
changeset
|
122 |
} |
a7c714b6cfb3
7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff
changeset
|
123 |
} |
a7c714b6cfb3
7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff
changeset
|
124 |
}; |
a7c714b6cfb3
7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
diff
changeset
|
125 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
49664
diff
changeset
|
126 |
#endif // SHARE_GC_G1_G1COLLECTORSTATE_HPP |