< prev index next >

src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp

Print this page




  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 "gc/g1/g1CollectionSetCandidates.hpp"
  27 #include "gc/g1/g1CollectionSetChooser.hpp"
  28 #include "gc/g1/heapRegion.inline.hpp"
  29 
  30 void G1CollectionSetCandidates::remove(uint num_regions) {
  31   assert(num_regions <= num_remaining(), "Trying to remove more regions (%u) than available (%u)", num_regions, num_remaining());
  32   for (uint i = 0; i < num_regions; i++) {
  33     _remaining_reclaimable_bytes -= at(_front_idx)->reclaimable_bytes();
  34     _front_idx++;
  35   }














  36 }
  37 
  38 void G1CollectionSetCandidates::iterate(HeapRegionClosure* cl) {
  39   for (uint i = _front_idx; i < _num_regions; i++) {
  40     HeapRegion* r = _regions[i];
  41     if (cl->do_heap_region(r)) {
  42       cl->set_incomplete();
  43       break;
  44     }
  45   }
  46 }
  47 
  48 #ifndef PRODUCT
  49 void G1CollectionSetCandidates::verify() const {
  50   guarantee(_front_idx <= _num_regions, "Index: %u Num_regions: %u", _front_idx, _num_regions);
  51   uint idx = _front_idx;
  52   size_t sum_of_reclaimable_bytes = 0;





  53   HeapRegion *prev = NULL;
  54   for (; idx < _num_regions; idx++) {
  55     HeapRegion *cur = _regions[idx];
  56     guarantee(cur != NULL, "Regions after _front_idx %u cannot be NULL but %u is", _front_idx, idx);
  57     guarantee(G1CollectionSetChooser::should_add(cur), "Region %u should be eligible for addition.", cur->hrm_index());
  58     if (prev != NULL) {
  59       guarantee(prev->gc_efficiency() >= cur->gc_efficiency(),
  60                 "GC efficiency for region %u: %1.4f smaller than for region %u: %1.4f",
  61                 prev->hrm_index(), prev->gc_efficiency(), cur->hrm_index(), cur->gc_efficiency());
  62     }
  63     sum_of_reclaimable_bytes += cur->reclaimable_bytes();
  64     prev = cur;
  65   }
  66   guarantee(sum_of_reclaimable_bytes == _remaining_reclaimable_bytes,
  67             "Inconsistent remaining_reclaimable bytes, remaining " SIZE_FORMAT " calculated " SIZE_FORMAT,
  68             _remaining_reclaimable_bytes, sum_of_reclaimable_bytes);
  69 }
  70 #endif // !PRODUCT


  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 "gc/g1/g1CollectionSetCandidates.hpp"
  27 #include "gc/g1/g1CollectionSetChooser.hpp"
  28 #include "gc/g1/heapRegion.inline.hpp"
  29 
  30 HeapRegion* G1CollectionSetCandidates::pop_front() {
  31   assert(_front_idx < _num_regions, "pre-condition");
  32   HeapRegion* hr = _regions[_front_idx];
  33   assert(hr != NULL, "pre-condition");
  34   _regions[_front_idx] = NULL;
  35   assert(hr->reclaimable_bytes() <= _remaining_reclaimable_bytes,
  36          "Remaining reclaimable bytes inconsistent "
  37          "from region: " SIZE_FORMAT " remaining: " SIZE_FORMAT,
  38          hr->reclaimable_bytes(), _remaining_reclaimable_bytes);
  39   _remaining_reclaimable_bytes -= hr->reclaimable_bytes();
  40   _front_idx++;
  41   return hr;
  42 }
  43 
  44 void G1CollectionSetCandidates::push_front(HeapRegion* hr) {
  45   assert(hr != NULL, "Can't put back a NULL region");
  46   assert(_front_idx >= 1, "Too many regions have been put back.");
  47   _front_idx--;
  48   _regions[_front_idx] = hr;
  49   _remaining_reclaimable_bytes += hr->reclaimable_bytes();
  50 }
  51 
  52 void G1CollectionSetCandidates::iterate(HeapRegionClosure* cl) {
  53   for (uint i = _front_idx; i < _num_regions; i++) {
  54     HeapRegion* r = _regions[i];
  55     if (cl->do_heap_region(r)) {
  56       cl->set_incomplete();
  57       break;
  58     }
  59   }
  60 }
  61 
  62 #ifndef PRODUCT
  63 void G1CollectionSetCandidates::verify() const {
  64   guarantee(_front_idx <= _num_regions, "Index: %u Num_regions: %u", _front_idx, _num_regions);
  65   uint idx = 0;
  66   size_t sum_of_reclaimable_bytes = 0;
  67   while (idx < _front_idx) {
  68     guarantee(_regions[idx] == NULL, "All entries before _front_idx %u should be NULL, but %u is not",
  69               _front_idx, idx);
  70     idx++;
  71   }
  72   HeapRegion *prev = NULL;
  73   for (; idx < _num_regions; idx++) {
  74     HeapRegion *cur = _regions[idx];
  75     guarantee(cur != NULL, "Regions after _front_idx %u cannot be NULL but %u is", _front_idx, idx);
  76     guarantee(G1CollectionSetChooser::should_add(cur), "Region %u should be eligible for addition.", cur->hrm_index());
  77     if (prev != NULL) {
  78       guarantee(prev->gc_efficiency() >= cur->gc_efficiency(),
  79                 "GC efficiency for region %u: %1.4f smaller than for region %u: %1.4f",
  80                 prev->hrm_index(), prev->gc_efficiency(), cur->hrm_index(), cur->gc_efficiency());
  81     }
  82     sum_of_reclaimable_bytes += cur->reclaimable_bytes();
  83     prev = cur;
  84   }
  85   guarantee(sum_of_reclaimable_bytes == _remaining_reclaimable_bytes,
  86             "Inconsistent remaining_reclaimable bytes, remaining " SIZE_FORMAT " calculated " SIZE_FORMAT,
  87             _remaining_reclaimable_bytes, sum_of_reclaimable_bytes);
  88 }
  89 #endif // !PRODUCT
< prev index next >