src/share/vm/gc_implementation/parallelScavenge/psOldGen.cpp

Mon, 22 Apr 2013 20:27:36 +0200

author
stefank
date
Mon, 22 Apr 2013 20:27:36 +0200
changeset 5011
a08c80e9e1e5
parent 4857
cc5b5976d72c
child 6198
55fb97c4c58d
permissions
-rw-r--r--

8012687: Remove unused is_root checks and closures
Reviewed-by: tschatzl, jmasa

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

mercurial