27
28 #include "gc_implementation/shared/ageTable.hpp"
29 #include "gc_implementation/shared/cSpaceCounters.hpp"
30 #include "gc_implementation/shared/generationCounters.hpp"
31 #include "gc_implementation/shared/copyFailedInfo.hpp"
32 #include "memory/generation.inline.hpp"
33 #include "utilities/stack.hpp"
34
35 class EdenSpace;
36 class ContiguousSpace;
37 class ScanClosure;
38 class STWGCTimer;
39
40 // DefNewGeneration is a young generation containing eden, from- and
41 // to-space.
42
43 class DefNewGeneration: public Generation {
44 friend class VMStructs;
45
46 protected:
47 Generation* _next_gen;
48 uint _tenuring_threshold; // Tenuring threshold for next collection.
49 ageTable _age_table;
50 // Size of object to pretenure in words; command line provides bytes
51 size_t _pretenure_size_threshold_words;
52
53 ageTable* age_table() { return &_age_table; }
54
55 // Initialize state to optimistically assume no promotion failure will
56 // happen.
57 void init_assuming_no_promotion_failure();
58 // True iff a promotion has failed in the current collection.
59 bool _promotion_failed;
60 bool promotion_failed() { return _promotion_failed; }
61 PromotionFailedInfo _promotion_failed_info;
62
63 // Handling promotion failure. A young generation collection
64 // can fail if a live object cannot be copied out of its
65 // location in eden or from-space during the collection. If
66 // a collection fails, the young generation is left in a
67 // consistent state such that it can be collected by a
165 CardTableRS* _rs;
166 template <class T> void do_oop_work(T* p);
167 public:
168 KeepAliveClosure(ScanWeakRefClosure* cl);
169 virtual void do_oop(oop* p);
170 virtual void do_oop(narrowOop* p);
171 };
172
173 class FastKeepAliveClosure: public KeepAliveClosure {
174 protected:
175 HeapWord* _boundary;
176 template <class T> void do_oop_work(T* p);
177 public:
178 FastKeepAliveClosure(DefNewGeneration* g, ScanWeakRefClosure* cl);
179 virtual void do_oop(oop* p);
180 virtual void do_oop(narrowOop* p);
181 };
182
183 class EvacuateFollowersClosure: public VoidClosure {
184 GenCollectedHeap* _gch;
185 int _level;
186 ScanClosure* _scan_cur_or_nonheap;
187 ScanClosure* _scan_older;
188 public:
189 EvacuateFollowersClosure(GenCollectedHeap* gch, int level,
190 ScanClosure* cur, ScanClosure* older);
191 void do_void();
192 };
193
194 class FastEvacuateFollowersClosure: public VoidClosure {
195 GenCollectedHeap* _gch;
196 int _level;
197 DefNewGeneration* _gen;
198 FastScanClosure* _scan_cur_or_nonheap;
199 FastScanClosure* _scan_older;
200 public:
201 FastEvacuateFollowersClosure(GenCollectedHeap* gch, int level,
202 DefNewGeneration* gen,
203 FastScanClosure* cur,
204 FastScanClosure* older);
205 void do_void();
206 };
207
208 public:
209 DefNewGeneration(ReservedSpace rs, size_t initial_byte_size, int level,
210 const char* policy="Copy");
211
212 virtual void ref_processor_init();
213
214 virtual Generation::Name kind() { return Generation::DefNew; }
215
216 // Accessing spaces
217 EdenSpace* eden() const { return _eden_space; }
218 ContiguousSpace* from() const { return _from_space; }
219 ContiguousSpace* to() const { return _to_space; }
220
221 virtual CompactibleSpace* first_compaction_space() const;
222
223 // Space enquiries
224 size_t capacity() const;
225 size_t used() const;
226 size_t free() const;
227 size_t max_capacity() const;
228 size_t capacity_before_gc() const;
229 size_t unsafe_max_alloc_nogc() const;
|
27
28 #include "gc_implementation/shared/ageTable.hpp"
29 #include "gc_implementation/shared/cSpaceCounters.hpp"
30 #include "gc_implementation/shared/generationCounters.hpp"
31 #include "gc_implementation/shared/copyFailedInfo.hpp"
32 #include "memory/generation.inline.hpp"
33 #include "utilities/stack.hpp"
34
35 class EdenSpace;
36 class ContiguousSpace;
37 class ScanClosure;
38 class STWGCTimer;
39
40 // DefNewGeneration is a young generation containing eden, from- and
41 // to-space.
42
43 class DefNewGeneration: public Generation {
44 friend class VMStructs;
45
46 protected:
47 Generation* _old_gen;
48 uint _tenuring_threshold; // Tenuring threshold for next collection.
49 ageTable _age_table;
50 // Size of object to pretenure in words; command line provides bytes
51 size_t _pretenure_size_threshold_words;
52
53 ageTable* age_table() { return &_age_table; }
54
55 // Initialize state to optimistically assume no promotion failure will
56 // happen.
57 void init_assuming_no_promotion_failure();
58 // True iff a promotion has failed in the current collection.
59 bool _promotion_failed;
60 bool promotion_failed() { return _promotion_failed; }
61 PromotionFailedInfo _promotion_failed_info;
62
63 // Handling promotion failure. A young generation collection
64 // can fail if a live object cannot be copied out of its
65 // location in eden or from-space during the collection. If
66 // a collection fails, the young generation is left in a
67 // consistent state such that it can be collected by a
165 CardTableRS* _rs;
166 template <class T> void do_oop_work(T* p);
167 public:
168 KeepAliveClosure(ScanWeakRefClosure* cl);
169 virtual void do_oop(oop* p);
170 virtual void do_oop(narrowOop* p);
171 };
172
173 class FastKeepAliveClosure: public KeepAliveClosure {
174 protected:
175 HeapWord* _boundary;
176 template <class T> void do_oop_work(T* p);
177 public:
178 FastKeepAliveClosure(DefNewGeneration* g, ScanWeakRefClosure* cl);
179 virtual void do_oop(oop* p);
180 virtual void do_oop(narrowOop* p);
181 };
182
183 class EvacuateFollowersClosure: public VoidClosure {
184 GenCollectedHeap* _gch;
185 ScanClosure* _scan_cur_or_nonheap;
186 ScanClosure* _scan_older;
187 public:
188 EvacuateFollowersClosure(GenCollectedHeap* gch,
189 ScanClosure* cur, ScanClosure* older);
190 void do_void();
191 };
192
193 class FastEvacuateFollowersClosure: public VoidClosure {
194 GenCollectedHeap* _gch;
195 DefNewGeneration* _gen;
196 FastScanClosure* _scan_cur_or_nonheap;
197 FastScanClosure* _scan_older;
198 public:
199 FastEvacuateFollowersClosure(GenCollectedHeap* gch,
200 DefNewGeneration* gen,
201 FastScanClosure* cur,
202 FastScanClosure* older);
203 void do_void();
204 };
205
206 public:
207 DefNewGeneration(ReservedSpace rs, size_t initial_byte_size,
208 const char* policy="Copy");
209
210 virtual void ref_processor_init();
211
212 virtual Generation::Name kind() { return Generation::DefNew; }
213
214 // Accessing spaces
215 EdenSpace* eden() const { return _eden_space; }
216 ContiguousSpace* from() const { return _from_space; }
217 ContiguousSpace* to() const { return _to_space; }
218
219 virtual CompactibleSpace* first_compaction_space() const;
220
221 // Space enquiries
222 size_t capacity() const;
223 size_t used() const;
224 size_t free() const;
225 size_t max_capacity() const;
226 size_t capacity_before_gc() const;
227 size_t unsafe_max_alloc_nogc() const;
|