comparison src/share/vm/gc_implementation/g1/concurrentMark.cpp @ 2361:1216415d8e35

7014923: G1: code cleanup Summary: Some G1 code cleanup. Reviewed-by: johnc, jcoomes, jwilhelm
author tonyp
date Fri, 04 Mar 2011 17:13:19 -0500
parents 3582bf76420e
children 92da084fefc9
comparison
equal deleted inserted replaced
2312:11303bede852 2361:1216415d8e35
1826 if (has_aborted()) return; 1826 if (has_aborted()) return;
1827 1827
1828 G1CollectedHeap* g1h = G1CollectedHeap::heap(); 1828 G1CollectedHeap* g1h = G1CollectedHeap::heap();
1829 1829
1830 _cleanup_list.verify_optional(); 1830 _cleanup_list.verify_optional();
1831 FreeRegionList local_free_list("Local Cleanup List"); 1831 FreeRegionList tmp_free_list("Tmp Free List");
1832 1832
1833 if (G1ConcRegionFreeingVerbose) { 1833 if (G1ConcRegionFreeingVerbose) {
1834 gclog_or_tty->print_cr("G1ConcRegionFreeing [complete cleanup] : " 1834 gclog_or_tty->print_cr("G1ConcRegionFreeing [complete cleanup] : "
1835 "cleanup list has "SIZE_FORMAT" entries", 1835 "cleanup list has "SIZE_FORMAT" entries",
1836 _cleanup_list.length()); 1836 _cleanup_list.length());
1840 // so it's not necessary to take any locks 1840 // so it's not necessary to take any locks
1841 while (!_cleanup_list.is_empty()) { 1841 while (!_cleanup_list.is_empty()) {
1842 HeapRegion* hr = _cleanup_list.remove_head(); 1842 HeapRegion* hr = _cleanup_list.remove_head();
1843 assert(hr != NULL, "the list was not empty"); 1843 assert(hr != NULL, "the list was not empty");
1844 hr->rem_set()->clear(); 1844 hr->rem_set()->clear();
1845 local_free_list.add_as_tail(hr); 1845 tmp_free_list.add_as_tail(hr);
1846 1846
1847 // Instead of adding one region at a time to the secondary_free_list, 1847 // Instead of adding one region at a time to the secondary_free_list,
1848 // we accumulate them in the local list and move them a few at a 1848 // we accumulate them in the local list and move them a few at a
1849 // time. This also cuts down on the number of notify_all() calls 1849 // time. This also cuts down on the number of notify_all() calls
1850 // we do during this process. We'll also append the local list when 1850 // we do during this process. We'll also append the local list when
1851 // _cleanup_list is empty (which means we just removed the last 1851 // _cleanup_list is empty (which means we just removed the last
1852 // region from the _cleanup_list). 1852 // region from the _cleanup_list).
1853 if ((local_free_list.length() % G1SecondaryFreeListAppendLength == 0) || 1853 if ((tmp_free_list.length() % G1SecondaryFreeListAppendLength == 0) ||
1854 _cleanup_list.is_empty()) { 1854 _cleanup_list.is_empty()) {
1855 if (G1ConcRegionFreeingVerbose) { 1855 if (G1ConcRegionFreeingVerbose) {
1856 gclog_or_tty->print_cr("G1ConcRegionFreeing [complete cleanup] : " 1856 gclog_or_tty->print_cr("G1ConcRegionFreeing [complete cleanup] : "
1857 "appending "SIZE_FORMAT" entries to the " 1857 "appending "SIZE_FORMAT" entries to the "
1858 "secondary_free_list, clean list still has " 1858 "secondary_free_list, clean list still has "
1859 SIZE_FORMAT" entries", 1859 SIZE_FORMAT" entries",
1860 local_free_list.length(), 1860 tmp_free_list.length(),
1861 _cleanup_list.length()); 1861 _cleanup_list.length());
1862 } 1862 }
1863 1863
1864 { 1864 {
1865 MutexLockerEx x(SecondaryFreeList_lock, Mutex::_no_safepoint_check_flag); 1865 MutexLockerEx x(SecondaryFreeList_lock, Mutex::_no_safepoint_check_flag);
1866 g1h->secondary_free_list_add_as_tail(&local_free_list); 1866 g1h->secondary_free_list_add_as_tail(&tmp_free_list);
1867 SecondaryFreeList_lock->notify_all(); 1867 SecondaryFreeList_lock->notify_all();
1868 } 1868 }
1869 1869
1870 if (G1StressConcRegionFreeing) { 1870 if (G1StressConcRegionFreeing) {
1871 for (uintx i = 0; i < G1StressConcRegionFreeingDelayMillis; ++i) { 1871 for (uintx i = 0; i < G1StressConcRegionFreeingDelayMillis; ++i) {
1872 os::sleep(Thread::current(), (jlong) 1, false); 1872 os::sleep(Thread::current(), (jlong) 1, false);
1873 } 1873 }
1874 } 1874 }
1875 } 1875 }
1876 } 1876 }
1877 assert(local_free_list.is_empty(), "post-condition"); 1877 assert(tmp_free_list.is_empty(), "post-condition");
1878 } 1878 }
1879 1879
1880 // Support closures for reference procssing in G1 1880 // Support closures for reference procssing in G1
1881 1881
1882 bool G1CMIsAliveClosure::do_object_b(oop obj) { 1882 bool G1CMIsAliveClosure::do_object_b(oop obj) {
3180 virtual void do_oop(narrowOop* p) { do_oop_work(p); } 3180 virtual void do_oop(narrowOop* p) { do_oop_work(p); }
3181 virtual void do_oop( oop* p) { do_oop_work(p); } 3181 virtual void do_oop( oop* p) { do_oop_work(p); }
3182 3182
3183 template <class T> void do_oop_work(T* p) { 3183 template <class T> void do_oop_work(T* p) {
3184 assert( _g1h->is_in_g1_reserved((HeapWord*) p), "invariant"); 3184 assert( _g1h->is_in_g1_reserved((HeapWord*) p), "invariant");
3185 assert(!_g1h->is_on_free_list( 3185 assert(!_g1h->is_on_master_free_list(
3186 _g1h->heap_region_containing((HeapWord*) p)), "invariant"); 3186 _g1h->heap_region_containing((HeapWord*) p)), "invariant");
3187 3187
3188 oop obj = oopDesc::load_decode_heap_oop(p); 3188 oop obj = oopDesc::load_decode_heap_oop(p);
3189 if (_cm->verbose_high()) 3189 if (_cm->verbose_high())
3190 gclog_or_tty->print_cr("[%d] we're looking at location " 3190 gclog_or_tty->print_cr("[%d] we're looking at location "
3401 } 3401 }
3402 3402
3403 void CMTask::push(oop obj) { 3403 void CMTask::push(oop obj) {
3404 HeapWord* objAddr = (HeapWord*) obj; 3404 HeapWord* objAddr = (HeapWord*) obj;
3405 assert(_g1h->is_in_g1_reserved(objAddr), "invariant"); 3405 assert(_g1h->is_in_g1_reserved(objAddr), "invariant");
3406 assert(!_g1h->is_on_free_list( 3406 assert(!_g1h->is_on_master_free_list(
3407 _g1h->heap_region_containing((HeapWord*) objAddr)), "invariant"); 3407 _g1h->heap_region_containing((HeapWord*) objAddr)), "invariant");
3408 assert(!_g1h->is_obj_ill(obj), "invariant"); 3408 assert(!_g1h->is_obj_ill(obj), "invariant");
3409 assert(_nextMarkBitMap->isMarked(objAddr), "invariant"); 3409 assert(_nextMarkBitMap->isMarked(objAddr), "invariant");
3410 3410
3411 if (_cm->verbose_high()) 3411 if (_cm->verbose_high())
3647 if (_cm->verbose_high()) 3647 if (_cm->verbose_high())
3648 gclog_or_tty->print_cr("[%d] popped "PTR_FORMAT, _task_id, 3648 gclog_or_tty->print_cr("[%d] popped "PTR_FORMAT, _task_id,
3649 (void*) obj); 3649 (void*) obj);
3650 3650
3651 assert(_g1h->is_in_g1_reserved((HeapWord*) obj), "invariant" ); 3651 assert(_g1h->is_in_g1_reserved((HeapWord*) obj), "invariant" );
3652 assert(!_g1h->is_on_free_list( 3652 assert(!_g1h->is_on_master_free_list(
3653 _g1h->heap_region_containing((HeapWord*) obj)), "invariant"); 3653 _g1h->heap_region_containing((HeapWord*) obj)), "invariant");
3654 3654
3655 scan_object(obj); 3655 scan_object(obj);
3656 3656
3657 if (_task_queue->size() <= target_size || has_aborted()) 3657 if (_task_queue->size() <= target_size || has_aborted())