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_GC_SHARED_GENCOLLECTEDHEAP_HPP
26 #define SHARE_GC_SHARED_GENCOLLECTEDHEAP_HPP
27
28 #include "gc/shared/collectedHeap.hpp"
29 #include "gc/shared/generation.hpp"
30 #include "gc/shared/oopStorageParState.hpp"
31 #include "gc/shared/preGCValues.hpp"
32 #include "gc/shared/softRefGenPolicy.hpp"
33
34 class AdaptiveSizePolicy;
35 class CardTableRS;
36 class GCPolicyCounters;
37 class GenerationSpec;
38 class StrongRootsScope;
39 class SubTasksDone;
40 class WorkerThreads;
41
42 // A "GenCollectedHeap" is a CollectedHeap that uses generational
43 // collection. It has two generations, young and old.
44 class GenCollectedHeap : public CollectedHeap {
45 friend class Generation;
46 friend class DefNewGeneration;
47 friend class TenuredGeneration;
48 friend class GenMarkSweep;
49 friend class VM_GenCollectForAllocation;
50 friend class VM_GenCollectFull;
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;
70 GenerationSpec* _old_gen_spec;
71
72 // The singleton CardTable Remembered Set.
73 CardTableRS* _rem_set;
74
75 SoftRefGenPolicy _soft_ref_gen_policy;
76
77 // The sizing of the heap is controlled by a sizing policy.
78 AdaptiveSizePolicy* _size_policy;
79
80 GCPolicyCounters* _gc_policy_counters;
81
82 // Indicates that the most recent previous incremental collection failed.
83 // The flag is cleared when an action is taken that might clear the
84 // condition that caused that incremental collection to fail.
85 bool _incremental_collection_failed;
86
87 // In support of ExplicitGCInvokesConcurrent functionality
88 unsigned int _full_collections_completed;
89
90 // Collects the given generation.
91 void collect_generation(Generation* gen, bool full, size_t size, bool is_tlab,
92 bool run_verification, bool clear_soft_refs);
93
94 // Reserve aligned space for the heap as needed by the contained generations.
95 ReservedHeapSpace allocate(size_t alignment);
96
97 // Initialize ("weak") refs processing support
98 void ref_processing_init();
99
100 PreGenGCValues get_pre_gc_values() const;
101
102 protected:
103
104 GCMemoryManager* _young_manager;
105 GCMemoryManager* _old_manager;
106
107 // Helper functions for allocation
108 HeapWord* attempt_allocation(size_t size,
109 bool is_tlab,
295 virtual void do_generation(Generation* gen) = 0;
296 };
297
298 // Apply "cl.do_generation" to all generations in the heap
299 // If "old_to_young" determines the order.
300 void generation_iterate(GenClosure* cl, bool old_to_young);
301
302 // Return "true" if all generations have reached the
303 // maximal committed limit that they can reach, without a garbage
304 // collection.
305 virtual bool is_maximal_no_gc() const override;
306
307 // This function returns the CardTableRS object that allows us to scan
308 // generations in a fully generational heap.
309 CardTableRS* rem_set() { return _rem_set; }
310
311 // Convenience function to be used in situations where the heap type can be
312 // asserted to be this type.
313 static GenCollectedHeap* heap();
314
315 // The ScanningOption determines which of the roots
316 // the closure is applied to:
317 // "SO_None" does none;
318 enum ScanningOption {
319 SO_None = 0x0,
320 SO_AllCodeCache = 0x8,
321 SO_ScavengeCodeCache = 0x10
322 };
323
324 protected:
325 virtual void gc_prologue(bool full);
326 virtual void gc_epilogue(bool full);
327
328 public:
329 // Apply closures on various roots in Young GC or marking/adjust phases of Full GC.
330 void process_roots(ScanningOption so,
331 OopClosure* strong_roots,
332 CLDClosure* strong_cld_closure,
333 CLDClosure* weak_cld_closure,
334 CodeBlobToOopClosure* code_roots);
|
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_GC_SHARED_GENCOLLECTEDHEAP_HPP
26 #define SHARE_GC_SHARED_GENCOLLECTEDHEAP_HPP
27
28 #include "gc/shared/collectedHeap.hpp"
29 #include "gc/shared/generation.hpp"
30 #include "gc/shared/oopStorageParState.hpp"
31 #include "gc/shared/preGCValues.hpp"
32 #include "gc/shared/softRefGenPolicy.hpp"
33
34 class AdaptiveSizePolicy;
35 class CardTableRS;
36 class GCPolicyCounters;
37 class GenerationSpec;
38 class SlidingForwarding;
39 class StrongRootsScope;
40 class SubTasksDone;
41 class WorkerThreads;
42
43 // A "GenCollectedHeap" is a CollectedHeap that uses generational
44 // collection. It has two generations, young and old.
45 class GenCollectedHeap : public CollectedHeap {
46 friend class Generation;
47 friend class DefNewGeneration;
48 friend class TenuredGeneration;
49 friend class GenMarkSweep;
50 friend class VM_GenCollectForAllocation;
51 friend class VM_GenCollectFull;
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;
71 GenerationSpec* _old_gen_spec;
72
73 // The singleton CardTable Remembered Set.
74 CardTableRS* _rem_set;
75
76 SoftRefGenPolicy _soft_ref_gen_policy;
77
78 // The sizing of the heap is controlled by a sizing policy.
79 AdaptiveSizePolicy* _size_policy;
80
81 GCPolicyCounters* _gc_policy_counters;
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 SlidingForwarding* _forwarding;
92
93 // Collects the given generation.
94 void collect_generation(Generation* gen, bool full, size_t size, bool is_tlab,
95 bool run_verification, bool clear_soft_refs);
96
97 // Reserve aligned space for the heap as needed by the contained generations.
98 ReservedHeapSpace allocate(size_t alignment);
99
100 // Initialize ("weak") refs processing support
101 void ref_processing_init();
102
103 PreGenGCValues get_pre_gc_values() const;
104
105 protected:
106
107 GCMemoryManager* _young_manager;
108 GCMemoryManager* _old_manager;
109
110 // Helper functions for allocation
111 HeapWord* attempt_allocation(size_t size,
112 bool is_tlab,
298 virtual void do_generation(Generation* gen) = 0;
299 };
300
301 // Apply "cl.do_generation" to all generations in the heap
302 // If "old_to_young" determines the order.
303 void generation_iterate(GenClosure* cl, bool old_to_young);
304
305 // Return "true" if all generations have reached the
306 // maximal committed limit that they can reach, without a garbage
307 // collection.
308 virtual bool is_maximal_no_gc() const override;
309
310 // This function returns the CardTableRS object that allows us to scan
311 // generations in a fully generational heap.
312 CardTableRS* rem_set() { return _rem_set; }
313
314 // Convenience function to be used in situations where the heap type can be
315 // asserted to be this type.
316 static GenCollectedHeap* heap();
317
318 SlidingForwarding* forwarding() const {
319 return _forwarding;
320 }
321
322 // The ScanningOption determines which of the roots
323 // the closure is applied to:
324 // "SO_None" does none;
325 enum ScanningOption {
326 SO_None = 0x0,
327 SO_AllCodeCache = 0x8,
328 SO_ScavengeCodeCache = 0x10
329 };
330
331 protected:
332 virtual void gc_prologue(bool full);
333 virtual void gc_epilogue(bool full);
334
335 public:
336 // Apply closures on various roots in Young GC or marking/adjust phases of Full GC.
337 void process_roots(ScanningOption so,
338 OopClosure* strong_roots,
339 CLDClosure* strong_cld_closure,
340 CLDClosure* weak_cld_closure,
341 CodeBlobToOopClosure* code_roots);
|