@@ -400,17 +400,16 @@ void CompactibleFreeListSpace::print_on(outputStream* st) const {
400400
401401void CompactibleFreeListSpace::print_indexed_free_lists (outputStream* st)
402402const {
403- reportIndexedFreeListStatistics ();
404- gclog_or_tty ->print_cr (" Layout of Indexed Freelists" );
405- gclog_or_tty ->print_cr (" ---------------------------" );
403+ reportIndexedFreeListStatistics (st );
404+ st ->print_cr (" Layout of Indexed Freelists" );
405+ st ->print_cr (" ---------------------------" );
406406 AdaptiveFreeList<FreeChunk>::print_labels_on (st, " size" );
407407 for (size_t i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) {
408- _indexedFreeList[i].print_on (gclog_or_tty);
409- for (FreeChunk* fc = _indexedFreeList[i].head (); fc != NULL ;
410- fc = fc->next ()) {
411- gclog_or_tty->print_cr (" \t [" PTR_FORMAT " ," PTR_FORMAT " ) %s" ,
412- p2i (fc), p2i ((HeapWord*)fc + i),
413- fc->cantCoalesce () ? " \t CC" : " " );
408+ _indexedFreeList[i].print_on (st);
409+ for (FreeChunk* fc = _indexedFreeList[i].head (); fc != NULL ; fc = fc->next ()) {
410+ st->print_cr (" \t [" PTR_FORMAT " ," PTR_FORMAT " ) %s" ,
411+ p2i (fc), p2i ((HeapWord*)fc + i),
412+ fc->cantCoalesce () ? " \t CC" : " " );
414413 }
415414 }
416415}
@@ -422,7 +421,7 @@ const {
422421
423422void CompactibleFreeListSpace::print_dictionary_free_lists (outputStream* st)
424423const {
425- _dictionary->report_statistics ();
424+ _dictionary->report_statistics (st );
426425 st->print_cr (" Layout of Freelists in Tree" );
427426 st->print_cr (" ---------------------------" );
428427 _dictionary->print_free_lists (st);
@@ -472,54 +471,58 @@ size_t BlkPrintingClosure::do_blk(HeapWord* addr) {
472471 return sz;
473472}
474473
475- void CompactibleFreeListSpace::dump_at_safepoint_with_locks (CMSCollector* c,
476- outputStream* st) {
477- st->print_cr (" \n =========================" );
474+ void CompactibleFreeListSpace::dump_at_safepoint_with_locks (CMSCollector* c, outputStream* st) {
475+ st->print_cr (" =========================" );
478476 st->print_cr (" Block layout in CMS Heap:" );
479477 st->print_cr (" =========================" );
480478 BlkPrintingClosure bpcl (c, this , c->markBitMap (), st);
481479 blk_iterate (&bpcl);
482480
483- st->print_cr (" \n =======================================" );
481+ st->print_cr (" =======================================" );
484482 st->print_cr (" Order & Layout of Promotion Info Blocks" );
485483 st->print_cr (" =======================================" );
486484 print_promo_info_blocks (st);
487485
488- st->print_cr (" \n ===========================" );
486+ st->print_cr (" ===========================" );
489487 st->print_cr (" Order of Indexed Free Lists" );
490488 st->print_cr (" =========================" );
491489 print_indexed_free_lists (st);
492490
493- st->print_cr (" \n =================================" );
491+ st->print_cr (" =================================" );
494492 st->print_cr (" Order of Free Lists in Dictionary" );
495493 st->print_cr (" =================================" );
496494 print_dictionary_free_lists (st);
497495}
498496
499497
500- void CompactibleFreeListSpace::reportFreeListStatistics () const {
498+ void CompactibleFreeListSpace::reportFreeListStatistics (const char * title ) const {
501499 assert_lock_strong (&_freelistLock);
502- assert (PrintFLSStatistics != 0 , " Reporting error" );
503- _dictionary->report_statistics ();
504- if (PrintFLSStatistics > 1 ) {
505- reportIndexedFreeListStatistics ();
500+ LogHandle (gc, freelist, stats) log;
501+ if (!log.is_debug ()) {
502+ return ;
503+ }
504+ log.debug (" %s" , title);
505+ _dictionary->report_statistics (log.debug_stream ());
506+ if (log.is_trace ()) {
507+ ResourceMark rm;
508+ reportIndexedFreeListStatistics (log.trace_stream ());
506509 size_t total_size = totalSizeInIndexedFreeLists () +
507510 _dictionary->total_chunk_size (DEBUG_ONLY (freelistLock ()));
508- gclog_or_tty-> print (" free=" SIZE_FORMAT " frag=%1.4f\n " , total_size, flsFrag ());
511+ log. trace (" free=" SIZE_FORMAT " frag=%1.4f" , total_size, flsFrag ());
509512 }
510513}
511514
512- void CompactibleFreeListSpace::reportIndexedFreeListStatistics () const {
515+ void CompactibleFreeListSpace::reportIndexedFreeListStatistics (outputStream* st ) const {
513516 assert_lock_strong (&_freelistLock);
514- gclog_or_tty-> print (" Statistics for IndexedFreeLists:\n "
515- " --------------------------------\n " );
517+ st-> print_cr (" Statistics for IndexedFreeLists:" );
518+ st-> print_cr ( " --------------------------------" );
516519 size_t total_size = totalSizeInIndexedFreeLists ();
517- size_t free_blocks = numFreeBlocksInIndexedFreeLists ();
518- gclog_or_tty-> print (" Total Free Space: " SIZE_FORMAT " \n " , total_size);
519- gclog_or_tty-> print (" Max Chunk Size: " SIZE_FORMAT " \n " , maxChunkSizeInIndexedFreeLists ());
520- gclog_or_tty-> print (" Number of Blocks: " SIZE_FORMAT " \n " , free_blocks);
520+ size_t free_blocks = numFreeBlocksInIndexedFreeLists ();
521+ st-> print_cr (" Total Free Space: " SIZE_FORMAT, total_size);
522+ st-> print_cr (" Max Chunk Size: " SIZE_FORMAT, maxChunkSizeInIndexedFreeLists ());
523+ st-> print_cr (" Number of Blocks: " SIZE_FORMAT, free_blocks);
521524 if (free_blocks != 0 ) {
522- gclog_or_tty-> print (" Av. Block Size: " SIZE_FORMAT " \n " , total_size/free_blocks);
525+ st-> print_cr (" Av. Block Size: " SIZE_FORMAT, total_size/free_blocks);
523526 }
524527}
525528
@@ -1824,10 +1827,7 @@ CompactibleFreeListSpace::sweep_completed() {
18241827void
18251828CompactibleFreeListSpace::gc_prologue () {
18261829 assert_locked ();
1827- if (PrintFLSStatistics != 0 ) {
1828- gclog_or_tty->print (" Before GC:\n " );
1829- reportFreeListStatistics ();
1830- }
1830+ reportFreeListStatistics (" Before GC:" );
18311831 refillLinearAllocBlocksIfNeeded ();
18321832}
18331833
@@ -1837,11 +1837,7 @@ CompactibleFreeListSpace::gc_epilogue() {
18371837 assert (_promoInfo.noPromotions (), " _promoInfo inconsistency" );
18381838 _promoInfo.stopTrackingPromotions ();
18391839 repairLinearAllocationBlocks ();
1840- // Print Space's stats
1841- if (PrintFLSStatistics != 0 ) {
1842- gclog_or_tty->print (" After GC:\n " );
1843- reportFreeListStatistics ();
1844- }
1840+ reportFreeListStatistics (" After GC:" );
18451841}
18461842
18471843// Iteration support, mostly delegated from a CMS generation
@@ -2014,9 +2010,7 @@ void CompactibleFreeListSpace::beginSweepFLCensus(
20142010 size_t i;
20152011 for (i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) {
20162012 AdaptiveFreeList<FreeChunk>* fl = &_indexedFreeList[i];
2017- if (PrintFLSStatistics > 1 ) {
2018- gclog_or_tty->print (" size[" SIZE_FORMAT " ] : " , i);
2019- }
2013+ log_trace (gc, freelist)(" size[" SIZE_FORMAT " ] : " , i);
20202014 fl->compute_desired (inter_sweep_current, inter_sweep_estimate, intra_sweep_estimate);
20212015 fl->set_coal_desired ((ssize_t )((double )fl->desired () * CMSSmallCoalSurplusPercent));
20222016 fl->set_before_sweep (fl->count ());
@@ -2065,16 +2059,10 @@ void CompactibleFreeListSpace::clearFLCensus() {
20652059}
20662060
20672061void CompactibleFreeListSpace::endSweepFLCensus (size_t sweep_count) {
2068- if (PrintFLSStatistics > 0 ) {
2069- HeapWord* largestAddr = (HeapWord*) dictionary ()->find_largest_dict ();
2070- gclog_or_tty->print_cr (" CMS: Large block " PTR_FORMAT,
2071- p2i (largestAddr));
2072- }
2062+ log_debug (gc, freelist)(" CMS: Large block " PTR_FORMAT, p2i (dictionary ()->find_largest_dict ()));
20732063 setFLSurplus ();
20742064 setFLHints ();
2075- if (PrintGC && PrintFLSCensus > 0 ) {
2076- printFLCensus (sweep_count);
2077- }
2065+ printFLCensus (sweep_count);
20782066 clearFLCensus ();
20792067 assert_locked ();
20802068 _dictionary->end_sweep_dict_census (CMSLargeSplitSurplusPercent);
@@ -2213,14 +2201,15 @@ class VerifyAllBlksClosure: public BlkClosure {
22132201 }
22142202 }
22152203 if (res == 0 ) {
2216- gclog_or_tty-> print_cr ( " Livelock: no rank reduction! " ) ;
2217- gclog_or_tty-> print_cr (
2218- " Current: addr = " PTR_FORMAT " , size = " SIZE_FORMAT " , obj = %s, live = %s \n "
2219- " Previous: addr = " PTR_FORMAT " , size = " SIZE_FORMAT " , obj = %s, live = %s \n " ,
2204+ LogHandle (gc, verify) log ;
2205+ log. info ( " Livelock: no rank reduction! " );
2206+ log. info ( " Current: addr = " PTR_FORMAT " , size = " SIZE_FORMAT " , obj = %s, live = %s \n "
2207+ " Previous: addr = " PTR_FORMAT " , size = " SIZE_FORMAT " , obj = %s, live = %s \n " ,
22202208 p2i (addr), res, was_obj ?" true" :" false" , was_live ?" true" :" false" ,
22212209 p2i (_last_addr), _last_size, _last_was_obj?" true" :" false" , _last_was_live?" true" :" false" );
2222- _sp->print_on (gclog_or_tty);
2223- guarantee (false , " Seppuku!" );
2210+ ResourceMark rm;
2211+ _sp->print_on (log.info_stream ());
2212+ guarantee (false , " Verification failed." );
22242213 }
22252214 _last_addr = addr;
22262215 _last_size = res;
@@ -2386,17 +2375,23 @@ void CompactibleFreeListSpace::check_free_list_consistency() const {
23862375
23872376void CompactibleFreeListSpace::printFLCensus (size_t sweep_count) const {
23882377 assert_lock_strong (&_freelistLock);
2378+ LogHandle (gc, freelist, census) log;
2379+ if (!log.is_debug ()) {
2380+ return ;
2381+ }
23892382 AdaptiveFreeList<FreeChunk> total;
2390- gclog_or_tty->print (" end sweep# " SIZE_FORMAT " \n " , sweep_count);
2391- AdaptiveFreeList<FreeChunk>::print_labels_on (gclog_or_tty, " size" );
2383+ log.debug (" end sweep# " SIZE_FORMAT, sweep_count);
2384+ ResourceMark rm;
2385+ outputStream* out = log.debug_stream ();
2386+ AdaptiveFreeList<FreeChunk>::print_labels_on (out, " size" );
23922387 size_t total_free = 0 ;
23932388 for (size_t i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) {
23942389 const AdaptiveFreeList<FreeChunk> *fl = &_indexedFreeList[i];
23952390 total_free += fl->count () * fl->size ();
23962391 if (i % (40 *IndexSetStride) == 0 ) {
2397- AdaptiveFreeList<FreeChunk>::print_labels_on (gclog_or_tty , " size" );
2392+ AdaptiveFreeList<FreeChunk>::print_labels_on (out , " size" );
23982393 }
2399- fl->print_on (gclog_or_tty );
2394+ fl->print_on (out );
24002395 total.set_bfr_surp ( total.bfr_surp () + fl->bfr_surp () );
24012396 total.set_surplus ( total.surplus () + fl->surplus () );
24022397 total.set_desired ( total.desired () + fl->desired () );
@@ -2408,14 +2403,13 @@ void CompactibleFreeListSpace::printFLCensus(size_t sweep_count) const {
24082403 total.set_split_births (total.split_births () + fl->split_births ());
24092404 total.set_split_deaths (total.split_deaths () + fl->split_deaths ());
24102405 }
2411- total.print_on (gclog_or_tty, " TOTAL" );
2412- gclog_or_tty->print_cr (" Total free in indexed lists "
2413- SIZE_FORMAT " words" , total_free);
2414- gclog_or_tty->print (" growth: %8.5f deficit: %8.5f\n " ,
2415- (double )(total.split_births ()+total.coal_births ()-total.split_deaths ()-total.coal_deaths ())/
2416- (total.prev_sweep () != 0 ? (double )total.prev_sweep () : 1.0 ),
2417- (double )(total.desired () - total.count ())/(total.desired () != 0 ? (double )total.desired () : 1.0 ));
2418- _dictionary->print_dict_census ();
2406+ total.print_on (out, " TOTAL" );
2407+ log.debug (" Total free in indexed lists " SIZE_FORMAT " words" , total_free);
2408+ log.debug (" growth: %8.5f deficit: %8.5f" ,
2409+ (double )(total.split_births ()+total.coal_births ()-total.split_deaths ()-total.coal_deaths ())/
2410+ (total.prev_sweep () != 0 ? (double )total.prev_sweep () : 1.0 ),
2411+ (double )(total.desired () - total.count ())/(total.desired () != 0 ? (double )total.desired () : 1.0 ));
2412+ _dictionary->print_dict_census (out);
24192413}
24202414
24212415// /////////////////////////////////////////////////////////////////////////
@@ -2544,10 +2538,7 @@ void CFLS_LAB::compute_desired_plab_size() {
25442538 // Reset counters for next round
25452539 _global_num_workers[i] = 0 ;
25462540 _global_num_blocks[i] = 0 ;
2547- if (PrintOldPLAB) {
2548- gclog_or_tty->print_cr (" [" SIZE_FORMAT " ]: " SIZE_FORMAT,
2549- i, (size_t )_blocks_to_claim[i].average ());
2550- }
2541+ log_trace (gc, plab)(" [" SIZE_FORMAT " ]: " SIZE_FORMAT, i, (size_t )_blocks_to_claim[i].average ());
25512542 }
25522543 }
25532544}
@@ -2584,10 +2575,8 @@ void CFLS_LAB::retire(int tid) {
25842575 _indexedFreeList[i].set_size (i);
25852576 }
25862577 }
2587- if (PrintOldPLAB) {
2588- gclog_or_tty->print_cr (" %d[" SIZE_FORMAT " ]: " SIZE_FORMAT " /" SIZE_FORMAT " /" SIZE_FORMAT,
2589- tid, i, num_retire, _num_blocks[i], (size_t )_blocks_to_claim[i].average ());
2590- }
2578+ log_trace (gc, plab)(" %d[" SIZE_FORMAT " ]: " SIZE_FORMAT " /" SIZE_FORMAT " /" SIZE_FORMAT,
2579+ tid, i, num_retire, _num_blocks[i], (size_t )_blocks_to_claim[i].average ());
25912580 // Reset stats for next round
25922581 _num_blocks[i] = 0 ;
25932582 }
0 commit comments