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 #include "precompiled.hpp"
26 #include "gc_implementation/shared/collectorCounters.hpp"
27 #include "gc_implementation/shared/parGCAllocBuffer.hpp"
28 #include "memory/allocation.inline.hpp"
29 #include "memory/blockOffsetTable.inline.hpp"
30 #include "memory/generation.inline.hpp"
31 #include "memory/generationSpec.hpp"
32 #include "memory/space.hpp"
33 #include "memory/tenuredGeneration.hpp"
34 #include "oops/oop.inline.hpp"
35 #include "runtime/java.hpp"
36 #include "utilities/macros.hpp"
37
38 TenuredGeneration::TenuredGeneration(ReservedSpace rs,
39 size_t initial_byte_size, int level,
40 GenRemSet* remset) :
41 OneContigSpaceCardGeneration(rs, initial_byte_size,
42 level, remset, NULL)
43 {
44 HeapWord* bottom = (HeapWord*) _virtual_space.low();
45 HeapWord* end = (HeapWord*) _virtual_space.high();
46 _the_space = new TenuredSpace(_bts, MemRegion(bottom, end));
47 _the_space->reset_saved_mark();
48 _shrink_factor = 0;
49 _capacity_at_prologue = 0;
50
51 _gc_stats = new GCStats();
52
53 // initialize performance counters
54
55 const char* gen_name = "old";
56 GenCollectorPolicy* gcp = (GenCollectorPolicy*) GenCollectedHeap::heap()->collector_policy();
57
58 // Generation Counters -- generation 1, 1 subspace
59 _gen_counters = new GenerationCounters(gen_name, 1, 1,
60 gcp->min_old_size(), gcp->max_old_size(), &_virtual_space);
61
62 _gc_counters = new CollectorCounters("MSC", 1);
154 size_t size,
155 bool is_tlab) {
156 retire_alloc_buffers_before_full_gc();
157 OneContigSpaceCardGeneration::collect(full, clear_all_soft_refs,
158 size, is_tlab);
159 }
160
161 void TenuredGeneration::compute_new_size() {
162 assert_locked_or_safepoint(Heap_lock);
163
164 // Compute some numbers about the state of the heap.
165 const size_t used_after_gc = used();
166 const size_t capacity_after_gc = capacity();
167
168 CardGeneration::compute_new_size();
169
170 assert(used() == used_after_gc && used_after_gc <= capacity(),
171 err_msg("used: " SIZE_FORMAT " used_after_gc: " SIZE_FORMAT
172 " capacity: " SIZE_FORMAT, used(), used_after_gc, capacity()));
173 }
174 void TenuredGeneration::update_gc_stats(int current_level,
175 bool full) {
176 // If the next lower level(s) has been collected, gather any statistics
177 // that are of interest at this point.
178 if (!full && (current_level + 1) == level()) {
179 // Calculate size of data promoted from the younger generations
180 // before doing the collection.
181 size_t used_before_gc = used();
182
183 // If the younger gen collections were skipped, then the
184 // number of promoted bytes will be 0 and adding it to the
185 // average will incorrectly lessen the average. It is, however,
186 // also possible that no promotion was needed.
187 if (used_before_gc >= _used_at_prologue) {
188 size_t promoted_in_bytes = used_before_gc - _used_at_prologue;
189 gc_stats()->avg_promoted()->sample(promoted_in_bytes);
190 }
191 }
192 }
193
194 void TenuredGeneration::update_counters() {
195 if (UsePerfData) {
196 _space_counters->update_all();
197 _gen_counters->update_all();
198 }
|
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 #include "precompiled.hpp"
26 #include "gc_implementation/shared/collectorCounters.hpp"
27 #include "gc_implementation/shared/parGCAllocBuffer.hpp"
28 #include "memory/allocation.inline.hpp"
29 #include "memory/blockOffsetTable.inline.hpp"
30 #include "memory/generation.inline.hpp"
31 #include "memory/generationSpec.hpp"
32 #include "memory/space.hpp"
33 #include "memory/tenuredGeneration.hpp"
34 #include "oops/oop.inline.hpp"
35 #include "runtime/java.hpp"
36 #include "utilities/macros.hpp"
37
38 TenuredGeneration::TenuredGeneration(ReservedSpace rs,
39 size_t initial_byte_size,
40 GenRemSet* remset) :
41 OneContigSpaceCardGeneration(rs, initial_byte_size, remset, NULL)
42 {
43 HeapWord* bottom = (HeapWord*) _virtual_space.low();
44 HeapWord* end = (HeapWord*) _virtual_space.high();
45 _the_space = new TenuredSpace(_bts, MemRegion(bottom, end));
46 _the_space->reset_saved_mark();
47 _shrink_factor = 0;
48 _capacity_at_prologue = 0;
49
50 _gc_stats = new GCStats();
51
52 // initialize performance counters
53
54 const char* gen_name = "old";
55 GenCollectorPolicy* gcp = (GenCollectorPolicy*) GenCollectedHeap::heap()->collector_policy();
56
57 // Generation Counters -- generation 1, 1 subspace
58 _gen_counters = new GenerationCounters(gen_name, 1, 1,
59 gcp->min_old_size(), gcp->max_old_size(), &_virtual_space);
60
61 _gc_counters = new CollectorCounters("MSC", 1);
153 size_t size,
154 bool is_tlab) {
155 retire_alloc_buffers_before_full_gc();
156 OneContigSpaceCardGeneration::collect(full, clear_all_soft_refs,
157 size, is_tlab);
158 }
159
160 void TenuredGeneration::compute_new_size() {
161 assert_locked_or_safepoint(Heap_lock);
162
163 // Compute some numbers about the state of the heap.
164 const size_t used_after_gc = used();
165 const size_t capacity_after_gc = capacity();
166
167 CardGeneration::compute_new_size();
168
169 assert(used() == used_after_gc && used_after_gc <= capacity(),
170 err_msg("used: " SIZE_FORMAT " used_after_gc: " SIZE_FORMAT
171 " capacity: " SIZE_FORMAT, used(), used_after_gc, capacity()));
172 }
173
174 void TenuredGeneration::update_gc_stats(Generation* current_generation,
175 bool full) {
176 // If the young generation has been collected, gather any statistics
177 // that are of interest at this point.
178 bool current_is_young = (current_generation == GenCollectedHeap::heap()->young_gen());
179 if (!full && current_is_young) {
180 // Calculate size of data promoted from the younger generations
181 // before doing the collection.
182 size_t used_before_gc = used();
183
184 // If the younger gen collections were skipped, then the
185 // number of promoted bytes will be 0 and adding it to the
186 // average will incorrectly lessen the average. It is, however,
187 // also possible that no promotion was needed.
188 if (used_before_gc >= _used_at_prologue) {
189 size_t promoted_in_bytes = used_before_gc - _used_at_prologue;
190 gc_stats()->avg_promoted()->sample(promoted_in_bytes);
191 }
192 }
193 }
194
195 void TenuredGeneration::update_counters() {
196 if (UsePerfData) {
197 _space_counters->update_all();
198 _gen_counters->update_all();
199 }
|