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