< prev index next >

src/share/vm/gc/g1/collectionSetChooser.hpp

Print this page
rev 8362 : 8079792: GC directory structure cleanup
Reviewed-by:
   1 /*
   2  * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_COLLECTIONSETCHOOSER_HPP
  26 #define SHARE_VM_GC_IMPLEMENTATION_G1_COLLECTIONSETCHOOSER_HPP
  27 
  28 #include "gc_implementation/g1/heapRegion.hpp"
  29 #include "utilities/growableArray.hpp"
  30 
  31 class CollectionSetChooser: public CHeapObj<mtGC> {
  32 
  33   GrowableArray<HeapRegion*> _regions;
  34 
  35   // Unfortunately, GrowableArray uses ints for length and indexes. To
  36   // avoid excessive casting in the rest of the class the following
  37   // wrapper methods are provided that use uints.
  38 
  39   uint regions_length()          { return (uint) _regions.length(); }
  40   HeapRegion* regions_at(uint i) { return _regions.at((int) i);     }
  41   void regions_at_put(uint i, HeapRegion* hr) {
  42     _regions.at_put((int) i, hr);
  43   }
  44   void regions_at_put_grow(uint i, HeapRegion* hr) {
  45     _regions.at_put_grow((int) i, hr);
  46   }
  47   void regions_trunc_to(uint i)  { _regions.trunc_to((uint) i); }
  48 


 175 
 176   void add_region(HeapRegion* hr) {
 177     if (_parallel) {
 178       if (_cur_chunk_idx == _cur_chunk_end) {
 179         _cur_chunk_idx = _chooser->claim_array_chunk(_chunk_size);
 180         _cur_chunk_end = _cur_chunk_idx + _chunk_size;
 181       }
 182       assert(_cur_chunk_idx < _cur_chunk_end, "invariant");
 183       _chooser->set_region(_cur_chunk_idx, hr);
 184       _cur_chunk_idx += 1;
 185     } else {
 186       _chooser->add_region(hr);
 187     }
 188     _regions_added += 1;
 189     _reclaimable_bytes_added += hr->reclaimable_bytes();
 190   }
 191 
 192   bool should_add(HeapRegion* hr) { return _chooser->should_add(hr); }
 193 };
 194 
 195 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_COLLECTIONSETCHOOSER_HPP
 196 
   1 /*
   2  * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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 #ifndef SHARE_VM_GC_G1_COLLECTIONSETCHOOSER_HPP
  26 #define SHARE_VM_GC_G1_COLLECTIONSETCHOOSER_HPP
  27 
  28 #include "gc/g1/heapRegion.hpp"
  29 #include "utilities/growableArray.hpp"
  30 
  31 class CollectionSetChooser: public CHeapObj<mtGC> {
  32 
  33   GrowableArray<HeapRegion*> _regions;
  34 
  35   // Unfortunately, GrowableArray uses ints for length and indexes. To
  36   // avoid excessive casting in the rest of the class the following
  37   // wrapper methods are provided that use uints.
  38 
  39   uint regions_length()          { return (uint) _regions.length(); }
  40   HeapRegion* regions_at(uint i) { return _regions.at((int) i);     }
  41   void regions_at_put(uint i, HeapRegion* hr) {
  42     _regions.at_put((int) i, hr);
  43   }
  44   void regions_at_put_grow(uint i, HeapRegion* hr) {
  45     _regions.at_put_grow((int) i, hr);
  46   }
  47   void regions_trunc_to(uint i)  { _regions.trunc_to((uint) i); }
  48 


 175 
 176   void add_region(HeapRegion* hr) {
 177     if (_parallel) {
 178       if (_cur_chunk_idx == _cur_chunk_end) {
 179         _cur_chunk_idx = _chooser->claim_array_chunk(_chunk_size);
 180         _cur_chunk_end = _cur_chunk_idx + _chunk_size;
 181       }
 182       assert(_cur_chunk_idx < _cur_chunk_end, "invariant");
 183       _chooser->set_region(_cur_chunk_idx, hr);
 184       _cur_chunk_idx += 1;
 185     } else {
 186       _chooser->add_region(hr);
 187     }
 188     _regions_added += 1;
 189     _reclaimable_bytes_added += hr->reclaimable_bytes();
 190   }
 191 
 192   bool should_add(HeapRegion* hr) { return _chooser->should_add(hr); }
 193 };
 194 
 195 #endif // SHARE_VM_GC_G1_COLLECTIONSETCHOOSER_HPP
 196 
< prev index next >