2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2018-02-26 09:34:12 +01:00
|
|
|
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "precompiled.hpp"
|
2014-05-07 14:16:45 -05:00
|
|
|
#include "classfile/stringTable.hpp"
|
2012-02-10 17:40:20 -08:00
|
|
|
#include "code/codeCache.hpp"
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "gc/parallel/gcTaskManager.hpp"
|
|
|
|
#include "gc/parallel/parallelScavengeHeap.hpp"
|
|
|
|
#include "gc/parallel/psAdaptiveSizePolicy.hpp"
|
|
|
|
#include "gc/parallel/psMarkSweep.hpp"
|
2016-01-18 10:25:41 +01:00
|
|
|
#include "gc/parallel/psParallelCompact.inline.hpp"
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "gc/parallel/psScavenge.inline.hpp"
|
|
|
|
#include "gc/parallel/psTasks.hpp"
|
|
|
|
#include "gc/shared/collectorPolicy.hpp"
|
|
|
|
#include "gc/shared/gcCause.hpp"
|
|
|
|
#include "gc/shared/gcHeapSummary.hpp"
|
2015-09-30 09:07:21 +02:00
|
|
|
#include "gc/shared/gcId.hpp"
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "gc/shared/gcLocker.inline.hpp"
|
|
|
|
#include "gc/shared/gcTimer.hpp"
|
|
|
|
#include "gc/shared/gcTrace.hpp"
|
2015-12-10 14:57:55 +01:00
|
|
|
#include "gc/shared/gcTraceTime.inline.hpp"
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "gc/shared/isGCActiveMark.hpp"
|
|
|
|
#include "gc/shared/referencePolicy.hpp"
|
|
|
|
#include "gc/shared/referenceProcessor.hpp"
|
|
|
|
#include "gc/shared/spaceDecorator.hpp"
|
2017-10-18 21:13:35 +02:00
|
|
|
#include "gc/shared/weakProcessor.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "memory/resourceArea.hpp"
|
2015-12-10 14:57:55 +01:00
|
|
|
#include "logging/log.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "oops/oop.inline.hpp"
|
|
|
|
#include "runtime/biasedLocking.hpp"
|
|
|
|
#include "runtime/handles.inline.hpp"
|
|
|
|
#include "runtime/threadCritical.hpp"
|
|
|
|
#include "runtime/vmThread.hpp"
|
|
|
|
#include "runtime/vm_operations.hpp"
|
|
|
|
#include "services/memoryService.hpp"
|
|
|
|
#include "utilities/stack.inline.hpp"
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
HeapWord* PSScavenge::_to_space_top_before_gc = NULL;
|
|
|
|
int PSScavenge::_consecutive_skipped_scavenges = 0;
|
|
|
|
ReferenceProcessor* PSScavenge::_ref_processor = NULL;
|
2018-02-26 09:34:12 +01:00
|
|
|
PSCardTable* PSScavenge::_card_table = NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
bool PSScavenge::_survivor_overflow = false;
|
2012-10-03 20:31:41 +02:00
|
|
|
uint PSScavenge::_tenuring_threshold = 0;
|
2007-12-01 00:00:00 +00:00
|
|
|
HeapWord* PSScavenge::_young_generation_boundary = NULL;
|
2013-05-30 10:58:16 +02:00
|
|
|
uintptr_t PSScavenge::_young_generation_boundary_compressed = 0;
|
2007-12-01 00:00:00 +00:00
|
|
|
elapsedTimer PSScavenge::_accumulated_time;
|
2013-06-10 11:30:51 +02:00
|
|
|
STWGCTimer PSScavenge::_gc_timer;
|
|
|
|
ParallelScavengeTracer PSScavenge::_gc_tracer;
|
2007-12-01 00:00:00 +00:00
|
|
|
CollectorCounters* PSScavenge::_counters = NULL;
|
|
|
|
|
|
|
|
// Define before use
|
|
|
|
class PSIsAliveClosure: public BoolObjectClosure {
|
|
|
|
public:
|
|
|
|
bool do_object_b(oop p) {
|
2013-05-30 10:58:16 +02:00
|
|
|
return (!PSScavenge::is_obj_in_young(p)) || p->is_forwarded();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
PSIsAliveClosure PSScavenge::_is_alive_closure;
|
|
|
|
|
|
|
|
class PSKeepAliveClosure: public OopClosure {
|
|
|
|
protected:
|
|
|
|
MutableSpace* _to_space;
|
|
|
|
PSPromotionManager* _promotion_manager;
|
|
|
|
|
|
|
|
public:
|
|
|
|
PSKeepAliveClosure(PSPromotionManager* pm) : _promotion_manager(pm) {
|
2015-04-13 15:47:48 +02:00
|
|
|
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
|
2007-12-01 00:00:00 +00:00
|
|
|
_to_space = heap->young_gen()->to_space();
|
|
|
|
|
|
|
|
assert(_promotion_manager != NULL, "Sanity");
|
|
|
|
}
|
|
|
|
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
template <class T> void do_oop_work(T* p) {
|
|
|
|
assert (!oopDesc::is_null(*p), "expected non-null ref");
|
2017-08-23 14:52:55 -04:00
|
|
|
assert (oopDesc::is_oop(oopDesc::load_decode_heap_oop_not_null(p)),
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
"expected an oop while scanning weak refs");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Weak refs may be visited more than once.
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
if (PSScavenge::should_scavenge(p, _to_space)) {
|
2015-02-20 13:54:42 +01:00
|
|
|
_promotion_manager->copy_and_push_safe_barrier<T, /*promote_immediately=*/false>(p);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
virtual void do_oop(oop* p) { PSKeepAliveClosure::do_oop_work(p); }
|
|
|
|
virtual void do_oop(narrowOop* p) { PSKeepAliveClosure::do_oop_work(p); }
|
2007-12-01 00:00:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class PSEvacuateFollowersClosure: public VoidClosure {
|
|
|
|
private:
|
|
|
|
PSPromotionManager* _promotion_manager;
|
|
|
|
public:
|
|
|
|
PSEvacuateFollowersClosure(PSPromotionManager* pm) : _promotion_manager(pm) {}
|
|
|
|
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
virtual void do_void() {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(_promotion_manager != NULL, "Sanity");
|
|
|
|
_promotion_manager->drain_stacks(true);
|
|
|
|
guarantee(_promotion_manager->stacks_empty(),
|
|
|
|
"stacks should be empty at this point");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class PSRefProcTaskProxy: public GCTask {
|
|
|
|
typedef AbstractRefProcTaskExecutor::ProcessTask ProcessTask;
|
|
|
|
ProcessTask & _rp_task;
|
|
|
|
uint _work_id;
|
|
|
|
public:
|
|
|
|
PSRefProcTaskProxy(ProcessTask & rp_task, uint work_id)
|
|
|
|
: _rp_task(rp_task),
|
|
|
|
_work_id(work_id)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual char* name() { return (char *)"Process referents by policy in parallel"; }
|
|
|
|
virtual void do_it(GCTaskManager* manager, uint which);
|
|
|
|
};
|
|
|
|
|
|
|
|
void PSRefProcTaskProxy::do_it(GCTaskManager* manager, uint which)
|
|
|
|
{
|
|
|
|
PSPromotionManager* promotion_manager =
|
|
|
|
PSPromotionManager::gc_thread_promotion_manager(which);
|
|
|
|
assert(promotion_manager != NULL, "sanity check");
|
|
|
|
PSKeepAliveClosure keep_alive(promotion_manager);
|
|
|
|
PSEvacuateFollowersClosure evac_followers(promotion_manager);
|
|
|
|
PSIsAliveClosure is_alive;
|
|
|
|
_rp_task.work(_work_id, is_alive, keep_alive, evac_followers);
|
|
|
|
}
|
|
|
|
|
|
|
|
class PSRefEnqueueTaskProxy: public GCTask {
|
|
|
|
typedef AbstractRefProcTaskExecutor::EnqueueTask EnqueueTask;
|
|
|
|
EnqueueTask& _enq_task;
|
|
|
|
uint _work_id;
|
|
|
|
|
|
|
|
public:
|
|
|
|
PSRefEnqueueTaskProxy(EnqueueTask& enq_task, uint work_id)
|
|
|
|
: _enq_task(enq_task),
|
|
|
|
_work_id(work_id)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual char* name() { return (char *)"Enqueue reference objects in parallel"; }
|
|
|
|
virtual void do_it(GCTaskManager* manager, uint which)
|
|
|
|
{
|
|
|
|
_enq_task.work(_work_id);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class PSRefProcTaskExecutor: public AbstractRefProcTaskExecutor {
|
|
|
|
virtual void execute(ProcessTask& task);
|
|
|
|
virtual void execute(EnqueueTask& task);
|
|
|
|
};
|
|
|
|
|
|
|
|
void PSRefProcTaskExecutor::execute(ProcessTask& task)
|
|
|
|
{
|
|
|
|
GCTaskQueue* q = GCTaskQueue::create();
|
2011-08-09 10:16:01 -07:00
|
|
|
GCTaskManager* manager = ParallelScavengeHeap::gc_task_manager();
|
|
|
|
for(uint i=0; i < manager->active_workers(); i++) {
|
2007-12-01 00:00:00 +00:00
|
|
|
q->enqueue(new PSRefProcTaskProxy(task, i));
|
|
|
|
}
|
2011-08-09 10:16:01 -07:00
|
|
|
ParallelTaskTerminator terminator(manager->active_workers(),
|
2010-07-22 10:27:41 -04:00
|
|
|
(TaskQueueSetSuper*) PSPromotionManager::stack_array_depth());
|
2011-08-09 10:16:01 -07:00
|
|
|
if (task.marks_oops_alive() && manager->active_workers() > 1) {
|
|
|
|
for (uint j = 0; j < manager->active_workers(); j++) {
|
2007-12-01 00:00:00 +00:00
|
|
|
q->enqueue(new StealTask(&terminator));
|
|
|
|
}
|
|
|
|
}
|
2011-08-09 10:16:01 -07:00
|
|
|
manager->execute_and_wait(q);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PSRefProcTaskExecutor::execute(EnqueueTask& task)
|
|
|
|
{
|
|
|
|
GCTaskQueue* q = GCTaskQueue::create();
|
2011-08-09 10:16:01 -07:00
|
|
|
GCTaskManager* manager = ParallelScavengeHeap::gc_task_manager();
|
|
|
|
for(uint i=0; i < manager->active_workers(); i++) {
|
2007-12-01 00:00:00 +00:00
|
|
|
q->enqueue(new PSRefEnqueueTaskProxy(task, i));
|
|
|
|
}
|
2011-08-09 10:16:01 -07:00
|
|
|
manager->execute_and_wait(q);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This method contains all heap specific policy for invoking scavenge.
|
|
|
|
// PSScavenge::invoke_no_policy() will do nothing but attempt to
|
|
|
|
// scavenge. It will not clean up after failed promotions, bail out if
|
|
|
|
// we've exceeded policy time limits, or any other special behavior.
|
|
|
|
// All such policy should be placed here.
|
|
|
|
//
|
|
|
|
// Note that this method should only be called from the vm_thread while
|
|
|
|
// at a safepoint!
|
2012-02-16 13:12:25 -08:00
|
|
|
bool PSScavenge::invoke() {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
|
|
|
|
assert(Thread::current() == (Thread*)VMThread::vm_thread(), "should be in vm thread");
|
2015-04-13 15:47:48 +02:00
|
|
|
assert(!ParallelScavengeHeap::heap()->is_gc_active(), "not reentrant");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2015-04-13 15:47:48 +02:00
|
|
|
ParallelScavengeHeap* const heap = ParallelScavengeHeap::heap();
|
2007-12-01 00:00:00 +00:00
|
|
|
PSAdaptiveSizePolicy* policy = heap->size_policy();
|
2010-04-13 13:52:10 -07:00
|
|
|
IsGCActiveMark mark;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2012-02-16 13:12:25 -08:00
|
|
|
const bool scavenge_done = PSScavenge::invoke_no_policy();
|
|
|
|
const bool need_full_gc = !scavenge_done ||
|
|
|
|
policy->should_full_GC(heap->old_gen()->free_in_bytes());
|
|
|
|
bool full_gc_done = false;
|
|
|
|
|
|
|
|
if (UsePerfData) {
|
|
|
|
PSGCAdaptivePolicyCounters* const counters = heap->gc_policy_counters();
|
|
|
|
const int ffs_val = need_full_gc ? full_follows_scavenge : not_skipped;
|
|
|
|
counters->update_full_follows_scavenge(ffs_val);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2012-02-16 13:12:25 -08:00
|
|
|
if (need_full_gc) {
|
2010-04-13 13:52:10 -07:00
|
|
|
GCCauseSetter gccs(heap, GCCause::_adaptive_size_policy);
|
2018-02-22 18:36:07 +01:00
|
|
|
SoftRefPolicy* srp = heap->soft_ref_policy();
|
|
|
|
const bool clear_all_softrefs = srp->should_clear_all_soft_refs();
|
2010-04-13 13:52:10 -07:00
|
|
|
|
|
|
|
if (UseParallelOldGC) {
|
2012-02-16 13:12:25 -08:00
|
|
|
full_gc_done = PSParallelCompact::invoke_no_policy(clear_all_softrefs);
|
2010-04-13 13:52:10 -07:00
|
|
|
} else {
|
2012-02-16 13:12:25 -08:00
|
|
|
full_gc_done = PSMarkSweep::invoke_no_policy(clear_all_softrefs);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
2012-02-16 13:12:25 -08:00
|
|
|
|
|
|
|
return full_gc_done;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This method contains no policy. You should probably
|
|
|
|
// be calling invoke() instead.
|
|
|
|
bool PSScavenge::invoke_no_policy() {
|
|
|
|
assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
|
|
|
|
assert(Thread::current() == (Thread*)VMThread::vm_thread(), "should be in vm thread");
|
|
|
|
|
2013-11-23 12:25:13 +01:00
|
|
|
_gc_timer.register_gc_start();
|
2013-06-10 11:30:51 +02:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
TimeStamp scavenge_entry;
|
|
|
|
TimeStamp scavenge_midpoint;
|
|
|
|
TimeStamp scavenge_exit;
|
|
|
|
|
|
|
|
scavenge_entry.update();
|
|
|
|
|
2016-01-14 13:26:19 +01:00
|
|
|
if (GCLocker::check_active_before_gc()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-04-13 15:47:48 +02:00
|
|
|
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
|
2007-12-01 00:00:00 +00:00
|
|
|
GCCause::Cause gc_cause = heap->gc_cause();
|
|
|
|
|
|
|
|
// Check for potential problems.
|
|
|
|
if (!should_attempt_scavenge()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-09-30 09:07:21 +02:00
|
|
|
GCIdMark gc_id_mark;
|
2013-06-10 11:30:51 +02:00
|
|
|
_gc_tracer.report_gc_start(heap->gc_cause(), _gc_timer.gc_start());
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
bool promotion_failure_occurred = false;
|
|
|
|
|
|
|
|
PSYoungGen* young_gen = heap->young_gen();
|
|
|
|
PSOldGen* old_gen = heap->old_gen();
|
|
|
|
PSAdaptiveSizePolicy* size_policy = heap->size_policy();
|
2013-06-10 11:30:51 +02:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
heap->increment_total_collections();
|
|
|
|
|
2015-04-15 11:30:36 -07:00
|
|
|
if (AdaptiveSizePolicy::should_update_eden_stats(gc_cause)) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Gather the feedback data for eden occupancy.
|
|
|
|
young_gen->eden_space()->accumulate_statistics();
|
|
|
|
}
|
|
|
|
|
2012-02-01 07:59:01 -08:00
|
|
|
heap->print_heap_before_gc();
|
2013-06-10 11:30:51 +02:00
|
|
|
heap->trace_heap_before_gc(&_gc_tracer);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
assert(!NeverTenure || _tenuring_threshold == markOopDesc::max_age + 1, "Sanity");
|
|
|
|
assert(!AlwaysTenure || _tenuring_threshold == 0, "Sanity");
|
|
|
|
|
|
|
|
// Fill in TLABs
|
|
|
|
heap->accumulate_statistics_all_tlabs();
|
|
|
|
heap->ensure_parsability(true); // retire TLABs
|
|
|
|
|
|
|
|
if (VerifyBeforeGC && heap->total_collections() >= VerifyGCStartAt) {
|
|
|
|
HandleMark hm; // Discard invalid handles created during verification
|
2015-12-10 14:57:55 +01:00
|
|
|
Universe::verify("Before GC");
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
ResourceMark rm;
|
|
|
|
HandleMark hm;
|
|
|
|
|
2015-12-10 14:57:55 +01:00
|
|
|
GCTraceCPUTime tcpu;
|
|
|
|
GCTraceTime(Info, gc) tm("Pause Young", NULL, gc_cause, true);
|
2007-12-01 00:00:00 +00:00
|
|
|
TraceCollectorStats tcs(counters());
|
2017-11-30 13:40:07 +01:00
|
|
|
TraceMemoryManagerStats tms(heap->young_gc_manager(), gc_cause);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2017-09-21 14:32:05 +02:00
|
|
|
if (log_is_enabled(Debug, gc, heap, exit)) {
|
|
|
|
accumulated_time()->start();
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Let the size policy know we're starting
|
|
|
|
size_policy->minor_collection_begin();
|
|
|
|
|
|
|
|
// Verify the object start arrays.
|
|
|
|
if (VerifyObjectStartArray &&
|
|
|
|
VerifyBeforeGC) {
|
|
|
|
old_gen->verify_object_start_array();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verify no unmarked old->young roots
|
|
|
|
if (VerifyRememberedSets) {
|
2018-02-26 09:34:12 +01:00
|
|
|
heap->card_table()->verify_all_young_refs_imprecise();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2015-10-16 14:11:29 +02:00
|
|
|
assert(young_gen->to_space()->is_empty(),
|
|
|
|
"Attempt to scavenge with live objects in to_space");
|
|
|
|
young_gen->to_space()->clear(SpaceDecorator::Mangle);
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
save_to_space_top_before_gc();
|
|
|
|
|
2017-11-06 21:28:03 -08:00
|
|
|
#if COMPILER2_OR_JVMCI
|
2015-10-08 12:49:30 -10:00
|
|
|
DerivedPointerTable::clear();
|
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2014-12-17 22:32:44 -05:00
|
|
|
reference_processor()->enable_discovery();
|
2008-12-01 23:25:24 -08:00
|
|
|
reference_processor()->setup_policy(false);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2015-12-10 14:57:55 +01:00
|
|
|
PreGCValues pre_gc_values(heap);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Reset our survivor overflow.
|
|
|
|
set_survivor_overflow(false);
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// We need to save the old top values before
|
2007-12-01 00:00:00 +00:00
|
|
|
// creating the promotion_manager. We pass the top
|
|
|
|
// values to the card_table, to prevent it from
|
|
|
|
// straying into the promotion labs.
|
|
|
|
HeapWord* old_top = old_gen->object_space()->top();
|
|
|
|
|
|
|
|
// Release all previously held resources
|
|
|
|
gc_task_manager()->release_all_resources();
|
|
|
|
|
2011-08-09 10:16:01 -07:00
|
|
|
// Set the number of GC threads to be used in this collection
|
|
|
|
gc_task_manager()->set_active_gang();
|
|
|
|
gc_task_manager()->task_idle_workers();
|
|
|
|
// Get the active number of workers here and use that value
|
|
|
|
// throughout the methods.
|
|
|
|
uint active_workers = gc_task_manager()->active_workers();
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
PSPromotionManager::pre_scavenge();
|
|
|
|
|
|
|
|
// We'll use the promotion manager again later.
|
|
|
|
PSPromotionManager* promotion_manager = PSPromotionManager::vm_thread_promotion_manager();
|
|
|
|
{
|
2015-12-10 14:57:55 +01:00
|
|
|
GCTraceTime(Debug, gc, phases) tm("Scavenge", &_gc_timer);
|
2009-09-15 21:53:47 -07:00
|
|
|
ParallelScavengeHeap::ParStrongRootsScope psrs;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
GCTaskQueue* q = GCTaskQueue::create();
|
|
|
|
|
2012-10-03 08:08:52 -07:00
|
|
|
if (!old_gen->object_space()->is_empty()) {
|
|
|
|
// There are only old-to-young pointers if there are objects
|
|
|
|
// in the old gen.
|
|
|
|
uint stripe_total = active_workers;
|
|
|
|
for(uint i=0; i < stripe_total; i++) {
|
|
|
|
q->enqueue(new OldToYoungRootsTask(old_gen, old_top, i, stripe_total));
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::universe));
|
|
|
|
q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::jni_handles));
|
|
|
|
// We scan the thread roots in parallel
|
|
|
|
Threads::create_thread_roots_tasks(q);
|
|
|
|
q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::object_synchronizer));
|
|
|
|
q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::management));
|
|
|
|
q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::system_dictionary));
|
2013-05-27 15:22:59 +02:00
|
|
|
q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::class_loader_data));
|
2007-12-01 00:00:00 +00:00
|
|
|
q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::jvmti));
|
2009-09-15 21:53:47 -07:00
|
|
|
q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::code_cache));
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
ParallelTaskTerminator terminator(
|
2011-08-09 10:16:01 -07:00
|
|
|
active_workers,
|
2010-07-22 10:27:41 -04:00
|
|
|
(TaskQueueSetSuper*) promotion_manager->stack_array_depth());
|
2016-06-08 14:11:51 -07:00
|
|
|
// If active_workers can exceed 1, add a StrealTask.
|
|
|
|
// PSPromotionManager::drain_stacks_depth() does not fully drain its
|
|
|
|
// stacks and expects a StealTask to complete the draining if
|
|
|
|
// ParallelGCThreads is > 1.
|
|
|
|
if (gc_task_manager()->workers() > 1) {
|
|
|
|
for (uint j = 0; j < active_workers; j++) {
|
|
|
|
q->enqueue(new StealTask(&terminator));
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gc_task_manager()->execute_and_wait(q);
|
|
|
|
}
|
|
|
|
|
|
|
|
scavenge_midpoint.update();
|
|
|
|
|
|
|
|
// Process reference objects discovered during scavenge
|
|
|
|
{
|
2016-03-18 08:59:07 +01:00
|
|
|
GCTraceTime(Debug, gc, phases) tm("Reference Processing", &_gc_timer);
|
2013-06-10 11:30:51 +02:00
|
|
|
|
2008-12-01 23:25:24 -08:00
|
|
|
reference_processor()->setup_policy(false); // not always_clear
|
2011-08-09 10:16:01 -07:00
|
|
|
reference_processor()->set_active_mt_degree(active_workers);
|
2017-10-23 11:20:53 +02:00
|
|
|
PSKeepAliveClosure keep_alive(promotion_manager);
|
|
|
|
PSEvacuateFollowersClosure evac_followers(promotion_manager);
|
2013-06-10 11:30:51 +02:00
|
|
|
ReferenceProcessorStats stats;
|
2017-08-10 18:09:19 -07:00
|
|
|
ReferenceProcessorPhaseTimes pt(&_gc_timer, reference_processor()->num_q());
|
2007-12-01 00:00:00 +00:00
|
|
|
if (reference_processor()->processing_is_mt()) {
|
|
|
|
PSRefProcTaskExecutor task_executor;
|
2013-06-10 11:30:51 +02:00
|
|
|
stats = reference_processor()->process_discovered_references(
|
|
|
|
&_is_alive_closure, &keep_alive, &evac_followers, &task_executor,
|
2017-08-10 18:09:19 -07:00
|
|
|
&pt);
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
2013-06-10 11:30:51 +02:00
|
|
|
stats = reference_processor()->process_discovered_references(
|
2017-08-10 18:09:19 -07:00
|
|
|
&_is_alive_closure, &keep_alive, &evac_followers, NULL, &pt);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2013-06-10 11:30:51 +02:00
|
|
|
_gc_tracer.report_gc_reference_stats(stats);
|
2017-08-10 18:09:19 -07:00
|
|
|
pt.print_all_references();
|
2013-06-10 11:30:51 +02:00
|
|
|
|
|
|
|
// Enqueue reference objects discovered during scavenge.
|
|
|
|
if (reference_processor()->processing_is_mt()) {
|
|
|
|
PSRefProcTaskExecutor task_executor;
|
2017-08-10 18:09:19 -07:00
|
|
|
reference_processor()->enqueue_discovered_references(&task_executor, &pt);
|
2013-06-10 11:30:51 +02:00
|
|
|
} else {
|
2017-08-10 18:09:19 -07:00
|
|
|
reference_processor()->enqueue_discovered_references(NULL, &pt);
|
2013-06-10 11:30:51 +02:00
|
|
|
}
|
2017-08-10 18:09:19 -07:00
|
|
|
|
|
|
|
pt.print_enqueue_phase();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2017-10-23 11:20:53 +02:00
|
|
|
assert(promotion_manager->stacks_empty(),"stacks should be empty at this point");
|
|
|
|
|
|
|
|
PSScavengeRootsClosure root_closure(promotion_manager);
|
|
|
|
|
2017-10-18 21:13:35 +02:00
|
|
|
{
|
|
|
|
GCTraceTime(Debug, gc, phases) tm("Weak Processing", &_gc_timer);
|
2017-10-23 11:20:53 +02:00
|
|
|
WeakProcessor::weak_oops_do(&_is_alive_closure, &root_closure);
|
2017-10-18 21:13:35 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 13:31:33 +01:00
|
|
|
{
|
2016-03-18 08:59:07 +01:00
|
|
|
GCTraceTime(Debug, gc, phases) tm("Scrub String Table", &_gc_timer);
|
2014-01-07 13:31:33 +01:00
|
|
|
// Unlink any dead interned Strings and process the remaining live ones.
|
|
|
|
StringTable::unlink_or_oops_do(&_is_alive_closure, &root_closure);
|
|
|
|
}
|
2011-03-22 13:36:33 -07:00
|
|
|
|
2017-10-23 11:20:53 +02:00
|
|
|
// Verify that usage of root_closure didn't copy any objects.
|
|
|
|
assert(promotion_manager->stacks_empty(),"stacks should be empty at this point");
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Finally, flush the promotion_manager's labs, and deallocate its stacks.
|
2013-06-10 11:30:51 +02:00
|
|
|
promotion_failure_occurred = PSPromotionManager::post_scavenge(_gc_tracer);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (promotion_failure_occurred) {
|
|
|
|
clean_up_failed_promotion();
|
2016-04-26 10:19:57 +02:00
|
|
|
log_info(gc, promotion)("Promotion failed");
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2015-10-08 12:47:17 +02:00
|
|
|
_gc_tracer.report_tenuring_threshold(tenuring_threshold());
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Let the size policy know we're done. Note that we count promotion
|
|
|
|
// failure cleanup time as part of the collection (otherwise, we're
|
|
|
|
// implicitly saying it's mutator time).
|
|
|
|
size_policy->minor_collection_end(gc_cause);
|
|
|
|
|
|
|
|
if (!promotion_failure_occurred) {
|
|
|
|
// Swap the survivor spaces.
|
2008-07-09 15:08:55 -07:00
|
|
|
young_gen->eden_space()->clear(SpaceDecorator::Mangle);
|
|
|
|
young_gen->from_space()->clear(SpaceDecorator::Mangle);
|
2007-12-01 00:00:00 +00:00
|
|
|
young_gen->swap_spaces();
|
|
|
|
|
|
|
|
size_t survived = young_gen->from_space()->used_in_bytes();
|
2015-12-10 14:57:55 +01:00
|
|
|
size_t promoted = old_gen->used_in_bytes() - pre_gc_values.old_gen_used();
|
2007-12-01 00:00:00 +00:00
|
|
|
size_policy->update_averages(_survivor_overflow, survived, promoted);
|
|
|
|
|
2010-04-13 13:52:10 -07:00
|
|
|
// A successful scavenge should restart the GC time limit count which is
|
|
|
|
// for full GC's.
|
|
|
|
size_policy->reset_gc_overhead_limit_count();
|
2007-12-01 00:00:00 +00:00
|
|
|
if (UseAdaptiveSizePolicy) {
|
|
|
|
// Calculate the new survivor size and tenuring threshold
|
|
|
|
|
2015-12-10 14:57:55 +01:00
|
|
|
log_debug(gc, ergo)("AdaptiveSizeStart: collection: %d ", heap->total_collections());
|
|
|
|
log_trace(gc, ergo)("old_gen_capacity: " SIZE_FORMAT " young_gen_capacity: " SIZE_FORMAT,
|
|
|
|
old_gen->capacity_in_bytes(), young_gen->capacity_in_bytes());
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (UsePerfData) {
|
|
|
|
PSGCAdaptivePolicyCounters* counters = heap->gc_policy_counters();
|
|
|
|
counters->update_old_eden_size(
|
|
|
|
size_policy->calculated_eden_size_in_bytes());
|
|
|
|
counters->update_old_promo_size(
|
|
|
|
size_policy->calculated_promo_size_in_bytes());
|
|
|
|
counters->update_old_capacity(old_gen->capacity_in_bytes());
|
|
|
|
counters->update_young_capacity(young_gen->capacity_in_bytes());
|
|
|
|
counters->update_survived(survived);
|
|
|
|
counters->update_promoted(promoted);
|
|
|
|
counters->update_survivor_overflowed(_survivor_overflow);
|
|
|
|
}
|
|
|
|
|
2014-01-29 23:17:05 +01:00
|
|
|
size_t max_young_size = young_gen->max_size();
|
|
|
|
|
|
|
|
// Deciding a free ratio in the young generation is tricky, so if
|
|
|
|
// MinHeapFreeRatio or MaxHeapFreeRatio are in use (implicating
|
|
|
|
// that the old generation size may have been limited because of them) we
|
|
|
|
// should then limit our young generation size using NewRatio to have it
|
|
|
|
// follow the old generation size.
|
|
|
|
if (MinHeapFreeRatio != 0 || MaxHeapFreeRatio != 100) {
|
|
|
|
max_young_size = MIN2(old_gen->capacity_in_bytes() / NewRatio, young_gen->max_size());
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
size_t survivor_limit =
|
2014-01-29 23:17:05 +01:00
|
|
|
size_policy->max_survivor_size(max_young_size);
|
2007-12-01 00:00:00 +00:00
|
|
|
_tenuring_threshold =
|
|
|
|
size_policy->compute_survivor_space_size_and_threshold(
|
|
|
|
_survivor_overflow,
|
|
|
|
_tenuring_threshold,
|
|
|
|
survivor_limit);
|
|
|
|
|
2015-12-10 14:57:55 +01:00
|
|
|
log_debug(gc, age)("Desired survivor size " SIZE_FORMAT " bytes, new threshold %u (max threshold " UINTX_FORMAT ")",
|
|
|
|
size_policy->calculated_survivor_size_in_bytes(),
|
|
|
|
_tenuring_threshold, MaxTenuringThreshold);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (UsePerfData) {
|
|
|
|
PSGCAdaptivePolicyCounters* counters = heap->gc_policy_counters();
|
|
|
|
counters->update_tenuring_threshold(_tenuring_threshold);
|
|
|
|
counters->update_survivor_size_counters();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do call at minor collections?
|
|
|
|
// Don't check if the size_policy is ready at this
|
|
|
|
// level. Let the size_policy check that internally.
|
2014-01-29 23:17:05 +01:00
|
|
|
if (UseAdaptiveGenerationSizePolicyAtMinorCollection &&
|
2015-04-15 11:30:36 -07:00
|
|
|
(AdaptiveSizePolicy::should_update_eden_stats(gc_cause))) {
|
2014-01-23 14:47:23 +01:00
|
|
|
// Calculate optimal free space amounts
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(young_gen->max_size() >
|
|
|
|
young_gen->from_space()->capacity_in_bytes() +
|
|
|
|
young_gen->to_space()->capacity_in_bytes(),
|
|
|
|
"Sizes of space in young gen are out-of-bounds");
|
2013-05-15 10:41:22 -07:00
|
|
|
|
|
|
|
size_t young_live = young_gen->used_in_bytes();
|
|
|
|
size_t eden_live = young_gen->eden_space()->used_in_bytes();
|
|
|
|
size_t cur_eden = young_gen->eden_space()->capacity_in_bytes();
|
|
|
|
size_t max_old_gen_size = old_gen->max_gen_size();
|
2014-01-29 23:17:05 +01:00
|
|
|
size_t max_eden_size = max_young_size -
|
2007-12-01 00:00:00 +00:00
|
|
|
young_gen->from_space()->capacity_in_bytes() -
|
|
|
|
young_gen->to_space()->capacity_in_bytes();
|
|
|
|
|
2013-05-15 10:41:22 -07:00
|
|
|
// Used for diagnostics
|
|
|
|
size_policy->clear_generation_free_space_flags();
|
|
|
|
|
|
|
|
size_policy->compute_eden_space_size(young_live,
|
|
|
|
eden_live,
|
|
|
|
cur_eden,
|
|
|
|
max_eden_size,
|
|
|
|
false /* not full gc*/);
|
|
|
|
|
|
|
|
size_policy->check_gc_overhead_limit(young_live,
|
|
|
|
eden_live,
|
|
|
|
max_old_gen_size,
|
|
|
|
max_eden_size,
|
|
|
|
false /* not full gc*/,
|
|
|
|
gc_cause,
|
2018-02-22 18:36:07 +01:00
|
|
|
heap->soft_ref_policy());
|
2013-05-15 10:41:22 -07:00
|
|
|
|
|
|
|
size_policy->decay_supplemental_growth(false /* not full gc*/);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
// Resize the young generation at every collection
|
|
|
|
// even if new sizes have not been calculated. This is
|
|
|
|
// to allow resizes that may have been inhibited by the
|
|
|
|
// relative location of the "to" and "from" spaces.
|
|
|
|
|
2015-08-18 21:32:21 +02:00
|
|
|
// Resizing the old gen at young collections can cause increases
|
2007-12-01 00:00:00 +00:00
|
|
|
// that don't feed back to the generation sizing policy until
|
2015-08-18 21:32:21 +02:00
|
|
|
// a full collection. Don't resize the old gen here.
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
heap->resize_young_gen(size_policy->calculated_eden_size_in_bytes(),
|
|
|
|
size_policy->calculated_survivor_size_in_bytes());
|
|
|
|
|
2015-12-10 14:57:55 +01:00
|
|
|
log_debug(gc, ergo)("AdaptiveSizeStop: collection: %d ", heap->total_collections());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update the structure of the eden. With NUMA-eden CPU hotplugging or offlining can
|
|
|
|
// cause the change of the heap layout. Make sure eden is reshaped if that's the case.
|
|
|
|
// Also update() will case adaptive NUMA chunk resizing.
|
|
|
|
assert(young_gen->eden_space()->is_empty(), "eden space should be empty now");
|
|
|
|
young_gen->eden_space()->update();
|
|
|
|
|
|
|
|
heap->gc_policy_counters()->update_counters();
|
|
|
|
|
|
|
|
heap->resize_all_tlabs();
|
|
|
|
|
|
|
|
assert(young_gen->to_space()->is_empty(), "to space should be empty now");
|
|
|
|
}
|
|
|
|
|
2017-11-06 21:28:03 -08:00
|
|
|
#if COMPILER2_OR_JVMCI
|
2015-10-08 12:49:30 -10:00
|
|
|
DerivedPointerTable::update_pointers();
|
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
NOT_PRODUCT(reference_processor()->verify_no_references_recorded());
|
2012-02-10 17:40:20 -08:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Re-verify object start arrays
|
|
|
|
if (VerifyObjectStartArray &&
|
|
|
|
VerifyAfterGC) {
|
|
|
|
old_gen->verify_object_start_array();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verify all old -> young cards are now precise
|
|
|
|
if (VerifyRememberedSets) {
|
|
|
|
// Precise verification will give false positives. Until this is fixed,
|
|
|
|
// use imprecise verification.
|
2018-02-26 09:34:12 +01:00
|
|
|
// heap->card_table()->verify_all_young_refs_precise();
|
|
|
|
heap->card_table()->verify_all_young_refs_imprecise();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2017-09-21 14:32:05 +02:00
|
|
|
if (log_is_enabled(Debug, gc, heap, exit)) {
|
|
|
|
accumulated_time()->stop();
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2015-12-10 14:57:55 +01:00
|
|
|
young_gen->print_used_change(pre_gc_values.young_gen_used());
|
|
|
|
old_gen->print_used_change(pre_gc_values.old_gen_used());
|
|
|
|
MetaspaceAux::print_metaspace_change(pre_gc_values.metadata_used());
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Track memory usage and detect low memory
|
|
|
|
MemoryService::track_memory_usage();
|
|
|
|
heap->update_counters();
|
2011-08-09 10:16:01 -07:00
|
|
|
|
|
|
|
gc_task_manager()->release_idle_workers();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (VerifyAfterGC && heap->total_collections() >= VerifyGCStartAt) {
|
|
|
|
HandleMark hm; // Discard invalid handles created during verification
|
2015-12-10 14:57:55 +01:00
|
|
|
Universe::verify("After GC");
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2012-02-01 07:59:01 -08:00
|
|
|
heap->print_heap_after_gc();
|
2013-06-10 11:30:51 +02:00
|
|
|
heap->trace_heap_after_gc(&_gc_tracer);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
scavenge_exit.update();
|
|
|
|
|
2015-12-10 14:57:55 +01:00
|
|
|
log_debug(gc, task, time)("VM-Thread " JLONG_FORMAT " " JLONG_FORMAT " " JLONG_FORMAT,
|
|
|
|
scavenge_entry.ticks(), scavenge_midpoint.ticks(),
|
|
|
|
scavenge_exit.ticks());
|
|
|
|
gc_task_manager()->print_task_time_stamps();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2009-02-08 13:18:01 -08:00
|
|
|
#ifdef TRACESPINNING
|
|
|
|
ParallelTaskTerminator::print_termination_counts();
|
|
|
|
#endif
|
|
|
|
|
2015-12-10 14:57:55 +01:00
|
|
|
AdaptiveSizePolicyOutput::print(size_policy, heap->total_collections());
|
2013-06-10 11:30:51 +02:00
|
|
|
|
2013-11-23 12:25:13 +01:00
|
|
|
_gc_timer.register_gc_end();
|
2013-06-10 11:30:51 +02:00
|
|
|
|
|
|
|
_gc_tracer.report_gc_end(_gc_timer.gc_end(), _gc_timer.time_partitions());
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
return !promotion_failure_occurred;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This method iterates over all objects in the young generation,
|
2016-03-09 09:45:47 +01:00
|
|
|
// removing all forwarding references. It then restores any preserved marks.
|
2007-12-01 00:00:00 +00:00
|
|
|
void PSScavenge::clean_up_failed_promotion() {
|
2015-04-13 15:47:48 +02:00
|
|
|
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
|
2007-12-01 00:00:00 +00:00
|
|
|
PSYoungGen* young_gen = heap->young_gen();
|
|
|
|
|
2016-03-09 09:45:47 +01:00
|
|
|
RemoveForwardedPointerClosure remove_fwd_ptr_closure;
|
|
|
|
young_gen->object_iterate(&remove_fwd_ptr_closure);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-03-09 09:45:47 +01:00
|
|
|
PSPromotionManager::restore_preserved_marks();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Reset the PromotionFailureALot counters.
|
2015-04-13 15:47:48 +02:00
|
|
|
NOT_PRODUCT(heap->reset_promotion_should_fail();)
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool PSScavenge::should_attempt_scavenge() {
|
2015-04-13 15:47:48 +02:00
|
|
|
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
|
2007-12-01 00:00:00 +00:00
|
|
|
PSGCAdaptivePolicyCounters* counters = heap->gc_policy_counters();
|
|
|
|
|
|
|
|
if (UsePerfData) {
|
|
|
|
counters->update_scavenge_skipped(not_skipped);
|
|
|
|
}
|
|
|
|
|
|
|
|
PSYoungGen* young_gen = heap->young_gen();
|
|
|
|
PSOldGen* old_gen = heap->old_gen();
|
|
|
|
|
2015-10-16 14:11:29 +02:00
|
|
|
// Do not attempt to promote unless to_space is empty
|
|
|
|
if (!young_gen->to_space()->is_empty()) {
|
|
|
|
_consecutive_skipped_scavenges++;
|
|
|
|
if (UsePerfData) {
|
|
|
|
counters->update_scavenge_skipped(to_space_not_empty);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2015-10-16 14:11:29 +02:00
|
|
|
return false;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Test to see if the scavenge will likely fail.
|
|
|
|
PSAdaptiveSizePolicy* policy = heap->size_policy();
|
|
|
|
|
|
|
|
// A similar test is done in the policy's should_full_GC(). If this is
|
|
|
|
// changed, decide if that test should also be changed.
|
|
|
|
size_t avg_promoted = (size_t) policy->padded_average_promoted_in_bytes();
|
|
|
|
size_t promotion_estimate = MIN2(avg_promoted, young_gen->used_in_bytes());
|
|
|
|
bool result = promotion_estimate < old_gen->free_in_bytes();
|
|
|
|
|
2015-12-10 14:57:55 +01:00
|
|
|
log_trace(ergo)("%s scavenge: average_promoted " SIZE_FORMAT " padded_average_promoted " SIZE_FORMAT " free in old gen " SIZE_FORMAT,
|
|
|
|
result ? "Do" : "Skip", (size_t) policy->average_promoted_in_bytes(),
|
|
|
|
(size_t) policy->padded_average_promoted_in_bytes(),
|
|
|
|
old_gen->free_in_bytes());
|
|
|
|
if (young_gen->used_in_bytes() < (size_t) policy->padded_average_promoted_in_bytes()) {
|
|
|
|
log_trace(ergo)(" padded_promoted_average is greater than maximum promotion = " SIZE_FORMAT, young_gen->used_in_bytes());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
_consecutive_skipped_scavenges = 0;
|
|
|
|
} else {
|
|
|
|
_consecutive_skipped_scavenges++;
|
|
|
|
if (UsePerfData) {
|
|
|
|
counters->update_scavenge_skipped(promoted_too_large);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Used to add tasks
|
|
|
|
GCTaskManager* const PSScavenge::gc_task_manager() {
|
|
|
|
assert(ParallelScavengeHeap::gc_task_manager() != NULL,
|
|
|
|
"shouldn't return NULL");
|
|
|
|
return ParallelScavengeHeap::gc_task_manager();
|
|
|
|
}
|
|
|
|
|
2016-01-18 10:25:41 +01:00
|
|
|
// Adaptive size policy support. When the young generation/old generation
|
|
|
|
// boundary moves, _young_generation_boundary must be reset
|
|
|
|
void PSScavenge::set_young_generation_boundary(HeapWord* v) {
|
|
|
|
_young_generation_boundary = v;
|
|
|
|
if (UseCompressedOops) {
|
|
|
|
_young_generation_boundary_compressed = (uintptr_t)oopDesc::encode_heap_oop((oop)v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
void PSScavenge::initialize() {
|
|
|
|
// Arguments must have been parsed
|
|
|
|
|
2014-03-26 12:49:34 +01:00
|
|
|
if (AlwaysTenure || NeverTenure) {
|
|
|
|
assert(MaxTenuringThreshold == 0 || MaxTenuringThreshold == markOopDesc::max_age + 1,
|
2015-09-29 11:02:08 +02:00
|
|
|
"MaxTenuringThreshold should be 0 or markOopDesc::max_age + 1, but is %d", (int) MaxTenuringThreshold);
|
2014-03-26 12:49:34 +01:00
|
|
|
_tenuring_threshold = MaxTenuringThreshold;
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
|
|
|
// We want to smooth out our startup times for the AdaptiveSizePolicy
|
|
|
|
_tenuring_threshold = (UseAdaptiveSizePolicy) ? InitialTenuringThreshold :
|
|
|
|
MaxTenuringThreshold;
|
|
|
|
}
|
|
|
|
|
2015-04-13 15:47:48 +02:00
|
|
|
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
|
2007-12-01 00:00:00 +00:00
|
|
|
PSYoungGen* young_gen = heap->young_gen();
|
|
|
|
PSOldGen* old_gen = heap->old_gen();
|
|
|
|
|
|
|
|
// Set boundary between young_gen and old_gen
|
|
|
|
assert(old_gen->reserved().end() <= young_gen->eden_space()->bottom(),
|
|
|
|
"old above young");
|
2013-05-30 10:58:16 +02:00
|
|
|
set_young_generation_boundary(young_gen->eden_space()->bottom());
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Initialize ref handling object for scavenging.
|
|
|
|
MemRegion mr = young_gen->reserved();
|
2011-08-09 10:16:01 -07:00
|
|
|
|
2011-03-17 10:32:46 -07:00
|
|
|
_ref_processor =
|
|
|
|
new ReferenceProcessor(mr, // span
|
|
|
|
ParallelRefProcEnabled && (ParallelGCThreads > 1), // mt processing
|
2015-06-05 09:50:09 +02:00
|
|
|
ParallelGCThreads, // mt processing degree
|
2011-03-17 10:32:46 -07:00
|
|
|
true, // mt discovery
|
2015-06-05 09:50:09 +02:00
|
|
|
ParallelGCThreads, // mt discovery degree
|
2011-03-17 10:32:46 -07:00
|
|
|
true, // atomic_discovery
|
2014-06-03 10:44:36 +02:00
|
|
|
NULL); // header provides liveness info
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Cache the cardtable
|
2018-02-26 09:34:12 +01:00
|
|
|
_card_table = heap->card_table();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
_counters = new CollectorCounters("PSScavenge", 0);
|
|
|
|
}
|