Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/g1/g1CollectorPolicy.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 | 922993931b3d |
children | 7383557659bd |
comparison
equal
deleted
inserted
replaced
6253:db823a892a55 | 6254:a2f7274eb6ef |
---|---|
1526 } | 1526 } |
1527 }; | 1527 }; |
1528 | 1528 |
1529 class ParKnownGarbageHRClosure: public HeapRegionClosure { | 1529 class ParKnownGarbageHRClosure: public HeapRegionClosure { |
1530 G1CollectedHeap* _g1h; | 1530 G1CollectedHeap* _g1h; |
1531 CollectionSetChooser* _hrSorted; | 1531 CSetChooserParUpdater _cset_updater; |
1532 uint _marked_regions_added; | |
1533 size_t _reclaimable_bytes_added; | |
1534 uint _chunk_size; | |
1535 uint _cur_chunk_idx; | |
1536 uint _cur_chunk_end; // Cur chunk [_cur_chunk_idx, _cur_chunk_end) | |
1537 | |
1538 void get_new_chunk() { | |
1539 _cur_chunk_idx = _hrSorted->claim_array_chunk(_chunk_size); | |
1540 _cur_chunk_end = _cur_chunk_idx + _chunk_size; | |
1541 } | |
1542 void add_region(HeapRegion* r) { | |
1543 if (_cur_chunk_idx == _cur_chunk_end) { | |
1544 get_new_chunk(); | |
1545 } | |
1546 assert(_cur_chunk_idx < _cur_chunk_end, "postcondition"); | |
1547 _hrSorted->set_region(_cur_chunk_idx, r); | |
1548 _marked_regions_added++; | |
1549 _reclaimable_bytes_added += r->reclaimable_bytes(); | |
1550 _cur_chunk_idx++; | |
1551 } | |
1552 | 1532 |
1553 public: | 1533 public: |
1554 ParKnownGarbageHRClosure(CollectionSetChooser* hrSorted, | 1534 ParKnownGarbageHRClosure(CollectionSetChooser* hrSorted, |
1555 uint chunk_size) : | 1535 uint chunk_size) : |
1556 _g1h(G1CollectedHeap::heap()), | 1536 _g1h(G1CollectedHeap::heap()), |
1557 _hrSorted(hrSorted), _chunk_size(chunk_size), | 1537 _cset_updater(hrSorted, true /* parallel */, chunk_size) { } |
1558 _marked_regions_added(0), _reclaimable_bytes_added(0), | |
1559 _cur_chunk_idx(0), _cur_chunk_end(0) { } | |
1560 | 1538 |
1561 bool doHeapRegion(HeapRegion* r) { | 1539 bool doHeapRegion(HeapRegion* r) { |
1562 // Do we have any marking information for this region? | 1540 // Do we have any marking information for this region? |
1563 if (r->is_marked()) { | 1541 if (r->is_marked()) { |
1564 // We will skip any region that's currently used as an old GC | 1542 // We will skip any region that's currently used as an old GC |
1565 // alloc region (we should not consider those for collection | 1543 // alloc region (we should not consider those for collection |
1566 // before we fill them up). | 1544 // before we fill them up). |
1567 if (_hrSorted->should_add(r) && !_g1h->is_old_gc_alloc_region(r)) { | 1545 if (_cset_updater.should_add(r) && !_g1h->is_old_gc_alloc_region(r)) { |
1568 add_region(r); | 1546 _cset_updater.add_region(r); |
1569 } | 1547 } |
1570 } | 1548 } |
1571 return false; | 1549 return false; |
1572 } | 1550 } |
1573 uint marked_regions_added() { return _marked_regions_added; } | |
1574 size_t reclaimable_bytes_added() { return _reclaimable_bytes_added; } | |
1575 }; | 1551 }; |
1576 | 1552 |
1577 class ParKnownGarbageTask: public AbstractGangTask { | 1553 class ParKnownGarbageTask: public AbstractGangTask { |
1578 CollectionSetChooser* _hrSorted; | 1554 CollectionSetChooser* _hrSorted; |
1579 uint _chunk_size; | 1555 uint _chunk_size; |
1589 | 1565 |
1590 // Back to zero for the claim value. | 1566 // Back to zero for the claim value. |
1591 _g1->heap_region_par_iterate_chunked(&parKnownGarbageCl, worker_id, | 1567 _g1->heap_region_par_iterate_chunked(&parKnownGarbageCl, worker_id, |
1592 _g1->workers()->active_workers(), | 1568 _g1->workers()->active_workers(), |
1593 HeapRegion::InitialClaimValue); | 1569 HeapRegion::InitialClaimValue); |
1594 uint regions_added = parKnownGarbageCl.marked_regions_added(); | |
1595 size_t reclaimable_bytes_added = | |
1596 parKnownGarbageCl.reclaimable_bytes_added(); | |
1597 _hrSorted->update_totals(regions_added, reclaimable_bytes_added); | |
1598 } | 1570 } |
1599 }; | 1571 }; |
1600 | 1572 |
1601 void | 1573 void |
1602 G1CollectorPolicy::record_concurrent_mark_cleanup_end(int no_of_gc_threads) { | 1574 G1CollectorPolicy::record_concurrent_mark_cleanup_end(int no_of_gc_threads) { |