author | kbarrett |
Tue, 30 Aug 2016 23:48:16 -0400 | |
changeset 40892 | 330a02d935ad |
parent 38185 | c432f8466c73 |
child 40914 | 90c87069b39c |
permissions | -rw-r--r-- |
1374 | 1 |
/* |
37985
539c597ee0fa
8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents:
37262
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
1374 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5350
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5350
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5350
diff
changeset
|
21 |
* questions. |
1374 | 22 |
* |
23 |
*/ |
|
24 |
||
37985
539c597ee0fa
8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents:
37262
diff
changeset
|
25 |
#ifndef SHARE_VM_GC_G1_G1POLICY_HPP |
539c597ee0fa
8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents:
37262
diff
changeset
|
26 |
#define SHARE_VM_GC_G1_G1POLICY_HPP |
7397 | 27 |
|
31331
a7c714b6cfb3
7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
30874
diff
changeset
|
28 |
#include "gc/g1/g1CollectorState.hpp" |
33624
509a72e7127b
8140489: Introduce shorthand for average_time_ms in G1CollectorPolicy
ehelin
parents:
33591
diff
changeset
|
29 |
#include "gc/g1/g1GCPhaseTimes.hpp" |
32378
8dd0e7359751
8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents:
31331
diff
changeset
|
30 |
#include "gc/g1/g1InCSetState.hpp" |
34298
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
34132
diff
changeset
|
31 |
#include "gc/g1/g1InitialMarkToMixedTimeTracker.hpp" |
30764 | 32 |
#include "gc/g1/g1MMUTracker.hpp" |
33214
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
33204
diff
changeset
|
33 |
#include "gc/g1/g1Predictions.hpp" |
37985
539c597ee0fa
8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents:
37262
diff
changeset
|
34 |
#include "gc/g1/g1YoungGenSizer.hpp" |
539c597ee0fa
8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents:
37262
diff
changeset
|
35 |
#include "gc/shared/gcCause.hpp" |
34298
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
34132
diff
changeset
|
36 |
#include "utilities/pair.hpp" |
7397 | 37 |
|
37985
539c597ee0fa
8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents:
37262
diff
changeset
|
38 |
// A G1Policy makes policy decisions that determine the |
1374 | 39 |
// characteristics of the collector. Examples include: |
40 |
// * choice of collection set. |
|
41 |
// * when to collect. |
|
42 |
||
43 |
class HeapRegion; |
|
37039
79f62b89a7a6
8151178: Move the collection set out of the G1 collector policy
mgerdin
parents:
36365
diff
changeset
|
44 |
class G1CollectionSet; |
1374 | 45 |
class CollectionSetChooser; |
34298
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
34132
diff
changeset
|
46 |
class G1IHOPControl; |
37134
9dd3975ca940
8151711: Move G1 number sequences out of the G1 collector policy
mgerdin
parents:
37070
diff
changeset
|
47 |
class G1Analytics; |
38183
cb68e4923223
8150721: Don't explicitly manage G1 young regions in YoungList
mgerdin
parents:
38109
diff
changeset
|
48 |
class G1SurvivorRegions; |
36102
84546518799d
8149820: Move G1YoungGenSizer to g1CollectorPolicy.cpp
ehelin
parents:
35927
diff
changeset
|
49 |
class G1YoungGenSizer; |
1374 | 50 |
|
37985
539c597ee0fa
8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents:
37262
diff
changeset
|
51 |
class G1Policy: public CHeapObj<mtGC> { |
1374 | 52 |
public: |
38076 | 53 |
virtual const G1Predictions& predictor() const = 0; |
54 |
virtual const G1Analytics* analytics() const = 0; |
|
33214
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
33204
diff
changeset
|
55 |
|
34298
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
34132
diff
changeset
|
56 |
// Add the given number of bytes to the total number of allocated bytes in the old gen. |
38076 | 57 |
virtual void add_bytes_allocated_in_old_since_last_gc(size_t bytes) = 0; |
34298
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
34132
diff
changeset
|
58 |
|
11174
fccee5238e70
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
11169
diff
changeset
|
59 |
// Accessors |
1374 | 60 |
|
38109
6503703df058
8155209: Move setting of young index in cset to G1CollectionSet
mgerdin
parents:
38106
diff
changeset
|
61 |
virtual void set_region_eden(HeapRegion* hr) = 0; |
6503703df058
8155209: Move setting of young index in cset to G1CollectionSet
mgerdin
parents:
38106
diff
changeset
|
62 |
virtual void set_region_survivor(HeapRegion* hr) = 0; |
33216
8ecefd0f0d10
8138750: Remove dead code in survivor rate group
tschatzl
parents:
33214
diff
changeset
|
63 |
|
38076 | 64 |
virtual void record_max_rs_lengths(size_t rs_lengths) = 0; |
33130
a776072941e8
8138969: G1CollectorPolicy should use const for applicable methods
ehelin
parents:
33105
diff
changeset
|
65 |
|
38076 | 66 |
virtual double predict_base_elapsed_time_ms(size_t pending_cards) const = 0; |
67 |
virtual double predict_base_elapsed_time_ms(size_t pending_cards, |
|
68 |
size_t scanned_cards) const = 0; |
|
33624
509a72e7127b
8140489: Introduce shorthand for average_time_ms in G1CollectorPolicy
ehelin
parents:
33591
diff
changeset
|
69 |
|
38076 | 70 |
virtual double predict_region_elapsed_time_ms(HeapRegion* hr, bool for_young_gc) const = 0; |
1374 | 71 |
|
38076 | 72 |
virtual void cset_regions_freed() = 0; |
33591
4a2823c696ce
8138975: G1CollectorPolicy::calculate_young_list_target_length should be const
ehelin
parents:
33217
diff
changeset
|
73 |
|
38076 | 74 |
virtual G1MMUTracker* mmu_tracker() = 0; |
10528
06fab03478df
7084509: G1: fix inconsistencies and mistakes in the young list target length calculations
tonyp
parents:
10523
diff
changeset
|
75 |
|
38076 | 76 |
virtual const G1MMUTracker* mmu_tracker() const = 0; |
10528
06fab03478df
7084509: G1: fix inconsistencies and mistakes in the young list target length calculations
tonyp
parents:
10523
diff
changeset
|
77 |
|
38076 | 78 |
virtual double max_pause_time_ms() const = 0; |
33591
4a2823c696ce
8138975: G1CollectorPolicy::calculate_young_list_target_length should be const
ehelin
parents:
33217
diff
changeset
|
79 |
|
38076 | 80 |
virtual size_t pending_cards() const = 0; |
37039
79f62b89a7a6
8151178: Move the collection set out of the G1 collector policy
mgerdin
parents:
36365
diff
changeset
|
81 |
|
15861
974c3ccaa5d2
8007036: G1: Too many old regions added to last mixed GC
johnc
parents:
15089
diff
changeset
|
82 |
// Calculate the minimum number of old regions we'll add to the CSet |
974c3ccaa5d2
8007036: G1: Too many old regions added to last mixed GC
johnc
parents:
15089
diff
changeset
|
83 |
// during a mixed GC. |
38076 | 84 |
virtual uint calc_min_old_cset_length() const = 0; |
15861
974c3ccaa5d2
8007036: G1: Too many old regions added to last mixed GC
johnc
parents:
15089
diff
changeset
|
85 |
|
974c3ccaa5d2
8007036: G1: Too many old regions added to last mixed GC
johnc
parents:
15089
diff
changeset
|
86 |
// Calculate the maximum number of old regions we'll add to the CSet |
974c3ccaa5d2
8007036: G1: Too many old regions added to last mixed GC
johnc
parents:
15089
diff
changeset
|
87 |
// during a mixed GC. |
38076 | 88 |
virtual uint calc_max_old_cset_length() const = 0; |
15861
974c3ccaa5d2
8007036: G1: Too many old regions added to last mixed GC
johnc
parents:
15089
diff
changeset
|
89 |
|
974c3ccaa5d2
8007036: G1: Too many old regions added to last mixed GC
johnc
parents:
15089
diff
changeset
|
90 |
// Returns the given amount of uncollected reclaimable space |
974c3ccaa5d2
8007036: G1: Too many old regions added to last mixed GC
johnc
parents:
15089
diff
changeset
|
91 |
// as a percentage of the current heap capacity. |
38076 | 92 |
virtual double reclaimable_bytes_perc(size_t reclaimable_bytes) const = 0; |
15861
974c3ccaa5d2
8007036: G1: Too many old regions added to last mixed GC
johnc
parents:
15089
diff
changeset
|
93 |
|
38076 | 94 |
virtual ~G1Policy() {} |
34298
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
34132
diff
changeset
|
95 |
|
38076 | 96 |
virtual G1CollectorState* collector_state() const = 0; |
34298
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
34132
diff
changeset
|
97 |
|
38076 | 98 |
virtual G1GCPhaseTimes* phase_times() const = 0; |
13288
331d5b6725f3
7178361: G1: Make sure that PrintGC and PrintGCDetails use the same timing for the GC pause
brutisso
parents:
12781
diff
changeset
|
99 |
|
10528
06fab03478df
7084509: G1: fix inconsistencies and mistakes in the young list target length calculations
tonyp
parents:
10523
diff
changeset
|
100 |
// Check the current value of the young list RSet lengths and |
06fab03478df
7084509: G1: fix inconsistencies and mistakes in the young list target length calculations
tonyp
parents:
10523
diff
changeset
|
101 |
// compare it against the last prediction. If the current value is |
06fab03478df
7084509: G1: fix inconsistencies and mistakes in the young list target length calculations
tonyp
parents:
10523
diff
changeset
|
102 |
// higher, recalculate the young list target length prediction. |
38076 | 103 |
virtual void revise_young_list_target_length_if_necessary(size_t rs_lengths) = 0; |
1374 | 104 |
|
10529
9d5bbffbb322
6929868: G1: introduce min / max young gen size bounds
brutisso
parents:
10528
diff
changeset
|
105 |
// This should be called after the heap is resized. |
38076 | 106 |
virtual void record_new_heap_size(uint new_number_of_regions) = 0; |
10528
06fab03478df
7084509: G1: fix inconsistencies and mistakes in the young list target length calculations
tonyp
parents:
10523
diff
changeset
|
107 |
|
38076 | 108 |
virtual void init(G1CollectedHeap* g1h, G1CollectionSet* collection_set) = 0; |
1374 | 109 |
|
38076 | 110 |
virtual void note_gc_start() = 0; |
33739 | 111 |
|
38076 | 112 |
virtual bool need_to_start_conc_mark(const char* source, size_t alloc_word_size = 0) = 0; |
33808
ee899178e46b
8140597: Forcing an initial mark causes G1 to abort mixed collections
tschatzl
parents:
33747
diff
changeset
|
113 |
|
16993
c9fd6b7ef40e
8010780: G1: Eden occupancy/capacity output wrong after a full GC
johnc
parents:
15861
diff
changeset
|
114 |
// Record the start and end of an evacuation pause. |
38076 | 115 |
virtual void record_collection_pause_start(double start_time_sec) = 0; |
116 |
virtual void record_collection_pause_end(double pause_time_ms, size_t cards_scanned, size_t heap_used_bytes_before_gc) = 0; |
|
1374 | 117 |
|
16993
c9fd6b7ef40e
8010780: G1: Eden occupancy/capacity output wrong after a full GC
johnc
parents:
15861
diff
changeset
|
118 |
// Record the start and end of a full collection. |
38076 | 119 |
virtual void record_full_collection_start() = 0; |
120 |
virtual void record_full_collection_end() = 0; |
|
1374 | 121 |
|
122 |
// Must currently be called while the world is stopped. |
|
38076 | 123 |
virtual void record_concurrent_mark_init_end(double mark_init_elapsed_time_ms) = 0; |
1374 | 124 |
|
16993
c9fd6b7ef40e
8010780: G1: Eden occupancy/capacity output wrong after a full GC
johnc
parents:
15861
diff
changeset
|
125 |
// Record start and end of remark. |
38076 | 126 |
virtual void record_concurrent_mark_remark_start() = 0; |
127 |
virtual void record_concurrent_mark_remark_end() = 0; |
|
1374 | 128 |
|
16993
c9fd6b7ef40e
8010780: G1: Eden occupancy/capacity output wrong after a full GC
johnc
parents:
15861
diff
changeset
|
129 |
// Record start, end, and completion of cleanup. |
38076 | 130 |
virtual void record_concurrent_mark_cleanup_start() = 0; |
131 |
virtual void record_concurrent_mark_cleanup_end() = 0; |
|
132 |
virtual void record_concurrent_mark_cleanup_completed() = 0; |
|
1374 | 133 |
|
38076 | 134 |
virtual void print_phases() = 0; |
33738
1708291bd3d7
8140508: Add utility method for logging phases to G1CollectorPolicy
ehelin
parents:
33624
diff
changeset
|
135 |
|
10243
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
10236
diff
changeset
|
136 |
// Record how much space we copied during a GC. This is typically |
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
10236
diff
changeset
|
137 |
// called when a GC alloc region is being retired. |
38076 | 138 |
virtual void record_bytes_copied_during_gc(size_t bytes) = 0; |
10243
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
10236
diff
changeset
|
139 |
|
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
10236
diff
changeset
|
140 |
// The amount of space we copied during a GC. |
38076 | 141 |
virtual size_t bytes_copied_during_gc() const = 0; |
1374 | 142 |
|
38183
cb68e4923223
8150721: Don't explicitly manage G1 young regions in YoungList
mgerdin
parents:
38109
diff
changeset
|
143 |
virtual void finalize_collection_set(double target_pause_time_ms, G1SurvivorRegions* survivor) = 0; |
11756
28b6fe22e43d
7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents:
11584
diff
changeset
|
144 |
|
6058
9c9aec6ab47d
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
5891
diff
changeset
|
145 |
// This sets the initiate_conc_mark_if_possible() flag to start a |
9c9aec6ab47d
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
5891
diff
changeset
|
146 |
// new cycle, as long as we are not already in one. It's best if it |
9c9aec6ab47d
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
5891
diff
changeset
|
147 |
// is called during a safepoint when the test whether a cycle is in |
9c9aec6ab47d
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
5891
diff
changeset
|
148 |
// progress or not is stable. |
38076 | 149 |
virtual bool force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause) = 0; |
6058
9c9aec6ab47d
6944166: G1: explicit GCs are not always handled correctly
tonyp
parents:
5891
diff
changeset
|
150 |
|
5243
99e5a8f5d81f
6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.")
tonyp
parents:
5240
diff
changeset
|
151 |
// This is called at the very beginning of an evacuation pause (it |
99e5a8f5d81f
6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.")
tonyp
parents:
5240
diff
changeset
|
152 |
// has to be the first thing that the pause does). If |
99e5a8f5d81f
6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.")
tonyp
parents:
5240
diff
changeset
|
153 |
// initiate_conc_mark_if_possible() is true, and the concurrent |
99e5a8f5d81f
6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.")
tonyp
parents:
5240
diff
changeset
|
154 |
// marking thread has completed its work during the previous cycle, |
99e5a8f5d81f
6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.")
tonyp
parents:
5240
diff
changeset
|
155 |
// it will set during_initial_mark_pause() to so that the pause does |
99e5a8f5d81f
6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.")
tonyp
parents:
5240
diff
changeset
|
156 |
// the initial-mark work and start a marking cycle. |
38076 | 157 |
virtual void decide_on_conc_mark_initiation() = 0; |
1374 | 158 |
|
159 |
||
38076 | 160 |
virtual void finished_recalculating_age_indexes(bool is_survivors) = 0; |
1374 | 161 |
|
38183
cb68e4923223
8150721: Don't explicitly manage G1 young regions in YoungList
mgerdin
parents:
38109
diff
changeset
|
162 |
virtual void transfer_survivors_to_cset(const G1SurvivorRegions* survivors) = 0; |
cb68e4923223
8150721: Don't explicitly manage G1 young regions in YoungList
mgerdin
parents:
38109
diff
changeset
|
163 |
|
38076 | 164 |
virtual size_t young_list_target_length() const = 0; |
7416
cfe3bfab7d48
6994056: G1: when GC locker is active, extend the Eden instead of allocating into the old gen
tonyp
parents:
7398
diff
changeset
|
165 |
|
38106 | 166 |
virtual bool should_allocate_mutator_region() const = 0; |
1374 | 167 |
|
38076 | 168 |
virtual bool can_expand_young_list() const = 0; |
34310
32e3c906b613
8139892: Allow G1CollectorPolicy to specify if reference processing should be enabled
ehelin
parents:
34298
diff
changeset
|
169 |
|
38076 | 170 |
virtual uint young_list_max_length() const = 0; |
1374 | 171 |
|
38076 | 172 |
virtual bool adaptive_young_list_length() const = 0; |
2009 | 173 |
|
38076 | 174 |
virtual bool should_process_references() const = 0; |
35909
cf5f3c85e179
8148736: Let the G1 heap transition log regions instead of bytes
brutisso
parents:
35907
diff
changeset
|
175 |
|
38076 | 176 |
virtual uint tenuring_threshold() const = 0; |
177 |
virtual uint max_survivor_regions() = 0; |
|
2009 | 178 |
|
38076 | 179 |
virtual void note_start_adding_survivor_regions() = 0; |
2009 | 180 |
|
38076 | 181 |
virtual void note_stop_adding_survivor_regions() = 0; |
7416
cfe3bfab7d48
6994056: G1: when GC locker is active, extend the Eden instead of allocating into the old gen
tonyp
parents:
7398
diff
changeset
|
182 |
|
38076 | 183 |
virtual void record_age_table(AgeTable* age_table) = 0; |
1374 | 184 |
}; |
185 |
||
37985
539c597ee0fa
8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents:
37262
diff
changeset
|
186 |
#endif // SHARE_VM_GC_G1_G1POLICY_HPP |