|
1 /* |
|
2 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
13 * accompanied this code). |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License version |
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 * |
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 * or visit www.oracle.com if you need additional information or have any |
|
21 * questions. |
|
22 * |
|
23 */ |
|
24 |
|
25 #ifndef SHARE_VM_GC_G1_G1COLLECTORSTATE_HPP |
|
26 #define SHARE_VM_GC_G1_G1COLLECTORSTATE_HPP |
|
27 |
|
28 #include "gc/g1/g1YCTypes.hpp" |
|
29 #include "memory/allocation.hpp" |
|
30 #include "utilities/globalDefinitions.hpp" |
|
31 |
|
32 // Various state variables that indicate |
|
33 // the phase of the G1 collection. |
|
34 class G1CollectorState VALUE_OBJ_CLASS_SPEC { |
|
35 // Indicates whether we are in "full young" or "mixed" GC mode. |
|
36 bool _gcs_are_young; |
|
37 // Was the last GC "young"? |
|
38 bool _last_gc_was_young; |
|
39 // Is this the "last young GC" before we start doing mixed GCs? |
|
40 // Set after a concurrent mark has completed. |
|
41 bool _last_young_gc; |
|
42 |
|
43 // If initiate_conc_mark_if_possible() is set at the beginning of a |
|
44 // pause, it is a suggestion that the pause should start a marking |
|
45 // cycle by doing the initial-mark work. However, it is possible |
|
46 // that the concurrent marking thread is still finishing up the |
|
47 // previous marking cycle (e.g., clearing the next marking |
|
48 // bitmap). If that is the case we cannot start a new cycle and |
|
49 // we'll have to wait for the concurrent marking thread to finish |
|
50 // what it is doing. In this case we will postpone the marking cycle |
|
51 // initiation decision for the next pause. When we eventually decide |
|
52 // to start a cycle, we will set _during_initial_mark_pause which |
|
53 // will stay true until the end of the initial-mark pause and it's |
|
54 // the condition that indicates that a pause is doing the |
|
55 // initial-mark work. |
|
56 volatile bool _during_initial_mark_pause; |
|
57 |
|
58 // At the end of a pause we check the heap occupancy and we decide |
|
59 // whether we will start a marking cycle during the next pause. If |
|
60 // we decide that we want to do that, we will set this parameter to |
|
61 // true. So, this parameter will stay true between the end of a |
|
62 // pause and the beginning of a subsequent pause (not necessarily |
|
63 // the next one, see the comments on the next field) when we decide |
|
64 // that we will indeed start a marking cycle and do the initial-mark |
|
65 // work. |
|
66 volatile bool _initiate_conc_mark_if_possible; |
|
67 |
|
68 // NOTE: if some of these are synonyms for others, |
|
69 // the redundant fields should be eliminated. XXX |
|
70 bool _during_marking; |
|
71 bool _mark_in_progress; |
|
72 bool _in_marking_window; |
|
73 bool _in_marking_window_im; |
|
74 |
|
75 bool _full_collection; |
|
76 |
|
77 public: |
|
78 G1CollectorState() : |
|
79 _gcs_are_young(true), |
|
80 _last_gc_was_young(false), |
|
81 _last_young_gc(false), |
|
82 |
|
83 _during_initial_mark_pause(false), |
|
84 _initiate_conc_mark_if_possible(false), |
|
85 |
|
86 _during_marking(false), |
|
87 _mark_in_progress(false), |
|
88 _in_marking_window(false), |
|
89 _in_marking_window_im(false), |
|
90 _full_collection(false) {} |
|
91 |
|
92 // Setters |
|
93 void set_gcs_are_young(bool v) { _gcs_are_young = v; } |
|
94 void set_last_gc_was_young(bool v) { _last_gc_was_young = v; } |
|
95 void set_last_young_gc(bool v) { _last_young_gc = v; } |
|
96 void set_during_initial_mark_pause(bool v) { _during_initial_mark_pause = v; } |
|
97 void set_initiate_conc_mark_if_possible(bool v) { _initiate_conc_mark_if_possible = v; } |
|
98 void set_during_marking(bool v) { _during_marking = v; } |
|
99 void set_mark_in_progress(bool v) { _mark_in_progress = v; } |
|
100 void set_in_marking_window(bool v) { _in_marking_window = v; } |
|
101 void set_in_marking_window_im(bool v) { _in_marking_window_im = v; } |
|
102 void set_full_collection(bool v) { _full_collection = v; } |
|
103 |
|
104 // Getters |
|
105 bool gcs_are_young() const { return _gcs_are_young; } |
|
106 bool last_gc_was_young() const { return _last_gc_was_young; } |
|
107 bool last_young_gc() const { return _last_young_gc; } |
|
108 bool during_initial_mark_pause() const { return _during_initial_mark_pause; } |
|
109 bool initiate_conc_mark_if_possible() const { return _initiate_conc_mark_if_possible; } |
|
110 bool during_marking() const { return _during_marking; } |
|
111 bool mark_in_progress() const { return _mark_in_progress; } |
|
112 bool in_marking_window() const { return _in_marking_window; } |
|
113 bool in_marking_window_im() const { return _in_marking_window_im; } |
|
114 bool full_collection() const { return _full_collection; } |
|
115 |
|
116 // Composite booleans (clients worry about flickering) |
|
117 bool during_concurrent_mark() const { |
|
118 return (_in_marking_window && !_in_marking_window_im); |
|
119 } |
|
120 |
|
121 G1YCType yc_type() const { |
|
122 if (during_initial_mark_pause()) { |
|
123 return InitialMark; |
|
124 } else if (mark_in_progress()) { |
|
125 return DuringMark; |
|
126 } else if (gcs_are_young()) { |
|
127 return Normal; |
|
128 } else { |
|
129 return Mixed; |
|
130 } |
|
131 } |
|
132 }; |
|
133 |
|
134 #endif // SHARE_VM_GC_G1_G1COLLECTORSTATE_HPP |