13 * accompanied this code).
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/adaptiveSizePolicy.hpp"
29 #include "gc/shared/collectedHeap.hpp"
30 #include "gc/shared/collectorPolicy.hpp"
31 #include "gc/shared/generation.hpp"
32
33 class FlexibleWorkGang;
34 class StrongRootsScope;
35 class SubTasksDone;
36
37 // A "GenCollectedHeap" is a CollectedHeap that uses generational
38 // collection. It has two generations, young and old.
39 class GenCollectedHeap : public CollectedHeap {
40 friend class GenCollectorPolicy;
41 friend class Generation;
42 friend class DefNewGeneration;
43 friend class TenuredGeneration;
44 friend class ConcurrentMarkSweepGeneration;
45 friend class CMSCollector;
46 friend class GenMarkSweep;
47 friend class VM_GenCollectForAllocation;
48 friend class VM_GenCollectFull;
49 friend class VM_GenCollectFullConcurrent;
50 friend class VM_GC_HeapInspection;
51 friend class VM_HeapDumper;
52 friend class HeapInspection;
53 friend class GCCauseSetter;
68 // Indicates that the most recent previous incremental collection failed.
69 // The flag is cleared when an action is taken that might clear the
70 // condition that caused that incremental collection to fail.
71 bool _incremental_collection_failed;
72
73 // In support of ExplicitGCInvokesConcurrent functionality
74 unsigned int _full_collections_completed;
75
76 // Data structure for claiming the (potentially) parallel tasks in
77 // (gen-specific) roots processing.
78 SubTasksDone* _process_strong_tasks;
79
80 // Collects the given generation.
81 void collect_generation(Generation* gen, bool full, size_t size, bool is_tlab,
82 bool run_verification, bool clear_soft_refs,
83 bool restore_marks_for_biased_locking);
84
85 // In block contents verification, the number of header words to skip
86 NOT_PRODUCT(static size_t _skip_header_HeapWords;)
87
88 FlexibleWorkGang* _workers;
89
90 protected:
91 // Helper functions for allocation
92 HeapWord* attempt_allocation(size_t size,
93 bool is_tlab,
94 bool first_only);
95
96 // Helper function for two callbacks below.
97 // Considers collection of the first max_level+1 generations.
98 void do_collection(bool full,
99 bool clear_all_soft_refs,
100 size_t size,
101 bool is_tlab,
102 int max_level);
103
104 // Callback from VM_GenCollectForAllocation operation.
105 // This function does everything necessary/possible to satisfy an
106 // allocation request that failed in the youngest generation that should
107 // have handled it (including collection, expansion, etc.)
108 HeapWord* satisfy_failed_allocation(size_t size, bool is_tlab);
109
110 // Callback from VM_GenCollectFull operation.
111 // Perform a full collection of the first max_level+1 generations.
112 virtual void do_full_collection(bool clear_all_soft_refs);
113 void do_full_collection(bool clear_all_soft_refs, int max_level);
114
115 // Does the "cause" of GC indicate that
116 // we absolutely __must__ clear soft refs?
117 bool must_clear_all_soft_refs();
118
119 public:
120 GenCollectedHeap(GenCollectorPolicy *policy);
121
122 FlexibleWorkGang* workers() const { return _workers; }
123
124 GCStats* gc_stats(int level) const;
125
126 // Returns JNI_OK on success
127 virtual jint initialize();
128
129 // Reserve aligned space for the heap as needed by the contained generations.
130 char* allocate(size_t alignment, ReservedSpace* heap_rs);
131
132 // Does operations required after initialization has been done.
133 void post_initialize();
134
135 // Initialize ("weak") refs processing support
136 virtual void ref_processing_init();
137
138 virtual Name kind() const {
139 return CollectedHeap::GenCollectedHeap;
140 }
141
142 Generation* young_gen() const { return _young_gen; }
|
13 * accompanied this code).
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/adaptiveSizePolicy.hpp"
29 #include "gc/shared/collectedHeap.hpp"
30 #include "gc/shared/collectorPolicy.hpp"
31 #include "gc/shared/generation.hpp"
32
33 class WorkGang;
34 class StrongRootsScope;
35 class SubTasksDone;
36
37 // A "GenCollectedHeap" is a CollectedHeap that uses generational
38 // collection. It has two generations, young and old.
39 class GenCollectedHeap : public CollectedHeap {
40 friend class GenCollectorPolicy;
41 friend class Generation;
42 friend class DefNewGeneration;
43 friend class TenuredGeneration;
44 friend class ConcurrentMarkSweepGeneration;
45 friend class CMSCollector;
46 friend class GenMarkSweep;
47 friend class VM_GenCollectForAllocation;
48 friend class VM_GenCollectFull;
49 friend class VM_GenCollectFullConcurrent;
50 friend class VM_GC_HeapInspection;
51 friend class VM_HeapDumper;
52 friend class HeapInspection;
53 friend class GCCauseSetter;
68 // Indicates that the most recent previous incremental collection failed.
69 // The flag is cleared when an action is taken that might clear the
70 // condition that caused that incremental collection to fail.
71 bool _incremental_collection_failed;
72
73 // In support of ExplicitGCInvokesConcurrent functionality
74 unsigned int _full_collections_completed;
75
76 // Data structure for claiming the (potentially) parallel tasks in
77 // (gen-specific) roots processing.
78 SubTasksDone* _process_strong_tasks;
79
80 // Collects the given generation.
81 void collect_generation(Generation* gen, bool full, size_t size, bool is_tlab,
82 bool run_verification, bool clear_soft_refs,
83 bool restore_marks_for_biased_locking);
84
85 // In block contents verification, the number of header words to skip
86 NOT_PRODUCT(static size_t _skip_header_HeapWords;)
87
88 WorkGang* _workers;
89
90 protected:
91 // Helper functions for allocation
92 HeapWord* attempt_allocation(size_t size,
93 bool is_tlab,
94 bool first_only);
95
96 // Helper function for two callbacks below.
97 // Considers collection of the first max_level+1 generations.
98 void do_collection(bool full,
99 bool clear_all_soft_refs,
100 size_t size,
101 bool is_tlab,
102 int max_level);
103
104 // Callback from VM_GenCollectForAllocation operation.
105 // This function does everything necessary/possible to satisfy an
106 // allocation request that failed in the youngest generation that should
107 // have handled it (including collection, expansion, etc.)
108 HeapWord* satisfy_failed_allocation(size_t size, bool is_tlab);
109
110 // Callback from VM_GenCollectFull operation.
111 // Perform a full collection of the first max_level+1 generations.
112 virtual void do_full_collection(bool clear_all_soft_refs);
113 void do_full_collection(bool clear_all_soft_refs, int max_level);
114
115 // Does the "cause" of GC indicate that
116 // we absolutely __must__ clear soft refs?
117 bool must_clear_all_soft_refs();
118
119 public:
120 GenCollectedHeap(GenCollectorPolicy *policy);
121
122 WorkGang* workers() const { return _workers; }
123
124 GCStats* gc_stats(int level) const;
125
126 // Returns JNI_OK on success
127 virtual jint initialize();
128
129 // Reserve aligned space for the heap as needed by the contained generations.
130 char* allocate(size_t alignment, ReservedSpace* heap_rs);
131
132 // Does operations required after initialization has been done.
133 void post_initialize();
134
135 // Initialize ("weak") refs processing support
136 virtual void ref_processing_init();
137
138 virtual Name kind() const {
139 return CollectedHeap::GenCollectedHeap;
140 }
141
142 Generation* young_gen() const { return _young_gen; }
|