comparison src/share/vm/gc_implementation/g1/g1MarkSweep.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 8651a65ac4b4
children 27a80744a83b
comparison
equal deleted inserted replaced
452:00b023ae2d78 453:c96030fff130
31 bool clear_all_softrefs) { 31 bool clear_all_softrefs) {
32 assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint"); 32 assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint");
33 33
34 // hook up weak ref data so it can be used during Mark-Sweep 34 // hook up weak ref data so it can be used during Mark-Sweep
35 assert(GenMarkSweep::ref_processor() == NULL, "no stomping"); 35 assert(GenMarkSweep::ref_processor() == NULL, "no stomping");
36 assert(rp != NULL, "should be non-NULL");
36 GenMarkSweep::_ref_processor = rp; 37 GenMarkSweep::_ref_processor = rp;
37 assert(rp != NULL, "should be non-NULL"); 38 rp->snap_policy(clear_all_softrefs);
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.
41 CodeCache::gc_prologue(); 42 CodeCache::gc_prologue();
42 Threads::gc_prologue(); 43 Threads::gc_prologue();
119 SharedHeap::SO_SystemClasses, 120 SharedHeap::SO_SystemClasses,
120 &GenMarkSweep::follow_root_closure, 121 &GenMarkSweep::follow_root_closure,
121 &GenMarkSweep::follow_root_closure); 122 &GenMarkSweep::follow_root_closure);
122 123
123 // Process reference objects found during marking 124 // Process reference objects found during marking
124 ReferencePolicy *soft_ref_policy; 125 ReferenceProcessor* rp = GenMarkSweep::ref_processor();
125 if (clear_all_softrefs) { 126 rp->snap_policy(clear_all_softrefs);
126 soft_ref_policy = new AlwaysClearPolicy(); 127 rp->process_discovered_references(&GenMarkSweep::is_alive,
127 } else { 128 &GenMarkSweep::keep_alive,
128 #ifdef COMPILER2 129 &GenMarkSweep::follow_stack_closure,
129 soft_ref_policy = new LRUMaxHeapPolicy(); 130 NULL);
130 #else
131 soft_ref_policy = new LRUCurrentHeapPolicy();
132 #endif
133 }
134 assert(soft_ref_policy != NULL,"No soft reference policy");
135 GenMarkSweep::ref_processor()->process_discovered_references(
136 soft_ref_policy,
137 &GenMarkSweep::is_alive,
138 &GenMarkSweep::keep_alive,
139 &GenMarkSweep::follow_stack_closure,
140 NULL);
141 131
142 // Follow system dictionary roots and unload classes 132 // Follow system dictionary roots and unload classes
143 bool purged_class = SystemDictionary::do_unloading(&GenMarkSweep::is_alive); 133 bool purged_class = SystemDictionary::do_unloading(&GenMarkSweep::is_alive);
144 assert(GenMarkSweep::_marking_stack->is_empty(), 134 assert(GenMarkSweep::_marking_stack->is_empty(),
145 "stack should be empty by now"); 135 "stack should be empty by now");