< prev index next >
src/share/vm/gc/cms/compactibleFreeListSpace.cpp
Print this page
@@ -398,19 +398,18 @@
st->print_cr(" _fitStrategy = %s", BOOL_TO_STR(_fitStrategy));
}
void CompactibleFreeListSpace::print_indexed_free_lists(outputStream* st)
const {
- reportIndexedFreeListStatistics();
- gclog_or_tty->print_cr("Layout of Indexed Freelists");
- gclog_or_tty->print_cr("---------------------------");
+ reportIndexedFreeListStatistics(st);
+ st->print_cr("Layout of Indexed Freelists");
+ st->print_cr("---------------------------");
AdaptiveFreeList<FreeChunk>::print_labels_on(st, "size");
for (size_t i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) {
- _indexedFreeList[i].print_on(gclog_or_tty);
- for (FreeChunk* fc = _indexedFreeList[i].head(); fc != NULL;
- fc = fc->next()) {
- gclog_or_tty->print_cr("\t[" PTR_FORMAT "," PTR_FORMAT ") %s",
+ _indexedFreeList[i].print_on(st);
+ for (FreeChunk* fc = _indexedFreeList[i].head(); fc != NULL; fc = fc->next()) {
+ st->print_cr("\t[" PTR_FORMAT "," PTR_FORMAT ") %s",
p2i(fc), p2i((HeapWord*)fc + i),
fc->cantCoalesce() ? "\t CC" : "");
}
}
}
@@ -420,11 +419,11 @@
_promoInfo.print_on(st);
}
void CompactibleFreeListSpace::print_dictionary_free_lists(outputStream* st)
const {
- _dictionary->report_statistics();
+ _dictionary->report_statistics(st);
st->print_cr("Layout of Freelists in Tree");
st->print_cr("---------------------------");
_dictionary->print_free_lists(st);
}
@@ -470,58 +469,62 @@
}
}
return sz;
}
-void CompactibleFreeListSpace::dump_at_safepoint_with_locks(CMSCollector* c,
- outputStream* st) {
- st->print_cr("\n=========================");
+void CompactibleFreeListSpace::dump_at_safepoint_with_locks(CMSCollector* c, outputStream* st) {
+ st->print_cr("=========================");
st->print_cr("Block layout in CMS Heap:");
st->print_cr("=========================");
BlkPrintingClosure bpcl(c, this, c->markBitMap(), st);
blk_iterate(&bpcl);
- st->print_cr("\n=======================================");
+ st->print_cr("=======================================");
st->print_cr("Order & Layout of Promotion Info Blocks");
st->print_cr("=======================================");
print_promo_info_blocks(st);
- st->print_cr("\n===========================");
+ st->print_cr("===========================");
st->print_cr("Order of Indexed Free Lists");
st->print_cr("=========================");
print_indexed_free_lists(st);
- st->print_cr("\n=================================");
+ st->print_cr("=================================");
st->print_cr("Order of Free Lists in Dictionary");
st->print_cr("=================================");
print_dictionary_free_lists(st);
}
-void CompactibleFreeListSpace::reportFreeListStatistics() const {
+void CompactibleFreeListSpace::reportFreeListStatistics(const char* title) const {
assert_lock_strong(&_freelistLock);
- assert(PrintFLSStatistics != 0, "Reporting error");
- _dictionary->report_statistics();
- if (PrintFLSStatistics > 1) {
- reportIndexedFreeListStatistics();
+ LogHandle(gc, freelist, stats) log;
+ if (!log.is_debug()) {
+ return;
+ }
+ log.debug("%s", title);
+ _dictionary->report_statistics(log.debug_stream());
+ if (log.is_trace()) {
+ ResourceMark rm;
+ reportIndexedFreeListStatistics(log.trace_stream());
size_t total_size = totalSizeInIndexedFreeLists() +
_dictionary->total_chunk_size(DEBUG_ONLY(freelistLock()));
- gclog_or_tty->print(" free=" SIZE_FORMAT " frag=%1.4f\n", total_size, flsFrag());
+ log.trace(" free=" SIZE_FORMAT " frag=%1.4f", total_size, flsFrag());
}
}
-void CompactibleFreeListSpace::reportIndexedFreeListStatistics() const {
+void CompactibleFreeListSpace::reportIndexedFreeListStatistics(outputStream* st) const {
assert_lock_strong(&_freelistLock);
- gclog_or_tty->print("Statistics for IndexedFreeLists:\n"
- "--------------------------------\n");
+ st->print_cr("Statistics for IndexedFreeLists:");
+ st->print_cr("--------------------------------");
size_t total_size = totalSizeInIndexedFreeLists();
size_t free_blocks = numFreeBlocksInIndexedFreeLists();
- gclog_or_tty->print("Total Free Space: " SIZE_FORMAT "\n", total_size);
- gclog_or_tty->print("Max Chunk Size: " SIZE_FORMAT "\n", maxChunkSizeInIndexedFreeLists());
- gclog_or_tty->print("Number of Blocks: " SIZE_FORMAT "\n", free_blocks);
+ st->print_cr("Total Free Space: " SIZE_FORMAT, total_size);
+ st->print_cr("Max Chunk Size: " SIZE_FORMAT, maxChunkSizeInIndexedFreeLists());
+ st->print_cr("Number of Blocks: " SIZE_FORMAT, free_blocks);
if (free_blocks != 0) {
- gclog_or_tty->print("Av. Block Size: " SIZE_FORMAT "\n", total_size/free_blocks);
+ st->print_cr("Av. Block Size: " SIZE_FORMAT, total_size/free_blocks);
}
}
size_t CompactibleFreeListSpace::numFreeBlocksInIndexedFreeLists() const {
size_t res = 0;
@@ -1822,28 +1825,21 @@
}
void
CompactibleFreeListSpace::gc_prologue() {
assert_locked();
- if (PrintFLSStatistics != 0) {
- gclog_or_tty->print("Before GC:\n");
- reportFreeListStatistics();
- }
+ reportFreeListStatistics("Before GC:");
refillLinearAllocBlocksIfNeeded();
}
void
CompactibleFreeListSpace::gc_epilogue() {
assert_locked();
assert(_promoInfo.noPromotions(), "_promoInfo inconsistency");
_promoInfo.stopTrackingPromotions();
repairLinearAllocationBlocks();
- // Print Space's stats
- if (PrintFLSStatistics != 0) {
- gclog_or_tty->print("After GC:\n");
- reportFreeListStatistics();
- }
+ reportFreeListStatistics("After GC:");
}
// Iteration support, mostly delegated from a CMS generation
void CompactibleFreeListSpace::save_marks() {
@@ -2012,13 +2008,11 @@
float intra_sweep_estimate) {
assert_locked();
size_t i;
for (i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) {
AdaptiveFreeList<FreeChunk>* fl = &_indexedFreeList[i];
- if (PrintFLSStatistics > 1) {
- gclog_or_tty->print("size[" SIZE_FORMAT "] : ", i);
- }
+ log_trace(gc, freelist)("size[" SIZE_FORMAT "] : ", i);
fl->compute_desired(inter_sweep_current, inter_sweep_estimate, intra_sweep_estimate);
fl->set_coal_desired((ssize_t)((double)fl->desired() * CMSSmallCoalSurplusPercent));
fl->set_before_sweep(fl->count());
fl->set_bfr_surp(fl->surplus());
}
@@ -2063,20 +2057,14 @@
fl->set_split_deaths(0);
}
}
void CompactibleFreeListSpace::endSweepFLCensus(size_t sweep_count) {
- if (PrintFLSStatistics > 0) {
- HeapWord* largestAddr = (HeapWord*) dictionary()->find_largest_dict();
- gclog_or_tty->print_cr("CMS: Large block " PTR_FORMAT,
- p2i(largestAddr));
- }
+ log_debug(gc, freelist)("CMS: Large block " PTR_FORMAT, p2i(dictionary()->find_largest_dict()));
setFLSurplus();
setFLHints();
- if (PrintGC && PrintFLSCensus > 0) {
printFLCensus(sweep_count);
- }
clearFLCensus();
assert_locked();
_dictionary->end_sweep_dict_census(CMSLargeSplitSurplusPercent);
}
@@ -2211,18 +2199,19 @@
guarantee(_sp->verify_chunk_in_free_list(fc),
"Chunk should be on a free list");
}
}
if (res == 0) {
- gclog_or_tty->print_cr("Livelock: no rank reduction!");
- gclog_or_tty->print_cr(
- " Current: addr = " PTR_FORMAT ", size = " SIZE_FORMAT ", obj = %s, live = %s \n"
+ LogHandle(gc, verify) log;
+ log.info("Livelock: no rank reduction!");
+ log.info(" Current: addr = " PTR_FORMAT ", size = " SIZE_FORMAT ", obj = %s, live = %s \n"
" Previous: addr = " PTR_FORMAT ", size = " SIZE_FORMAT ", obj = %s, live = %s \n",
p2i(addr), res, was_obj ?"true":"false", was_live ?"true":"false",
p2i(_last_addr), _last_size, _last_was_obj?"true":"false", _last_was_live?"true":"false");
- _sp->print_on(gclog_or_tty);
- guarantee(false, "Seppuku!");
+ ResourceMark rm;
+ _sp->print_on(log.info_stream());
+ guarantee(false, "Verification failed.");
}
_last_addr = addr;
_last_size = res;
_last_was_obj = was_obj;
_last_was_live = was_live;
@@ -2384,21 +2373,27 @@
}
#endif
void CompactibleFreeListSpace::printFLCensus(size_t sweep_count) const {
assert_lock_strong(&_freelistLock);
+ LogHandle(gc, freelist, census) log;
+ if (!log.is_debug()) {
+ return;
+ }
AdaptiveFreeList<FreeChunk> total;
- gclog_or_tty->print("end sweep# " SIZE_FORMAT "\n", sweep_count);
- AdaptiveFreeList<FreeChunk>::print_labels_on(gclog_or_tty, "size");
+ log.debug("end sweep# " SIZE_FORMAT, sweep_count);
+ ResourceMark rm;
+ outputStream* out = log.debug_stream();
+ AdaptiveFreeList<FreeChunk>::print_labels_on(out, "size");
size_t total_free = 0;
for (size_t i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) {
const AdaptiveFreeList<FreeChunk> *fl = &_indexedFreeList[i];
total_free += fl->count() * fl->size();
if (i % (40*IndexSetStride) == 0) {
- AdaptiveFreeList<FreeChunk>::print_labels_on(gclog_or_tty, "size");
+ AdaptiveFreeList<FreeChunk>::print_labels_on(out, "size");
}
- fl->print_on(gclog_or_tty);
+ fl->print_on(out);
total.set_bfr_surp( total.bfr_surp() + fl->bfr_surp() );
total.set_surplus( total.surplus() + fl->surplus() );
total.set_desired( total.desired() + fl->desired() );
total.set_prev_sweep( total.prev_sweep() + fl->prev_sweep() );
total.set_before_sweep(total.before_sweep() + fl->before_sweep());
@@ -2406,18 +2401,17 @@
total.set_coal_births( total.coal_births() + fl->coal_births() );
total.set_coal_deaths( total.coal_deaths() + fl->coal_deaths() );
total.set_split_births(total.split_births() + fl->split_births());
total.set_split_deaths(total.split_deaths() + fl->split_deaths());
}
- total.print_on(gclog_or_tty, "TOTAL");
- gclog_or_tty->print_cr("Total free in indexed lists "
- SIZE_FORMAT " words", total_free);
- gclog_or_tty->print("growth: %8.5f deficit: %8.5f\n",
+ total.print_on(out, "TOTAL");
+ log.debug("Total free in indexed lists " SIZE_FORMAT " words", total_free);
+ log.debug("growth: %8.5f deficit: %8.5f",
(double)(total.split_births()+total.coal_births()-total.split_deaths()-total.coal_deaths())/
(total.prev_sweep() != 0 ? (double)total.prev_sweep() : 1.0),
(double)(total.desired() - total.count())/(total.desired() != 0 ? (double)total.desired() : 1.0));
- _dictionary->print_dict_census();
+ _dictionary->print_dict_census(out);
}
///////////////////////////////////////////////////////////////////////////
// CFLS_LAB
///////////////////////////////////////////////////////////////////////////
@@ -2542,14 +2536,11 @@
_global_num_blocks[i]/(_global_num_workers[i]*CMSOldPLABNumRefills))));
}
// Reset counters for next round
_global_num_workers[i] = 0;
_global_num_blocks[i] = 0;
- if (PrintOldPLAB) {
- gclog_or_tty->print_cr("[" SIZE_FORMAT "]: " SIZE_FORMAT,
- i, (size_t)_blocks_to_claim[i].average());
- }
+ log_trace(gc, plab)("[" SIZE_FORMAT "]: " SIZE_FORMAT, i, (size_t)_blocks_to_claim[i].average());
}
}
}
// If this is changed in the future to allow parallel
@@ -2582,14 +2573,12 @@
// Reset this list.
_indexedFreeList[i] = AdaptiveFreeList<FreeChunk>();
_indexedFreeList[i].set_size(i);
}
}
- if (PrintOldPLAB) {
- gclog_or_tty->print_cr("%d[" SIZE_FORMAT "]: " SIZE_FORMAT "/" SIZE_FORMAT "/" SIZE_FORMAT,
+ log_trace(gc, plab)("%d[" SIZE_FORMAT "]: " SIZE_FORMAT "/" SIZE_FORMAT "/" SIZE_FORMAT,
tid, i, num_retire, _num_blocks[i], (size_t)_blocks_to_claim[i].average());
- }
// Reset stats for next round
_num_blocks[i] = 0;
}
}
}
< prev index next >