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 StrongRootsScope;
35 class SubTasksDone;
36 class WorkGang;
37
38 // A "GenCollectedHeap" is a CollectedHeap that uses generational
39 // collection. It has two generations, young and old.
40 class GenCollectedHeap : public CollectedHeap {
41 friend class GenCollectorPolicy;
42 friend class Generation;
43 friend class DefNewGeneration;
44 friend class TenuredGeneration;
45 friend class ConcurrentMarkSweepGeneration;
46 friend class CMSCollector;
47 friend class GenMarkSweep;
48 friend class VM_GenCollectForAllocation;
49 friend class VM_GenCollectFull;
50 friend class VM_GenCollectFullConcurrent;
51 friend class VM_GC_HeapInspection;
52 friend class VM_HeapDumper;
53 friend class HeapInspection;
54 friend class GCCauseSetter;
55 friend class VMStructs;
56 public:
57 friend class VM_PopulateDumpSharedSpace;
58
59 enum GenerationType {
60 YoungGen,
61 OldGen
62 };
63
64 private:
65 Generation* _young_gen;
66 Generation* _old_gen;
67
68 // The singleton CardTable Remembered Set.
69 CardTableRS* _rem_set;
70
71 // The generational collector policy.
72 GenCollectorPolicy* _gen_policy;
73
74 SoftRefGenPolicy _soft_ref_gen_policy;
75
76 // The sizing of the heap is controlled by a sizing policy.
77 AdaptiveSizePolicy* _size_policy;
78
79 // Indicates that the most recent previous incremental collection failed.
80 // The flag is cleared when an action is taken that might clear the
81 // condition that caused that incremental collection to fail.
82 bool _incremental_collection_failed;
83
84 // In support of ExplicitGCInvokesConcurrent functionality
85 unsigned int _full_collections_completed;
86
87 // Collects the given generation.
132 bool clear_all_soft_refs,
133 size_t size,
134 bool is_tlab,
135 GenerationType max_generation);
136
137 // Callback from VM_GenCollectForAllocation operation.
138 // This function does everything necessary/possible to satisfy an
139 // allocation request that failed in the youngest generation that should
140 // have handled it (including collection, expansion, etc.)
141 HeapWord* satisfy_failed_allocation(size_t size, bool is_tlab);
142
143 // Callback from VM_GenCollectFull operation.
144 // Perform a full collection of the first max_level+1 generations.
145 virtual void do_full_collection(bool clear_all_soft_refs);
146 void do_full_collection(bool clear_all_soft_refs, GenerationType max_generation);
147
148 // Does the "cause" of GC indicate that
149 // we absolutely __must__ clear soft refs?
150 bool must_clear_all_soft_refs();
151
152 GenCollectedHeap(GenCollectorPolicy *policy);
153
154 virtual void check_gen_kinds() = 0;
155
156 public:
157
158 // Returns JNI_OK on success
159 virtual jint initialize();
160
161 void initialize_size_policy(size_t init_eden_size,
162 size_t init_promo_size,
163 size_t init_survivor_size);
164
165 // Does operations required after initialization has been done.
166 void post_initialize();
167
168 Generation* young_gen() const { return _young_gen; }
169 Generation* old_gen() const { return _old_gen; }
170
171 bool is_young_gen(const Generation* gen) const { return gen == _young_gen; }
172 bool is_old_gen(const Generation* gen) const { return gen == _old_gen; }
173
174 // The generational collector policy.
175 GenCollectorPolicy* gen_policy() const { return _gen_policy; }
176
177 virtual CollectorPolicy* collector_policy() const { return gen_policy(); }
178
179 virtual SoftRefPolicy* soft_ref_policy() { return &_soft_ref_gen_policy; }
180
181 // Adaptive size policy
182 virtual AdaptiveSizePolicy* size_policy() {
183 return _size_policy;
184 }
185
186 // Return the (conservative) maximum heap alignment
187 static size_t conservative_max_heap_alignment() {
188 return Generation::GenGrain;
189 }
190
191 size_t capacity() const;
192 size_t used() 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 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;
54 friend class HeapInspection;
55 friend class GCCauseSetter;
56 friend class VMStructs;
57 public:
58 friend class VM_PopulateDumpSharedSpace;
59
60 enum GenerationType {
61 YoungGen,
62 OldGen
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.
136 bool clear_all_soft_refs,
137 size_t size,
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_size_policy(size_t init_eden_size,
168 size_t init_promo_size,
169 size_t init_survivor_size);
170
171 // Does operations required after initialization has been done.
172 void post_initialize();
173
174 Generation* young_gen() const { return _young_gen; }
175 Generation* old_gen() const { return _old_gen; }
176
177 bool is_young_gen(const Generation* gen) const { return gen == _young_gen; }
178 bool is_old_gen(const Generation* gen) const { return gen == _old_gen; }
179
180 GenerationSpec* young_gen_spec() const;
181 GenerationSpec* old_gen_spec() const;
182
183 // The generational collector policy.
184 GenCollectorPolicy* gen_policy() const { return _gen_policy; }
185
186 virtual CollectorPolicy* collector_policy() const { return gen_policy(); }
187
188 virtual SoftRefPolicy* soft_ref_policy() { return &_soft_ref_gen_policy; }
189
190 // Adaptive size policy
191 virtual AdaptiveSizePolicy* size_policy() {
192 return _size_policy;
193 }
194
195 // Return the (conservative) maximum heap alignment
196 static size_t conservative_max_heap_alignment() {
197 return Generation::GenGrain;
198 }
199
200 size_t capacity() const;
201 size_t used() const;
|