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

Fri, 16 Mar 2012 16:14:04 +0100

author
nloodin
date
Fri, 16 Mar 2012 16:14:04 +0100
changeset 3665
8a729074feae
parent 2971
c9ca3f51cf41
child 3711
b632e80fc9dc
permissions
-rw-r--r--

7154517: Build error in hotspot-gc without precompiled headers
Reviewed-by: jcoomes, brutisso

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

mercurial