comparison src/share/vm/gc_implementation/g1/concurrentMark.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 0edda524b58c
children 27a80744a83b
comparison
equal deleted inserted replaced
452:00b023ae2d78 453:c96030fff130
809 809
810 // Start weak-reference discovery. 810 // Start weak-reference discovery.
811 ReferenceProcessor* rp = g1h->ref_processor(); 811 ReferenceProcessor* rp = g1h->ref_processor();
812 rp->verify_no_references_recorded(); 812 rp->verify_no_references_recorded();
813 rp->enable_discovery(); // enable ("weak") refs discovery 813 rp->enable_discovery(); // enable ("weak") refs discovery
814 rp->snap_policy(false); // snapshot the soft ref policy to be used in this cycle
814 815
815 SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set(); 816 SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set();
816 satb_mq_set.set_process_completed_threshold(G1SATBProcessCompletedThreshold); 817 satb_mq_set.set_process_completed_threshold(G1SATBProcessCompletedThreshold);
817 satb_mq_set.set_active_all_threads(true); 818 satb_mq_set.set_active_all_threads(true);
818 819
1827 }; 1828 };
1828 1829
1829 void ConcurrentMark::weakRefsWork(bool clear_all_soft_refs) { 1830 void ConcurrentMark::weakRefsWork(bool clear_all_soft_refs) {
1830 ResourceMark rm; 1831 ResourceMark rm;
1831 HandleMark hm; 1832 HandleMark hm;
1832 ReferencePolicy* soft_ref_policy; 1833 G1CollectedHeap* g1h = G1CollectedHeap::heap();
1834 ReferenceProcessor* rp = g1h->ref_processor();
1833 1835
1834 // Process weak references. 1836 // Process weak references.
1835 if (clear_all_soft_refs) { 1837 rp->snap_policy(clear_all_soft_refs);
1836 soft_ref_policy = new AlwaysClearPolicy();
1837 } else {
1838 #ifdef COMPILER2
1839 soft_ref_policy = new LRUMaxHeapPolicy();
1840 #else
1841 soft_ref_policy = new LRUCurrentHeapPolicy();
1842 #endif
1843 }
1844 assert(_markStack.isEmpty(), "mark stack should be empty"); 1838 assert(_markStack.isEmpty(), "mark stack should be empty");
1845 1839
1846 G1CollectedHeap* g1 = G1CollectedHeap::heap(); 1840 G1CMIsAliveClosure g1IsAliveClosure (g1h);
1847 G1CMIsAliveClosure g1IsAliveClosure(g1); 1841 G1CMKeepAliveClosure g1KeepAliveClosure(g1h, this, nextMarkBitMap());
1848
1849 G1CMKeepAliveClosure g1KeepAliveClosure(g1, this, nextMarkBitMap());
1850 G1CMDrainMarkingStackClosure 1842 G1CMDrainMarkingStackClosure
1851 g1DrainMarkingStackClosure(nextMarkBitMap(), &_markStack, 1843 g1DrainMarkingStackClosure(nextMarkBitMap(), &_markStack,
1852 &g1KeepAliveClosure); 1844 &g1KeepAliveClosure);
1853 1845
1854 // XXXYYY Also: copy the parallel ref processing code from CMS. 1846 // XXXYYY Also: copy the parallel ref processing code from CMS.
1855 ReferenceProcessor* rp = g1->ref_processor(); 1847 rp->process_discovered_references(&g1IsAliveClosure,
1856 rp->process_discovered_references(soft_ref_policy,
1857 &g1IsAliveClosure,
1858 &g1KeepAliveClosure, 1848 &g1KeepAliveClosure,
1859 &g1DrainMarkingStackClosure, 1849 &g1DrainMarkingStackClosure,
1860 NULL); 1850 NULL);
1861 assert(_markStack.overflow() || _markStack.isEmpty(), 1851 assert(_markStack.overflow() || _markStack.isEmpty(),
1862 "mark stack should be empty (unless it overflowed)"); 1852 "mark stack should be empty (unless it overflowed)");