comparison src/share/vm/memory/genMarkSweep.cpp @ 453:c96030fff130

6684579: SoftReference processing can be made more efficient Summary: 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
author ysr
date Thu, 20 Nov 2008 16:56:09 -0800
parents 1ee8caae33af
children 27a80744a83b
comparison
equal deleted inserted replaced
452:00b023ae2d78 453:c96030fff130
29 bool clear_all_softrefs) { 29 bool clear_all_softrefs) {
30 assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint"); 30 assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint");
31 31
32 // hook up weak ref data so it can be used during Mark-Sweep 32 // hook up weak ref data so it can be used during Mark-Sweep
33 assert(ref_processor() == NULL, "no stomping"); 33 assert(ref_processor() == NULL, "no stomping");
34 assert(rp != NULL, "should be non-NULL");
34 _ref_processor = rp; 35 _ref_processor = rp;
35 assert(rp != NULL, "should be non-NULL"); 36 rp->snap_policy(clear_all_softrefs);
36 37
37 TraceTime t1("Full GC", PrintGC && !PrintGCDetails, true, gclog_or_tty); 38 TraceTime t1("Full GC", PrintGC && !PrintGCDetails, true, gclog_or_tty);
38 39
39 // When collecting the permanent generation methodOops may be moving, 40 // When collecting the permanent generation methodOops may be moving,
40 // so we either have to flush all bcp data or convert it into bci. 41 // so we either have to flush all bcp data or convert it into bci.
243 SharedHeap::SO_SystemClasses, 244 SharedHeap::SO_SystemClasses,
244 &follow_root_closure, &follow_root_closure); 245 &follow_root_closure, &follow_root_closure);
245 246
246 // Process reference objects found during marking 247 // Process reference objects found during marking
247 { 248 {
248 ReferencePolicy *soft_ref_policy; 249 ref_processor()->snap_policy(clear_all_softrefs);
249 if (clear_all_softrefs) {
250 soft_ref_policy = new AlwaysClearPolicy();
251 } else {
252 #ifdef COMPILER2
253 soft_ref_policy = new LRUMaxHeapPolicy();
254 #else
255 soft_ref_policy = new LRUCurrentHeapPolicy();
256 #endif // COMPILER2
257 }
258 assert(soft_ref_policy != NULL,"No soft reference policy");
259 ref_processor()->process_discovered_references( 250 ref_processor()->process_discovered_references(
260 soft_ref_policy, &is_alive, &keep_alive, 251 &is_alive, &keep_alive, &follow_stack_closure, NULL);
261 &follow_stack_closure, NULL);
262 } 252 }
263 253
264 // Follow system dictionary roots and unload classes 254 // Follow system dictionary roots and unload classes
265 bool purged_class = SystemDictionary::do_unloading(&is_alive); 255 bool purged_class = SystemDictionary::do_unloading(&is_alive);
266 256