comparison src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp @ 12:6432c3bb6240

6668743: CMS: Consolidate block statistics reporting code Summary: Reduce the amount of related code replication and improve pretty printing. Reviewed-by: jmasa
author ysr
date Fri, 29 Feb 2008 14:42:56 -0800
parents a61af66fc99e
children ba764ed4b6f2
comparison
equal deleted inserted replaced
11:3c1dbcaaab1d 12:6432c3bb6240
1833 void CompactibleFreeListSpace::object_iterate_since_last_GC(ObjectClosure* cl) { 1833 void CompactibleFreeListSpace::object_iterate_since_last_GC(ObjectClosure* cl) {
1834 // ugghh... how would one do this efficiently for a non-contiguous space? 1834 // ugghh... how would one do this efficiently for a non-contiguous space?
1835 guarantee(false, "NYI"); 1835 guarantee(false, "NYI");
1836 } 1836 }
1837 1837
1838 bool CompactibleFreeListSpace::linearAllocationWouldFail() { 1838 bool CompactibleFreeListSpace::linearAllocationWouldFail() const {
1839 return _smallLinearAllocBlock._word_size == 0; 1839 return _smallLinearAllocBlock._word_size == 0;
1840 } 1840 }
1841 1841
1842 void CompactibleFreeListSpace::repairLinearAllocationBlocks() { 1842 void CompactibleFreeListSpace::repairLinearAllocationBlocks() {
1843 // Fix up linear allocation blocks to look like free blocks 1843 // Fix up linear allocation blocks to look like free blocks
1904 blk->_word_size = fc->size(); 1904 blk->_word_size = fc->size();
1905 fc->dontCoalesce(); // to prevent sweeper from sweeping us up 1905 fc->dontCoalesce(); // to prevent sweeper from sweeping us up
1906 } 1906 }
1907 } 1907 }
1908 1908
1909 // Support for concurrent collection policy decisions.
1910 bool CompactibleFreeListSpace::should_concurrent_collect() const {
1911 // In the future we might want to add in frgamentation stats --
1912 // including erosion of the "mountain" into this decision as well.
1913 return !adaptive_freelists() && linearAllocationWouldFail();
1914 }
1915
1909 // Support for compaction 1916 // Support for compaction
1910 1917
1911 void CompactibleFreeListSpace::prepare_for_compaction(CompactPoint* cp) { 1918 void CompactibleFreeListSpace::prepare_for_compaction(CompactPoint* cp) {
1912 SCAN_AND_FORWARD(cp,end,block_is_obj,block_size); 1919 SCAN_AND_FORWARD(cp,end,block_is_obj,block_size);
1913 // prepare_for_compaction() uses the space between live objects 1920 // prepare_for_compaction() uses the space between live objects
2011 fl->set_splitBirths(0); 2018 fl->set_splitBirths(0);
2012 fl->set_splitDeaths(0); 2019 fl->set_splitDeaths(0);
2013 } 2020 }
2014 } 2021 }
2015 2022
2016 void CompactibleFreeListSpace::endSweepFLCensus(int sweepCt) { 2023 void CompactibleFreeListSpace::endSweepFLCensus(size_t sweep_count) {
2017 setFLSurplus(); 2024 setFLSurplus();
2018 setFLHints(); 2025 setFLHints();
2019 if (PrintGC && PrintFLSCensus > 0) { 2026 if (PrintGC && PrintFLSCensus > 0) {
2020 printFLCensus(sweepCt); 2027 printFLCensus(sweep_count);
2021 } 2028 }
2022 clearFLCensus(); 2029 clearFLCensus();
2023 assert_locked(); 2030 assert_locked();
2024 _dictionary->endSweepDictCensus(SplitSurplusPercent); 2031 _dictionary->endSweepDictCensus(SplitSurplusPercent);
2025 } 2032 }
2291 assert((IndexSetStride != 2) || (IndexSetSize % 2 == 1), 2298 assert((IndexSetStride != 2) || (IndexSetSize % 2 == 1),
2292 "For-loops that iterate over IndexSet with stride 2 may be wrong"); 2299 "For-loops that iterate over IndexSet with stride 2 may be wrong");
2293 } 2300 }
2294 #endif 2301 #endif
2295 2302
2296 void CompactibleFreeListSpace::printFLCensus(int sweepCt) const { 2303 void CompactibleFreeListSpace::printFLCensus(size_t sweep_count) const {
2297 assert_lock_strong(&_freelistLock); 2304 assert_lock_strong(&_freelistLock);
2298 ssize_t bfrSurp = 0; 2305 FreeList total;
2299 ssize_t surplus = 0; 2306 gclog_or_tty->print("end sweep# " SIZE_FORMAT "\n", sweep_count);
2300 ssize_t desired = 0; 2307 FreeList::print_labels_on(gclog_or_tty, "size");
2301 ssize_t prevSweep = 0;
2302 ssize_t beforeSweep = 0;
2303 ssize_t count = 0;
2304 ssize_t coalBirths = 0;
2305 ssize_t coalDeaths = 0;
2306 ssize_t splitBirths = 0;
2307 ssize_t splitDeaths = 0;
2308 gclog_or_tty->print("end sweep# %d\n", sweepCt);
2309 gclog_or_tty->print("%4s\t" "%7s\t" "%7s\t" "%7s\t" "%7s\t"
2310 "%7s\t" "%7s\t" "%7s\t" "%7s\t" "%7s\t"
2311 "%7s\t" "\n",
2312 "size", "bfrsurp", "surplus", "desired", "prvSwep",
2313 "bfrSwep", "count", "cBirths", "cDeaths", "sBirths",
2314 "sDeaths");
2315
2316 size_t totalFree = 0; 2308 size_t totalFree = 0;
2317 for (size_t i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) { 2309 for (size_t i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) {
2318 const FreeList *fl = &_indexedFreeList[i]; 2310 const FreeList *fl = &_indexedFreeList[i];
2319 totalFree += fl->count() * fl->size(); 2311 totalFree += fl->count() * fl->size();
2320 2312 if (i % (40*IndexSetStride) == 0) {
2321 gclog_or_tty->print("%4d\t" "%7d\t" "%7d\t" "%7d\t" 2313 FreeList::print_labels_on(gclog_or_tty, "size");
2322 "%7d\t" "%7d\t" "%7d\t" "%7d\t" 2314 }
2323 "%7d\t" "%7d\t" "%7d\t" "\n", 2315 fl->print_on(gclog_or_tty);
2324 fl->size(), fl->bfrSurp(), fl->surplus(), fl->desired(), 2316 total.set_bfrSurp( total.bfrSurp() + fl->bfrSurp() );
2325 fl->prevSweep(), fl->beforeSweep(), fl->count(), fl->coalBirths(), 2317 total.set_surplus( total.surplus() + fl->surplus() );
2326 fl->coalDeaths(), fl->splitBirths(), fl->splitDeaths()); 2318 total.set_desired( total.desired() + fl->desired() );
2327 bfrSurp += fl->bfrSurp(); 2319 total.set_prevSweep( total.prevSweep() + fl->prevSweep() );
2328 surplus += fl->surplus(); 2320 total.set_beforeSweep(total.beforeSweep() + fl->beforeSweep());
2329 desired += fl->desired(); 2321 total.set_count( total.count() + fl->count() );
2330 prevSweep += fl->prevSweep(); 2322 total.set_coalBirths( total.coalBirths() + fl->coalBirths() );
2331 beforeSweep += fl->beforeSweep(); 2323 total.set_coalDeaths( total.coalDeaths() + fl->coalDeaths() );
2332 count += fl->count(); 2324 total.set_splitBirths(total.splitBirths() + fl->splitBirths());
2333 coalBirths += fl->coalBirths(); 2325 total.set_splitDeaths(total.splitDeaths() + fl->splitDeaths());
2334 coalDeaths += fl->coalDeaths(); 2326 }
2335 splitBirths += fl->splitBirths(); 2327 total.print_on(gclog_or_tty, "TOTAL");
2336 splitDeaths += fl->splitDeaths(); 2328 gclog_or_tty->print_cr("Total free in indexed lists "
2337 } 2329 SIZE_FORMAT " words", totalFree);
2338 gclog_or_tty->print("%4s\t"
2339 "%7d\t" "%7d\t" "%7d\t" "%7d\t" "%7d\t"
2340 "%7d\t" "%7d\t" "%7d\t" "%7d\t" "%7d\t" "\n",
2341 "totl",
2342 bfrSurp, surplus, desired, prevSweep, beforeSweep,
2343 count, coalBirths, coalDeaths, splitBirths, splitDeaths);
2344 gclog_or_tty->print_cr("Total free in indexed lists %d words", totalFree);
2345 gclog_or_tty->print("growth: %8.5f deficit: %8.5f\n", 2330 gclog_or_tty->print("growth: %8.5f deficit: %8.5f\n",
2346 (double)(splitBirths+coalBirths-splitDeaths-coalDeaths)/ 2331 (double)(total.splitBirths()+total.coalBirths()-total.splitDeaths()-total.coalDeaths())/
2347 (prevSweep != 0 ? (double)prevSweep : 1.0), 2332 (total.prevSweep() != 0 ? (double)total.prevSweep() : 1.0),
2348 (double)(desired - count)/(desired != 0 ? (double)desired : 1.0)); 2333 (double)(total.desired() - total.count())/(total.desired() != 0 ? (double)total.desired() : 1.0));
2349 _dictionary->printDictCensus(); 2334 _dictionary->printDictCensus();
2350 } 2335 }
2351 2336
2352 // Return the next displaced header, incrementing the pointer and 2337 // Return the next displaced header, incrementing the pointer and
2353 // recycling spool area as necessary. 2338 // recycling spool area as necessary.