34
35 // A "GenCollectedHeap" is a SharedHeap that uses generational
36 // collection. It has two generations, young and old.
37 class GenCollectedHeap : public SharedHeap {
38 friend class GenCollectorPolicy;
39 friend class Generation;
40 friend class DefNewGeneration;
41 friend class TenuredGeneration;
42 friend class ConcurrentMarkSweepGeneration;
43 friend class CMSCollector;
44 friend class GenMarkSweep;
45 friend class VM_GenCollectForAllocation;
46 friend class VM_GenCollectFull;
47 friend class VM_GenCollectFullConcurrent;
48 friend class VM_GC_HeapInspection;
49 friend class VM_HeapDumper;
50 friend class HeapInspection;
51 friend class GCCauseSetter;
52 friend class VMStructs;
53 public:
54 enum SomeConstants {
55 max_gens = 10
56 };
57
58 friend class VM_PopulateDumpSharedSpace;
59
60 protected:
61 // Fields:
62 static GenCollectedHeap* _gch;
63
64 private:
65 int _n_gens;
66
67 Generation* _young_gen;
68 Generation* _old_gen;
69
70 // The generational collector policy.
71 GenCollectorPolicy* _gen_policy;
72
73 // Indicates that the most recent previous incremental collection failed.
74 // The flag is cleared when an action is taken that might clear the
75 // condition that caused that incremental collection to fail.
76 bool _incremental_collection_failed;
77
78 // In support of ExplicitGCInvokesConcurrent functionality
79 unsigned int _full_collections_completed;
80
81 // Data structure for claiming the (potentially) parallel tasks in
82 // (gen-specific) roots processing.
83 SubTasksDone* _gen_process_roots_tasks;
84 SubTasksDone* gen_process_roots_tasks() { return _gen_process_roots_tasks; }
85
86 void collect_generation(Generation* gen, bool full, size_t size, bool is_tlab,
350 // The functions below are helper functions that a subclass of
351 // "CollectedHeap" can use in the implementation of its virtual
352 // functions.
353
354 class GenClosure : public StackObj {
355 public:
356 virtual void do_generation(Generation* gen) = 0;
357 };
358
359 // Apply "cl.do_generation" to all generations in the heap
360 // If "old_to_young" determines the order.
361 void generation_iterate(GenClosure* cl, bool old_to_young);
362
363 void space_iterate(SpaceClosure* cl);
364
365 // Return "true" if all generations have reached the
366 // maximal committed limit that they can reach, without a garbage
367 // collection.
368 virtual bool is_maximal_no_gc() const;
369
370 int n_gens() const {
371 assert(_n_gens == gen_policy()->number_of_generations(), "Sanity");
372 return _n_gens;
373 }
374
375 // Convenience function to be used in situations where the heap type can be
376 // asserted to be this type.
377 static GenCollectedHeap* heap();
378
379 void set_par_threads(uint t);
380
381 // Invoke the "do_oop" method of one of the closures "not_older_gens"
382 // or "older_gens" on root locations for the generation at
383 // "level". (The "older_gens" closure is used for scanning references
384 // from older generations; "not_older_gens" is used everywhere else.)
385 // If "younger_gens_as_roots" is false, younger generations are
386 // not scanned as roots; in this case, the caller must be arranging to
387 // scan the younger generations itself. (For example, a generation might
388 // explicitly mark reachable objects in younger generations, to avoid
389 // excess storage retention.)
390 // The "so" argument determines which of the roots
391 // the closure is applied to:
392 // "SO_None" does none;
393 private:
394 void gen_process_roots(int level,
|
34
35 // A "GenCollectedHeap" is a SharedHeap that uses generational
36 // collection. It has two generations, young and old.
37 class GenCollectedHeap : public SharedHeap {
38 friend class GenCollectorPolicy;
39 friend class Generation;
40 friend class DefNewGeneration;
41 friend class TenuredGeneration;
42 friend class ConcurrentMarkSweepGeneration;
43 friend class CMSCollector;
44 friend class GenMarkSweep;
45 friend class VM_GenCollectForAllocation;
46 friend class VM_GenCollectFull;
47 friend class VM_GenCollectFullConcurrent;
48 friend class VM_GC_HeapInspection;
49 friend class VM_HeapDumper;
50 friend class HeapInspection;
51 friend class GCCauseSetter;
52 friend class VMStructs;
53 public:
54 friend class VM_PopulateDumpSharedSpace;
55
56 protected:
57 // Fields:
58 static GenCollectedHeap* _gch;
59
60 private:
61 Generation* _young_gen;
62 Generation* _old_gen;
63
64 // The generational collector policy.
65 GenCollectorPolicy* _gen_policy;
66
67 // Indicates that the most recent previous incremental collection failed.
68 // The flag is cleared when an action is taken that might clear the
69 // condition that caused that incremental collection to fail.
70 bool _incremental_collection_failed;
71
72 // In support of ExplicitGCInvokesConcurrent functionality
73 unsigned int _full_collections_completed;
74
75 // Data structure for claiming the (potentially) parallel tasks in
76 // (gen-specific) roots processing.
77 SubTasksDone* _gen_process_roots_tasks;
78 SubTasksDone* gen_process_roots_tasks() { return _gen_process_roots_tasks; }
79
80 void collect_generation(Generation* gen, bool full, size_t size, bool is_tlab,
344 // The functions below are helper functions that a subclass of
345 // "CollectedHeap" can use in the implementation of its virtual
346 // functions.
347
348 class GenClosure : public StackObj {
349 public:
350 virtual void do_generation(Generation* gen) = 0;
351 };
352
353 // Apply "cl.do_generation" to all generations in the heap
354 // If "old_to_young" determines the order.
355 void generation_iterate(GenClosure* cl, bool old_to_young);
356
357 void space_iterate(SpaceClosure* cl);
358
359 // Return "true" if all generations have reached the
360 // maximal committed limit that they can reach, without a garbage
361 // collection.
362 virtual bool is_maximal_no_gc() const;
363
364 // Convenience function to be used in situations where the heap type can be
365 // asserted to be this type.
366 static GenCollectedHeap* heap();
367
368 void set_par_threads(uint t);
369
370 // Invoke the "do_oop" method of one of the closures "not_older_gens"
371 // or "older_gens" on root locations for the generation at
372 // "level". (The "older_gens" closure is used for scanning references
373 // from older generations; "not_older_gens" is used everywhere else.)
374 // If "younger_gens_as_roots" is false, younger generations are
375 // not scanned as roots; in this case, the caller must be arranging to
376 // scan the younger generations itself. (For example, a generation might
377 // explicitly mark reachable objects in younger generations, to avoid
378 // excess storage retention.)
379 // The "so" argument determines which of the roots
380 // the closure is applied to:
381 // "SO_None" does none;
382 private:
383 void gen_process_roots(int level,
|