< prev index next >

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

Print this page
rev 56448 : imported patch 8220310.mut.0
rev 56449 : imported patch 8220310.mut.1
rev 56450 : imported patch 8220310.mut.2
rev 56451 : imported patch 8220310.mut.3
rev 56452 : [mq]: 8220310.mut.4


   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_HEAPREGIONSET_INLINE_HPP
  26 #define SHARE_GC_G1_HEAPREGIONSET_INLINE_HPP
  27 

  28 #include "gc/g1/heapRegionSet.hpp"
  29 
  30 inline void HeapRegionSetBase::add(HeapRegion* hr) {
  31   check_mt_safety();
  32   assert_heap_region_set(hr->containing_set() == NULL, "should not already have a containing set");
  33   assert_heap_region_set(hr->next() == NULL, "should not already be linked");
  34   assert_heap_region_set(hr->prev() == NULL, "should not already be linked");
  35 
  36   _length++;
  37   hr->set_containing_set(this);
  38   verify_region(hr);
  39 }
  40 
  41 inline void HeapRegionSetBase::remove(HeapRegion* hr) {
  42   check_mt_safety();
  43   verify_region(hr);
  44   assert_heap_region_set(hr->next() == NULL, "should already be unlinked");
  45   assert_heap_region_set(hr->prev() == NULL, "should already be unlinked");
  46 
  47   hr->set_containing_set(NULL);


 128   if (is_empty()) {
 129     return NULL;
 130   }
 131   assert_free_region_list(length() > 0 && _head != NULL && _tail != NULL, "invariant");
 132 
 133   HeapRegion* hr;
 134 
 135   if (from_head) {
 136     hr = remove_from_head_impl();
 137   } else {
 138     hr = remove_from_tail_impl();
 139   }
 140 
 141   if (_last == hr) {
 142     _last = NULL;
 143   }
 144 
 145   // remove() will verify the region and check mt safety.
 146   remove(hr);
 147   return hr;





























































 148 }
 149 
 150 #endif // SHARE_GC_G1_HEAPREGIONSET_INLINE_HPP


   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_HEAPREGIONSET_INLINE_HPP
  26 #define SHARE_GC_G1_HEAPREGIONSET_INLINE_HPP
  27 
  28 #include "gc/g1/g1NUMA.hpp"
  29 #include "gc/g1/heapRegionSet.hpp"
  30 
  31 inline void HeapRegionSetBase::add(HeapRegion* hr) {
  32   check_mt_safety();
  33   assert_heap_region_set(hr->containing_set() == NULL, "should not already have a containing set");
  34   assert_heap_region_set(hr->next() == NULL, "should not already be linked");
  35   assert_heap_region_set(hr->prev() == NULL, "should not already be linked");
  36 
  37   _length++;
  38   hr->set_containing_set(this);
  39   verify_region(hr);
  40 }
  41 
  42 inline void HeapRegionSetBase::remove(HeapRegion* hr) {
  43   check_mt_safety();
  44   verify_region(hr);
  45   assert_heap_region_set(hr->next() == NULL, "should already be unlinked");
  46   assert_heap_region_set(hr->prev() == NULL, "should already be unlinked");
  47 
  48   hr->set_containing_set(NULL);


 129   if (is_empty()) {
 130     return NULL;
 131   }
 132   assert_free_region_list(length() > 0 && _head != NULL && _tail != NULL, "invariant");
 133 
 134   HeapRegion* hr;
 135 
 136   if (from_head) {
 137     hr = remove_from_head_impl();
 138   } else {
 139     hr = remove_from_tail_impl();
 140   }
 141 
 142   if (_last == hr) {
 143     _last = NULL;
 144   }
 145 
 146   // remove() will verify the region and check mt safety.
 147   remove(hr);
 148   return hr;
 149 }
 150 
 151 inline HeapRegion* FreeRegionList::remove_region_with_node_index(bool from_head,
 152                                                                  const uint requested_node_index,
 153                                                                  uint* allocated_node_index) {
 154   assert(UseNUMA, "Invariant");
 155 
 156   const uint max_search_depth = G1NUMA::numa()->max_search_depth();
 157   HeapRegion* cur;
 158 
 159   // Find the region to use, searching from _head or _tail as requested.
 160   size_t cur_depth = 0;
 161   if (from_head) {
 162     for (cur = _head;
 163          cur != NULL && cur_depth < max_search_depth;
 164          cur = cur->next(), ++cur_depth) {
 165       if (requested_node_index == cur->node_index()) {
 166         break;
 167       }
 168     }
 169   } else {
 170     for (cur = _tail;
 171          cur != NULL && cur_depth < max_search_depth;
 172          cur = cur->prev(), ++cur_depth) {
 173       if (requested_node_index == cur->node_index()) {
 174         break;
 175       }
 176     }
 177   }
 178 
 179   // Didn't find a region to use.
 180   if (cur == NULL || cur_depth >= max_search_depth) {
 181     return NULL;
 182   }
 183 
 184   // Splice the region out of the list.
 185   HeapRegion* prev = cur->prev();
 186   HeapRegion* next = cur->next();
 187   if (prev == NULL) {
 188     _head = next;
 189   } else {
 190     prev->set_next(next);
 191   }
 192   if (next == NULL) {
 193     _tail = prev;
 194   } else {
 195     next->set_prev(prev);
 196   }
 197   cur->set_prev(NULL);
 198   cur->set_next(NULL);
 199 
 200   if (_last == cur) {
 201     _last = NULL;
 202   }
 203 
 204   remove(cur);
 205   if (allocated_node_index != NULL) {
 206     *allocated_node_index = cur->node_index();
 207   }
 208 
 209   return cur;
 210 }
 211 
 212 #endif // SHARE_GC_G1_HEAPREGIONSET_INLINE_HPP
< prev index next >