5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "code/codeCache.hpp"
27 #include "code/icBuffer.hpp"
28 #include "gc_implementation/g1/bufferingOopClosure.hpp"
29 #include "gc_implementation/g1/concurrentG1Refine.hpp"
30 #include "gc_implementation/g1/concurrentG1RefineThread.hpp"
31 #include "gc_implementation/g1/concurrentMarkThread.inline.hpp"
32 #include "gc_implementation/g1/g1AllocRegion.inline.hpp"
33 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
34 #include "gc_implementation/g1/g1CollectorPolicy.hpp"
35 #include "gc_implementation/g1/g1ErgoVerbose.hpp"
36 #include "gc_implementation/g1/g1EvacFailure.hpp"
37 #include "gc_implementation/g1/g1GCPhaseTimes.hpp"
38 #include "gc_implementation/g1/g1Log.hpp"
39 #include "gc_implementation/g1/g1MarkSweep.hpp"
40 #include "gc_implementation/g1/g1OopClosures.inline.hpp"
41 #include "gc_implementation/g1/g1RemSet.inline.hpp"
42 #include "gc_implementation/g1/g1StringDedup.hpp"
43 #include "gc_implementation/g1/g1YCTypes.hpp"
44 #include "gc_implementation/g1/heapRegion.inline.hpp"
352
353 void YoungList::print() {
354 HeapRegion* lists[] = {_head, _survivor_head};
355 const char* names[] = {"YOUNG", "SURVIVOR"};
356
357 for (unsigned int list = 0; list < ARRAY_SIZE(lists); ++list) {
358 gclog_or_tty->print_cr("%s LIST CONTENTS", names[list]);
359 HeapRegion *curr = lists[list];
360 if (curr == NULL)
361 gclog_or_tty->print_cr(" empty");
362 while (curr != NULL) {
363 gclog_or_tty->print_cr(" "HR_FORMAT", P: "PTR_FORMAT "N: "PTR_FORMAT", age: %4d",
364 HR_FORMAT_PARAMS(curr),
365 curr->prev_top_at_mark_start(),
366 curr->next_top_at_mark_start(),
367 curr->age_in_surv_rate_group_cond());
368 curr = curr->get_next_young_region();
369 }
370 }
371
372 gclog_or_tty->print_cr("");
373 }
374
375 void G1CollectedHeap::push_dirty_cards_region(HeapRegion* hr)
376 {
377 // Claim the right to put the region on the dirty cards region list
378 // by installing a self pointer.
379 HeapRegion* next = hr->get_next_dirty_cards_region();
380 if (next == NULL) {
381 HeapRegion* res = (HeapRegion*)
382 Atomic::cmpxchg_ptr(hr, hr->next_dirty_cards_region_addr(),
383 NULL);
384 if (res == NULL) {
385 HeapRegion* head;
386 do {
387 // Put the region to the dirty cards region list.
388 head = _dirty_cards_region_list;
389 next = (HeapRegion*)
390 Atomic::cmpxchg_ptr(hr, &_dirty_cards_region_list, head);
391 if (next == head) {
392 assert(hr->get_next_dirty_cards_region() == hr,
3438 VerifyRegionClosure blk(false, vo);
3439 heap_region_iterate(&blk);
3440 if (blk.failures()) {
3441 failures = true;
3442 }
3443 }
3444 if (!silent) gclog_or_tty->print("RemSet ");
3445 rem_set()->verify();
3446
3447 if (G1StringDedup::is_enabled()) {
3448 if (!silent) gclog_or_tty->print("StrDedup ");
3449 G1StringDedup::verify();
3450 }
3451
3452 if (failures) {
3453 gclog_or_tty->print_cr("Heap:");
3454 // It helps to have the per-region information in the output to
3455 // help us track down what went wrong. This is why we call
3456 // print_extended_on() instead of print_on().
3457 print_extended_on(gclog_or_tty);
3458 gclog_or_tty->print_cr("");
3459 #ifndef PRODUCT
3460 if (VerifyDuringGC && G1VerifyDuringGCPrintReachable) {
3461 concurrent_mark()->print_reachable("at-verification-failure",
3462 vo, false /* all */);
3463 }
3464 #endif
3465 gclog_or_tty->flush();
3466 }
3467 guarantee(!failures, "there should not have been any failures");
3468 } else {
3469 if (!silent) {
3470 gclog_or_tty->print("(SKIPPING Roots, HeapRegionSets, HeapRegions, RemSet");
3471 if (G1StringDedup::is_enabled()) {
3472 gclog_or_tty->print(", StrDedup");
3473 }
3474 gclog_or_tty->print(") ");
3475 }
3476 }
3477 }
3478
3632 public:
3633 bool doHeapRegion(HeapRegion* r) {
3634 HeapRegionRemSet* hrrs = r->rem_set();
3635 size_t occupied = hrrs->occupied();
3636 _occupied_sum += occupied;
3637
3638 gclog_or_tty->print_cr("Printing RSet for region "HR_FORMAT,
3639 HR_FORMAT_PARAMS(r));
3640 if (occupied == 0) {
3641 gclog_or_tty->print_cr(" RSet is empty");
3642 } else {
3643 hrrs->print();
3644 }
3645 gclog_or_tty->print_cr("----------");
3646 return false;
3647 }
3648
3649 PrintRSetsClosure(const char* msg) : _msg(msg), _occupied_sum(0) {
3650 gclog_or_tty->cr();
3651 gclog_or_tty->print_cr("========================================");
3652 gclog_or_tty->print_cr(msg);
3653 gclog_or_tty->cr();
3654 }
3655
3656 ~PrintRSetsClosure() {
3657 gclog_or_tty->print_cr("Occupied Sum: "SIZE_FORMAT, _occupied_sum);
3658 gclog_or_tty->print_cr("========================================");
3659 gclog_or_tty->cr();
3660 }
3661 };
3662
3663 void G1CollectedHeap::print_cset_rsets() {
3664 PrintRSetsClosure cl("Printing CSet RSets");
3665 collection_set_iterate(&cl);
3666 }
3667
3668 void G1CollectedHeap::print_all_rsets() {
3669 PrintRSetsClosure cl("Printing All RSets");;
3670 heap_region_iterate(&cl);
3671 }
3672 #endif // PRODUCT
|
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #if !defined(__clang_major__) && defined(__GNUC__)
26 #define ATTRIBUTE_PRINTF(x,y) // FIXME, formats are a mess.
27 #endif
28
29 #include "precompiled.hpp"
30 #include "code/codeCache.hpp"
31 #include "code/icBuffer.hpp"
32 #include "gc_implementation/g1/bufferingOopClosure.hpp"
33 #include "gc_implementation/g1/concurrentG1Refine.hpp"
34 #include "gc_implementation/g1/concurrentG1RefineThread.hpp"
35 #include "gc_implementation/g1/concurrentMarkThread.inline.hpp"
36 #include "gc_implementation/g1/g1AllocRegion.inline.hpp"
37 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
38 #include "gc_implementation/g1/g1CollectorPolicy.hpp"
39 #include "gc_implementation/g1/g1ErgoVerbose.hpp"
40 #include "gc_implementation/g1/g1EvacFailure.hpp"
41 #include "gc_implementation/g1/g1GCPhaseTimes.hpp"
42 #include "gc_implementation/g1/g1Log.hpp"
43 #include "gc_implementation/g1/g1MarkSweep.hpp"
44 #include "gc_implementation/g1/g1OopClosures.inline.hpp"
45 #include "gc_implementation/g1/g1RemSet.inline.hpp"
46 #include "gc_implementation/g1/g1StringDedup.hpp"
47 #include "gc_implementation/g1/g1YCTypes.hpp"
48 #include "gc_implementation/g1/heapRegion.inline.hpp"
356
357 void YoungList::print() {
358 HeapRegion* lists[] = {_head, _survivor_head};
359 const char* names[] = {"YOUNG", "SURVIVOR"};
360
361 for (unsigned int list = 0; list < ARRAY_SIZE(lists); ++list) {
362 gclog_or_tty->print_cr("%s LIST CONTENTS", names[list]);
363 HeapRegion *curr = lists[list];
364 if (curr == NULL)
365 gclog_or_tty->print_cr(" empty");
366 while (curr != NULL) {
367 gclog_or_tty->print_cr(" "HR_FORMAT", P: "PTR_FORMAT "N: "PTR_FORMAT", age: %4d",
368 HR_FORMAT_PARAMS(curr),
369 curr->prev_top_at_mark_start(),
370 curr->next_top_at_mark_start(),
371 curr->age_in_surv_rate_group_cond());
372 curr = curr->get_next_young_region();
373 }
374 }
375
376 gclog_or_tty->cr();
377 }
378
379 void G1CollectedHeap::push_dirty_cards_region(HeapRegion* hr)
380 {
381 // Claim the right to put the region on the dirty cards region list
382 // by installing a self pointer.
383 HeapRegion* next = hr->get_next_dirty_cards_region();
384 if (next == NULL) {
385 HeapRegion* res = (HeapRegion*)
386 Atomic::cmpxchg_ptr(hr, hr->next_dirty_cards_region_addr(),
387 NULL);
388 if (res == NULL) {
389 HeapRegion* head;
390 do {
391 // Put the region to the dirty cards region list.
392 head = _dirty_cards_region_list;
393 next = (HeapRegion*)
394 Atomic::cmpxchg_ptr(hr, &_dirty_cards_region_list, head);
395 if (next == head) {
396 assert(hr->get_next_dirty_cards_region() == hr,
3442 VerifyRegionClosure blk(false, vo);
3443 heap_region_iterate(&blk);
3444 if (blk.failures()) {
3445 failures = true;
3446 }
3447 }
3448 if (!silent) gclog_or_tty->print("RemSet ");
3449 rem_set()->verify();
3450
3451 if (G1StringDedup::is_enabled()) {
3452 if (!silent) gclog_or_tty->print("StrDedup ");
3453 G1StringDedup::verify();
3454 }
3455
3456 if (failures) {
3457 gclog_or_tty->print_cr("Heap:");
3458 // It helps to have the per-region information in the output to
3459 // help us track down what went wrong. This is why we call
3460 // print_extended_on() instead of print_on().
3461 print_extended_on(gclog_or_tty);
3462 gclog_or_tty->cr();
3463 #ifndef PRODUCT
3464 if (VerifyDuringGC && G1VerifyDuringGCPrintReachable) {
3465 concurrent_mark()->print_reachable("at-verification-failure",
3466 vo, false /* all */);
3467 }
3468 #endif
3469 gclog_or_tty->flush();
3470 }
3471 guarantee(!failures, "there should not have been any failures");
3472 } else {
3473 if (!silent) {
3474 gclog_or_tty->print("(SKIPPING Roots, HeapRegionSets, HeapRegions, RemSet");
3475 if (G1StringDedup::is_enabled()) {
3476 gclog_or_tty->print(", StrDedup");
3477 }
3478 gclog_or_tty->print(") ");
3479 }
3480 }
3481 }
3482
3636 public:
3637 bool doHeapRegion(HeapRegion* r) {
3638 HeapRegionRemSet* hrrs = r->rem_set();
3639 size_t occupied = hrrs->occupied();
3640 _occupied_sum += occupied;
3641
3642 gclog_or_tty->print_cr("Printing RSet for region "HR_FORMAT,
3643 HR_FORMAT_PARAMS(r));
3644 if (occupied == 0) {
3645 gclog_or_tty->print_cr(" RSet is empty");
3646 } else {
3647 hrrs->print();
3648 }
3649 gclog_or_tty->print_cr("----------");
3650 return false;
3651 }
3652
3653 PrintRSetsClosure(const char* msg) : _msg(msg), _occupied_sum(0) {
3654 gclog_or_tty->cr();
3655 gclog_or_tty->print_cr("========================================");
3656 gclog_or_tty->print_raw_cr(msg);
3657 gclog_or_tty->cr();
3658 }
3659
3660 ~PrintRSetsClosure() {
3661 gclog_or_tty->print_cr("Occupied Sum: "SIZE_FORMAT, _occupied_sum);
3662 gclog_or_tty->print_cr("========================================");
3663 gclog_or_tty->cr();
3664 }
3665 };
3666
3667 void G1CollectedHeap::print_cset_rsets() {
3668 PrintRSetsClosure cl("Printing CSet RSets");
3669 collection_set_iterate(&cl);
3670 }
3671
3672 void G1CollectedHeap::print_all_rsets() {
3673 PrintRSetsClosure cl("Printing All RSets");;
3674 heap_region_iterate(&cl);
3675 }
3676 #endif // PRODUCT
|