< prev index next >

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

Print this page
rev 56448 : imported patch 8220310.mut.0
rev 56449 : imported patch 8220310.mut.1
rev 56461 : imported patch 8220312.stat.2
rev 56463 : [mq]: 8220312.stat.4


 119 // so that we can reason about all the region groups in the heap using
 120 // the same interface (namely, the HeapRegionSetBase API).
 121 
 122 class HeapRegionSet : public HeapRegionSetBase {
 123 public:
 124   HeapRegionSet(const char* name, HeapRegionSetChecker* checker):
 125     HeapRegionSetBase(name, checker) {
 126   }
 127 
 128   void bulk_remove(const uint removed) {
 129     _length -= removed;
 130   }
 131 };
 132 
 133 // A set that links all the regions added to it in a doubly-linked
 134 // sorted list. We should try to avoid doing operations that iterate over
 135 // such lists in performance critical paths. Typically we should
 136 // add / remove one region at a time or concatenate two lists.
 137 
 138 class FreeRegionListIterator;

 139 
 140 class FreeRegionList : public HeapRegionSetBase {
 141   friend class FreeRegionListIterator;
 142 
 143 private:
 144   HeapRegion* _head;
 145   HeapRegion* _tail;
 146 
 147   // _last is used to keep track of where we added an element the last
 148   // time. It helps to improve performance when adding several ordered items in a row.
 149   HeapRegion* _last;
 150 


 151   static uint _unrealistically_long_length;
 152 
 153   inline HeapRegion* remove_from_head_impl();
 154   inline HeapRegion* remove_from_tail_impl();
 155 



 156 protected:
 157   // See the comment for HeapRegionSetBase::clear()
 158   virtual void clear();
 159 
 160 public:
 161   FreeRegionList(const char* name, HeapRegionSetChecker* checker = NULL):
 162     HeapRegionSetBase(name, checker) {
 163     clear();
 164   }
 165 
 166   void verify_list();
 167 
 168 #ifdef ASSERT
 169   bool contains(HeapRegion* hr) const {
 170     return hr->containing_set() == this;
 171   }
 172 #endif
 173 
 174   static void set_unrealistically_long_length(uint len);
 175 
 176   // Add hr to the list. The region should not be a member of another set.
 177   // Assumes that the list is ordered and will preserve that order. The order
 178   // is determined by hrm_index.
 179   inline void add_ordered(HeapRegion* hr);
 180 
 181   // Removes from head or tail based on the given argument.
 182   HeapRegion* remove_region(bool from_head);
 183 
 184   HeapRegion* remove_region_with_node_index(bool from_head,
 185                                             const uint requested_node_index,
 186                                             uint* region_node_index);
 187 
 188   // Merge two ordered lists. The result is also ordered. The order is
 189   // determined by hrm_index.
 190   void add_ordered(FreeRegionList* from_list);
 191 
 192   // It empties the list by removing all regions from it.
 193   void remove_all();
 194 
 195   // Remove all (contiguous) regions from first to first + num_regions -1 from
 196   // this list.
 197   // Num_regions must be > 1.
 198   void remove_starting_at(HeapRegion* first, uint num_regions);
 199 
 200   virtual void verify();
 201 
 202   uint num_of_regions_in_range(uint start, uint end) const;



 203 };
 204 
 205 // Iterator class that provides a convenient way to iterate over the
 206 // regions of a FreeRegionList.
 207 
 208 class FreeRegionListIterator : public StackObj {
 209 private:
 210   FreeRegionList* _list;
 211   HeapRegion*     _curr;
 212 
 213 public:
 214   bool more_available() {
 215     return _curr != NULL;
 216   }
 217 
 218   HeapRegion* get_next() {
 219     assert(more_available(),
 220            "get_next() should be called when more regions are available");
 221 
 222     // If we are going to introduce a count in the iterator we should
 223     // do the "cycle" check.
 224 
 225     HeapRegion* hr = _curr;
 226     _list->verify_region(hr);
 227     _curr = hr->next();
 228     return hr;
 229   }
 230 
 231   FreeRegionListIterator(FreeRegionList* list)
 232   : _list(list),
 233     _curr(list->_head) {
 234   }






















 235 };
 236 
 237 #endif // SHARE_GC_G1_HEAPREGIONSET_HPP


 119 // so that we can reason about all the region groups in the heap using
 120 // the same interface (namely, the HeapRegionSetBase API).
 121 
 122 class HeapRegionSet : public HeapRegionSetBase {
 123 public:
 124   HeapRegionSet(const char* name, HeapRegionSetChecker* checker):
 125     HeapRegionSetBase(name, checker) {
 126   }
 127 
 128   void bulk_remove(const uint removed) {
 129     _length -= removed;
 130   }
 131 };
 132 
 133 // A set that links all the regions added to it in a doubly-linked
 134 // sorted list. We should try to avoid doing operations that iterate over
 135 // such lists in performance critical paths. Typically we should
 136 // add / remove one region at a time or concatenate two lists.
 137 
 138 class FreeRegionListIterator;
 139 class NodeInfo;
 140 
 141 class FreeRegionList : public HeapRegionSetBase {
 142   friend class FreeRegionListIterator;
 143 
 144 private:
 145   HeapRegion* _head;
 146   HeapRegion* _tail;
 147 
 148   // _last is used to keep track of where we added an element the last
 149   // time. It helps to improve performance when adding several ordered items in a row.
 150   HeapRegion* _last;
 151 
 152   NodeInfo*   _node_info;
 153 
 154   static uint _unrealistically_long_length;
 155 
 156   inline HeapRegion* remove_from_head_impl();
 157   inline HeapRegion* remove_from_tail_impl();
 158 
 159   inline void increase_length(uint node_index);
 160   inline void decrease_length(uint node_index);
 161 
 162 protected:
 163   // See the comment for HeapRegionSetBase::clear()
 164   virtual void clear();
 165 
 166 public:
 167   FreeRegionList(const char* name, HeapRegionSetChecker* checker = NULL);
 168   ~FreeRegionList();


 169 
 170   void verify_list();
 171 
 172 #ifdef ASSERT
 173   bool contains(HeapRegion* hr) const {
 174     return hr->containing_set() == this;
 175   }
 176 #endif
 177 
 178   static void set_unrealistically_long_length(uint len);
 179 
 180   // Add hr to the list. The region should not be a member of another set.
 181   // Assumes that the list is ordered and will preserve that order. The order
 182   // is determined by hrm_index.
 183   inline void add_ordered(HeapRegion* hr);
 184 
 185   // Removes from head or tail based on the given argument.
 186   HeapRegion* remove_region(bool from_head);
 187 
 188   HeapRegion* remove_region_with_node_index(bool from_head,
 189                                             const uint requested_node_index);

 190 
 191   // Merge two ordered lists. The result is also ordered. The order is
 192   // determined by hrm_index.
 193   void add_ordered(FreeRegionList* from_list);
 194 
 195   // It empties the list by removing all regions from it.
 196   void remove_all();
 197 
 198   // Remove all (contiguous) regions from first to first + num_regions -1 from
 199   // this list.
 200   // Num_regions must be > 1.
 201   void remove_starting_at(HeapRegion* first, uint num_regions);
 202 
 203   virtual void verify();
 204 
 205   uint num_of_regions_in_range(uint start, uint end) const;
 206 
 207   using HeapRegionSetBase::length;
 208   uint length(uint node_index) const;
 209 };
 210 
 211 // Iterator class that provides a convenient way to iterate over the
 212 // regions of a FreeRegionList.
 213 
 214 class FreeRegionListIterator : public StackObj {
 215 private:
 216   FreeRegionList* _list;
 217   HeapRegion*     _curr;
 218 
 219 public:
 220   bool more_available() {
 221     return _curr != NULL;
 222   }
 223 
 224   HeapRegion* get_next() {
 225     assert(more_available(),
 226            "get_next() should be called when more regions are available");
 227 
 228     // If we are going to introduce a count in the iterator we should
 229     // do the "cycle" check.
 230 
 231     HeapRegion* hr = _curr;
 232     _list->verify_region(hr);
 233     _curr = hr->next();
 234     return hr;
 235   }
 236 
 237   FreeRegionListIterator(FreeRegionList* list)
 238   : _list(list),
 239     _curr(list->_head) {
 240   }
 241 };
 242 
 243 class G1NUMA;
 244 
 245 // This class is only initialized if there are multiple active nodes.
 246 class NodeInfo : public CHeapObj<mtGC> {
 247   G1NUMA* _numa;
 248   uint*   _length_of_node;
 249   uint    _num_nodes;
 250 
 251 public:
 252   NodeInfo();
 253   ~NodeInfo();
 254 
 255   inline void increase_length(uint node_index);
 256   inline void decrease_length(uint node_index);
 257 
 258   inline uint length(uint index) const;
 259 
 260   void clear();
 261 
 262   void add(NodeInfo* info);
 263 };
 264 
 265 #endif // SHARE_GC_G1_HEAPREGIONSET_HPP
< prev index next >