comparison src/share/vm/gc_implementation/g1/concurrentMark.cpp @ 6254:a2f7274eb6ef

7114678: G1: various small fixes, code cleanup, and refactoring Summary: Various cleanups as a prelude to introducing iterators for HeapRegions. Reviewed-by: johnc, brutisso
author tonyp
date Thu, 19 Jul 2012 15:15:54 -0700
parents 3a431b605145
children da91efe96a93
comparison
equal deleted inserted replaced
6253:db823a892a55 6254:a2f7274eb6ef
1224 // Normal (non-humongous) case: just set the bit. 1224 // Normal (non-humongous) case: just set the bit.
1225 _region_bm->par_at_put(index, true); 1225 _region_bm->par_at_put(index, true);
1226 } else { 1226 } else {
1227 // Starts humongous case: calculate how many regions are part of 1227 // Starts humongous case: calculate how many regions are part of
1228 // this humongous region and then set the bit range. 1228 // this humongous region and then set the bit range.
1229 G1CollectedHeap* g1h = G1CollectedHeap::heap(); 1229 BitMap::idx_t end_index = (BitMap::idx_t) hr->last_hc_index();
1230 HeapRegion *last_hr = g1h->heap_region_containing_raw(hr->end() - 1);
1231 BitMap::idx_t end_index = (BitMap::idx_t) last_hr->hrs_index() + 1;
1232 _region_bm->par_at_put_range(index, end_index, true); 1230 _region_bm->par_at_put_range(index, end_index, true);
1233 } 1231 }
1234 } 1232 }
1235 1233
1236 public: 1234 public:
1643 _hrrs_cleanup_task(hrrs_cleanup_task) { } 1641 _hrrs_cleanup_task(hrrs_cleanup_task) { }
1644 1642
1645 size_t freed_bytes() { return _freed_bytes; } 1643 size_t freed_bytes() { return _freed_bytes; }
1646 1644
1647 bool doHeapRegion(HeapRegion *hr) { 1645 bool doHeapRegion(HeapRegion *hr) {
1646 if (hr->continuesHumongous()) {
1647 return false;
1648 }
1648 // We use a claim value of zero here because all regions 1649 // We use a claim value of zero here because all regions
1649 // were claimed with value 1 in the FinalCount task. 1650 // were claimed with value 1 in the FinalCount task.
1650 hr->reset_gc_time_stamp(); 1651 _g1->reset_gc_time_stamps(hr);
1651 if (!hr->continuesHumongous()) { 1652 double start = os::elapsedTime();
1652 double start = os::elapsedTime(); 1653 _regions_claimed++;
1653 _regions_claimed++; 1654 hr->note_end_of_marking();
1654 hr->note_end_of_marking(); 1655 _max_live_bytes += hr->max_live_bytes();
1655 _max_live_bytes += hr->max_live_bytes(); 1656 _g1->free_region_if_empty(hr,
1656 _g1->free_region_if_empty(hr, 1657 &_freed_bytes,
1657 &_freed_bytes, 1658 _local_cleanup_list,
1658 _local_cleanup_list, 1659 _old_proxy_set,
1659 _old_proxy_set, 1660 _humongous_proxy_set,
1660 _humongous_proxy_set, 1661 _hrrs_cleanup_task,
1661 _hrrs_cleanup_task, 1662 true /* par */);
1662 true /* par */); 1663 double region_time = (os::elapsedTime() - start);
1663 double region_time = (os::elapsedTime() - start); 1664 _claimed_region_time += region_time;
1664 _claimed_region_time += region_time; 1665 if (region_time > _max_region_time) {
1665 if (region_time > _max_region_time) { 1666 _max_region_time = region_time;
1666 _max_region_time = region_time;
1667 }
1668 } 1667 }
1669 return false; 1668 return false;
1670 } 1669 }
1671 1670
1672 size_t max_live_bytes() { return _max_live_bytes; } 1671 size_t max_live_bytes() { return _max_live_bytes; }
1879 assert(g1h->check_heap_region_claim_values(HeapRegion::NoteEndClaimValue), 1878 assert(g1h->check_heap_region_claim_values(HeapRegion::NoteEndClaimValue),
1880 "sanity check"); 1879 "sanity check");
1881 } else { 1880 } else {
1882 g1_par_note_end_task.work(0); 1881 g1_par_note_end_task.work(0);
1883 } 1882 }
1883 g1h->check_gc_time_stamps();
1884 1884
1885 if (!cleanup_list_is_empty()) { 1885 if (!cleanup_list_is_empty()) {
1886 // The cleanup list is not empty, so we'll have to process it 1886 // The cleanup list is not empty, so we'll have to process it
1887 // concurrently. Notify anyone else that might be wanting free 1887 // concurrently. Notify anyone else that might be wanting free
1888 // regions that there will be more free regions coming soon. 1888 // regions that there will be more free regions coming soon.
2447 } else if (!_g1h->is_in_g1_reserved(obj)) { 2447 } else if (!_g1h->is_in_g1_reserved(obj)) {
2448 str = " O"; 2448 str = " O";
2449 } else { 2449 } else {
2450 HeapRegion* hr = _g1h->heap_region_containing(obj); 2450 HeapRegion* hr = _g1h->heap_region_containing(obj);
2451 guarantee(hr != NULL, "invariant"); 2451 guarantee(hr != NULL, "invariant");
2452 bool over_tams = false; 2452 bool over_tams = _g1h->allocated_since_marking(obj, hr, _vo);
2453 bool marked = false; 2453 bool marked = _g1h->is_marked(obj, _vo);
2454
2455 switch (_vo) {
2456 case VerifyOption_G1UsePrevMarking:
2457 over_tams = hr->obj_allocated_since_prev_marking(obj);
2458 marked = _g1h->isMarkedPrev(obj);
2459 break;
2460 case VerifyOption_G1UseNextMarking:
2461 over_tams = hr->obj_allocated_since_next_marking(obj);
2462 marked = _g1h->isMarkedNext(obj);
2463 break;
2464 case VerifyOption_G1UseMarkWord:
2465 marked = obj->is_gc_marked();
2466 break;
2467 default:
2468 ShouldNotReachHere();
2469 }
2470 2454
2471 if (over_tams) { 2455 if (over_tams) {
2472 str = " >"; 2456 str = " >";
2473 if (marked) { 2457 if (marked) {
2474 str2 = " AND MARKED"; 2458 str2 = " AND MARKED";
2500 HeapRegion* hr) : 2484 HeapRegion* hr) :
2501 _g1h(G1CollectedHeap::heap()), 2485 _g1h(G1CollectedHeap::heap()),
2502 _out(out), _vo(vo), _all(all), _hr(hr) { } 2486 _out(out), _vo(vo), _all(all), _hr(hr) { }
2503 2487
2504 void do_object(oop o) { 2488 void do_object(oop o) {
2505 bool over_tams = false; 2489 bool over_tams = _g1h->allocated_since_marking(o, _hr, _vo);
2506 bool marked = false; 2490 bool marked = _g1h->is_marked(o, _vo);
2507
2508 switch (_vo) {
2509 case VerifyOption_G1UsePrevMarking:
2510 over_tams = _hr->obj_allocated_since_prev_marking(o);
2511 marked = _g1h->isMarkedPrev(o);
2512 break;
2513 case VerifyOption_G1UseNextMarking:
2514 over_tams = _hr->obj_allocated_since_next_marking(o);
2515 marked = _g1h->isMarkedNext(o);
2516 break;
2517 case VerifyOption_G1UseMarkWord:
2518 marked = o->is_gc_marked();
2519 break;
2520 default:
2521 ShouldNotReachHere();
2522 }
2523 bool print_it = _all || over_tams || marked; 2491 bool print_it = _all || over_tams || marked;
2524 2492
2525 if (print_it) { 2493 if (print_it) {
2526 _out->print_cr(" "PTR_FORMAT"%s", 2494 _out->print_cr(" "PTR_FORMAT"%s",
2527 o, (over_tams) ? " >" : (marked) ? " M" : ""); 2495 o, (over_tams) ? " >" : (marked) ? " M" : "");
2531 } 2499 }
2532 }; 2500 };
2533 2501
2534 class PrintReachableRegionClosure : public HeapRegionClosure { 2502 class PrintReachableRegionClosure : public HeapRegionClosure {
2535 private: 2503 private:
2536 outputStream* _out; 2504 G1CollectedHeap* _g1h;
2537 VerifyOption _vo; 2505 outputStream* _out;
2538 bool _all; 2506 VerifyOption _vo;
2507 bool _all;
2539 2508
2540 public: 2509 public:
2541 bool doHeapRegion(HeapRegion* hr) { 2510 bool doHeapRegion(HeapRegion* hr) {
2542 HeapWord* b = hr->bottom(); 2511 HeapWord* b = hr->bottom();
2543 HeapWord* e = hr->end(); 2512 HeapWord* e = hr->end();
2544 HeapWord* t = hr->top(); 2513 HeapWord* t = hr->top();
2545 HeapWord* p = NULL; 2514 HeapWord* p = _g1h->top_at_mark_start(hr, _vo);
2546
2547 switch (_vo) {
2548 case VerifyOption_G1UsePrevMarking:
2549 p = hr->prev_top_at_mark_start();
2550 break;
2551 case VerifyOption_G1UseNextMarking:
2552 p = hr->next_top_at_mark_start();
2553 break;
2554 case VerifyOption_G1UseMarkWord:
2555 // When we are verifying marking using the mark word
2556 // TAMS has no relevance.
2557 assert(p == NULL, "post-condition");
2558 break;
2559 default:
2560 ShouldNotReachHere();
2561 }
2562 _out->print_cr("** ["PTR_FORMAT", "PTR_FORMAT"] top: "PTR_FORMAT" " 2515 _out->print_cr("** ["PTR_FORMAT", "PTR_FORMAT"] top: "PTR_FORMAT" "
2563 "TAMS: "PTR_FORMAT, b, e, t, p); 2516 "TAMS: "PTR_FORMAT, b, e, t, p);
2564 _out->cr(); 2517 _out->cr();
2565 2518
2566 HeapWord* from = b; 2519 HeapWord* from = b;
2578 } 2531 }
2579 2532
2580 PrintReachableRegionClosure(outputStream* out, 2533 PrintReachableRegionClosure(outputStream* out,
2581 VerifyOption vo, 2534 VerifyOption vo,
2582 bool all) : 2535 bool all) :
2583 _out(out), _vo(vo), _all(all) { } 2536 _g1h(G1CollectedHeap::heap()), _out(out), _vo(vo), _all(all) { }
2584 }; 2537 };
2585
2586 static const char* verify_option_to_tams(VerifyOption vo) {
2587 switch (vo) {
2588 case VerifyOption_G1UsePrevMarking:
2589 return "PTAMS";
2590 case VerifyOption_G1UseNextMarking:
2591 return "NTAMS";
2592 default:
2593 return "NONE";
2594 }
2595 }
2596 2538
2597 void ConcurrentMark::print_reachable(const char* str, 2539 void ConcurrentMark::print_reachable(const char* str,
2598 VerifyOption vo, 2540 VerifyOption vo,
2599 bool all) { 2541 bool all) {
2600 gclog_or_tty->cr(); 2542 gclog_or_tty->cr();
2620 gclog_or_tty->print_cr(" #### error: could not open file"); 2562 gclog_or_tty->print_cr(" #### error: could not open file");
2621 return; 2563 return;
2622 } 2564 }
2623 2565
2624 outputStream* out = &fout; 2566 outputStream* out = &fout;
2625 out->print_cr("-- USING %s", verify_option_to_tams(vo)); 2567 out->print_cr("-- USING %s", _g1h->top_at_mark_start_str(vo));
2626 out->cr(); 2568 out->cr();
2627 2569
2628 out->print_cr("--- ITERATING OVER REGIONS"); 2570 out->print_cr("--- ITERATING OVER REGIONS");
2629 out->cr(); 2571 out->cr();
2630 PrintReachableRegionClosure rcl(out, vo, all); 2572 PrintReachableRegionClosure rcl(out, vo, all);