src/hotspot/share/gc/g1/heapRegionSet.cpp
changeset 59062 6530de931b8e
parent 53116 bb03098c4dde
equal deleted inserted replaced
59061:df6f2350edfa 59062:6530de931b8e
     1 /*
     1 /*
     2  * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    22  *
    22  *
    23  */
    23  */
    24 
    24 
    25 #include "precompiled.hpp"
    25 #include "precompiled.hpp"
    26 #include "gc/g1/g1CollectedHeap.inline.hpp"
    26 #include "gc/g1/g1CollectedHeap.inline.hpp"
       
    27 #include "gc/g1/g1NUMA.hpp"
    27 #include "gc/g1/heapRegionRemSet.hpp"
    28 #include "gc/g1/heapRegionRemSet.hpp"
    28 #include "gc/g1/heapRegionSet.inline.hpp"
    29 #include "gc/g1/heapRegionSet.inline.hpp"
    29 
    30 
    30 uint FreeRegionList::_unrealistically_long_length = 0;
    31 uint FreeRegionList::_unrealistically_long_length = 0;
    31 
    32 
    99 
   100 
   100     HeapRegion* next = curr->next();
   101     HeapRegion* next = curr->next();
   101     curr->set_next(NULL);
   102     curr->set_next(NULL);
   102     curr->set_prev(NULL);
   103     curr->set_prev(NULL);
   103     curr->set_containing_set(NULL);
   104     curr->set_containing_set(NULL);
       
   105 
       
   106     decrease_length(curr->node_index());
       
   107 
   104     curr = next;
   108     curr = next;
   105   }
   109   }
   106   clear();
   110   clear();
   107 
   111 
   108   verify_optional();
   112   verify_optional();
   115   verify_optional();
   119   verify_optional();
   116   from_list->verify_optional();
   120   from_list->verify_optional();
   117 
   121 
   118   if (from_list->is_empty()) {
   122   if (from_list->is_empty()) {
   119     return;
   123     return;
       
   124   }
       
   125 
       
   126   if (_node_info != NULL && from_list->_node_info != NULL) {
       
   127     _node_info->add(from_list->_node_info);
   120   }
   128   }
   121 
   129 
   122   #ifdef ASSERT
   130   #ifdef ASSERT
   123   FreeRegionListIterator iter(from_list);
   131   FreeRegionListIterator iter(from_list);
   124   while (iter.more_available()) {
   132   while (iter.more_available()) {
   218     curr->set_next(NULL);
   226     curr->set_next(NULL);
   219     curr->set_prev(NULL);
   227     curr->set_prev(NULL);
   220     remove(curr);
   228     remove(curr);
   221 
   229 
   222     count++;
   230     count++;
       
   231 
       
   232     decrease_length(curr->node_index());
       
   233 
   223     curr = next;
   234     curr = next;
   224   }
   235   }
   225 
   236 
   226   assert(count == num_regions,
   237   assert(count == num_regions,
   227          "[%s] count: %u should be == num_regions: %u",
   238          "[%s] count: %u should be == num_regions: %u",
   265 void FreeRegionList::clear() {
   276 void FreeRegionList::clear() {
   266   _length = 0;
   277   _length = 0;
   267   _head = NULL;
   278   _head = NULL;
   268   _tail = NULL;
   279   _tail = NULL;
   269   _last = NULL;
   280   _last = NULL;
       
   281 
       
   282   if (_node_info!= NULL) {
       
   283     _node_info->clear();
       
   284   }
   270 }
   285 }
   271 
   286 
   272 void FreeRegionList::verify_list() {
   287 void FreeRegionList::verify_list() {
   273   HeapRegion* curr = _head;
   288   HeapRegion* curr = _head;
   274   HeapRegion* prev1 = NULL;
   289   HeapRegion* prev1 = NULL;
   301 
   316 
   302   guarantee(_tail == prev0, "Expected %s to end with %u but it ended with %u.", name(), _tail->hrm_index(), prev0->hrm_index());
   317   guarantee(_tail == prev0, "Expected %s to end with %u but it ended with %u.", name(), _tail->hrm_index(), prev0->hrm_index());
   303   guarantee(_tail == NULL || _tail->next() == NULL, "_tail should not have a next");
   318   guarantee(_tail == NULL || _tail->next() == NULL, "_tail should not have a next");
   304   guarantee(length() == count, "%s count mismatch. Expected %u, actual %u.", name(), length(), count);
   319   guarantee(length() == count, "%s count mismatch. Expected %u, actual %u.", name(), length(), count);
   305 }
   320 }
       
   321 
       
   322 
       
   323 FreeRegionList::FreeRegionList(const char* name, HeapRegionSetChecker* checker):
       
   324   HeapRegionSetBase(name, checker),
       
   325   _node_info(G1NUMA::numa()->is_enabled() ? new NodeInfo() : NULL) {
       
   326 
       
   327   clear();
       
   328 }
       
   329 
       
   330 FreeRegionList::~FreeRegionList() {
       
   331   if (_node_info != NULL) {
       
   332     delete _node_info;
       
   333   }
       
   334 }
       
   335 
       
   336 FreeRegionList::NodeInfo::NodeInfo() : _numa(G1NUMA::numa()), _length_of_node(NULL),
       
   337                                        _num_nodes(_numa->num_active_nodes()) {
       
   338   assert(UseNUMA, "Invariant");
       
   339 
       
   340   _length_of_node = NEW_C_HEAP_ARRAY(uint, _num_nodes, mtGC);
       
   341 }
       
   342 
       
   343 FreeRegionList::NodeInfo::~NodeInfo() {
       
   344   FREE_C_HEAP_ARRAY(uint, _length_of_node);
       
   345 }
       
   346 
       
   347 void FreeRegionList::NodeInfo::clear() {
       
   348   for (uint i = 0; i < _num_nodes; ++i) {
       
   349     _length_of_node[i] = 0;
       
   350   }
       
   351 }
       
   352 
       
   353 void FreeRegionList::NodeInfo::add(NodeInfo* info) {
       
   354   for (uint i = 0; i < _num_nodes; ++i) {
       
   355     _length_of_node[i] += info->_length_of_node[i];
       
   356   }
       
   357 }
       
   358