Mercurial > hg > graal-jvmci-8
annotate src/share/vm/gc_implementation/parallelScavenge/psOldGen.cpp @ 356:1ee8caae33af
Merge
author | tonyp |
---|---|
date | Thu, 21 Aug 2008 23:36:31 -0400 |
parents | 818a18cd69a8 |
children | 9ee9cf798b59 a4b729f5b611 |
rev | line source |
---|---|
0 | 1 /* |
2 * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 # include "incls/_precompiled.incl" | |
26 # include "incls/_psOldGen.cpp.incl" | |
27 | |
28 inline const char* PSOldGen::select_name() { | |
29 return UseParallelOldGC ? "ParOldGen" : "PSOldGen"; | |
30 } | |
31 | |
32 PSOldGen::PSOldGen(ReservedSpace rs, size_t alignment, | |
33 size_t initial_size, size_t min_size, size_t max_size, | |
34 const char* perf_data_name, int level): | |
35 _name(select_name()), _init_gen_size(initial_size), _min_gen_size(min_size), | |
36 _max_gen_size(max_size) | |
37 { | |
38 initialize(rs, alignment, perf_data_name, level); | |
39 } | |
40 | |
41 PSOldGen::PSOldGen(size_t initial_size, | |
42 size_t min_size, size_t max_size, | |
43 const char* perf_data_name, int level): | |
44 _name(select_name()), _init_gen_size(initial_size), _min_gen_size(min_size), | |
45 _max_gen_size(max_size) | |
46 {} | |
47 | |
48 void PSOldGen::initialize(ReservedSpace rs, size_t alignment, | |
49 const char* perf_data_name, int level) { | |
50 initialize_virtual_space(rs, alignment); | |
51 initialize_work(perf_data_name, level); | |
52 // The old gen can grow to gen_size_limit(). _reserve reflects only | |
53 // the current maximum that can be committed. | |
54 assert(_reserved.byte_size() <= gen_size_limit(), "Consistency check"); | |
55 } | |
56 | |
57 void PSOldGen::initialize_virtual_space(ReservedSpace rs, size_t alignment) { | |
58 | |
59 _virtual_space = new PSVirtualSpace(rs, alignment); | |
60 if (!_virtual_space->expand_by(_init_gen_size)) { | |
61 vm_exit_during_initialization("Could not reserve enough space for " | |
62 "object heap"); | |
63 } | |
64 } | |
65 | |
66 void PSOldGen::initialize_work(const char* perf_data_name, int level) { | |
67 // | |
68 // Basic memory initialization | |
69 // | |
70 | |
71 MemRegion limit_reserved((HeapWord*)virtual_space()->low_boundary(), | |
72 heap_word_size(_max_gen_size)); | |
73 assert(limit_reserved.byte_size() == _max_gen_size, | |
74 "word vs bytes confusion"); | |
75 // | |
76 // Object start stuff | |
77 // | |
78 | |
79 start_array()->initialize(limit_reserved); | |
80 | |
81 _reserved = MemRegion((HeapWord*)virtual_space()->low_boundary(), | |
82 (HeapWord*)virtual_space()->high_boundary()); | |
83 | |
84 // | |
85 // Card table stuff | |
86 // | |
87 | |
88 MemRegion cmr((HeapWord*)virtual_space()->low(), | |
89 (HeapWord*)virtual_space()->high()); | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
90 if (ZapUnusedHeapArea) { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
91 // Mangle newly committed space immediately rather than |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
92 // waiting for the initialization of the space even though |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
93 // mangling is related to spaces. Doing it here eliminates |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
94 // the need to carry along information that a complete mangling |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
95 // (bottom to end) needs to be done. |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
96 SpaceMangler::mangle_region(cmr); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
97 } |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
98 |
0 | 99 Universe::heap()->barrier_set()->resize_covered_region(cmr); |
100 | |
101 CardTableModRefBS* _ct = (CardTableModRefBS*)Universe::heap()->barrier_set(); | |
102 assert (_ct->kind() == BarrierSet::CardTableModRef, "Sanity"); | |
103 | |
104 // Verify that the start and end of this generation is the start of a card. | |
105 // If this wasn't true, a single card could span more than one generation, | |
106 // which would cause problems when we commit/uncommit memory, and when we | |
107 // clear and dirty cards. | |
108 guarantee(_ct->is_card_aligned(_reserved.start()), "generation must be card aligned"); | |
109 if (_reserved.end() != Universe::heap()->reserved_region().end()) { | |
110 // Don't check at the very end of the heap as we'll assert that we're probing off | |
111 // the end if we try. | |
112 guarantee(_ct->is_card_aligned(_reserved.end()), "generation must be card aligned"); | |
113 } | |
114 | |
115 // | |
116 // ObjectSpace stuff | |
117 // | |
118 | |
119 _object_space = new MutableSpace(); | |
120 | |
121 if (_object_space == NULL) | |
122 vm_exit_during_initialization("Could not allocate an old gen space"); | |
123 | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
124 object_space()->initialize(cmr, |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
125 SpaceDecorator::Clear, |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
126 SpaceDecorator::Mangle); |
0 | 127 |
128 _object_mark_sweep = new PSMarkSweepDecorator(_object_space, start_array(), MarkSweepDeadRatio); | |
129 | |
130 if (_object_mark_sweep == NULL) | |
131 vm_exit_during_initialization("Could not complete allocation of old generation"); | |
132 | |
133 // Update the start_array | |
134 start_array()->set_covered_region(cmr); | |
135 | |
136 // Generation Counters, generation 'level', 1 subspace | |
137 _gen_counters = new PSGenerationCounters(perf_data_name, level, 1, | |
138 virtual_space()); | |
139 _space_counters = new SpaceCounters(perf_data_name, 0, | |
140 virtual_space()->reserved_size(), | |
141 _object_space, _gen_counters); | |
142 } | |
143 | |
144 // Assume that the generation has been allocated if its | |
145 // reserved size is not 0. | |
146 bool PSOldGen::is_allocated() { | |
147 return virtual_space()->reserved_size() != 0; | |
148 } | |
149 | |
150 void PSOldGen::precompact() { | |
151 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); | |
152 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); | |
153 | |
154 // Reset start array first. | |
155 debug_only(if (!UseParallelOldGC || !VerifyParallelOldWithMarkSweep) {) | |
156 start_array()->reset(); | |
157 debug_only(}) | |
158 | |
159 object_mark_sweep()->precompact(); | |
160 | |
161 // Now compact the young gen | |
162 heap->young_gen()->precompact(); | |
163 } | |
164 | |
165 void PSOldGen::adjust_pointers() { | |
166 object_mark_sweep()->adjust_pointers(); | |
167 } | |
168 | |
169 void PSOldGen::compact() { | |
170 object_mark_sweep()->compact(ZapUnusedHeapArea); | |
171 } | |
172 | |
173 void PSOldGen::move_and_update(ParCompactionManager* cm) { | |
174 PSParallelCompact::move_and_update(cm, PSParallelCompact::old_space_id); | |
175 } | |
176 | |
177 size_t PSOldGen::contiguous_available() const { | |
178 return object_space()->free_in_bytes() + virtual_space()->uncommitted_size(); | |
179 } | |
180 | |
181 // Allocation. We report all successful allocations to the size policy | |
182 // Note that the perm gen does not use this method, and should not! | |
183 HeapWord* PSOldGen::allocate(size_t word_size, bool is_tlab) { | |
184 assert_locked_or_safepoint(Heap_lock); | |
185 HeapWord* res = allocate_noexpand(word_size, is_tlab); | |
186 | |
187 if (res == NULL) { | |
188 res = expand_and_allocate(word_size, is_tlab); | |
189 } | |
190 | |
191 // Allocations in the old generation need to be reported | |
192 if (res != NULL) { | |
193 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); | |
194 heap->size_policy()->tenured_allocation(word_size); | |
195 } | |
196 | |
197 return res; | |
198 } | |
199 | |
200 HeapWord* PSOldGen::expand_and_allocate(size_t word_size, bool is_tlab) { | |
201 assert(!is_tlab, "TLAB's are not supported in PSOldGen"); | |
202 expand(word_size*HeapWordSize); | |
203 if (GCExpandToAllocateDelayMillis > 0) { | |
204 os::sleep(Thread::current(), GCExpandToAllocateDelayMillis, false); | |
205 } | |
206 return allocate_noexpand(word_size, is_tlab); | |
207 } | |
208 | |
209 HeapWord* PSOldGen::expand_and_cas_allocate(size_t word_size) { | |
210 expand(word_size*HeapWordSize); | |
211 if (GCExpandToAllocateDelayMillis > 0) { | |
212 os::sleep(Thread::current(), GCExpandToAllocateDelayMillis, false); | |
213 } | |
214 return cas_allocate_noexpand(word_size); | |
215 } | |
216 | |
217 void PSOldGen::expand(size_t bytes) { | |
271
818a18cd69a8
6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents:
263
diff
changeset
|
218 if (bytes == 0) { |
818a18cd69a8
6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents:
263
diff
changeset
|
219 return; |
818a18cd69a8
6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents:
263
diff
changeset
|
220 } |
0 | 221 MutexLocker x(ExpandHeap_lock); |
222 const size_t alignment = virtual_space()->alignment(); | |
223 size_t aligned_bytes = align_size_up(bytes, alignment); | |
224 size_t aligned_expand_bytes = align_size_up(MinHeapDeltaBytes, alignment); | |
271
818a18cd69a8
6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents:
263
diff
changeset
|
225 if (aligned_bytes == 0){ |
818a18cd69a8
6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents:
263
diff
changeset
|
226 // The alignment caused the number of bytes to wrap. An expand_by(0) will |
818a18cd69a8
6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents:
263
diff
changeset
|
227 // return true with the implication that and expansion was done when it |
818a18cd69a8
6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents:
263
diff
changeset
|
228 // was not. A call to expand implies a best effort to expand by "bytes" |
818a18cd69a8
6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents:
263
diff
changeset
|
229 // but not a guarantee. Align down to give a best effort. This is likely |
818a18cd69a8
6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents:
263
diff
changeset
|
230 // the most that the generation can expand since it has some capacity to |
818a18cd69a8
6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents:
263
diff
changeset
|
231 // start with. |
818a18cd69a8
6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents:
263
diff
changeset
|
232 aligned_bytes = align_size_down(bytes, alignment); |
818a18cd69a8
6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents:
263
diff
changeset
|
233 } |
0 | 234 |
235 bool success = false; | |
236 if (aligned_expand_bytes > aligned_bytes) { | |
237 success = expand_by(aligned_expand_bytes); | |
238 } | |
239 if (!success) { | |
240 success = expand_by(aligned_bytes); | |
241 } | |
242 if (!success) { | |
243 success = expand_to_reserved(); | |
244 } | |
245 | |
271
818a18cd69a8
6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents:
263
diff
changeset
|
246 if (PrintGC && Verbose) { |
818a18cd69a8
6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents:
263
diff
changeset
|
247 if (success && GC_locker::is_active()) { |
0 | 248 gclog_or_tty->print_cr("Garbage collection disabled, expanded heap instead"); |
249 } | |
250 } | |
251 } | |
252 | |
253 bool PSOldGen::expand_by(size_t bytes) { | |
254 assert_lock_strong(ExpandHeap_lock); | |
255 assert_locked_or_safepoint(Heap_lock); | |
271
818a18cd69a8
6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents:
263
diff
changeset
|
256 if (bytes == 0) { |
818a18cd69a8
6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents:
263
diff
changeset
|
257 return true; // That's what virtual_space()->expand_by(0) would return |
818a18cd69a8
6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents:
263
diff
changeset
|
258 } |
0 | 259 bool result = virtual_space()->expand_by(bytes); |
260 if (result) { | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
261 if (ZapUnusedHeapArea) { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
262 // We need to mangle the newly expanded area. The memregion spans |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
263 // end -> new_end, we assume that top -> end is already mangled. |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
264 // Do the mangling before post_resize() is called because |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
265 // the space is available for allocation after post_resize(); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
266 HeapWord* const virtual_space_high = (HeapWord*) virtual_space()->high(); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
267 assert(object_space()->end() < virtual_space_high, |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
268 "Should be true before post_resize()"); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
269 MemRegion mangle_region(object_space()->end(), virtual_space_high); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
270 // Note that the object space has not yet been updated to |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
271 // coincede with the new underlying virtual space. |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
272 SpaceMangler::mangle_region(mangle_region); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
273 } |
0 | 274 post_resize(); |
275 if (UsePerfData) { | |
276 _space_counters->update_capacity(); | |
277 _gen_counters->update_all(); | |
278 } | |
279 } | |
280 | |
281 if (result && Verbose && PrintGC) { | |
282 size_t new_mem_size = virtual_space()->committed_size(); | |
283 size_t old_mem_size = new_mem_size - bytes; | |
284 gclog_or_tty->print_cr("Expanding %s from " SIZE_FORMAT "K by " | |
285 SIZE_FORMAT "K to " | |
286 SIZE_FORMAT "K", | |
287 name(), old_mem_size/K, bytes/K, new_mem_size/K); | |
288 } | |
289 | |
290 return result; | |
291 } | |
292 | |
293 bool PSOldGen::expand_to_reserved() { | |
294 assert_lock_strong(ExpandHeap_lock); | |
295 assert_locked_or_safepoint(Heap_lock); | |
296 | |
297 bool result = true; | |
298 const size_t remaining_bytes = virtual_space()->uncommitted_size(); | |
299 if (remaining_bytes > 0) { | |
300 result = expand_by(remaining_bytes); | |
301 DEBUG_ONLY(if (!result) warning("grow to reserve failed")); | |
302 } | |
303 return result; | |
304 } | |
305 | |
306 void PSOldGen::shrink(size_t bytes) { | |
307 assert_lock_strong(ExpandHeap_lock); | |
308 assert_locked_or_safepoint(Heap_lock); | |
309 | |
310 size_t size = align_size_down(bytes, virtual_space()->alignment()); | |
311 if (size > 0) { | |
312 assert_lock_strong(ExpandHeap_lock); | |
313 virtual_space()->shrink_by(bytes); | |
314 post_resize(); | |
315 | |
316 if (Verbose && PrintGC) { | |
317 size_t new_mem_size = virtual_space()->committed_size(); | |
318 size_t old_mem_size = new_mem_size + bytes; | |
319 gclog_or_tty->print_cr("Shrinking %s from " SIZE_FORMAT "K by " | |
320 SIZE_FORMAT "K to " | |
321 SIZE_FORMAT "K", | |
322 name(), old_mem_size/K, bytes/K, new_mem_size/K); | |
323 } | |
324 } | |
325 } | |
326 | |
327 void PSOldGen::resize(size_t desired_free_space) { | |
328 const size_t alignment = virtual_space()->alignment(); | |
329 const size_t size_before = virtual_space()->committed_size(); | |
330 size_t new_size = used_in_bytes() + desired_free_space; | |
331 if (new_size < used_in_bytes()) { | |
332 // Overflowed the addition. | |
333 new_size = gen_size_limit(); | |
334 } | |
335 // Adjust according to our min and max | |
336 new_size = MAX2(MIN2(new_size, gen_size_limit()), min_gen_size()); | |
337 | |
338 assert(gen_size_limit() >= reserved().byte_size(), "max new size problem?"); | |
339 new_size = align_size_up(new_size, alignment); | |
340 | |
341 const size_t current_size = capacity_in_bytes(); | |
342 | |
343 if (PrintAdaptiveSizePolicy && Verbose) { | |
344 gclog_or_tty->print_cr("AdaptiveSizePolicy::old generation size: " | |
345 "desired free: " SIZE_FORMAT " used: " SIZE_FORMAT | |
346 " new size: " SIZE_FORMAT " current size " SIZE_FORMAT | |
347 " gen limits: " SIZE_FORMAT " / " SIZE_FORMAT, | |
348 desired_free_space, used_in_bytes(), new_size, current_size, | |
349 gen_size_limit(), min_gen_size()); | |
350 } | |
351 | |
352 if (new_size == current_size) { | |
353 // No change requested | |
354 return; | |
355 } | |
356 if (new_size > current_size) { | |
357 size_t change_bytes = new_size - current_size; | |
358 expand(change_bytes); | |
359 } else { | |
360 size_t change_bytes = current_size - new_size; | |
361 // shrink doesn't grab this lock, expand does. Is that right? | |
362 MutexLocker x(ExpandHeap_lock); | |
363 shrink(change_bytes); | |
364 } | |
365 | |
366 if (PrintAdaptiveSizePolicy) { | |
367 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); | |
368 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); | |
369 gclog_or_tty->print_cr("AdaptiveSizePolicy::old generation size: " | |
370 "collection: %d " | |
371 "(" SIZE_FORMAT ") -> (" SIZE_FORMAT ") ", | |
372 heap->total_collections(), | |
373 size_before, virtual_space()->committed_size()); | |
374 } | |
375 } | |
376 | |
377 // NOTE! We need to be careful about resizing. During a GC, multiple | |
378 // allocators may be active during heap expansion. If we allow the | |
379 // heap resizing to become visible before we have correctly resized | |
380 // all heap related data structures, we may cause program failures. | |
381 void PSOldGen::post_resize() { | |
382 // First construct a memregion representing the new size | |
383 MemRegion new_memregion((HeapWord*)virtual_space()->low(), | |
384 (HeapWord*)virtual_space()->high()); | |
385 size_t new_word_size = new_memregion.word_size(); | |
386 | |
387 start_array()->set_covered_region(new_memregion); | |
388 Universe::heap()->barrier_set()->resize_covered_region(new_memregion); | |
389 | |
390 HeapWord* const virtual_space_high = (HeapWord*) virtual_space()->high(); | |
391 | |
392 // ALWAYS do this last!! | |
393 object_space()->set_end(virtual_space_high); | |
394 | |
395 assert(new_word_size == heap_word_size(object_space()->capacity_in_bytes()), | |
396 "Sanity"); | |
397 } | |
398 | |
399 size_t PSOldGen::gen_size_limit() { | |
400 return _max_gen_size; | |
401 } | |
402 | |
403 void PSOldGen::reset_after_change() { | |
404 ShouldNotReachHere(); | |
405 return; | |
406 } | |
407 | |
408 size_t PSOldGen::available_for_expansion() { | |
409 ShouldNotReachHere(); | |
410 return 0; | |
411 } | |
412 | |
413 size_t PSOldGen::available_for_contraction() { | |
414 ShouldNotReachHere(); | |
415 return 0; | |
416 } | |
417 | |
418 void PSOldGen::print() const { print_on(tty);} | |
419 void PSOldGen::print_on(outputStream* st) const { | |
420 st->print(" %-15s", name()); | |
421 if (PrintGCDetails && Verbose) { | |
422 st->print(" total " SIZE_FORMAT ", used " SIZE_FORMAT, | |
423 capacity_in_bytes(), used_in_bytes()); | |
424 } else { | |
425 st->print(" total " SIZE_FORMAT "K, used " SIZE_FORMAT "K", | |
426 capacity_in_bytes()/K, used_in_bytes()/K); | |
427 } | |
428 st->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT ")", | |
429 virtual_space()->low_boundary(), | |
430 virtual_space()->high(), | |
431 virtual_space()->high_boundary()); | |
432 | |
433 st->print(" object"); object_space()->print_on(st); | |
434 } | |
435 | |
436 void PSOldGen::print_used_change(size_t prev_used) const { | |
437 gclog_or_tty->print(" [%s:", name()); | |
438 gclog_or_tty->print(" " SIZE_FORMAT "K" | |
439 "->" SIZE_FORMAT "K" | |
440 "(" SIZE_FORMAT "K)", | |
441 prev_used / K, used_in_bytes() / K, | |
442 capacity_in_bytes() / K); | |
443 gclog_or_tty->print("]"); | |
444 } | |
445 | |
446 void PSOldGen::update_counters() { | |
447 if (UsePerfData) { | |
448 _space_counters->update_all(); | |
449 _gen_counters->update_all(); | |
450 } | |
451 } | |
452 | |
453 #ifndef PRODUCT | |
454 | |
455 void PSOldGen::space_invariants() { | |
456 assert(object_space()->end() == (HeapWord*) virtual_space()->high(), | |
457 "Space invariant"); | |
458 assert(object_space()->bottom() == (HeapWord*) virtual_space()->low(), | |
459 "Space invariant"); | |
460 assert(virtual_space()->low_boundary() <= virtual_space()->low(), | |
461 "Space invariant"); | |
462 assert(virtual_space()->high_boundary() >= virtual_space()->high(), | |
463 "Space invariant"); | |
464 assert(virtual_space()->low_boundary() == (char*) _reserved.start(), | |
465 "Space invariant"); | |
466 assert(virtual_space()->high_boundary() == (char*) _reserved.end(), | |
467 "Space invariant"); | |
468 assert(virtual_space()->committed_size() <= virtual_space()->reserved_size(), | |
469 "Space invariant"); | |
470 } | |
471 #endif | |
472 | |
473 void PSOldGen::verify(bool allow_dirty) { | |
474 object_space()->verify(allow_dirty); | |
475 } | |
476 class VerifyObjectStartArrayClosure : public ObjectClosure { | |
477 PSOldGen* _gen; | |
478 ObjectStartArray* _start_array; | |
479 | |
480 public: | |
481 VerifyObjectStartArrayClosure(PSOldGen* gen, ObjectStartArray* start_array) : | |
482 _gen(gen), _start_array(start_array) { } | |
483 | |
484 virtual void do_object(oop obj) { | |
485 HeapWord* test_addr = (HeapWord*)obj + 1; | |
486 guarantee(_start_array->object_start(test_addr) == (HeapWord*)obj, "ObjectStartArray cannot find start of object"); | |
487 guarantee(_start_array->is_block_allocated((HeapWord*)obj), "ObjectStartArray missing block allocation"); | |
488 } | |
489 }; | |
490 | |
491 void PSOldGen::verify_object_start_array() { | |
492 VerifyObjectStartArrayClosure check( this, &_start_array ); | |
493 object_iterate(&check); | |
494 } | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
495 |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
496 #ifndef PRODUCT |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
497 void PSOldGen::record_spaces_top() { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
498 assert(ZapUnusedHeapArea, "Not mangling unused space"); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
499 object_space()->set_top_for_allocations(); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
500 } |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
0
diff
changeset
|
501 #endif |