src/share/vm/gc_implementation/g1/heapRegionSet.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hs-gc9 Sdiff src/share/vm/gc_implementation/g1

src/share/vm/gc_implementation/g1/heapRegionSet.hpp

Print this page




  67   }
  68 
  69   void decrement(const uint length_to_remove, const size_t capacity_to_remove) {
  70     _length -= length_to_remove;
  71     _capacity -= capacity_to_remove;
  72   }
  73 };
  74 
  75 //////////////////// HeapRegionSetBase ////////////////////
  76 
  77 // Base class for all the classes that represent heap region sets. It
  78 // contains the basic attributes that each set needs to maintain
  79 // (e.g., length, region num, used bytes sum) plus any shared
  80 // functionality (e.g., verification).
  81 
  82 class HeapRegionSetBase VALUE_OBJ_CLASS_SPEC {
  83   friend class VMStructs;
  84 private:
  85   bool _is_humongous;
  86   bool _is_empty;
  87   bool _is_linked;
  88   HRSMtSafeChecker* _mt_safety_checker;
  89 
  90 protected:
  91   // The number of regions added to the set. If the set contains
  92   // only humongous regions, this reflects only 'starts humongous'
  93   // regions and does not include 'continues humongous' ones.
  94   HeapRegionSetCount _count;
  95 
  96   const char* _name;
  97 
  98   bool _verify_in_progress;
  99 
 100   // verify_region() is used to ensure that the contents of a region
 101   // added to / removed from a set are consistent.
 102   void verify_region(HeapRegion* hr) PRODUCT_RETURN;
 103 
 104   // Indicates whether all regions in the set should be humongous or
 105   // not. Only used during verification.
 106   bool regions_humongous() { return _is_humongous; }
 107 
 108   // Indicates whether all regions in the set should be empty or
 109   // not. Only used during verification.
 110   bool regions_empty() { return _is_empty; }
 111 
 112   bool regions_linked() { return _is_linked; }
 113 
 114   bool check_mt_safety() {
 115     if (_mt_safety_checker != NULL) {
 116       _mt_safety_checker->check();
 117     }
 118     return true;
 119   }
 120 
 121   virtual void fill_in_ext_msg_extra(hrs_ext_msg* msg) { }
 122 
 123   HeapRegionSetBase(const char* name, bool humongous, bool empty, bool linked, HRSMtSafeChecker* mt_safety_checker);
 124 
 125 public:
 126   const char* name() { return _name; }
 127 
 128   uint length() { return _count.length(); }
 129 
 130   bool is_empty() { return _count.length() == 0; }
 131 
 132   size_t total_capacity_bytes() {
 133     return _count.capacity();
 134   }
 135 
 136   // It updates the fields of the set to reflect hr being added to
 137   // the set and tags the region appropriately.
 138   inline void add(HeapRegion* hr);
 139 
 140   // It updates the fields of the set to reflect hr being removed
 141   // from the set and tags the region appropriately.
 142   inline void remove(HeapRegion* hr);
 143 


 175 
 176 //////////////////// HeapRegionSet ////////////////////
 177 
 178 #define hrs_assert_sets_match(_set1_, _set2_)                                 \
 179   do {                                                                        \
 180     assert(((_set1_)->regions_humongous() ==                                  \
 181                                             (_set2_)->regions_humongous()) && \
 182            ((_set1_)->regions_empty() == (_set2_)->regions_empty()),          \
 183            hrs_err_msg("the contents of set %s and set %s should match",      \
 184                        (_set1_)->name(), (_set2_)->name()));                  \
 185   } while (0)
 186 
 187 // This class represents heap region sets whose members are not
 188 // explicitly tracked. It's helpful to group regions using such sets
 189 // so that we can reason about all the region groups in the heap using
 190 // the same interface (namely, the HeapRegionSetBase API).
 191 
 192 class HeapRegionSet : public HeapRegionSetBase {
 193 public:
 194   HeapRegionSet(const char* name, bool humongous, HRSMtSafeChecker* mt_safety_checker):
 195     HeapRegionSetBase(name, humongous, false /* empty */, false /* linked */, mt_safety_checker) { }
 196 
 197   void bulk_remove(const HeapRegionSetCount& removed) {
 198     _count.decrement(removed.length(), removed.capacity());
 199   }
 200 };
 201 
 202 //////////////////// HeapRegionLinkedList ////////////////////
 203 
 204 // A set that links all the regions added to it in a singly-linked
 205 // list. We should try to avoid doing operations that iterate over
 206 // such lists in performance critical paths. Typically we should
 207 // add / remove one region at a time or concatenate two lists. All
 208 // those operations are done in constant time.
 209 
 210 class FreeRegionListIterator;
 211 
 212 class FreeRegionList : public HeapRegionSetBase {
 213   friend class FreeRegionListIterator;
 214 
 215 private:
 216   HeapRegion* _head;
 217   HeapRegion* _tail;
 218 
 219 protected:
 220   virtual void fill_in_ext_msg_extra(hrs_ext_msg* msg);
 221 
 222   // See the comment for HeapRegionSetBase::clear()
 223   virtual void clear();
 224 
 225 public:
 226   FreeRegionList(const char* name, HRSMtSafeChecker* mt_safety_checker):
 227     HeapRegionSetBase(name, false /* humongous */, true /* empty */, true /* linked */, mt_safety_checker) {
 228     clear();
 229   }
 230 
 231   void verify_list();
 232 
 233   HeapRegion* head() { return _head; }
 234   HeapRegion* tail() { return _tail; }
 235 
 236   static uint _unrealistically_long_length;
 237   static void set_unrealistically_long_length(uint len);
 238 
 239   // It adds hr to the list as the new head. The region should not be
 240   // a member of another set.
 241   inline void add_as_head(HeapRegion* hr);
 242 
 243   // It adds hr to the list as the new tail. The region should not be
 244   // a member of another set.
 245   inline void add_as_tail(HeapRegion* hr);
 246 
 247   // It removes and returns the head of the list. It assumes that the




  67   }
  68 
  69   void decrement(const uint length_to_remove, const size_t capacity_to_remove) {
  70     _length -= length_to_remove;
  71     _capacity -= capacity_to_remove;
  72   }
  73 };
  74 
  75 //////////////////// HeapRegionSetBase ////////////////////
  76 
  77 // Base class for all the classes that represent heap region sets. It
  78 // contains the basic attributes that each set needs to maintain
  79 // (e.g., length, region num, used bytes sum) plus any shared
  80 // functionality (e.g., verification).
  81 
  82 class HeapRegionSetBase VALUE_OBJ_CLASS_SPEC {
  83   friend class VMStructs;
  84 private:
  85   bool _is_humongous;
  86   bool _is_empty;

  87   HRSMtSafeChecker* _mt_safety_checker;
  88 
  89 protected:
  90   // The number of regions added to the set. If the set contains
  91   // only humongous regions, this reflects only 'starts humongous'
  92   // regions and does not include 'continues humongous' ones.
  93   HeapRegionSetCount _count;
  94 
  95   const char* _name;
  96 
  97   bool _verify_in_progress;
  98 
  99   // verify_region() is used to ensure that the contents of a region
 100   // added to / removed from a set are consistent.
 101   void verify_region(HeapRegion* hr) PRODUCT_RETURN;
 102 
 103   // Indicates whether all regions in the set should be humongous or
 104   // not. Only used during verification.
 105   bool regions_humongous() { return _is_humongous; }
 106 
 107   // Indicates whether all regions in the set should be empty or
 108   // not. Only used during verification.
 109   bool regions_empty() { return _is_empty; }
 110 


 111   bool check_mt_safety() {
 112     if (_mt_safety_checker != NULL) {
 113       _mt_safety_checker->check();
 114     }
 115     return true;
 116   }
 117 
 118   virtual void fill_in_ext_msg_extra(hrs_ext_msg* msg) { }
 119 
 120   HeapRegionSetBase(const char* name, bool humongous, bool empty, HRSMtSafeChecker* mt_safety_checker);
 121 
 122 public:
 123   const char* name() { return _name; }
 124 
 125   uint length() { return _count.length(); }
 126 
 127   bool is_empty() { return _count.length() == 0; }
 128 
 129   size_t total_capacity_bytes() {
 130     return _count.capacity();
 131   }
 132 
 133   // It updates the fields of the set to reflect hr being added to
 134   // the set and tags the region appropriately.
 135   inline void add(HeapRegion* hr);
 136 
 137   // It updates the fields of the set to reflect hr being removed
 138   // from the set and tags the region appropriately.
 139   inline void remove(HeapRegion* hr);
 140 


 172 
 173 //////////////////// HeapRegionSet ////////////////////
 174 
 175 #define hrs_assert_sets_match(_set1_, _set2_)                                 \
 176   do {                                                                        \
 177     assert(((_set1_)->regions_humongous() ==                                  \
 178                                             (_set2_)->regions_humongous()) && \
 179            ((_set1_)->regions_empty() == (_set2_)->regions_empty()),          \
 180            hrs_err_msg("the contents of set %s and set %s should match",      \
 181                        (_set1_)->name(), (_set2_)->name()));                  \
 182   } while (0)
 183 
 184 // This class represents heap region sets whose members are not
 185 // explicitly tracked. It's helpful to group regions using such sets
 186 // so that we can reason about all the region groups in the heap using
 187 // the same interface (namely, the HeapRegionSetBase API).
 188 
 189 class HeapRegionSet : public HeapRegionSetBase {
 190 public:
 191   HeapRegionSet(const char* name, bool humongous, HRSMtSafeChecker* mt_safety_checker):
 192     HeapRegionSetBase(name, humongous, false /* empty */, mt_safety_checker) { }
 193 
 194   void bulk_remove(const HeapRegionSetCount& removed) {
 195     _count.decrement(removed.length(), removed.capacity());
 196   }
 197 };
 198 
 199 //////////////////// HeapRegionLinkedList ////////////////////
 200 
 201 // A set that links all the regions added to it in a singly-linked
 202 // list. We should try to avoid doing operations that iterate over
 203 // such lists in performance critical paths. Typically we should
 204 // add / remove one region at a time or concatenate two lists. All
 205 // those operations are done in constant time.
 206 
 207 class FreeRegionListIterator;
 208 
 209 class FreeRegionList : public HeapRegionSetBase {
 210   friend class FreeRegionListIterator;
 211 
 212 private:
 213   HeapRegion* _head;
 214   HeapRegion* _tail;
 215 
 216 protected:
 217   virtual void fill_in_ext_msg_extra(hrs_ext_msg* msg);
 218 
 219   // See the comment for HeapRegionSetBase::clear()
 220   virtual void clear();
 221 
 222 public:
 223   FreeRegionList(const char* name, HRSMtSafeChecker* mt_safety_checker):
 224     HeapRegionSetBase(name, false /* humongous */, true /* empty */, mt_safety_checker) {
 225     clear();
 226   }
 227 
 228   void verify_list();
 229 
 230   HeapRegion* head() { return _head; }
 231   HeapRegion* tail() { return _tail; }
 232 
 233   static uint _unrealistically_long_length;
 234   static void set_unrealistically_long_length(uint len);
 235 
 236   // It adds hr to the list as the new head. The region should not be
 237   // a member of another set.
 238   inline void add_as_head(HeapRegion* hr);
 239 
 240   // It adds hr to the list as the new tail. The region should not be
 241   // a member of another set.
 242   inline void add_as_tail(HeapRegion* hr);
 243 
 244   // It removes and returns the head of the list. It assumes that the


src/share/vm/gc_implementation/g1/heapRegionSet.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File