Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp
38921 views
/*1* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "gc_implementation/parallelScavenge/adjoiningGenerations.hpp"26#include "gc_implementation/parallelScavenge/adjoiningVirtualSpaces.hpp"27#include "gc_implementation/parallelScavenge/cardTableExtension.hpp"28#include "gc_implementation/parallelScavenge/gcTaskManager.hpp"29#include "gc_implementation/parallelScavenge/generationSizer.hpp"30#include "gc_implementation/parallelScavenge/parallelScavengeHeap.inline.hpp"31#include "gc_implementation/parallelScavenge/psAdaptiveSizePolicy.hpp"32#include "gc_implementation/parallelScavenge/psMarkSweep.hpp"33#include "gc_implementation/parallelScavenge/psParallelCompact.hpp"34#include "gc_implementation/parallelScavenge/psPromotionManager.hpp"35#include "gc_implementation/parallelScavenge/psScavenge.hpp"36#include "gc_implementation/parallelScavenge/vmPSOperations.hpp"37#include "gc_implementation/shared/gcHeapSummary.hpp"38#include "gc_implementation/shared/gcWhen.hpp"39#include "memory/gcLocker.inline.hpp"40#include "oops/oop.inline.hpp"41#include "runtime/handles.inline.hpp"42#include "runtime/java.hpp"43#include "runtime/vmThread.hpp"44#include "services/memTracker.hpp"45#include "utilities/vmError.hpp"4647PSYoungGen* ParallelScavengeHeap::_young_gen = NULL;48PSOldGen* ParallelScavengeHeap::_old_gen = NULL;49PSAdaptiveSizePolicy* ParallelScavengeHeap::_size_policy = NULL;50PSGCAdaptivePolicyCounters* ParallelScavengeHeap::_gc_policy_counters = NULL;51ParallelScavengeHeap* ParallelScavengeHeap::_psh = NULL;52GCTaskManager* ParallelScavengeHeap::_gc_task_manager = NULL;5354jint ParallelScavengeHeap::initialize() {55CollectedHeap::pre_initialize();5657// Initialize collector policy58_collector_policy = new GenerationSizer();59_collector_policy->initialize_all();6061const size_t heap_size = _collector_policy->max_heap_byte_size();6263ReservedSpace heap_rs = Universe::reserve_heap(heap_size, _collector_policy->heap_alignment());64MemTracker::record_virtual_memory_type((address)heap_rs.base(), mtJavaHeap);6566os::trace_page_sizes("ps main", _collector_policy->min_heap_byte_size(),67heap_size, generation_alignment(),68heap_rs.base(),69heap_rs.size());70if (!heap_rs.is_reserved()) {71vm_shutdown_during_initialization(72"Could not reserve enough space for object heap");73return JNI_ENOMEM;74}7576_reserved = MemRegion((HeapWord*)heap_rs.base(),77(HeapWord*)(heap_rs.base() + heap_rs.size()));7879CardTableExtension* const barrier_set = new CardTableExtension(_reserved, 3);80barrier_set->initialize();81_barrier_set = barrier_set;82oopDesc::set_bs(_barrier_set);83if (_barrier_set == NULL) {84vm_shutdown_during_initialization(85"Could not reserve enough space for barrier set");86return JNI_ENOMEM;87}8889// Make up the generations90// Calculate the maximum size that a generation can grow. This91// includes growth into the other generation. Note that the92// parameter _max_gen_size is kept as the maximum93// size of the generation as the boundaries currently stand.94// _max_gen_size is still used as that value.95double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0;96double max_gc_minor_pause_sec = ((double) MaxGCMinorPauseMillis)/1000.0;9798_gens = new AdjoiningGenerations(heap_rs, _collector_policy, generation_alignment());99100_old_gen = _gens->old_gen();101_young_gen = _gens->young_gen();102103const size_t eden_capacity = _young_gen->eden_space()->capacity_in_bytes();104const size_t old_capacity = _old_gen->capacity_in_bytes();105const size_t initial_promo_size = MIN2(eden_capacity, old_capacity);106_size_policy =107new PSAdaptiveSizePolicy(eden_capacity,108initial_promo_size,109young_gen()->to_space()->capacity_in_bytes(),110_collector_policy->gen_alignment(),111max_gc_pause_sec,112max_gc_minor_pause_sec,113GCTimeRatio114);115116assert(!UseAdaptiveGCBoundary ||117(old_gen()->virtual_space()->high_boundary() ==118young_gen()->virtual_space()->low_boundary()),119"Boundaries must meet");120// initialize the policy counters - 2 collectors, 3 generations121_gc_policy_counters =122new PSGCAdaptivePolicyCounters("ParScav:MSC", 2, 3, _size_policy);123_psh = this;124125// Set up the GCTaskManager126_gc_task_manager = GCTaskManager::create(ParallelGCThreads);127128if (UseParallelOldGC && !PSParallelCompact::initialize()) {129return JNI_ENOMEM;130}131132return JNI_OK;133}134135void ParallelScavengeHeap::post_initialize() {136// Need to init the tenuring threshold137PSScavenge::initialize();138if (UseParallelOldGC) {139PSParallelCompact::post_initialize();140} else {141PSMarkSweep::initialize();142}143PSPromotionManager::initialize();144}145146void ParallelScavengeHeap::update_counters() {147young_gen()->update_counters();148old_gen()->update_counters();149MetaspaceCounters::update_performance_counters();150CompressedClassSpaceCounters::update_performance_counters();151}152153size_t ParallelScavengeHeap::capacity() const {154size_t value = young_gen()->capacity_in_bytes() + old_gen()->capacity_in_bytes();155return value;156}157158size_t ParallelScavengeHeap::used() const {159size_t value = young_gen()->used_in_bytes() + old_gen()->used_in_bytes();160return value;161}162163bool ParallelScavengeHeap::is_maximal_no_gc() const {164return old_gen()->is_maximal_no_gc() && young_gen()->is_maximal_no_gc();165}166167168size_t ParallelScavengeHeap::max_capacity() const {169size_t estimated = reserved_region().byte_size();170if (UseAdaptiveSizePolicy) {171estimated -= _size_policy->max_survivor_size(young_gen()->max_size());172} else {173estimated -= young_gen()->to_space()->capacity_in_bytes();174}175return MAX2(estimated, capacity());176}177178bool ParallelScavengeHeap::is_in(const void* p) const {179if (young_gen()->is_in(p)) {180return true;181}182183if (old_gen()->is_in(p)) {184return true;185}186187return false;188}189190bool ParallelScavengeHeap::is_in_reserved(const void* p) const {191if (young_gen()->is_in_reserved(p)) {192return true;193}194195if (old_gen()->is_in_reserved(p)) {196return true;197}198199return false;200}201202bool ParallelScavengeHeap::is_scavengable(const void* addr) {203return is_in_young((oop)addr);204}205206#ifdef ASSERT207// Don't implement this by using is_in_young(). This method is used208// in some cases to check that is_in_young() is correct.209bool ParallelScavengeHeap::is_in_partial_collection(const void *p) {210assert(is_in_reserved(p) || p == NULL,211"Does not work if address is non-null and outside of the heap");212// The order of the generations is old (low addr), young (high addr)213return p >= old_gen()->reserved().end();214}215#endif216217// There are two levels of allocation policy here.218//219// When an allocation request fails, the requesting thread must invoke a VM220// operation, transfer control to the VM thread, and await the results of a221// garbage collection. That is quite expensive, and we should avoid doing it222// multiple times if possible.223//224// To accomplish this, we have a basic allocation policy, and also a225// failed allocation policy.226//227// The basic allocation policy controls how you allocate memory without228// attempting garbage collection. It is okay to grab locks and229// expand the heap, if that can be done without coming to a safepoint.230// It is likely that the basic allocation policy will not be very231// aggressive.232//233// The failed allocation policy is invoked from the VM thread after234// the basic allocation policy is unable to satisfy a mem_allocate235// request. This policy needs to cover the entire range of collection,236// heap expansion, and out-of-memory conditions. It should make every237// attempt to allocate the requested memory.238239// Basic allocation policy. Should never be called at a safepoint, or240// from the VM thread.241//242// This method must handle cases where many mem_allocate requests fail243// simultaneously. When that happens, only one VM operation will succeed,244// and the rest will not be executed. For that reason, this method loops245// during failed allocation attempts. If the java heap becomes exhausted,246// we rely on the size_policy object to force a bail out.247HeapWord* ParallelScavengeHeap::mem_allocate(248size_t size,249bool* gc_overhead_limit_was_exceeded) {250assert(!SafepointSynchronize::is_at_safepoint(), "should not be at safepoint");251assert(Thread::current() != (Thread*)VMThread::vm_thread(), "should not be in vm thread");252assert(!Heap_lock->owned_by_self(), "this thread should not own the Heap_lock");253254// In general gc_overhead_limit_was_exceeded should be false so255// set it so here and reset it to true only if the gc time256// limit is being exceeded as checked below.257*gc_overhead_limit_was_exceeded = false;258259HeapWord* result = young_gen()->allocate(size);260261uint loop_count = 0;262uint gc_count = 0;263uint gclocker_stalled_count = 0;264265while (result == NULL) {266// We don't want to have multiple collections for a single filled generation.267// To prevent this, each thread tracks the total_collections() value, and if268// the count has changed, does not do a new collection.269//270// The collection count must be read only while holding the heap lock. VM271// operations also hold the heap lock during collections. There is a lock272// contention case where thread A blocks waiting on the Heap_lock, while273// thread B is holding it doing a collection. When thread A gets the lock,274// the collection count has already changed. To prevent duplicate collections,275// The policy MUST attempt allocations during the same period it reads the276// total_collections() value!277{278MutexLocker ml(Heap_lock);279gc_count = Universe::heap()->total_collections();280281result = young_gen()->allocate(size);282if (result != NULL) {283return result;284}285286// If certain conditions hold, try allocating from the old gen.287result = mem_allocate_old_gen(size);288if (result != NULL) {289return result;290}291292if (gclocker_stalled_count > GCLockerRetryAllocationCount) {293return NULL;294}295296// Failed to allocate without a gc.297if (GC_locker::is_active_and_needs_gc()) {298// If this thread is not in a jni critical section, we stall299// the requestor until the critical section has cleared and300// GC allowed. When the critical section clears, a GC is301// initiated by the last thread exiting the critical section; so302// we retry the allocation sequence from the beginning of the loop,303// rather than causing more, now probably unnecessary, GC attempts.304JavaThread* jthr = JavaThread::current();305if (!jthr->in_critical()) {306MutexUnlocker mul(Heap_lock);307GC_locker::stall_until_clear();308gclocker_stalled_count += 1;309continue;310} else {311if (CheckJNICalls) {312fatal("Possible deadlock due to allocating while"313" in jni critical section");314}315return NULL;316}317}318}319320if (result == NULL) {321// Generate a VM operation322VM_ParallelGCFailedAllocation op(size, gc_count);323VMThread::execute(&op);324325// Did the VM operation execute? If so, return the result directly.326// This prevents us from looping until time out on requests that can327// not be satisfied.328if (op.prologue_succeeded()) {329assert(Universe::heap()->is_in_or_null(op.result()),330"result not in heap");331332// If GC was locked out during VM operation then retry allocation333// and/or stall as necessary.334if (op.gc_locked()) {335assert(op.result() == NULL, "must be NULL if gc_locked() is true");336continue; // retry and/or stall as necessary337}338339// Exit the loop if the gc time limit has been exceeded.340// The allocation must have failed above ("result" guarding341// this path is NULL) and the most recent collection has exceeded the342// gc overhead limit (although enough may have been collected to343// satisfy the allocation). Exit the loop so that an out-of-memory344// will be thrown (return a NULL ignoring the contents of345// op.result()),346// but clear gc_overhead_limit_exceeded so that the next collection347// starts with a clean slate (i.e., forgets about previous overhead348// excesses). Fill op.result() with a filler object so that the349// heap remains parsable.350const bool limit_exceeded = size_policy()->gc_overhead_limit_exceeded();351const bool softrefs_clear = collector_policy()->all_soft_refs_clear();352353if (limit_exceeded && softrefs_clear) {354*gc_overhead_limit_was_exceeded = true;355size_policy()->set_gc_overhead_limit_exceeded(false);356if (PrintGCDetails && Verbose) {357gclog_or_tty->print_cr("ParallelScavengeHeap::mem_allocate: "358"return NULL because gc_overhead_limit_exceeded is set");359}360if (op.result() != NULL) {361CollectedHeap::fill_with_object(op.result(), size);362}363return NULL;364}365366return op.result();367}368}369370// The policy object will prevent us from looping forever. If the371// time spent in gc crosses a threshold, we will bail out.372loop_count++;373if ((result == NULL) && (QueuedAllocationWarningCount > 0) &&374(loop_count % QueuedAllocationWarningCount == 0)) {375warning("ParallelScavengeHeap::mem_allocate retries %d times \n\t"376" size=" SIZE_FORMAT, loop_count, size);377}378}379380return result;381}382383// A "death march" is a series of ultra-slow allocations in which a full gc is384// done before each allocation, and after the full gc the allocation still385// cannot be satisfied from the young gen. This routine detects that condition;386// it should be called after a full gc has been done and the allocation387// attempted from the young gen. The parameter 'addr' should be the result of388// that young gen allocation attempt.389void390ParallelScavengeHeap::death_march_check(HeapWord* const addr, size_t size) {391if (addr != NULL) {392_death_march_count = 0; // death march has ended393} else if (_death_march_count == 0) {394if (should_alloc_in_eden(size)) {395_death_march_count = 1; // death march has started396}397}398}399400HeapWord* ParallelScavengeHeap::mem_allocate_old_gen(size_t size) {401if (!should_alloc_in_eden(size) || GC_locker::is_active_and_needs_gc()) {402// Size is too big for eden, or gc is locked out.403return old_gen()->allocate(size);404}405406// If a "death march" is in progress, allocate from the old gen a limited407// number of times before doing a GC.408if (_death_march_count > 0) {409if (_death_march_count < 64) {410++_death_march_count;411return old_gen()->allocate(size);412} else {413_death_march_count = 0;414}415}416return NULL;417}418419void ParallelScavengeHeap::do_full_collection(bool clear_all_soft_refs) {420if (UseParallelOldGC) {421// The do_full_collection() parameter clear_all_soft_refs422// is interpreted here as maximum_compaction which will423// cause SoftRefs to be cleared.424bool maximum_compaction = clear_all_soft_refs;425PSParallelCompact::invoke(maximum_compaction);426} else {427PSMarkSweep::invoke(clear_all_soft_refs);428}429}430431// Failed allocation policy. Must be called from the VM thread, and432// only at a safepoint! Note that this method has policy for allocation433// flow, and NOT collection policy. So we do not check for gc collection434// time over limit here, that is the responsibility of the heap specific435// collection methods. This method decides where to attempt allocations,436// and when to attempt collections, but no collection specific policy.437HeapWord* ParallelScavengeHeap::failed_mem_allocate(size_t size) {438assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");439assert(Thread::current() == (Thread*)VMThread::vm_thread(), "should be in vm thread");440assert(!Universe::heap()->is_gc_active(), "not reentrant");441assert(!Heap_lock->owned_by_self(), "this thread should not own the Heap_lock");442443// We assume that allocation in eden will fail unless we collect.444445// First level allocation failure, scavenge and allocate in young gen.446GCCauseSetter gccs(this, GCCause::_allocation_failure);447const bool invoked_full_gc = PSScavenge::invoke();448HeapWord* result = young_gen()->allocate(size);449450// Second level allocation failure.451// Mark sweep and allocate in young generation.452if (result == NULL && !invoked_full_gc) {453do_full_collection(false);454result = young_gen()->allocate(size);455}456457death_march_check(result, size);458459// Third level allocation failure.460// After mark sweep and young generation allocation failure,461// allocate in old generation.462if (result == NULL) {463result = old_gen()->allocate(size);464}465466// Fourth level allocation failure. We're running out of memory.467// More complete mark sweep and allocate in young generation.468if (result == NULL) {469do_full_collection(true);470result = young_gen()->allocate(size);471}472473// Fifth level allocation failure.474// After more complete mark sweep, allocate in old generation.475if (result == NULL) {476result = old_gen()->allocate(size);477}478479return result;480}481482void ParallelScavengeHeap::ensure_parsability(bool retire_tlabs) {483CollectedHeap::ensure_parsability(retire_tlabs);484young_gen()->eden_space()->ensure_parsability();485}486487size_t ParallelScavengeHeap::tlab_capacity(Thread* thr) const {488return young_gen()->eden_space()->tlab_capacity(thr);489}490491size_t ParallelScavengeHeap::tlab_used(Thread* thr) const {492return young_gen()->eden_space()->tlab_used(thr);493}494495size_t ParallelScavengeHeap::unsafe_max_tlab_alloc(Thread* thr) const {496return young_gen()->eden_space()->unsafe_max_tlab_alloc(thr);497}498499HeapWord* ParallelScavengeHeap::allocate_new_tlab(size_t size) {500return young_gen()->allocate(size);501}502503void ParallelScavengeHeap::accumulate_statistics_all_tlabs() {504CollectedHeap::accumulate_statistics_all_tlabs();505}506507void ParallelScavengeHeap::resize_all_tlabs() {508CollectedHeap::resize_all_tlabs();509}510511bool ParallelScavengeHeap::can_elide_initializing_store_barrier(oop new_obj) {512// We don't need barriers for stores to objects in the513// young gen and, a fortiori, for initializing stores to514// objects therein.515return is_in_young(new_obj);516}517518// This method is used by System.gc() and JVMTI.519void ParallelScavengeHeap::collect(GCCause::Cause cause) {520assert(!Heap_lock->owned_by_self(),521"this thread should not own the Heap_lock");522523uint gc_count = 0;524uint full_gc_count = 0;525{526MutexLocker ml(Heap_lock);527// This value is guarded by the Heap_lock528gc_count = Universe::heap()->total_collections();529full_gc_count = Universe::heap()->total_full_collections();530}531532if (GC_locker::should_discard(cause, gc_count)) {533return;534}535536VM_ParallelGCSystemGC op(gc_count, full_gc_count, cause);537VMThread::execute(&op);538}539540void ParallelScavengeHeap::oop_iterate(ExtendedOopClosure* cl) {541Unimplemented();542}543544void ParallelScavengeHeap::object_iterate(ObjectClosure* cl) {545young_gen()->object_iterate(cl);546old_gen()->object_iterate(cl);547}548549550HeapWord* ParallelScavengeHeap::block_start(const void* addr) const {551if (young_gen()->is_in_reserved(addr)) {552assert(young_gen()->is_in(addr),553"addr should be in allocated part of young gen");554// called from os::print_location by find or VMError555if (Debugging || VMError::fatal_error_in_progress()) return NULL;556Unimplemented();557} else if (old_gen()->is_in_reserved(addr)) {558assert(old_gen()->is_in(addr),559"addr should be in allocated part of old gen");560return old_gen()->start_array()->object_start((HeapWord*)addr);561}562return 0;563}564565size_t ParallelScavengeHeap::block_size(const HeapWord* addr) const {566return oop(addr)->size();567}568569bool ParallelScavengeHeap::block_is_obj(const HeapWord* addr) const {570return block_start(addr) == addr;571}572573jlong ParallelScavengeHeap::millis_since_last_gc() {574return UseParallelOldGC ?575PSParallelCompact::millis_since_last_gc() :576PSMarkSweep::millis_since_last_gc();577}578579void ParallelScavengeHeap::prepare_for_verify() {580ensure_parsability(false); // no need to retire TLABs for verification581}582583PSHeapSummary ParallelScavengeHeap::create_ps_heap_summary() {584PSOldGen* old = old_gen();585HeapWord* old_committed_end = (HeapWord*)old->virtual_space()->committed_high_addr();586VirtualSpaceSummary old_summary(old->reserved().start(), old_committed_end, old->reserved().end());587SpaceSummary old_space(old->reserved().start(), old_committed_end, old->used_in_bytes());588589PSYoungGen* young = young_gen();590VirtualSpaceSummary young_summary(young->reserved().start(),591(HeapWord*)young->virtual_space()->committed_high_addr(), young->reserved().end());592593MutableSpace* eden = young_gen()->eden_space();594SpaceSummary eden_space(eden->bottom(), eden->end(), eden->used_in_bytes());595596MutableSpace* from = young_gen()->from_space();597SpaceSummary from_space(from->bottom(), from->end(), from->used_in_bytes());598599MutableSpace* to = young_gen()->to_space();600SpaceSummary to_space(to->bottom(), to->end(), to->used_in_bytes());601602VirtualSpaceSummary heap_summary = create_heap_space_summary();603return PSHeapSummary(heap_summary, used(), old_summary, old_space, young_summary, eden_space, from_space, to_space);604}605606void ParallelScavengeHeap::print_on(outputStream* st) const {607young_gen()->print_on(st);608old_gen()->print_on(st);609MetaspaceAux::print_on(st);610}611612void ParallelScavengeHeap::print_on_error(outputStream* st) const {613this->CollectedHeap::print_on_error(st);614615if (UseParallelOldGC) {616st->cr();617PSParallelCompact::print_on_error(st);618}619}620621void ParallelScavengeHeap::gc_threads_do(ThreadClosure* tc) const {622PSScavenge::gc_task_manager()->threads_do(tc);623}624625void ParallelScavengeHeap::print_gc_threads_on(outputStream* st) const {626PSScavenge::gc_task_manager()->print_threads_on(st);627}628629void ParallelScavengeHeap::print_tracing_info() const {630if (TraceGen0Time) {631double time = PSScavenge::accumulated_time()->seconds();632tty->print_cr("[Accumulated GC generation 0 time %3.7f secs]", time);633}634if (TraceGen1Time) {635double time = UseParallelOldGC ? PSParallelCompact::accumulated_time()->seconds() : PSMarkSweep::accumulated_time()->seconds();636tty->print_cr("[Accumulated GC generation 1 time %3.7f secs]", time);637}638}639640641void ParallelScavengeHeap::verify(bool silent, VerifyOption option /* ignored */) {642// Why do we need the total_collections()-filter below?643if (total_collections() > 0) {644if (!silent) {645gclog_or_tty->print("tenured ");646}647old_gen()->verify();648649if (!silent) {650gclog_or_tty->print("eden ");651}652young_gen()->verify();653}654}655656void ParallelScavengeHeap::print_heap_change(size_t prev_used) {657if (PrintGCDetails && Verbose) {658gclog_or_tty->print(" " SIZE_FORMAT659"->" SIZE_FORMAT660"(" SIZE_FORMAT ")",661prev_used, used(), capacity());662} else {663gclog_or_tty->print(" " SIZE_FORMAT "K"664"->" SIZE_FORMAT "K"665"(" SIZE_FORMAT "K)",666prev_used / K, used() / K, capacity() / K);667}668}669670void ParallelScavengeHeap::trace_heap(GCWhen::Type when, GCTracer* gc_tracer) {671const PSHeapSummary& heap_summary = create_ps_heap_summary();672gc_tracer->report_gc_heap_summary(when, heap_summary);673674const MetaspaceSummary& metaspace_summary = create_metaspace_summary();675gc_tracer->report_metaspace_summary(when, metaspace_summary);676}677678ParallelScavengeHeap* ParallelScavengeHeap::heap() {679assert(_psh != NULL, "Uninitialized access to ParallelScavengeHeap::heap()");680assert(_psh->kind() == CollectedHeap::ParallelScavengeHeap, "not a parallel scavenge heap");681return _psh;682}683684// Before delegating the resize to the young generation,685// the reserved space for the young and old generations686// may be changed to accomodate the desired resize.687void ParallelScavengeHeap::resize_young_gen(size_t eden_size,688size_t survivor_size) {689if (UseAdaptiveGCBoundary) {690if (size_policy()->bytes_absorbed_from_eden() != 0) {691size_policy()->reset_bytes_absorbed_from_eden();692return; // The generation changed size already.693}694gens()->adjust_boundary_for_young_gen_needs(eden_size, survivor_size);695}696697// Delegate the resize to the generation.698_young_gen->resize(eden_size, survivor_size);699}700701// Before delegating the resize to the old generation,702// the reserved space for the young and old generations703// may be changed to accomodate the desired resize.704void ParallelScavengeHeap::resize_old_gen(size_t desired_free_space) {705if (UseAdaptiveGCBoundary) {706if (size_policy()->bytes_absorbed_from_eden() != 0) {707size_policy()->reset_bytes_absorbed_from_eden();708return; // The generation changed size already.709}710gens()->adjust_boundary_for_old_gen_needs(desired_free_space);711}712713// Delegate the resize to the generation.714_old_gen->resize(desired_free_space);715}716717ParallelScavengeHeap::ParStrongRootsScope::ParStrongRootsScope() {718// nothing particular719}720721ParallelScavengeHeap::ParStrongRootsScope::~ParStrongRootsScope() {722// nothing particular723}724725#ifndef PRODUCT726void ParallelScavengeHeap::record_gen_tops_before_GC() {727if (ZapUnusedHeapArea) {728young_gen()->record_spaces_top();729old_gen()->record_spaces_top();730}731}732733void ParallelScavengeHeap::gen_mangle_unused_area() {734if (ZapUnusedHeapArea) {735young_gen()->eden_space()->mangle_unused_area();736young_gen()->to_space()->mangle_unused_area();737young_gen()->from_space()->mangle_unused_area();738old_gen()->object_space()->mangle_unused_area();739}740}741#endif742743744