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

Wed, 13 Jan 2010 15:26:39 -0800

author
ysr
date
Wed, 13 Jan 2010 15:26:39 -0800
changeset 1601
7b0e9cba0307
parent 1462
39b01ab7035a
child 1822
0bfd3fb24150
permissions
-rw-r--r--

6896647: card marks can be deferred too long
Summary: Deferred card marks are now flushed during the gc prologue. Parallel[Scavege,OldGC] and SerialGC no longer defer card marks generated by COMPILER2 as a result of ReduceInitialCardMarks. For these cases, introduced a diagnostic option to defer the card marks, only for the purposes of testing and diagnostics. CMS and G1 continue to defer card marks. Potential performance concern related to single-threaded flushing of deferred card marks in the gc prologue will be addressed in the future.
Reviewed-by: never, johnc

duke@435 1 /*
jrose@1100 2 * Copyright 2001-2009 Sun Microsystems, Inc. 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 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 # include "incls/_precompiled.incl"
duke@435 26 # include "incls/_parallelScavengeHeap.cpp.incl"
duke@435 27
duke@435 28 PSYoungGen* ParallelScavengeHeap::_young_gen = NULL;
duke@435 29 PSOldGen* ParallelScavengeHeap::_old_gen = NULL;
duke@435 30 PSPermGen* ParallelScavengeHeap::_perm_gen = NULL;
duke@435 31 PSAdaptiveSizePolicy* ParallelScavengeHeap::_size_policy = NULL;
duke@435 32 PSGCAdaptivePolicyCounters* ParallelScavengeHeap::_gc_policy_counters = NULL;
duke@435 33 ParallelScavengeHeap* ParallelScavengeHeap::_psh = NULL;
duke@435 34 GCTaskManager* ParallelScavengeHeap::_gc_task_manager = NULL;
duke@435 35
duke@435 36 static void trace_gen_sizes(const char* const str,
duke@435 37 size_t pg_min, size_t pg_max,
duke@435 38 size_t og_min, size_t og_max,
duke@435 39 size_t yg_min, size_t yg_max)
duke@435 40 {
duke@435 41 if (TracePageSizes) {
duke@435 42 tty->print_cr("%s: " SIZE_FORMAT "," SIZE_FORMAT " "
duke@435 43 SIZE_FORMAT "," SIZE_FORMAT " "
duke@435 44 SIZE_FORMAT "," SIZE_FORMAT " "
duke@435 45 SIZE_FORMAT,
duke@435 46 str, pg_min / K, pg_max / K,
duke@435 47 og_min / K, og_max / K,
duke@435 48 yg_min / K, yg_max / K,
duke@435 49 (pg_max + og_max + yg_max) / K);
duke@435 50 }
duke@435 51 }
duke@435 52
duke@435 53 jint ParallelScavengeHeap::initialize() {
ysr@1601 54 CollectedHeap::pre_initialize();
ysr@1601 55
duke@435 56 // Cannot be initialized until after the flags are parsed
duke@435 57 GenerationSizer flag_parser;
duke@435 58
duke@435 59 size_t yg_min_size = flag_parser.min_young_gen_size();
duke@435 60 size_t yg_max_size = flag_parser.max_young_gen_size();
duke@435 61 size_t og_min_size = flag_parser.min_old_gen_size();
duke@435 62 size_t og_max_size = flag_parser.max_old_gen_size();
duke@435 63 // Why isn't there a min_perm_gen_size()?
duke@435 64 size_t pg_min_size = flag_parser.perm_gen_size();
duke@435 65 size_t pg_max_size = flag_parser.max_perm_gen_size();
duke@435 66
duke@435 67 trace_gen_sizes("ps heap raw",
duke@435 68 pg_min_size, pg_max_size,
duke@435 69 og_min_size, og_max_size,
duke@435 70 yg_min_size, yg_max_size);
duke@435 71
duke@435 72 // The ReservedSpace ctor used below requires that the page size for the perm
duke@435 73 // gen is <= the page size for the rest of the heap (young + old gens).
duke@435 74 const size_t og_page_sz = os::page_size_for_region(yg_min_size + og_min_size,
duke@435 75 yg_max_size + og_max_size,
duke@435 76 8);
duke@435 77 const size_t pg_page_sz = MIN2(os::page_size_for_region(pg_min_size,
duke@435 78 pg_max_size, 16),
duke@435 79 og_page_sz);
duke@435 80
duke@435 81 const size_t pg_align = set_alignment(_perm_gen_alignment, pg_page_sz);
duke@435 82 const size_t og_align = set_alignment(_old_gen_alignment, og_page_sz);
duke@435 83 const size_t yg_align = set_alignment(_young_gen_alignment, og_page_sz);
duke@435 84
duke@435 85 // Update sizes to reflect the selected page size(s).
duke@435 86 //
duke@435 87 // NEEDS_CLEANUP. The default TwoGenerationCollectorPolicy uses NewRatio; it
duke@435 88 // should check UseAdaptiveSizePolicy. Changes from generationSizer could
duke@435 89 // move to the common code.
duke@435 90 yg_min_size = align_size_up(yg_min_size, yg_align);
duke@435 91 yg_max_size = align_size_up(yg_max_size, yg_align);
duke@435 92 size_t yg_cur_size = align_size_up(flag_parser.young_gen_size(), yg_align);
duke@435 93 yg_cur_size = MAX2(yg_cur_size, yg_min_size);
duke@435 94
duke@435 95 og_min_size = align_size_up(og_min_size, og_align);
duke@435 96 og_max_size = align_size_up(og_max_size, og_align);
duke@435 97 size_t og_cur_size = align_size_up(flag_parser.old_gen_size(), og_align);
duke@435 98 og_cur_size = MAX2(og_cur_size, og_min_size);
duke@435 99
duke@435 100 pg_min_size = align_size_up(pg_min_size, pg_align);
duke@435 101 pg_max_size = align_size_up(pg_max_size, pg_align);
duke@435 102 size_t pg_cur_size = pg_min_size;
duke@435 103
duke@435 104 trace_gen_sizes("ps heap rnd",
duke@435 105 pg_min_size, pg_max_size,
duke@435 106 og_min_size, og_max_size,
duke@435 107 yg_min_size, yg_max_size);
duke@435 108
kvn@1077 109 const size_t total_reserved = pg_max_size + og_max_size + yg_max_size;
kvn@1077 110 char* addr = Universe::preferred_heap_base(total_reserved, Universe::UnscaledNarrowOop);
kvn@1077 111
duke@435 112 // The main part of the heap (old gen + young gen) can often use a larger page
duke@435 113 // size than is needed or wanted for the perm gen. Use the "compound
duke@435 114 // alignment" ReservedSpace ctor to avoid having to use the same page size for
duke@435 115 // all gens.
kvn@1077 116
coleenp@672 117 ReservedHeapSpace heap_rs(pg_max_size, pg_align, og_max_size + yg_max_size,
kvn@1077 118 og_align, addr);
kvn@1077 119
kvn@1077 120 if (UseCompressedOops) {
kvn@1077 121 if (addr != NULL && !heap_rs.is_reserved()) {
kvn@1077 122 // Failed to reserve at specified address - the requested memory
kvn@1077 123 // region is taken already, for example, by 'java' launcher.
kvn@1077 124 // Try again to reserver heap higher.
kvn@1077 125 addr = Universe::preferred_heap_base(total_reserved, Universe::ZeroBasedNarrowOop);
kvn@1077 126 ReservedHeapSpace heap_rs0(pg_max_size, pg_align, og_max_size + yg_max_size,
kvn@1077 127 og_align, addr);
kvn@1077 128 if (addr != NULL && !heap_rs0.is_reserved()) {
kvn@1077 129 // Failed to reserve at specified address again - give up.
kvn@1077 130 addr = Universe::preferred_heap_base(total_reserved, Universe::HeapBasedNarrowOop);
kvn@1077 131 assert(addr == NULL, "");
kvn@1077 132 ReservedHeapSpace heap_rs1(pg_max_size, pg_align, og_max_size + yg_max_size,
kvn@1077 133 og_align, addr);
kvn@1077 134 heap_rs = heap_rs1;
kvn@1077 135 } else {
kvn@1077 136 heap_rs = heap_rs0;
kvn@1077 137 }
kvn@1077 138 }
kvn@1077 139 }
kvn@1077 140
duke@435 141 os::trace_page_sizes("ps perm", pg_min_size, pg_max_size, pg_page_sz,
duke@435 142 heap_rs.base(), pg_max_size);
duke@435 143 os::trace_page_sizes("ps main", og_min_size + yg_min_size,
duke@435 144 og_max_size + yg_max_size, og_page_sz,
duke@435 145 heap_rs.base() + pg_max_size,
duke@435 146 heap_rs.size() - pg_max_size);
duke@435 147 if (!heap_rs.is_reserved()) {
duke@435 148 vm_shutdown_during_initialization(
duke@435 149 "Could not reserve enough space for object heap");
duke@435 150 return JNI_ENOMEM;
duke@435 151 }
duke@435 152
duke@435 153 _reserved = MemRegion((HeapWord*)heap_rs.base(),
duke@435 154 (HeapWord*)(heap_rs.base() + heap_rs.size()));
duke@435 155
duke@435 156 CardTableExtension* const barrier_set = new CardTableExtension(_reserved, 3);
duke@435 157 _barrier_set = barrier_set;
duke@435 158 oopDesc::set_bs(_barrier_set);
duke@435 159 if (_barrier_set == NULL) {
duke@435 160 vm_shutdown_during_initialization(
duke@435 161 "Could not reserve enough space for barrier set");
duke@435 162 return JNI_ENOMEM;
duke@435 163 }
duke@435 164
duke@435 165 // Initial young gen size is 4 Mb
duke@435 166 //
duke@435 167 // XXX - what about flag_parser.young_gen_size()?
duke@435 168 const size_t init_young_size = align_size_up(4 * M, yg_align);
duke@435 169 yg_cur_size = MAX2(MIN2(init_young_size, yg_max_size), yg_cur_size);
duke@435 170
duke@435 171 // Split the reserved space into perm gen and the main heap (everything else).
duke@435 172 // The main heap uses a different alignment.
duke@435 173 ReservedSpace perm_rs = heap_rs.first_part(pg_max_size);
duke@435 174 ReservedSpace main_rs = heap_rs.last_part(pg_max_size, og_align);
duke@435 175
duke@435 176 // Make up the generations
duke@435 177 // Calculate the maximum size that a generation can grow. This
duke@435 178 // includes growth into the other generation. Note that the
duke@435 179 // parameter _max_gen_size is kept as the maximum
duke@435 180 // size of the generation as the boundaries currently stand.
duke@435 181 // _max_gen_size is still used as that value.
duke@435 182 double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0;
duke@435 183 double max_gc_minor_pause_sec = ((double) MaxGCMinorPauseMillis)/1000.0;
duke@435 184
duke@435 185 _gens = new AdjoiningGenerations(main_rs,
duke@435 186 og_cur_size,
duke@435 187 og_min_size,
duke@435 188 og_max_size,
duke@435 189 yg_cur_size,
duke@435 190 yg_min_size,
duke@435 191 yg_max_size,
duke@435 192 yg_align);
duke@435 193
duke@435 194 _old_gen = _gens->old_gen();
duke@435 195 _young_gen = _gens->young_gen();
duke@435 196
duke@435 197 const size_t eden_capacity = _young_gen->eden_space()->capacity_in_bytes();
duke@435 198 const size_t old_capacity = _old_gen->capacity_in_bytes();
duke@435 199 const size_t initial_promo_size = MIN2(eden_capacity, old_capacity);
duke@435 200 _size_policy =
duke@435 201 new PSAdaptiveSizePolicy(eden_capacity,
duke@435 202 initial_promo_size,
duke@435 203 young_gen()->to_space()->capacity_in_bytes(),
jmasa@448 204 intra_heap_alignment(),
duke@435 205 max_gc_pause_sec,
duke@435 206 max_gc_minor_pause_sec,
duke@435 207 GCTimeRatio
duke@435 208 );
duke@435 209
duke@435 210 _perm_gen = new PSPermGen(perm_rs,
duke@435 211 pg_align,
duke@435 212 pg_cur_size,
duke@435 213 pg_cur_size,
duke@435 214 pg_max_size,
duke@435 215 "perm", 2);
duke@435 216
duke@435 217 assert(!UseAdaptiveGCBoundary ||
duke@435 218 (old_gen()->virtual_space()->high_boundary() ==
duke@435 219 young_gen()->virtual_space()->low_boundary()),
duke@435 220 "Boundaries must meet");
duke@435 221 // initialize the policy counters - 2 collectors, 3 generations
duke@435 222 _gc_policy_counters =
duke@435 223 new PSGCAdaptivePolicyCounters("ParScav:MSC", 2, 3, _size_policy);
duke@435 224 _psh = this;
duke@435 225
duke@435 226 // Set up the GCTaskManager
duke@435 227 _gc_task_manager = GCTaskManager::create(ParallelGCThreads);
duke@435 228
duke@435 229 if (UseParallelOldGC && !PSParallelCompact::initialize()) {
duke@435 230 return JNI_ENOMEM;
duke@435 231 }
duke@435 232
duke@435 233 return JNI_OK;
duke@435 234 }
duke@435 235
duke@435 236 void ParallelScavengeHeap::post_initialize() {
duke@435 237 // Need to init the tenuring threshold
duke@435 238 PSScavenge::initialize();
duke@435 239 if (UseParallelOldGC) {
duke@435 240 PSParallelCompact::post_initialize();
duke@435 241 } else {
duke@435 242 PSMarkSweep::initialize();
duke@435 243 }
duke@435 244 PSPromotionManager::initialize();
duke@435 245 }
duke@435 246
duke@435 247 void ParallelScavengeHeap::update_counters() {
duke@435 248 young_gen()->update_counters();
duke@435 249 old_gen()->update_counters();
duke@435 250 perm_gen()->update_counters();
duke@435 251 }
duke@435 252
duke@435 253 size_t ParallelScavengeHeap::capacity() const {
duke@435 254 size_t value = young_gen()->capacity_in_bytes() + old_gen()->capacity_in_bytes();
duke@435 255 return value;
duke@435 256 }
duke@435 257
duke@435 258 size_t ParallelScavengeHeap::used() const {
duke@435 259 size_t value = young_gen()->used_in_bytes() + old_gen()->used_in_bytes();
duke@435 260 return value;
duke@435 261 }
duke@435 262
duke@435 263 bool ParallelScavengeHeap::is_maximal_no_gc() const {
duke@435 264 return old_gen()->is_maximal_no_gc() && young_gen()->is_maximal_no_gc();
duke@435 265 }
duke@435 266
duke@435 267
duke@435 268 size_t ParallelScavengeHeap::permanent_capacity() const {
duke@435 269 return perm_gen()->capacity_in_bytes();
duke@435 270 }
duke@435 271
duke@435 272 size_t ParallelScavengeHeap::permanent_used() const {
duke@435 273 return perm_gen()->used_in_bytes();
duke@435 274 }
duke@435 275
duke@435 276 size_t ParallelScavengeHeap::max_capacity() const {
duke@435 277 size_t estimated = reserved_region().byte_size();
duke@435 278 estimated -= perm_gen()->reserved().byte_size();
duke@435 279 if (UseAdaptiveSizePolicy) {
duke@435 280 estimated -= _size_policy->max_survivor_size(young_gen()->max_size());
duke@435 281 } else {
duke@435 282 estimated -= young_gen()->to_space()->capacity_in_bytes();
duke@435 283 }
duke@435 284 return MAX2(estimated, capacity());
duke@435 285 }
duke@435 286
duke@435 287 bool ParallelScavengeHeap::is_in(const void* p) const {
duke@435 288 if (young_gen()->is_in(p)) {
duke@435 289 return true;
duke@435 290 }
duke@435 291
duke@435 292 if (old_gen()->is_in(p)) {
duke@435 293 return true;
duke@435 294 }
duke@435 295
duke@435 296 if (perm_gen()->is_in(p)) {
duke@435 297 return true;
duke@435 298 }
duke@435 299
duke@435 300 return false;
duke@435 301 }
duke@435 302
duke@435 303 bool ParallelScavengeHeap::is_in_reserved(const void* p) const {
duke@435 304 if (young_gen()->is_in_reserved(p)) {
duke@435 305 return true;
duke@435 306 }
duke@435 307
duke@435 308 if (old_gen()->is_in_reserved(p)) {
duke@435 309 return true;
duke@435 310 }
duke@435 311
duke@435 312 if (perm_gen()->is_in_reserved(p)) {
duke@435 313 return true;
duke@435 314 }
duke@435 315
duke@435 316 return false;
duke@435 317 }
duke@435 318
duke@435 319 // There are two levels of allocation policy here.
duke@435 320 //
duke@435 321 // When an allocation request fails, the requesting thread must invoke a VM
duke@435 322 // operation, transfer control to the VM thread, and await the results of a
duke@435 323 // garbage collection. That is quite expensive, and we should avoid doing it
duke@435 324 // multiple times if possible.
duke@435 325 //
duke@435 326 // To accomplish this, we have a basic allocation policy, and also a
duke@435 327 // failed allocation policy.
duke@435 328 //
duke@435 329 // The basic allocation policy controls how you allocate memory without
duke@435 330 // attempting garbage collection. It is okay to grab locks and
duke@435 331 // expand the heap, if that can be done without coming to a safepoint.
duke@435 332 // It is likely that the basic allocation policy will not be very
duke@435 333 // aggressive.
duke@435 334 //
duke@435 335 // The failed allocation policy is invoked from the VM thread after
duke@435 336 // the basic allocation policy is unable to satisfy a mem_allocate
duke@435 337 // request. This policy needs to cover the entire range of collection,
duke@435 338 // heap expansion, and out-of-memory conditions. It should make every
duke@435 339 // attempt to allocate the requested memory.
duke@435 340
duke@435 341 // Basic allocation policy. Should never be called at a safepoint, or
duke@435 342 // from the VM thread.
duke@435 343 //
duke@435 344 // This method must handle cases where many mem_allocate requests fail
duke@435 345 // simultaneously. When that happens, only one VM operation will succeed,
duke@435 346 // and the rest will not be executed. For that reason, this method loops
duke@435 347 // during failed allocation attempts. If the java heap becomes exhausted,
duke@435 348 // we rely on the size_policy object to force a bail out.
duke@435 349 HeapWord* ParallelScavengeHeap::mem_allocate(
duke@435 350 size_t size,
duke@435 351 bool is_noref,
duke@435 352 bool is_tlab,
duke@435 353 bool* gc_overhead_limit_was_exceeded) {
duke@435 354 assert(!SafepointSynchronize::is_at_safepoint(), "should not be at safepoint");
duke@435 355 assert(Thread::current() != (Thread*)VMThread::vm_thread(), "should not be in vm thread");
duke@435 356 assert(!Heap_lock->owned_by_self(), "this thread should not own the Heap_lock");
duke@435 357
duke@435 358 HeapWord* result = young_gen()->allocate(size, is_tlab);
duke@435 359
duke@435 360 uint loop_count = 0;
duke@435 361 uint gc_count = 0;
duke@435 362
duke@435 363 while (result == NULL) {
duke@435 364 // We don't want to have multiple collections for a single filled generation.
duke@435 365 // To prevent this, each thread tracks the total_collections() value, and if
duke@435 366 // the count has changed, does not do a new collection.
duke@435 367 //
duke@435 368 // The collection count must be read only while holding the heap lock. VM
duke@435 369 // operations also hold the heap lock during collections. There is a lock
duke@435 370 // contention case where thread A blocks waiting on the Heap_lock, while
duke@435 371 // thread B is holding it doing a collection. When thread A gets the lock,
duke@435 372 // the collection count has already changed. To prevent duplicate collections,
duke@435 373 // The policy MUST attempt allocations during the same period it reads the
duke@435 374 // total_collections() value!
duke@435 375 {
duke@435 376 MutexLocker ml(Heap_lock);
duke@435 377 gc_count = Universe::heap()->total_collections();
duke@435 378
duke@435 379 result = young_gen()->allocate(size, is_tlab);
duke@435 380
duke@435 381 // (1) If the requested object is too large to easily fit in the
duke@435 382 // young_gen, or
duke@435 383 // (2) If GC is locked out via GCLocker, young gen is full and
duke@435 384 // the need for a GC already signalled to GCLocker (done
duke@435 385 // at a safepoint),
duke@435 386 // ... then, rather than force a safepoint and (a potentially futile)
duke@435 387 // collection (attempt) for each allocation, try allocation directly
duke@435 388 // in old_gen. For case (2) above, we may in the future allow
duke@435 389 // TLAB allocation directly in the old gen.
duke@435 390 if (result != NULL) {
duke@435 391 return result;
duke@435 392 }
duke@435 393 if (!is_tlab &&
iveresov@808 394 size >= (young_gen()->eden_space()->capacity_in_words(Thread::current()) / 2)) {
duke@435 395 result = old_gen()->allocate(size, is_tlab);
duke@435 396 if (result != NULL) {
duke@435 397 return result;
duke@435 398 }
duke@435 399 }
duke@435 400 if (GC_locker::is_active_and_needs_gc()) {
duke@435 401 // GC is locked out. If this is a TLAB allocation,
duke@435 402 // return NULL; the requestor will retry allocation
duke@435 403 // of an idividual object at a time.
duke@435 404 if (is_tlab) {
duke@435 405 return NULL;
duke@435 406 }
duke@435 407
duke@435 408 // If this thread is not in a jni critical section, we stall
duke@435 409 // the requestor until the critical section has cleared and
duke@435 410 // GC allowed. When the critical section clears, a GC is
duke@435 411 // initiated by the last thread exiting the critical section; so
duke@435 412 // we retry the allocation sequence from the beginning of the loop,
duke@435 413 // rather than causing more, now probably unnecessary, GC attempts.
duke@435 414 JavaThread* jthr = JavaThread::current();
duke@435 415 if (!jthr->in_critical()) {
duke@435 416 MutexUnlocker mul(Heap_lock);
duke@435 417 GC_locker::stall_until_clear();
duke@435 418 continue;
duke@435 419 } else {
duke@435 420 if (CheckJNICalls) {
duke@435 421 fatal("Possible deadlock due to allocating while"
duke@435 422 " in jni critical section");
duke@435 423 }
duke@435 424 return NULL;
duke@435 425 }
duke@435 426 }
duke@435 427 }
duke@435 428
duke@435 429 if (result == NULL) {
duke@435 430
duke@435 431 // Exit the loop if if the gc time limit has been exceeded.
duke@435 432 // The allocation must have failed above (result must be NULL),
duke@435 433 // and the most recent collection must have exceeded the
duke@435 434 // gc time limit. Exit the loop so that an out-of-memory
duke@435 435 // will be thrown (returning a NULL will do that), but
duke@435 436 // clear gc_time_limit_exceeded so that the next collection
duke@435 437 // will succeeded if the applications decides to handle the
duke@435 438 // out-of-memory and tries to go on.
duke@435 439 *gc_overhead_limit_was_exceeded = size_policy()->gc_time_limit_exceeded();
duke@435 440 if (size_policy()->gc_time_limit_exceeded()) {
duke@435 441 size_policy()->set_gc_time_limit_exceeded(false);
duke@435 442 if (PrintGCDetails && Verbose) {
duke@435 443 gclog_or_tty->print_cr("ParallelScavengeHeap::mem_allocate: "
duke@435 444 "return NULL because gc_time_limit_exceeded is set");
duke@435 445 }
duke@435 446 return NULL;
duke@435 447 }
duke@435 448
duke@435 449 // Generate a VM operation
duke@435 450 VM_ParallelGCFailedAllocation op(size, is_tlab, gc_count);
duke@435 451 VMThread::execute(&op);
duke@435 452
duke@435 453 // Did the VM operation execute? If so, return the result directly.
duke@435 454 // This prevents us from looping until time out on requests that can
duke@435 455 // not be satisfied.
duke@435 456 if (op.prologue_succeeded()) {
duke@435 457 assert(Universe::heap()->is_in_or_null(op.result()),
duke@435 458 "result not in heap");
duke@435 459
duke@435 460 // If GC was locked out during VM operation then retry allocation
duke@435 461 // and/or stall as necessary.
duke@435 462 if (op.gc_locked()) {
duke@435 463 assert(op.result() == NULL, "must be NULL if gc_locked() is true");
duke@435 464 continue; // retry and/or stall as necessary
duke@435 465 }
duke@435 466 // If a NULL result is being returned, an out-of-memory
duke@435 467 // will be thrown now. Clear the gc_time_limit_exceeded
duke@435 468 // flag to avoid the following situation.
duke@435 469 // gc_time_limit_exceeded is set during a collection
duke@435 470 // the collection fails to return enough space and an OOM is thrown
duke@435 471 // the next GC is skipped because the gc_time_limit_exceeded
duke@435 472 // flag is set and another OOM is thrown
duke@435 473 if (op.result() == NULL) {
duke@435 474 size_policy()->set_gc_time_limit_exceeded(false);
duke@435 475 }
duke@435 476 return op.result();
duke@435 477 }
duke@435 478 }
duke@435 479
duke@435 480 // The policy object will prevent us from looping forever. If the
duke@435 481 // time spent in gc crosses a threshold, we will bail out.
duke@435 482 loop_count++;
duke@435 483 if ((result == NULL) && (QueuedAllocationWarningCount > 0) &&
duke@435 484 (loop_count % QueuedAllocationWarningCount == 0)) {
duke@435 485 warning("ParallelScavengeHeap::mem_allocate retries %d times \n\t"
duke@435 486 " size=%d %s", loop_count, size, is_tlab ? "(TLAB)" : "");
duke@435 487 }
duke@435 488 }
duke@435 489
duke@435 490 return result;
duke@435 491 }
duke@435 492
duke@435 493 // Failed allocation policy. Must be called from the VM thread, and
duke@435 494 // only at a safepoint! Note that this method has policy for allocation
duke@435 495 // flow, and NOT collection policy. So we do not check for gc collection
duke@435 496 // time over limit here, that is the responsibility of the heap specific
duke@435 497 // collection methods. This method decides where to attempt allocations,
duke@435 498 // and when to attempt collections, but no collection specific policy.
duke@435 499 HeapWord* ParallelScavengeHeap::failed_mem_allocate(size_t size, bool is_tlab) {
duke@435 500 assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
duke@435 501 assert(Thread::current() == (Thread*)VMThread::vm_thread(), "should be in vm thread");
duke@435 502 assert(!Universe::heap()->is_gc_active(), "not reentrant");
duke@435 503 assert(!Heap_lock->owned_by_self(), "this thread should not own the Heap_lock");
duke@435 504
duke@435 505 size_t mark_sweep_invocation_count = total_invocations();
duke@435 506
duke@435 507 // We assume (and assert!) that an allocation at this point will fail
duke@435 508 // unless we collect.
duke@435 509
duke@435 510 // First level allocation failure, scavenge and allocate in young gen.
duke@435 511 GCCauseSetter gccs(this, GCCause::_allocation_failure);
duke@435 512 PSScavenge::invoke();
duke@435 513 HeapWord* result = young_gen()->allocate(size, is_tlab);
duke@435 514
duke@435 515 // Second level allocation failure.
duke@435 516 // Mark sweep and allocate in young generation.
duke@435 517 if (result == NULL) {
duke@435 518 // There is some chance the scavenge method decided to invoke mark_sweep.
duke@435 519 // Don't mark sweep twice if so.
duke@435 520 if (mark_sweep_invocation_count == total_invocations()) {
duke@435 521 invoke_full_gc(false);
duke@435 522 result = young_gen()->allocate(size, is_tlab);
duke@435 523 }
duke@435 524 }
duke@435 525
duke@435 526 // Third level allocation failure.
duke@435 527 // After mark sweep and young generation allocation failure,
duke@435 528 // allocate in old generation.
duke@435 529 if (result == NULL && !is_tlab) {
duke@435 530 result = old_gen()->allocate(size, is_tlab);
duke@435 531 }
duke@435 532
duke@435 533 // Fourth level allocation failure. We're running out of memory.
duke@435 534 // More complete mark sweep and allocate in young generation.
duke@435 535 if (result == NULL) {
duke@435 536 invoke_full_gc(true);
duke@435 537 result = young_gen()->allocate(size, is_tlab);
duke@435 538 }
duke@435 539
duke@435 540 // Fifth level allocation failure.
duke@435 541 // After more complete mark sweep, allocate in old generation.
duke@435 542 if (result == NULL && !is_tlab) {
duke@435 543 result = old_gen()->allocate(size, is_tlab);
duke@435 544 }
duke@435 545
duke@435 546 return result;
duke@435 547 }
duke@435 548
duke@435 549 //
duke@435 550 // This is the policy loop for allocating in the permanent generation.
duke@435 551 // If the initial allocation fails, we create a vm operation which will
duke@435 552 // cause a collection.
duke@435 553 HeapWord* ParallelScavengeHeap::permanent_mem_allocate(size_t size) {
duke@435 554 assert(!SafepointSynchronize::is_at_safepoint(), "should not be at safepoint");
duke@435 555 assert(Thread::current() != (Thread*)VMThread::vm_thread(), "should not be in vm thread");
duke@435 556 assert(!Heap_lock->owned_by_self(), "this thread should not own the Heap_lock");
duke@435 557
duke@435 558 HeapWord* result;
duke@435 559
duke@435 560 uint loop_count = 0;
duke@435 561 uint gc_count = 0;
duke@435 562 uint full_gc_count = 0;
duke@435 563
duke@435 564 do {
duke@435 565 // We don't want to have multiple collections for a single filled generation.
duke@435 566 // To prevent this, each thread tracks the total_collections() value, and if
duke@435 567 // the count has changed, does not do a new collection.
duke@435 568 //
duke@435 569 // The collection count must be read only while holding the heap lock. VM
duke@435 570 // operations also hold the heap lock during collections. There is a lock
duke@435 571 // contention case where thread A blocks waiting on the Heap_lock, while
duke@435 572 // thread B is holding it doing a collection. When thread A gets the lock,
duke@435 573 // the collection count has already changed. To prevent duplicate collections,
duke@435 574 // The policy MUST attempt allocations during the same period it reads the
duke@435 575 // total_collections() value!
duke@435 576 {
duke@435 577 MutexLocker ml(Heap_lock);
duke@435 578 gc_count = Universe::heap()->total_collections();
duke@435 579 full_gc_count = Universe::heap()->total_full_collections();
duke@435 580
duke@435 581 result = perm_gen()->allocate_permanent(size);
apetrusenko@574 582
apetrusenko@574 583 if (result != NULL) {
apetrusenko@574 584 return result;
apetrusenko@574 585 }
apetrusenko@574 586
apetrusenko@574 587 if (GC_locker::is_active_and_needs_gc()) {
apetrusenko@574 588 // If this thread is not in a jni critical section, we stall
apetrusenko@574 589 // the requestor until the critical section has cleared and
apetrusenko@574 590 // GC allowed. When the critical section clears, a GC is
apetrusenko@574 591 // initiated by the last thread exiting the critical section; so
apetrusenko@574 592 // we retry the allocation sequence from the beginning of the loop,
apetrusenko@574 593 // rather than causing more, now probably unnecessary, GC attempts.
apetrusenko@574 594 JavaThread* jthr = JavaThread::current();
apetrusenko@574 595 if (!jthr->in_critical()) {
apetrusenko@574 596 MutexUnlocker mul(Heap_lock);
apetrusenko@574 597 GC_locker::stall_until_clear();
apetrusenko@574 598 continue;
apetrusenko@574 599 } else {
apetrusenko@574 600 if (CheckJNICalls) {
apetrusenko@574 601 fatal("Possible deadlock due to allocating while"
apetrusenko@574 602 " in jni critical section");
apetrusenko@574 603 }
apetrusenko@574 604 return NULL;
apetrusenko@574 605 }
apetrusenko@574 606 }
duke@435 607 }
duke@435 608
duke@435 609 if (result == NULL) {
duke@435 610
duke@435 611 // Exit the loop if the gc time limit has been exceeded.
duke@435 612 // The allocation must have failed above (result must be NULL),
duke@435 613 // and the most recent collection must have exceeded the
duke@435 614 // gc time limit. Exit the loop so that an out-of-memory
duke@435 615 // will be thrown (returning a NULL will do that), but
duke@435 616 // clear gc_time_limit_exceeded so that the next collection
duke@435 617 // will succeeded if the applications decides to handle the
duke@435 618 // out-of-memory and tries to go on.
duke@435 619 if (size_policy()->gc_time_limit_exceeded()) {
duke@435 620 size_policy()->set_gc_time_limit_exceeded(false);
duke@435 621 if (PrintGCDetails && Verbose) {
duke@435 622 gclog_or_tty->print_cr("ParallelScavengeHeap::permanent_mem_allocate: "
duke@435 623 "return NULL because gc_time_limit_exceeded is set");
duke@435 624 }
duke@435 625 assert(result == NULL, "Allocation did not fail");
duke@435 626 return NULL;
duke@435 627 }
duke@435 628
duke@435 629 // Generate a VM operation
duke@435 630 VM_ParallelGCFailedPermanentAllocation op(size, gc_count, full_gc_count);
duke@435 631 VMThread::execute(&op);
duke@435 632
duke@435 633 // Did the VM operation execute? If so, return the result directly.
duke@435 634 // This prevents us from looping until time out on requests that can
duke@435 635 // not be satisfied.
duke@435 636 if (op.prologue_succeeded()) {
duke@435 637 assert(Universe::heap()->is_in_permanent_or_null(op.result()),
duke@435 638 "result not in heap");
apetrusenko@574 639 // If GC was locked out during VM operation then retry allocation
apetrusenko@574 640 // and/or stall as necessary.
apetrusenko@574 641 if (op.gc_locked()) {
apetrusenko@574 642 assert(op.result() == NULL, "must be NULL if gc_locked() is true");
apetrusenko@574 643 continue; // retry and/or stall as necessary
apetrusenko@574 644 }
duke@435 645 // If a NULL results is being returned, an out-of-memory
duke@435 646 // will be thrown now. Clear the gc_time_limit_exceeded
duke@435 647 // flag to avoid the following situation.
duke@435 648 // gc_time_limit_exceeded is set during a collection
duke@435 649 // the collection fails to return enough space and an OOM is thrown
duke@435 650 // the next GC is skipped because the gc_time_limit_exceeded
duke@435 651 // flag is set and another OOM is thrown
duke@435 652 if (op.result() == NULL) {
duke@435 653 size_policy()->set_gc_time_limit_exceeded(false);
duke@435 654 }
duke@435 655 return op.result();
duke@435 656 }
duke@435 657 }
duke@435 658
duke@435 659 // The policy object will prevent us from looping forever. If the
duke@435 660 // time spent in gc crosses a threshold, we will bail out.
duke@435 661 loop_count++;
duke@435 662 if ((QueuedAllocationWarningCount > 0) &&
duke@435 663 (loop_count % QueuedAllocationWarningCount == 0)) {
duke@435 664 warning("ParallelScavengeHeap::permanent_mem_allocate retries %d times \n\t"
duke@435 665 " size=%d", loop_count, size);
duke@435 666 }
duke@435 667 } while (result == NULL);
duke@435 668
duke@435 669 return result;
duke@435 670 }
duke@435 671
duke@435 672 //
duke@435 673 // This is the policy code for permanent allocations which have failed
duke@435 674 // and require a collection. Note that just as in failed_mem_allocate,
duke@435 675 // we do not set collection policy, only where & when to allocate and
duke@435 676 // collect.
duke@435 677 HeapWord* ParallelScavengeHeap::failed_permanent_mem_allocate(size_t size) {
duke@435 678 assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
duke@435 679 assert(Thread::current() == (Thread*)VMThread::vm_thread(), "should be in vm thread");
duke@435 680 assert(!Universe::heap()->is_gc_active(), "not reentrant");
duke@435 681 assert(!Heap_lock->owned_by_self(), "this thread should not own the Heap_lock");
duke@435 682 assert(size > perm_gen()->free_in_words(), "Allocation should fail");
duke@435 683
duke@435 684 // We assume (and assert!) that an allocation at this point will fail
duke@435 685 // unless we collect.
duke@435 686
duke@435 687 // First level allocation failure. Mark-sweep and allocate in perm gen.
duke@435 688 GCCauseSetter gccs(this, GCCause::_allocation_failure);
duke@435 689 invoke_full_gc(false);
duke@435 690 HeapWord* result = perm_gen()->allocate_permanent(size);
duke@435 691
duke@435 692 // Second level allocation failure. We're running out of memory.
duke@435 693 if (result == NULL) {
duke@435 694 invoke_full_gc(true);
duke@435 695 result = perm_gen()->allocate_permanent(size);
duke@435 696 }
duke@435 697
duke@435 698 return result;
duke@435 699 }
duke@435 700
duke@435 701 void ParallelScavengeHeap::ensure_parsability(bool retire_tlabs) {
duke@435 702 CollectedHeap::ensure_parsability(retire_tlabs);
duke@435 703 young_gen()->eden_space()->ensure_parsability();
duke@435 704 }
duke@435 705
duke@435 706 size_t ParallelScavengeHeap::unsafe_max_alloc() {
duke@435 707 return young_gen()->eden_space()->free_in_bytes();
duke@435 708 }
duke@435 709
duke@435 710 size_t ParallelScavengeHeap::tlab_capacity(Thread* thr) const {
duke@435 711 return young_gen()->eden_space()->tlab_capacity(thr);
duke@435 712 }
duke@435 713
duke@435 714 size_t ParallelScavengeHeap::unsafe_max_tlab_alloc(Thread* thr) const {
duke@435 715 return young_gen()->eden_space()->unsafe_max_tlab_alloc(thr);
duke@435 716 }
duke@435 717
duke@435 718 HeapWord* ParallelScavengeHeap::allocate_new_tlab(size_t size) {
duke@435 719 return young_gen()->allocate(size, true);
duke@435 720 }
duke@435 721
duke@435 722 void ParallelScavengeHeap::accumulate_statistics_all_tlabs() {
duke@435 723 CollectedHeap::accumulate_statistics_all_tlabs();
duke@435 724 }
duke@435 725
duke@435 726 void ParallelScavengeHeap::resize_all_tlabs() {
duke@435 727 CollectedHeap::resize_all_tlabs();
duke@435 728 }
duke@435 729
ysr@1462 730 bool ParallelScavengeHeap::can_elide_initializing_store_barrier(oop new_obj) {
ysr@1462 731 // We don't need barriers for stores to objects in the
ysr@1462 732 // young gen and, a fortiori, for initializing stores to
ysr@1462 733 // objects therein.
ysr@1462 734 return is_in_young(new_obj);
ysr@1462 735 }
ysr@1462 736
duke@435 737 // This method is used by System.gc() and JVMTI.
duke@435 738 void ParallelScavengeHeap::collect(GCCause::Cause cause) {
duke@435 739 assert(!Heap_lock->owned_by_self(),
duke@435 740 "this thread should not own the Heap_lock");
duke@435 741
duke@435 742 unsigned int gc_count = 0;
duke@435 743 unsigned int full_gc_count = 0;
duke@435 744 {
duke@435 745 MutexLocker ml(Heap_lock);
duke@435 746 // This value is guarded by the Heap_lock
duke@435 747 gc_count = Universe::heap()->total_collections();
duke@435 748 full_gc_count = Universe::heap()->total_full_collections();
duke@435 749 }
duke@435 750
duke@435 751 VM_ParallelGCSystemGC op(gc_count, full_gc_count, cause);
duke@435 752 VMThread::execute(&op);
duke@435 753 }
duke@435 754
duke@435 755 // This interface assumes that it's being called by the
duke@435 756 // vm thread. It collects the heap assuming that the
duke@435 757 // heap lock is already held and that we are executing in
duke@435 758 // the context of the vm thread.
duke@435 759 void ParallelScavengeHeap::collect_as_vm_thread(GCCause::Cause cause) {
duke@435 760 assert(Thread::current()->is_VM_thread(), "Precondition#1");
duke@435 761 assert(Heap_lock->is_locked(), "Precondition#2");
duke@435 762 GCCauseSetter gcs(this, cause);
duke@435 763 switch (cause) {
duke@435 764 case GCCause::_heap_inspection:
duke@435 765 case GCCause::_heap_dump: {
duke@435 766 HandleMark hm;
duke@435 767 invoke_full_gc(false);
duke@435 768 break;
duke@435 769 }
duke@435 770 default: // XXX FIX ME
duke@435 771 ShouldNotReachHere();
duke@435 772 }
duke@435 773 }
duke@435 774
duke@435 775
duke@435 776 void ParallelScavengeHeap::oop_iterate(OopClosure* cl) {
duke@435 777 Unimplemented();
duke@435 778 }
duke@435 779
duke@435 780 void ParallelScavengeHeap::object_iterate(ObjectClosure* cl) {
duke@435 781 young_gen()->object_iterate(cl);
duke@435 782 old_gen()->object_iterate(cl);
duke@435 783 perm_gen()->object_iterate(cl);
duke@435 784 }
duke@435 785
duke@435 786 void ParallelScavengeHeap::permanent_oop_iterate(OopClosure* cl) {
duke@435 787 Unimplemented();
duke@435 788 }
duke@435 789
duke@435 790 void ParallelScavengeHeap::permanent_object_iterate(ObjectClosure* cl) {
duke@435 791 perm_gen()->object_iterate(cl);
duke@435 792 }
duke@435 793
duke@435 794 HeapWord* ParallelScavengeHeap::block_start(const void* addr) const {
duke@435 795 if (young_gen()->is_in_reserved(addr)) {
duke@435 796 assert(young_gen()->is_in(addr),
duke@435 797 "addr should be in allocated part of young gen");
jrose@1100 798 if (Debugging) return NULL; // called from find() in debug.cpp
duke@435 799 Unimplemented();
duke@435 800 } else if (old_gen()->is_in_reserved(addr)) {
duke@435 801 assert(old_gen()->is_in(addr),
duke@435 802 "addr should be in allocated part of old gen");
duke@435 803 return old_gen()->start_array()->object_start((HeapWord*)addr);
duke@435 804 } else if (perm_gen()->is_in_reserved(addr)) {
duke@435 805 assert(perm_gen()->is_in(addr),
duke@435 806 "addr should be in allocated part of perm gen");
duke@435 807 return perm_gen()->start_array()->object_start((HeapWord*)addr);
duke@435 808 }
duke@435 809 return 0;
duke@435 810 }
duke@435 811
duke@435 812 size_t ParallelScavengeHeap::block_size(const HeapWord* addr) const {
duke@435 813 return oop(addr)->size();
duke@435 814 }
duke@435 815
duke@435 816 bool ParallelScavengeHeap::block_is_obj(const HeapWord* addr) const {
duke@435 817 return block_start(addr) == addr;
duke@435 818 }
duke@435 819
duke@435 820 jlong ParallelScavengeHeap::millis_since_last_gc() {
duke@435 821 return UseParallelOldGC ?
duke@435 822 PSParallelCompact::millis_since_last_gc() :
duke@435 823 PSMarkSweep::millis_since_last_gc();
duke@435 824 }
duke@435 825
duke@435 826 void ParallelScavengeHeap::prepare_for_verify() {
duke@435 827 ensure_parsability(false); // no need to retire TLABs for verification
duke@435 828 }
duke@435 829
duke@435 830 void ParallelScavengeHeap::print() const { print_on(tty); }
duke@435 831
duke@435 832 void ParallelScavengeHeap::print_on(outputStream* st) const {
duke@435 833 young_gen()->print_on(st);
duke@435 834 old_gen()->print_on(st);
duke@435 835 perm_gen()->print_on(st);
duke@435 836 }
duke@435 837
duke@435 838 void ParallelScavengeHeap::gc_threads_do(ThreadClosure* tc) const {
duke@435 839 PSScavenge::gc_task_manager()->threads_do(tc);
duke@435 840 }
duke@435 841
duke@435 842 void ParallelScavengeHeap::print_gc_threads_on(outputStream* st) const {
duke@435 843 PSScavenge::gc_task_manager()->print_threads_on(st);
duke@435 844 }
duke@435 845
duke@435 846 void ParallelScavengeHeap::print_tracing_info() const {
duke@435 847 if (TraceGen0Time) {
duke@435 848 double time = PSScavenge::accumulated_time()->seconds();
duke@435 849 tty->print_cr("[Accumulated GC generation 0 time %3.7f secs]", time);
duke@435 850 }
duke@435 851 if (TraceGen1Time) {
duke@435 852 double time = PSMarkSweep::accumulated_time()->seconds();
duke@435 853 tty->print_cr("[Accumulated GC generation 1 time %3.7f secs]", time);
duke@435 854 }
duke@435 855 }
duke@435 856
duke@435 857
ysr@1280 858 void ParallelScavengeHeap::verify(bool allow_dirty, bool silent, bool option /* ignored */) {
duke@435 859 // Why do we need the total_collections()-filter below?
duke@435 860 if (total_collections() > 0) {
duke@435 861 if (!silent) {
duke@435 862 gclog_or_tty->print("permanent ");
duke@435 863 }
duke@435 864 perm_gen()->verify(allow_dirty);
duke@435 865
duke@435 866 if (!silent) {
duke@435 867 gclog_or_tty->print("tenured ");
duke@435 868 }
duke@435 869 old_gen()->verify(allow_dirty);
duke@435 870
duke@435 871 if (!silent) {
duke@435 872 gclog_or_tty->print("eden ");
duke@435 873 }
duke@435 874 young_gen()->verify(allow_dirty);
duke@435 875 }
duke@435 876 if (!silent) {
duke@435 877 gclog_or_tty->print("ref_proc ");
duke@435 878 }
duke@435 879 ReferenceProcessor::verify();
duke@435 880 }
duke@435 881
duke@435 882 void ParallelScavengeHeap::print_heap_change(size_t prev_used) {
duke@435 883 if (PrintGCDetails && Verbose) {
duke@435 884 gclog_or_tty->print(" " SIZE_FORMAT
duke@435 885 "->" SIZE_FORMAT
duke@435 886 "(" SIZE_FORMAT ")",
duke@435 887 prev_used, used(), capacity());
duke@435 888 } else {
duke@435 889 gclog_or_tty->print(" " SIZE_FORMAT "K"
duke@435 890 "->" SIZE_FORMAT "K"
duke@435 891 "(" SIZE_FORMAT "K)",
duke@435 892 prev_used / K, used() / K, capacity() / K);
duke@435 893 }
duke@435 894 }
duke@435 895
duke@435 896 ParallelScavengeHeap* ParallelScavengeHeap::heap() {
duke@435 897 assert(_psh != NULL, "Uninitialized access to ParallelScavengeHeap::heap()");
duke@435 898 assert(_psh->kind() == CollectedHeap::ParallelScavengeHeap, "not a parallel scavenge heap");
duke@435 899 return _psh;
duke@435 900 }
duke@435 901
duke@435 902 // Before delegating the resize to the young generation,
duke@435 903 // the reserved space for the young and old generations
duke@435 904 // may be changed to accomodate the desired resize.
duke@435 905 void ParallelScavengeHeap::resize_young_gen(size_t eden_size,
duke@435 906 size_t survivor_size) {
duke@435 907 if (UseAdaptiveGCBoundary) {
duke@435 908 if (size_policy()->bytes_absorbed_from_eden() != 0) {
duke@435 909 size_policy()->reset_bytes_absorbed_from_eden();
duke@435 910 return; // The generation changed size already.
duke@435 911 }
duke@435 912 gens()->adjust_boundary_for_young_gen_needs(eden_size, survivor_size);
duke@435 913 }
duke@435 914
duke@435 915 // Delegate the resize to the generation.
duke@435 916 _young_gen->resize(eden_size, survivor_size);
duke@435 917 }
duke@435 918
duke@435 919 // Before delegating the resize to the old generation,
duke@435 920 // the reserved space for the young and old generations
duke@435 921 // may be changed to accomodate the desired resize.
duke@435 922 void ParallelScavengeHeap::resize_old_gen(size_t desired_free_space) {
duke@435 923 if (UseAdaptiveGCBoundary) {
duke@435 924 if (size_policy()->bytes_absorbed_from_eden() != 0) {
duke@435 925 size_policy()->reset_bytes_absorbed_from_eden();
duke@435 926 return; // The generation changed size already.
duke@435 927 }
duke@435 928 gens()->adjust_boundary_for_old_gen_needs(desired_free_space);
duke@435 929 }
duke@435 930
duke@435 931 // Delegate the resize to the generation.
duke@435 932 _old_gen->resize(desired_free_space);
duke@435 933 }
jmasa@698 934
jrose@1424 935 ParallelScavengeHeap::ParStrongRootsScope::ParStrongRootsScope() {
jrose@1424 936 // nothing particular
jrose@1424 937 }
jrose@1424 938
jrose@1424 939 ParallelScavengeHeap::ParStrongRootsScope::~ParStrongRootsScope() {
jrose@1424 940 // nothing particular
jrose@1424 941 }
jrose@1424 942
jmasa@698 943 #ifndef PRODUCT
jmasa@698 944 void ParallelScavengeHeap::record_gen_tops_before_GC() {
jmasa@698 945 if (ZapUnusedHeapArea) {
jmasa@698 946 young_gen()->record_spaces_top();
jmasa@698 947 old_gen()->record_spaces_top();
jmasa@698 948 perm_gen()->record_spaces_top();
jmasa@698 949 }
jmasa@698 950 }
jmasa@698 951
jmasa@698 952 void ParallelScavengeHeap::gen_mangle_unused_area() {
jmasa@698 953 if (ZapUnusedHeapArea) {
jmasa@698 954 young_gen()->eden_space()->mangle_unused_area();
jmasa@698 955 young_gen()->to_space()->mangle_unused_area();
jmasa@698 956 young_gen()->from_space()->mangle_unused_area();
jmasa@698 957 old_gen()->object_space()->mangle_unused_area();
jmasa@698 958 perm_gen()->object_space()->mangle_unused_area();
jmasa@698 959 }
jmasa@698 960 }
jmasa@698 961 #endif

mercurial