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_TENUREDGENERATION_HPP
26 #define SHARE_VM_MEMORY_TENUREDGENERATION_HPP
27
28 #include "gc_implementation/shared/cSpaceCounters.hpp"
29 #include "gc_implementation/shared/gcStats.hpp"
30 #include "gc_implementation/shared/generationCounters.hpp"
31 #include "memory/generation.hpp"
32 #include "utilities/macros.hpp"
33
34 // TenuredGeneration models the heap containing old (promoted/tenured) objects.
35
36 class TenuredGeneration: public OneContigSpaceCardGeneration {
37 friend class VMStructs;
38 protected:
39 GenerationCounters* _gen_counters;
40 CSpaceCounters* _space_counters;
41
42 public:
43 TenuredGeneration(ReservedSpace rs, size_t initial_byte_size, int level,
44 GenRemSet* remset);
45
46 Generation::Name kind() { return Generation::MarkSweepCompact; }
47
48 // Printing
49 const char* name() const { return "tenured generation"; }
50 const char* short_name() const { return "Tenured"; }
51
52 // Does a "full" (forced) collection invoked on this generation collect
53 // all younger generations as well? Note that this is a
54 // hack to allow the collection of the younger gen first if the flag is
55 // set.
56 virtual bool full_collects_younger_generations() const {
57 return !ScavengeBeforeFullGC;
58 }
59
60 virtual void gc_prologue(bool full);
61 bool should_collect(bool full,
62 size_t word_size,
63 bool is_tlab);
64
65 virtual void compute_new_size();
66
67 // Performance Counter support
68 void update_counters();
69
70 // Statistics
71
72 virtual void update_gc_stats(int level, bool full);
73
74 virtual bool promotion_attempt_is_safe(size_t max_promoted_in_bytes) const;
75 };
76
77 #endif // SHARE_VM_MEMORY_TENUREDGENERATION_HPP
|
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_TENUREDGENERATION_HPP
26 #define SHARE_VM_MEMORY_TENUREDGENERATION_HPP
27
28 #include "gc_implementation/shared/cSpaceCounters.hpp"
29 #include "gc_implementation/shared/gcStats.hpp"
30 #include "gc_implementation/shared/generationCounters.hpp"
31 #include "memory/generation.hpp"
32 #include "utilities/macros.hpp"
33
34 // TenuredGeneration models the heap containing old (promoted/tenured) objects
35 // contained in a single contiguous space.
36 //
37 // Garbage collection is performed using mark-compact.
38
39 class TenuredGeneration: public CardGeneration {
40 friend class VMStructs;
41 // Abstractly, this is a subtype that gets access to protected fields.
42 friend class VM_PopulateDumpSharedSpace;
43
44 protected:
45 ContiguousSpace* _the_space; // actual space holding objects
46 WaterMark _last_gc; // watermark between objects allocated before
47 // and after last GC.
48
49 GenerationCounters* _gen_counters;
50 CSpaceCounters* _space_counters;
51
52 // Grow generation with specified size (returns false if unable to grow)
53 virtual bool grow_by(size_t bytes);
54 // Grow generation to reserved size.
55 virtual bool grow_to_reserved();
56 // Shrink generation with specified size (returns false if unable to shrink)
57 void shrink_by(size_t bytes);
58
59 // Allocation failure
60 virtual bool expand(size_t bytes, size_t expand_bytes);
61 void shrink(size_t bytes);
62
63 // Accessing spaces
64 ContiguousSpace* the_space() const { return _the_space; }
65
66 public:
67 TenuredGeneration(ReservedSpace rs, size_t initial_byte_size,
68 int level, GenRemSet* remset);
69
70 Generation::Name kind() { return Generation::MarkSweepCompact; }
71
72 // Printing
73 const char* name() const { return "tenured generation"; }
74 const char* short_name() const { return "Tenured"; }
75
76 // Does a "full" (forced) collection invoked on this generation collect
77 // all younger generations as well? Note that this is a
78 // hack to allow the collection of the younger gen first if the flag is
79 // set.
80 virtual bool full_collects_younger_generations() const {
81 return !ScavengeBeforeFullGC;
82 }
83
84 inline bool is_in(const void* p) const;
85
86 // Space enquiries
87 size_t capacity() const;
88 size_t used() const;
89 size_t free() const;
90
91 MemRegion used_region() const;
92
93 size_t unsafe_max_alloc_nogc() const;
94 size_t contiguous_available() const;
95
96 // Iteration
97 void object_iterate(ObjectClosure* blk);
98 void space_iterate(SpaceClosure* blk, bool usedOnly = false);
99
100 void younger_refs_iterate(OopsInGenClosure* blk);
101
102 inline CompactibleSpace* first_compaction_space() const;
103
104 virtual inline HeapWord* allocate(size_t word_size, bool is_tlab);
105 virtual inline HeapWord* par_allocate(size_t word_size, bool is_tlab);
106
107 // Accessing marks
108 inline WaterMark top_mark();
109 inline WaterMark bottom_mark();
110
111 #define TenuredGen_SINCE_SAVE_MARKS_DECL(OopClosureType, nv_suffix) \
112 void oop_since_save_marks_iterate##nv_suffix(OopClosureType* cl);
113 TenuredGen_SINCE_SAVE_MARKS_DECL(OopsInGenClosure,_v)
114 SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(TenuredGen_SINCE_SAVE_MARKS_DECL)
115
116 void save_marks();
117 void reset_saved_marks();
118 bool no_allocs_since_save_marks();
119
120 inline size_t block_size(const HeapWord* addr) const;
121
122 inline bool block_is_obj(const HeapWord* addr) const;
123
124 virtual void collect(bool full,
125 bool clear_all_soft_refs,
126 size_t size,
127 bool is_tlab);
128 HeapWord* expand_and_allocate(size_t size,
129 bool is_tlab,
130 bool parallel = false);
131
132 virtual void prepare_for_verify();
133
134
135 virtual void gc_prologue(bool full);
136 virtual void gc_epilogue(bool full);
137 bool should_collect(bool full,
138 size_t word_size,
139 bool is_tlab);
140
141 virtual void compute_new_size();
142
143 // Performance Counter support
144 void update_counters();
145
146 virtual void record_spaces_top();
147
148 // Statistics
149
150 virtual void update_gc_stats(int level, bool full);
151
152 virtual bool promotion_attempt_is_safe(size_t max_promoted_in_bytes) const;
153
154 virtual void verify();
155 virtual void print_on(outputStream* st) const;
156 };
157
158 #endif // SHARE_VM_MEMORY_TENUREDGENERATION_HPP
|