Mercurial > hg > graal-compiler
comparison src/share/vm/gc_implementation/g1/collectionSetChooser.cpp @ 2435:371bbc844bf1
7027766: G1: introduce flag to dump the liveness information per region at the end of marking
Summary: Repurpose the existing flag G1PrintRegionLivenessInfo to print out the liveness distribution across the regions in the heap at the end of marking.
Reviewed-by: iveresov, jwilhelm
author | tonyp |
---|---|
date | Mon, 04 Apr 2011 14:23:17 -0400 |
parents | f95d63e2154a |
children | 20213c8a3c40 |
comparison
equal
deleted
inserted
replaced
2434:c84ee870e0b9 | 2435:371bbc844bf1 |
---|---|
260 gclog_or_tty->print_cr(" Sorted %d marked regions.", _numMarkedRegions); | 260 gclog_or_tty->print_cr(" Sorted %d marked regions.", _numMarkedRegions); |
261 } | 261 } |
262 for (int i = 0; i < _numMarkedRegions; i++) { | 262 for (int i = 0; i < _numMarkedRegions; i++) { |
263 assert(_markedRegions.at(i) != NULL, "Should be true by sorting!"); | 263 assert(_markedRegions.at(i) != NULL, "Should be true by sorting!"); |
264 _markedRegions.at(i)->set_sort_index(i); | 264 _markedRegions.at(i)->set_sort_index(i); |
265 if (G1PrintRegionLivenessInfo > 0) { | 265 } |
266 if (i == 0) gclog_or_tty->print_cr("Sorted marked regions:"); | 266 if (G1PrintRegionLivenessInfo) { |
267 if (i < G1PrintRegionLivenessInfo || | 267 G1PrintRegionLivenessInfoClosure cl(gclog_or_tty, "Post-Sorting"); |
268 (_numMarkedRegions-i) < G1PrintRegionLivenessInfo) { | 268 for (int i = 0; i < _numMarkedRegions; ++i) { |
269 HeapRegion* hr = _markedRegions.at(i); | 269 HeapRegion* r = _markedRegions.at(i); |
270 size_t u = hr->used(); | 270 cl.doHeapRegion(r); |
271 gclog_or_tty->print_cr(" Region %d: %d used, %d max live, %5.2f%%.", | 271 } |
272 i, u, hr->max_live_bytes(), | 272 } |
273 100.0*(float)hr->max_live_bytes()/(float)u); | |
274 } | |
275 } | |
276 } | |
277 if (G1PolicyVerbose > 1) | |
278 printSortedHeapRegions(); | |
279 assert(verify(), "should now be sorted"); | 273 assert(verify(), "should now be sorted"); |
280 } | |
281 | |
282 void | |
283 printHeapRegion(HeapRegion *hr) { | |
284 if (hr->isHumongous()) | |
285 gclog_or_tty->print("H: "); | |
286 if (hr->in_collection_set()) | |
287 gclog_or_tty->print("CS: "); | |
288 gclog_or_tty->print_cr("Region " PTR_FORMAT " (%s%s) " | |
289 "[" PTR_FORMAT ", " PTR_FORMAT"] " | |
290 "Used: " SIZE_FORMAT "K, garbage: " SIZE_FORMAT "K.", | |
291 hr, hr->is_young() ? "Y " : " ", | |
292 hr->is_marked()? "M1" : "M0", | |
293 hr->bottom(), hr->end(), | |
294 hr->used()/K, hr->garbage_bytes()/K); | |
295 } | 274 } |
296 | 275 |
297 void | 276 void |
298 CollectionSetChooser::addMarkedHeapRegion(HeapRegion* hr) { | 277 CollectionSetChooser::addMarkedHeapRegion(HeapRegion* hr) { |
299 assert(!hr->isHumongous(), | 278 assert(!hr->isHumongous(), |
349 _cache.clear(); | 328 _cache.clear(); |
350 }; | 329 }; |
351 | 330 |
352 void | 331 void |
353 CollectionSetChooser::updateAfterFullCollection() { | 332 CollectionSetChooser::updateAfterFullCollection() { |
354 G1CollectedHeap* g1h = G1CollectedHeap::heap(); | |
355 clearMarkedHeapRegions(); | 333 clearMarkedHeapRegions(); |
356 } | |
357 | |
358 void | |
359 CollectionSetChooser::printSortedHeapRegions() { | |
360 gclog_or_tty->print_cr("Printing %d Heap Regions sorted by amount of known garbage", | |
361 _numMarkedRegions); | |
362 | |
363 DEBUG_ONLY(int marked_count = 0;) | |
364 for (int i = 0; i < _markedRegions.length(); i++) { | |
365 HeapRegion* r = _markedRegions.at(i); | |
366 if (r != NULL) { | |
367 printHeapRegion(r); | |
368 DEBUG_ONLY(marked_count++;) | |
369 } | |
370 } | |
371 assert(marked_count == _numMarkedRegions, "must be"); | |
372 gclog_or_tty->print_cr("Done sorted heap region print"); | |
373 } | 334 } |
374 | 335 |
375 void CollectionSetChooser::removeRegion(HeapRegion *hr) { | 336 void CollectionSetChooser::removeRegion(HeapRegion *hr) { |
376 int si = hr->sort_index(); | 337 int si = hr->sort_index(); |
377 assert(si == -1 || hr->is_marked(), "Sort index not valid."); | 338 assert(si == -1 || hr->is_marked(), "Sort index not valid."); |