--- old/src/hotspot/share/gc/g1/heapRegionSet.inline.hpp 2019-11-01 16:13:25.816400530 -0700 +++ new/src/hotspot/share/gc/g1/heapRegionSet.inline.hpp 2019-11-01 16:13:25.544400522 -0700 @@ -95,6 +95,8 @@ _head = hr; } _last = hr; + + increase_length(hr->node_index()); } inline HeapRegion* FreeRegionList::remove_from_head_impl() { @@ -145,12 +147,14 @@ // remove() will verify the region and check mt safety. remove(hr); + + decrease_length(hr->node_index()); + return hr; } inline HeapRegion* FreeRegionList::remove_region_with_node_index(bool from_head, - const uint requested_node_index, - uint* allocated_node_index) { + const uint requested_node_index) { assert(UseNUMA, "Invariant"); const uint max_search_depth = G1NUMA::numa()->max_search_depth(); @@ -202,11 +206,48 @@ } remove(cur); - if (allocated_node_index != NULL) { - *allocated_node_index = cur->node_index(); - } + decrease_length(cur->node_index()); return cur; } +inline void NodeInfo::increase_length(uint node_index) { + if (node_index < _num_nodes) { + _length_of_node[node_index] += 1; + } +} + +inline void NodeInfo::decrease_length(uint node_index) { + if (node_index < _num_nodes) { + assert(_length_of_node[node_index] > 0, + "Current length %u should be greater than zero for node %u", + _length_of_node[node_index], node_index); + _length_of_node[node_index] -= 1; + } +} + +inline uint NodeInfo::length(uint node_index) const { + return _length_of_node[node_index]; +} + +inline void FreeRegionList::increase_length(uint node_index) { + if (_node_info != NULL) { + return _node_info->increase_length(node_index); + } +} + +inline void FreeRegionList::decrease_length(uint node_index) { + if (_node_info != NULL) { + return _node_info->decrease_length(node_index); + } +} + +inline uint FreeRegionList::length(uint node_index) const { + if (_node_info != NULL) { + return _node_info->length(node_index); + } else { + return 0; + } +} + #endif // SHARE_GC_G1_HEAPREGIONSET_INLINE_HPP