< prev index next >

src/hotspot/share/gc/g1/g1CollectionSet.hpp

Print this page
rev 53416 : imported patch 8217330-split-collectionsetchooser


   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_GC_G1_G1COLLECTIONSET_HPP
  26 #define SHARE_GC_G1_G1COLLECTIONSET_HPP
  27 
  28 #include "gc/g1/collectionSetChooser.hpp"
  29 #include "utilities/debug.hpp"
  30 #include "utilities/globalDefinitions.hpp"
  31 
  32 class G1CollectedHeap;
  33 class G1CollectorState;
  34 class G1GCPhaseTimes;
  35 class G1ParScanThreadStateSet;
  36 class G1Policy;
  37 class G1SurvivorRegions;
  38 class HeapRegion;
  39 
  40 class G1CollectionSet {
  41   G1CollectedHeap* _g1h;
  42   G1Policy* _policy;
  43 
  44   CollectionSetChooser* _cset_chooser;

  45 
  46   uint _eden_region_length;
  47   uint _survivor_region_length;
  48   uint _old_region_length;
  49 
  50   // The actual collection set as a set of region indices.
  51   // All entries in _collection_set_regions below _collection_set_cur_length are
  52   // assumed to be valid entries.
  53   // We assume that at any time there is at most only one writer and (one or more)
  54   // concurrent readers. This means we are good with using storestore and loadload
  55   // barriers on the writer and reader respectively only.
  56   uint* _collection_set_regions;
  57   volatile size_t _collection_set_cur_length;
  58   size_t _collection_set_max_length;
  59 
  60   // When doing mixed collections we can add old regions to the collection, which
  61   // can be collected if there is enough time. We call these optional regions and
  62   // the pointer to these regions are stored in the array below.
  63   HeapRegion** _optional_regions;
  64   uint _optional_region_length;


 111   // See the comment for _inc_recorded_rs_lengths_diffs.
 112   double _inc_predicted_elapsed_time_ms_diffs;
 113 
 114   G1CollectorState* collector_state();
 115   G1GCPhaseTimes* phase_times();
 116 
 117   void verify_young_cset_indices() const NOT_DEBUG_RETURN;
 118   void add_as_optional(HeapRegion* hr);
 119   void add_as_old(HeapRegion* hr);
 120   bool optional_is_full();
 121 
 122 public:
 123   G1CollectionSet(G1CollectedHeap* g1h, G1Policy* policy);
 124   ~G1CollectionSet();
 125 
 126   // Initializes the collection set giving the maximum possible length of the collection set.
 127   void initialize(uint max_region_length);
 128   void initialize_optional(uint max_length);
 129   void free_optional_regions();
 130 
 131   CollectionSetChooser* cset_chooser();








 132 
 133   void init_region_lengths(uint eden_cset_region_length,
 134                            uint survivor_cset_region_length);
 135 
 136   void set_recorded_rs_lengths(size_t rs_lengths);
 137 
 138   uint region_length() const       { return young_region_length() +
 139                                             old_region_length(); }
 140   uint young_region_length() const { return eden_region_length() +
 141                                             survivor_region_length(); }
 142 
 143   uint eden_region_length() const     { return _eden_region_length;     }
 144   uint survivor_region_length() const { return _survivor_region_length; }
 145   uint old_region_length() const      { return _old_region_length;      }
 146   uint optional_region_length() const { return _optional_region_length; }
 147 
 148   // Incremental collection set support
 149 
 150   // Initialize incremental collection set info.
 151   void start_incremental_building();


 236 private:
 237   G1CollectionSet* _cset;
 238   G1ParScanThreadStateSet* _pset;
 239   uint _current_index;
 240   uint _current_limit;
 241   bool _prepare_failed;
 242   bool _evacuation_failed;
 243 
 244   void prepare_to_evacuate_optional_region(HeapRegion* hr);
 245 
 246 public:
 247   static const uint InvalidCSetIndex = UINT_MAX;
 248 
 249   G1OptionalCSet(G1CollectionSet* cset, G1ParScanThreadStateSet* pset) :
 250     _cset(cset),
 251     _pset(pset),
 252     _current_index(0),
 253     _current_limit(0),
 254     _prepare_failed(false),
 255     _evacuation_failed(false) { }
 256   // The destructor returns regions to the cset-chooser and
 257   // frees the optional structure in the cset.
 258   ~G1OptionalCSet();
 259 
 260   uint current_index() { return _current_index; }
 261   uint current_limit() { return _current_limit; }
 262 
 263   uint size();
 264   bool is_empty();
 265 
 266   HeapRegion* region_at(uint index);
 267 
 268   // Prepare a set of regions for optional evacuation.
 269   void prepare_evacuation(double time_left_ms);
 270   bool prepare_failed();
 271 
 272   // Complete the evacuation of the previously prepared
 273   // regions by updating their state and check for failures.
 274   void complete_evacuation();
 275   bool evacuation_failed();
 276 };
 277 


   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_GC_G1_G1COLLECTIONSET_HPP
  26 #define SHARE_GC_G1_G1COLLECTIONSET_HPP
  27 
  28 #include "gc/g1/g1CollectionSetCandidates.hpp"
  29 #include "utilities/debug.hpp"
  30 #include "utilities/globalDefinitions.hpp"
  31 
  32 class G1CollectedHeap;
  33 class G1CollectorState;
  34 class G1GCPhaseTimes;
  35 class G1ParScanThreadStateSet;
  36 class G1Policy;
  37 class G1SurvivorRegions;
  38 class HeapRegion;
  39 
  40 class G1CollectionSet {
  41   G1CollectedHeap* _g1h;
  42   G1Policy* _policy;
  43 
  44   // All old gen collection set candidate regions for the current mixed gc phase.
  45   G1CollectionSetCandidates* _candidates;
  46 
  47   uint _eden_region_length;
  48   uint _survivor_region_length;
  49   uint _old_region_length;
  50 
  51   // The actual collection set as a set of region indices.
  52   // All entries in _collection_set_regions below _collection_set_cur_length are
  53   // assumed to be valid entries.
  54   // We assume that at any time there is at most only one writer and (one or more)
  55   // concurrent readers. This means we are good with using storestore and loadload
  56   // barriers on the writer and reader respectively only.
  57   uint* _collection_set_regions;
  58   volatile size_t _collection_set_cur_length;
  59   size_t _collection_set_max_length;
  60 
  61   // When doing mixed collections we can add old regions to the collection, which
  62   // can be collected if there is enough time. We call these optional regions and
  63   // the pointer to these regions are stored in the array below.
  64   HeapRegion** _optional_regions;
  65   uint _optional_region_length;


 112   // See the comment for _inc_recorded_rs_lengths_diffs.
 113   double _inc_predicted_elapsed_time_ms_diffs;
 114 
 115   G1CollectorState* collector_state();
 116   G1GCPhaseTimes* phase_times();
 117 
 118   void verify_young_cset_indices() const NOT_DEBUG_RETURN;
 119   void add_as_optional(HeapRegion* hr);
 120   void add_as_old(HeapRegion* hr);
 121   bool optional_is_full();
 122 
 123 public:
 124   G1CollectionSet(G1CollectedHeap* g1h, G1Policy* policy);
 125   ~G1CollectionSet();
 126 
 127   // Initializes the collection set giving the maximum possible length of the collection set.
 128   void initialize(uint max_region_length);
 129   void initialize_optional(uint max_length);
 130   void free_optional_regions();
 131 
 132   void clear_candidates() {
 133     delete _candidates;
 134     _candidates = NULL;
 135   }
 136   void set_candidates(G1CollectionSetCandidates* candidates) {
 137     assert(_candidates == NULL, "Trying to replace collection set candidates.");
 138     _candidates = candidates;
 139   }
 140   G1CollectionSetCandidates* candidates() { return _candidates; }
 141   
 142   void init_region_lengths(uint eden_cset_region_length,
 143                            uint survivor_cset_region_length);
 144 
 145   void set_recorded_rs_lengths(size_t rs_lengths);
 146 
 147   uint region_length() const       { return young_region_length() +
 148                                             old_region_length(); }
 149   uint young_region_length() const { return eden_region_length() +
 150                                             survivor_region_length(); }
 151 
 152   uint eden_region_length() const     { return _eden_region_length;     }
 153   uint survivor_region_length() const { return _survivor_region_length; }
 154   uint old_region_length() const      { return _old_region_length;      }
 155   uint optional_region_length() const { return _optional_region_length; }
 156 
 157   // Incremental collection set support
 158 
 159   // Initialize incremental collection set info.
 160   void start_incremental_building();


 245 private:
 246   G1CollectionSet* _cset;
 247   G1ParScanThreadStateSet* _pset;
 248   uint _current_index;
 249   uint _current_limit;
 250   bool _prepare_failed;
 251   bool _evacuation_failed;
 252 
 253   void prepare_to_evacuate_optional_region(HeapRegion* hr);
 254 
 255 public:
 256   static const uint InvalidCSetIndex = UINT_MAX;
 257 
 258   G1OptionalCSet(G1CollectionSet* cset, G1ParScanThreadStateSet* pset) :
 259     _cset(cset),
 260     _pset(pset),
 261     _current_index(0),
 262     _current_limit(0),
 263     _prepare_failed(false),
 264     _evacuation_failed(false) { }
 265   // The destructor returns regions to the collection set candidates set and
 266   // frees the optional structure in the collection set.
 267   ~G1OptionalCSet();
 268 
 269   uint current_index() { return _current_index; }
 270   uint current_limit() { return _current_limit; }
 271 
 272   uint size();
 273   bool is_empty();
 274 
 275   HeapRegion* region_at(uint index);
 276 
 277   // Prepare a set of regions for optional evacuation.
 278   void prepare_evacuation(double time_left_ms);
 279   bool prepare_failed();
 280 
 281   // Complete the evacuation of the previously prepared
 282   // regions by updating their state and check for failures.
 283   void complete_evacuation();
 284   bool evacuation_failed();
 285 };
 286 
< prev index next >