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_SHARED_GENCOLLECTEDHEAP_HPP
26 #define SHARE_VM_GC_SHARED_GENCOLLECTEDHEAP_HPP
27
28 #include "gc/shared/collectedHeap.hpp"
29 #include "gc/shared/collectorPolicy.hpp"
30 #include "gc/shared/generation.hpp"
31 #include "gc/shared/softRefGenPolicy.hpp"
32
33 class AdaptiveSizePolicy;
34 class GenerationSpec;
35 class StrongRootsScope;
36 class SubTasksDone;
37 class WorkGang;
38
39 // A "GenCollectedHeap" is a CollectedHeap that uses generational
40 // collection. It has two generations, young and old.
41 class GenCollectedHeap : public CollectedHeap {
42 friend class GenCollectorPolicy;
43 friend class Generation;
44 friend class DefNewGeneration;
45 friend class TenuredGeneration;
46 friend class ConcurrentMarkSweepGeneration;
47 friend class CMSCollector;
48 friend class GenMarkSweep;
49 friend class VM_GenCollectForAllocation;
50 friend class VM_GenCollectFull;
51 friend class VM_GenCollectFullConcurrent;
52 friend class VM_GC_HeapInspection;
53 friend class VM_HeapDumper;
63 };
64
65 private:
66 Generation* _young_gen;
67 Generation* _old_gen;
68
69 GenerationSpec* _young_gen_spec;
70 GenerationSpec* _old_gen_spec;
71
72 // The singleton CardTable Remembered Set.
73 CardTableRS* _rem_set;
74
75 // The generational collector policy.
76 GenCollectorPolicy* _gen_policy;
77
78 SoftRefGenPolicy _soft_ref_gen_policy;
79
80 // The sizing of the heap is controlled by a sizing policy.
81 AdaptiveSizePolicy* _size_policy;
82
83 // Indicates that the most recent previous incremental collection failed.
84 // The flag is cleared when an action is taken that might clear the
85 // condition that caused that incremental collection to fail.
86 bool _incremental_collection_failed;
87
88 // In support of ExplicitGCInvokesConcurrent functionality
89 unsigned int _full_collections_completed;
90
91 // Collects the given generation.
92 void collect_generation(Generation* gen, bool full, size_t size, bool is_tlab,
93 bool run_verification, bool clear_soft_refs,
94 bool restore_marks_for_biased_locking);
95
96 // Reserve aligned space for the heap as needed by the contained generations.
97 char* allocate(size_t alignment, ReservedSpace* heap_rs);
98
99 // Initialize ("weak") refs processing support
100 void ref_processing_init();
101
102 protected:
138 bool is_tlab,
139 GenerationType max_generation);
140
141 // Callback from VM_GenCollectForAllocation operation.
142 // This function does everything necessary/possible to satisfy an
143 // allocation request that failed in the youngest generation that should
144 // have handled it (including collection, expansion, etc.)
145 HeapWord* satisfy_failed_allocation(size_t size, bool is_tlab);
146
147 // Callback from VM_GenCollectFull operation.
148 // Perform a full collection of the first max_level+1 generations.
149 virtual void do_full_collection(bool clear_all_soft_refs);
150 void do_full_collection(bool clear_all_soft_refs, GenerationType max_generation);
151
152 // Does the "cause" of GC indicate that
153 // we absolutely __must__ clear soft refs?
154 bool must_clear_all_soft_refs();
155
156 GenCollectedHeap(GenCollectorPolicy *policy,
157 Generation::Name young,
158 Generation::Name old);
159
160 virtual void check_gen_kinds() = 0;
161
162 public:
163
164 // Returns JNI_OK on success
165 virtual jint initialize();
166
167 void initialize_generations(Generation::Name young,
168 Generation::Name old);
169
170 void initialize_size_policy(size_t init_eden_size,
171 size_t init_promo_size,
172 size_t init_survivor_size);
173
174 // Does operations required after initialization has been done.
175 void post_initialize();
176
177 Generation* young_gen() const { return _young_gen; }
178 Generation* old_gen() const { return _old_gen; }
179
180 bool is_young_gen(const Generation* gen) const { return gen == _young_gen; }
181 bool is_old_gen(const Generation* gen) const { return gen == _old_gen; }
182
183 GenerationSpec* young_gen_spec() const;
184 GenerationSpec* old_gen_spec() const;
185
186 // The generational collector policy.
187 GenCollectorPolicy* gen_policy() const { return _gen_policy; }
188
189 virtual CollectorPolicy* collector_policy() const { return gen_policy(); }
190
191 virtual SoftRefPolicy* soft_ref_policy() { return &_soft_ref_gen_policy; }
192
193 // Adaptive size policy
194 virtual AdaptiveSizePolicy* size_policy() {
195 return _size_policy;
196 }
197
198 // Return the (conservative) maximum heap alignment
199 static size_t conservative_max_heap_alignment() {
200 return Generation::GenGrain;
201 }
202
203 size_t capacity() const;
204 size_t used() const;
205
206 // Save the "used_region" for both generations.
207 void save_used_regions();
208
209 size_t max_capacity() const;
210
211 HeapWord* mem_allocate(size_t size, bool* gc_overhead_limit_was_exceeded);
212
213 // We may support a shared contiguous allocation area, if the youngest
214 // generation does.
215 bool supports_inline_contig_alloc() const;
216 HeapWord* volatile* top_addr() const;
|
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_SHARED_GENCOLLECTEDHEAP_HPP
26 #define SHARE_VM_GC_SHARED_GENCOLLECTEDHEAP_HPP
27
28 #include "gc/shared/collectedHeap.hpp"
29 #include "gc/shared/collectorPolicy.hpp"
30 #include "gc/shared/generation.hpp"
31 #include "gc/shared/softRefGenPolicy.hpp"
32
33 class AdaptiveSizePolicy;
34 class GCPolicyCounters;
35 class GenerationSpec;
36 class StrongRootsScope;
37 class SubTasksDone;
38 class WorkGang;
39
40 // A "GenCollectedHeap" is a CollectedHeap that uses generational
41 // collection. It has two generations, young and old.
42 class GenCollectedHeap : public CollectedHeap {
43 friend class GenCollectorPolicy;
44 friend class Generation;
45 friend class DefNewGeneration;
46 friend class TenuredGeneration;
47 friend class ConcurrentMarkSweepGeneration;
48 friend class CMSCollector;
49 friend class GenMarkSweep;
50 friend class VM_GenCollectForAllocation;
51 friend class VM_GenCollectFull;
52 friend class VM_GenCollectFullConcurrent;
53 friend class VM_GC_HeapInspection;
54 friend class VM_HeapDumper;
64 };
65
66 private:
67 Generation* _young_gen;
68 Generation* _old_gen;
69
70 GenerationSpec* _young_gen_spec;
71 GenerationSpec* _old_gen_spec;
72
73 // The singleton CardTable Remembered Set.
74 CardTableRS* _rem_set;
75
76 // The generational collector policy.
77 GenCollectorPolicy* _gen_policy;
78
79 SoftRefGenPolicy _soft_ref_gen_policy;
80
81 // The sizing of the heap is controlled by a sizing policy.
82 AdaptiveSizePolicy* _size_policy;
83
84 GCPolicyCounters* _gc_policy_counters;
85
86 // Indicates that the most recent previous incremental collection failed.
87 // The flag is cleared when an action is taken that might clear the
88 // condition that caused that incremental collection to fail.
89 bool _incremental_collection_failed;
90
91 // In support of ExplicitGCInvokesConcurrent functionality
92 unsigned int _full_collections_completed;
93
94 // Collects the given generation.
95 void collect_generation(Generation* gen, bool full, size_t size, bool is_tlab,
96 bool run_verification, bool clear_soft_refs,
97 bool restore_marks_for_biased_locking);
98
99 // Reserve aligned space for the heap as needed by the contained generations.
100 char* allocate(size_t alignment, ReservedSpace* heap_rs);
101
102 // Initialize ("weak") refs processing support
103 void ref_processing_init();
104
105 protected:
141 bool is_tlab,
142 GenerationType max_generation);
143
144 // Callback from VM_GenCollectForAllocation operation.
145 // This function does everything necessary/possible to satisfy an
146 // allocation request that failed in the youngest generation that should
147 // have handled it (including collection, expansion, etc.)
148 HeapWord* satisfy_failed_allocation(size_t size, bool is_tlab);
149
150 // Callback from VM_GenCollectFull operation.
151 // Perform a full collection of the first max_level+1 generations.
152 virtual void do_full_collection(bool clear_all_soft_refs);
153 void do_full_collection(bool clear_all_soft_refs, GenerationType max_generation);
154
155 // Does the "cause" of GC indicate that
156 // we absolutely __must__ clear soft refs?
157 bool must_clear_all_soft_refs();
158
159 GenCollectedHeap(GenCollectorPolicy *policy,
160 Generation::Name young,
161 Generation::Name old,
162 const char* policy_counters_name);
163
164 virtual void check_gen_kinds() = 0;
165
166 public:
167
168 // Returns JNI_OK on success
169 virtual jint initialize();
170
171 void initialize_generations(Generation::Name young,
172 Generation::Name old);
173
174 void initialize_size_policy(size_t init_eden_size,
175 size_t init_promo_size,
176 size_t init_survivor_size);
177
178 // Does operations required after initialization has been done.
179 void post_initialize();
180
181 Generation* young_gen() const { return _young_gen; }
182 Generation* old_gen() const { return _old_gen; }
183
184 bool is_young_gen(const Generation* gen) const { return gen == _young_gen; }
185 bool is_old_gen(const Generation* gen) const { return gen == _old_gen; }
186
187 GenerationSpec* young_gen_spec() const;
188 GenerationSpec* old_gen_spec() const;
189
190 // The generational collector policy.
191 GenCollectorPolicy* gen_policy() const { return _gen_policy; }
192
193 virtual CollectorPolicy* collector_policy() const { return gen_policy(); }
194
195 virtual SoftRefPolicy* soft_ref_policy() { return &_soft_ref_gen_policy; }
196
197 // Adaptive size policy
198 virtual AdaptiveSizePolicy* size_policy() {
199 return _size_policy;
200 }
201
202 // Performance Counter support
203 GCPolicyCounters* counters() { return _gc_policy_counters; }
204
205 // Return the (conservative) maximum heap alignment
206 static size_t conservative_max_heap_alignment() {
207 return Generation::GenGrain;
208 }
209
210 size_t capacity() const;
211 size_t used() const;
212
213 // Save the "used_region" for both generations.
214 void save_used_regions();
215
216 size_t max_capacity() const;
217
218 HeapWord* mem_allocate(size_t size, bool* gc_overhead_limit_was_exceeded);
219
220 // We may support a shared contiguous allocation area, if the youngest
221 // generation does.
222 bool supports_inline_contig_alloc() const;
223 HeapWord* volatile* top_addr() const;
|