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

Mon, 12 Aug 2019 18:30:40 +0300

author
apetushkov
date
Mon, 12 Aug 2019 18:30:40 +0300
changeset 9858
b985cbb00e68
parent 6680
78bbf4d43a14
child 6876
710a3c8b516e
permissions
-rw-r--r--

8223147: JFR Backport
8199712: Flight Recorder
8203346: JFR: Inconsistent signature of jfr_add_string_constant
8195817: JFR.stop should require name of recording
8195818: JFR.start should increase autogenerated name by one
8195819: Remove recording=x from jcmd JFR.check output
8203921: JFR thread sampling is missing fixes from JDK-8194552
8203929: Limit amount of data for JFR.dump
8203664: JFR start failure after AppCDS archive created with JFR StartFlightRecording
8003209: JFR events for network utilization
8207392: [PPC64] Implement JFR profiling
8202835: jfr/event/os/TestSystemProcess.java fails on missing events
Summary: Backport JFR from JDK11. Initial integration
Reviewed-by: neugens

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

mercurial