src/hotspot/share/gc/g1/heapRegionSet.inline.hpp
changeset 59062 6530de931b8e
parent 59060 fce1fa1bdc91
equal deleted inserted replaced
59061:df6f2350edfa 59062:6530de931b8e
    93     // The list was empty
    93     // The list was empty
    94     _tail = hr;
    94     _tail = hr;
    95     _head = hr;
    95     _head = hr;
    96   }
    96   }
    97   _last = hr;
    97   _last = hr;
       
    98 
       
    99   increase_length(hr->node_index());
    98 }
   100 }
    99 
   101 
   100 inline HeapRegion* FreeRegionList::remove_from_head_impl() {
   102 inline HeapRegion* FreeRegionList::remove_from_head_impl() {
   101   HeapRegion* result = _head;
   103   HeapRegion* result = _head;
   102   _head = result->next();
   104   _head = result->next();
   143     _last = NULL;
   145     _last = NULL;
   144   }
   146   }
   145 
   147 
   146   // remove() will verify the region and check mt safety.
   148   // remove() will verify the region and check mt safety.
   147   remove(hr);
   149   remove(hr);
       
   150 
       
   151   decrease_length(hr->node_index());
       
   152 
   148   return hr;
   153   return hr;
   149 }
   154 }
   150 
   155 
   151 inline HeapRegion* FreeRegionList::remove_region_with_node_index(bool from_head,
   156 inline HeapRegion* FreeRegionList::remove_region_with_node_index(bool from_head,
   152                                                                  const uint requested_node_index,
   157                                                                  uint requested_node_index) {
   153                                                                  uint* allocated_node_index) {
       
   154   assert(UseNUMA, "Invariant");
   158   assert(UseNUMA, "Invariant");
   155 
   159 
   156   const uint max_search_depth = G1NUMA::numa()->max_search_depth();
   160   const uint max_search_depth = G1NUMA::numa()->max_search_depth();
   157   HeapRegion* cur;
   161   HeapRegion* cur;
   158 
   162 
   200   if (_last == cur) {
   204   if (_last == cur) {
   201     _last = NULL;
   205     _last = NULL;
   202   }
   206   }
   203 
   207 
   204   remove(cur);
   208   remove(cur);
   205   if (allocated_node_index != NULL) {
   209   decrease_length(cur->node_index());
   206     *allocated_node_index = cur->node_index();
       
   207   }
       
   208 
   210 
   209   return cur;
   211   return cur;
   210 }
   212 }
   211 
   213 
       
   214 inline void FreeRegionList::NodeInfo::increase_length(uint node_index) {
       
   215   if (node_index < _num_nodes) {
       
   216     _length_of_node[node_index] += 1;
       
   217   }
       
   218 }
       
   219 
       
   220 inline void FreeRegionList::NodeInfo::decrease_length(uint node_index) {
       
   221   if (node_index < _num_nodes) {
       
   222     assert(_length_of_node[node_index] > 0,
       
   223            "Current length %u should be greater than zero for node %u",
       
   224            _length_of_node[node_index], node_index);
       
   225     _length_of_node[node_index] -= 1;
       
   226   }
       
   227 }
       
   228 
       
   229 inline uint FreeRegionList::NodeInfo::length(uint node_index) const {
       
   230   return _length_of_node[node_index];
       
   231 }
       
   232 
       
   233 inline void FreeRegionList::increase_length(uint node_index) {
       
   234   if (_node_info != NULL) {
       
   235     return _node_info->increase_length(node_index);
       
   236   }
       
   237 }
       
   238 
       
   239 inline void FreeRegionList::decrease_length(uint node_index) {
       
   240   if (_node_info != NULL) {
       
   241     return _node_info->decrease_length(node_index);
       
   242   }
       
   243 }
       
   244 
       
   245 inline uint FreeRegionList::length(uint node_index) const {
       
   246   if (_node_info != NULL) {
       
   247     return _node_info->length(node_index);
       
   248   } else {
       
   249     return 0;
       
   250   }
       
   251 }
       
   252 
   212 #endif // SHARE_GC_G1_HEAPREGIONSET_INLINE_HPP
   253 #endif // SHARE_GC_G1_HEAPREGIONSET_INLINE_HPP