6684579: SoftReference processing can be made more efficient

For current soft-ref clearing policies, we can decide at marking time if a soft-reference will definitely not be cleared, postponing the decision of whether it will definitely be cleared to the final reference processing phase. This can be especially beneficial in the case of concurrent collectors where the marking is usually concurrent but reference processing is usually not.

Reviewed-by: jmasa
This commit is contained in:
Y. Srinivas Ramakrishna 2008-11-20 16:56:09 -08:00
parent db6bef2c70
commit 7d7cf3f8af
18 changed files with 137 additions and 164 deletions

View file

@ -759,17 +759,12 @@ void ParNewGeneration::collect(bool full,
thread_state_set.steals(),
thread_state_set.pops()+thread_state_set.steals());
}
assert(thread_state_set.pushes() == thread_state_set.pops() + thread_state_set.steals(),
assert(thread_state_set.pushes() == thread_state_set.pops()
+ thread_state_set.steals(),
"Or else the queues are leaky.");
// For now, process discovered weak refs sequentially.
#ifdef COMPILER2
ReferencePolicy *soft_ref_policy = new LRUMaxHeapPolicy();
#else
ReferencePolicy *soft_ref_policy = new LRUCurrentHeapPolicy();
#endif // COMPILER2
// Process (weak) reference objects found during scavenge.
ReferenceProcessor* rp = ref_processor();
IsAliveClosure is_alive(this);
ScanWeakRefClosure scan_weak_ref(this);
KeepAliveClosure keep_alive(&scan_weak_ref);
@ -778,18 +773,17 @@ void ParNewGeneration::collect(bool full,
set_promo_failure_scan_stack_closure(&scan_without_gc_barrier);
EvacuateFollowersClosureGeneral evacuate_followers(gch, _level,
&scan_without_gc_barrier, &scan_with_gc_barrier);
if (ref_processor()->processing_is_mt()) {
rp->snap_policy(clear_all_soft_refs);
if (rp->processing_is_mt()) {
ParNewRefProcTaskExecutor task_executor(*this, thread_state_set);
ref_processor()->process_discovered_references(
soft_ref_policy, &is_alive, &keep_alive, &evacuate_followers,
&task_executor);
rp->process_discovered_references(&is_alive, &keep_alive,
&evacuate_followers, &task_executor);
} else {
thread_state_set.flush();
gch->set_par_threads(0); // 0 ==> non-parallel.
gch->save_marks();
ref_processor()->process_discovered_references(
soft_ref_policy, &is_alive, &keep_alive, &evacuate_followers,
NULL);
rp->process_discovered_references(&is_alive, &keep_alive,
&evacuate_followers, NULL);
}
if (!promotion_failed()) {
// Swap the survivor spaces.
@ -851,14 +845,14 @@ void ParNewGeneration::collect(bool full,
SpecializationStats::print();
ref_processor()->set_enqueuing_is_done(true);
if (ref_processor()->processing_is_mt()) {
rp->set_enqueuing_is_done(true);
if (rp->processing_is_mt()) {
ParNewRefProcTaskExecutor task_executor(*this, thread_state_set);
ref_processor()->enqueue_discovered_references(&task_executor);
rp->enqueue_discovered_references(&task_executor);
} else {
ref_processor()->enqueue_discovered_references(NULL);
rp->enqueue_discovered_references(NULL);
}
ref_processor()->verify_no_references_recorded();
rp->verify_no_references_recorded();
}
static int sum;