rev 47451 : imported patch 8189729-perc-naming
1 /*
2 * Copyright (c) 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_G1POLICY_HPP
26 #define SHARE_VM_GC_G1_G1POLICY_HPP
27
28 #include "gc/g1/g1CollectorState.hpp"
29 #include "gc/g1/g1GCPhaseTimes.hpp"
30 #include "gc/g1/g1InCSetState.hpp"
31 #include "gc/g1/g1InitialMarkToMixedTimeTracker.hpp"
32 #include "gc/g1/g1MMUTracker.hpp"
33 #include "gc/g1/g1Predictions.hpp"
34 #include "gc/g1/g1YoungGenSizer.hpp"
35 #include "gc/shared/gcCause.hpp"
36 #include "utilities/pair.hpp"
37
38 // A G1Policy makes policy decisions that determine the
39 // characteristics of the collector. Examples include:
40 // * choice of collection set.
41 // * when to collect.
42
43 class HeapRegion;
44 class G1CollectionSet;
45 class CollectionSetChooser;
46 class G1IHOPControl;
47 class G1Analytics;
48 class G1SurvivorRegions;
49 class G1YoungGenSizer;
50
51 class G1Policy: public CHeapObj<mtGC> {
52 public:
53 virtual const G1Predictions& predictor() const = 0;
54 virtual const G1Analytics* analytics() const = 0;
55
56 // Add the given number of bytes to the total number of allocated bytes in the old gen.
57 virtual void add_bytes_allocated_in_old_since_last_gc(size_t bytes) = 0;
58
59 // Accessors
60
61 virtual void set_region_eden(HeapRegion* hr) = 0;
62 virtual void set_region_survivor(HeapRegion* hr) = 0;
63
64 virtual void record_max_rs_lengths(size_t rs_lengths) = 0;
65
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;
69
70 virtual double predict_region_elapsed_time_ms(HeapRegion* hr, bool for_young_gc) const = 0;
71
72 virtual void cset_regions_freed() = 0;
73
74 virtual G1MMUTracker* mmu_tracker() = 0;
75
76 virtual const G1MMUTracker* mmu_tracker() const = 0;
77
78 virtual double max_pause_time_ms() const = 0;
79
80 virtual size_t pending_cards() const = 0;
81
82 // Calculate the minimum number of old regions we'll add to the CSet
83 // during a mixed GC.
84 virtual uint calc_min_old_cset_length() const = 0;
85
86 // Calculate the maximum number of old regions we'll add to the CSet
87 // during a mixed GC.
88 virtual uint calc_max_old_cset_length() const = 0;
89
90 // Returns the given amount of uncollected reclaimable space
91 // as a percentage of the current heap capacity.
92 virtual double reclaimable_bytes_perc(size_t reclaimable_bytes) const = 0;
93
94 virtual ~G1Policy() {}
95
96 virtual G1CollectorState* collector_state() const = 0;
97
98 virtual G1GCPhaseTimes* phase_times() const = 0;
99
100 // Check the current value of the young list RSet lengths and
101 // compare it against the last prediction. If the current value is
102 // higher, recalculate the young list target length prediction.
103 virtual void revise_young_list_target_length_if_necessary(size_t rs_lengths) = 0;
104
105 // This should be called after the heap is resized.
106 virtual void record_new_heap_size(uint new_number_of_regions) = 0;
107
108 virtual void init(G1CollectedHeap* g1h, G1CollectionSet* collection_set) = 0;
109
110 virtual void note_gc_start() = 0;
111
112 virtual bool need_to_start_conc_mark(const char* source, size_t alloc_word_size = 0) = 0;
113
114 // Record the start and end of an evacuation pause.
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;
117
118 // Record the start and end of a full collection.
119 virtual void record_full_collection_start() = 0;
120 virtual void record_full_collection_end() = 0;
121
122 virtual jlong collection_pause_end_millis() = 0;
123
124 // Must currently be called while the world is stopped.
125 virtual void record_concurrent_mark_init_end(double mark_init_elapsed_time_ms) = 0;
126
127 // Record start and end of remark.
128 virtual void record_concurrent_mark_remark_start() = 0;
129 virtual void record_concurrent_mark_remark_end() = 0;
130
131 // Record start, end, and completion of cleanup.
132 virtual void record_concurrent_mark_cleanup_start() = 0;
133 virtual void record_concurrent_mark_cleanup_end() = 0;
134 virtual void record_concurrent_mark_cleanup_completed() = 0;
135
136 virtual void print_phases() = 0;
137
138 // Record how much space we copied during a GC. This is typically
139 // called when a GC alloc region is being retired.
140 virtual void record_bytes_copied_during_gc(size_t bytes) = 0;
141
142 // The amount of space we copied during a GC.
143 virtual size_t bytes_copied_during_gc() const = 0;
144
145 virtual void finalize_collection_set(double target_pause_time_ms, G1SurvivorRegions* survivor) = 0;
146
147 // This sets the initiate_conc_mark_if_possible() flag to start a
148 // new cycle, as long as we are not already in one. It's best if it
149 // is called during a safepoint when the test whether a cycle is in
150 // progress or not is stable.
151 virtual bool force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause) = 0;
152
153 // This is called at the very beginning of an evacuation pause (it
154 // has to be the first thing that the pause does). If
155 // initiate_conc_mark_if_possible() is true, and the concurrent
156 // marking thread has completed its work during the previous cycle,
157 // it will set during_initial_mark_pause() to so that the pause does
158 // the initial-mark work and start a marking cycle.
159 virtual void decide_on_conc_mark_initiation() = 0;
160
161
162 virtual void finished_recalculating_age_indexes(bool is_survivors) = 0;
163
164 virtual void transfer_survivors_to_cset(const G1SurvivorRegions* survivors) = 0;
165
166 virtual size_t young_list_target_length() const = 0;
167
168 virtual bool should_allocate_mutator_region() const = 0;
169
170 virtual bool can_expand_young_list() const = 0;
171
172 virtual uint young_list_max_length() const = 0;
173
174 virtual bool adaptive_young_list_length() const = 0;
175
176 virtual bool should_process_references() const = 0;
177
178 virtual uint tenuring_threshold() const = 0;
179 virtual uint max_survivor_regions() = 0;
180
181 virtual void note_start_adding_survivor_regions() = 0;
182
183 virtual void note_stop_adding_survivor_regions() = 0;
184
185 virtual void record_age_table(AgeTable* age_table) = 0;
186 virtual void print_age_table() = 0;
187 protected:
188 virtual size_t desired_survivor_size() const = 0;
189 };
190
191 #endif // SHARE_VM_GC_G1_G1POLICY_HPP
--- EOF ---