src/hotspot/share/gc/g1/heapRegionSet.inline.hpp
author sangheki
Wed, 13 Nov 2019 10:49:12 -0800
changeset 59060 fce1fa1bdc91
parent 53244 9807daeb47c4
child 59062 6530de931b8e
permissions -rw-r--r--
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3) Reviewed-by: kbarrett, sjohanss, tschatzl, pliden
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
     2
 * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
     4
 *
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
     7
 * published by the Free Software Foundation.
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
     8
 *
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    13
 * accompanied this code).
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    14
 *
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    18
 *
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    21
 * questions.
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    22
 *
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    23
 */
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    24
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
    25
#ifndef SHARE_GC_G1_HEAPREGIONSET_INLINE_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
    26
#define SHARE_GC_G1_HEAPREGIONSET_INLINE_HPP
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    27
59060
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
    28
#include "gc/g1/g1NUMA.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 26316
diff changeset
    29
#include "gc/g1/heapRegionSet.hpp"
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    30
23450
c7c6202fc7e2 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 13336
diff changeset
    31
inline void HeapRegionSetBase::add(HeapRegion* hr) {
c7c6202fc7e2 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 13336
diff changeset
    32
  check_mt_safety();
33753
3add06d0880f 8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents: 33105
diff changeset
    33
  assert_heap_region_set(hr->containing_set() == NULL, "should not already have a containing set");
3add06d0880f 8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents: 33105
diff changeset
    34
  assert_heap_region_set(hr->next() == NULL, "should not already be linked");
3add06d0880f 8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents: 33105
diff changeset
    35
  assert_heap_region_set(hr->prev() == NULL, "should not already be linked");
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    36
35065
b4ff0249c092 8144996: Replace the HeapRegionSetCount class with an uint
david
parents: 33753
diff changeset
    37
  _length++;
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    38
  hr->set_containing_set(this);
23450
c7c6202fc7e2 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 13336
diff changeset
    39
  verify_region(hr);
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    40
}
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    41
23450
c7c6202fc7e2 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 13336
diff changeset
    42
inline void HeapRegionSetBase::remove(HeapRegion* hr) {
c7c6202fc7e2 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 13336
diff changeset
    43
  check_mt_safety();
c7c6202fc7e2 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 13336
diff changeset
    44
  verify_region(hr);
33753
3add06d0880f 8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents: 33105
diff changeset
    45
  assert_heap_region_set(hr->next() == NULL, "should already be unlinked");
3add06d0880f 8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents: 33105
diff changeset
    46
  assert_heap_region_set(hr->prev() == NULL, "should already be unlinked");
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    47
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    48
  hr->set_containing_set(NULL);
35065
b4ff0249c092 8144996: Replace the HeapRegionSetCount class with an uint
david
parents: 33753
diff changeset
    49
  assert_heap_region_set(_length > 0, "pre-condition");
b4ff0249c092 8144996: Replace the HeapRegionSetCount class with an uint
david
parents: 33753
diff changeset
    50
  _length--;
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    51
}
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
    52
23471
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    53
inline void FreeRegionList::add_ordered(HeapRegion* hr) {
33753
3add06d0880f 8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents: 33105
diff changeset
    54
  assert_free_region_list((length() == 0 && _head == NULL && _tail == NULL && _last == NULL) ||
3add06d0880f 8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents: 33105
diff changeset
    55
                          (length() >  0 && _head != NULL && _tail != NULL),
3add06d0880f 8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents: 33105
diff changeset
    56
                          "invariant");
23471
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    57
  // add() will verify the region and check mt safety.
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    58
  add(hr);
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    59
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    60
  // Now link the region
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    61
  if (_head != NULL) {
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    62
    HeapRegion* curr;
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    63
26316
93f6b40c038b 8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents: 26157
diff changeset
    64
    if (_last != NULL && _last->hrm_index() < hr->hrm_index()) {
23471
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    65
      curr = _last;
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    66
    } else {
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    67
      curr = _head;
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    68
    }
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    69
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    70
    // Find first entry with a Region Index larger than entry to insert.
26316
93f6b40c038b 8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents: 26157
diff changeset
    71
    while (curr != NULL && curr->hrm_index() < hr->hrm_index()) {
23471
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    72
      curr = curr->next();
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    73
    }
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    74
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    75
    hr->set_next(curr);
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    76
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    77
    if (curr == NULL) {
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    78
      // Adding at the end
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    79
      hr->set_prev(_tail);
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    80
      _tail->set_next(hr);
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    81
      _tail = hr;
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    82
    } else if (curr->prev() == NULL) {
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    83
      // Adding at the beginning
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    84
      hr->set_prev(NULL);
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    85
      _head = hr;
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    86
      curr->set_prev(hr);
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    87
    } else {
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    88
      hr->set_prev(curr->prev());
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    89
      hr->prev()->set_next(hr);
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    90
      curr->set_prev(hr);
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    91
    }
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    92
  } else {
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    93
    // The list was empty
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    94
    _tail = hr;
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    95
    _head = hr;
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    96
  }
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    97
  _last = hr;
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    98
}
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
    99
26157
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   100
inline HeapRegion* FreeRegionList::remove_from_head_impl() {
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   101
  HeapRegion* result = _head;
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   102
  _head = result->next();
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
   103
  if (_head == NULL) {
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
   104
    _tail = NULL;
23471
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
   105
  } else {
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
   106
    _head->set_prev(NULL);
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
   107
  }
26157
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   108
  result->set_next(NULL);
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   109
  return result;
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   110
}
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   111
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   112
inline HeapRegion* FreeRegionList::remove_from_tail_impl() {
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   113
  HeapRegion* result = _tail;
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   114
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   115
  _tail = result->prev();
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   116
  if (_tail == NULL) {
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   117
    _head = NULL;
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   118
  } else {
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   119
    _tail->set_next(NULL);
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   120
  }
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   121
  result->set_prev(NULL);
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   122
  return result;
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   123
}
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   124
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   125
inline HeapRegion* FreeRegionList::remove_region(bool from_head) {
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   126
  check_mt_safety();
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   127
  verify_optional();
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   128
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   129
  if (is_empty()) {
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   130
    return NULL;
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   131
  }
33753
3add06d0880f 8137756: Remove hrs_err_msg and hrs_ext_msg from heapRegionSet
david
parents: 33105
diff changeset
   132
  assert_free_region_list(length() > 0 && _head != NULL && _tail != NULL, "invariant");
26157
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   133
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   134
  HeapRegion* hr;
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   135
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   136
  if (from_head) {
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   137
    hr = remove_from_head_impl();
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   138
  } else {
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   139
    hr = remove_from_tail_impl();
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 23857
diff changeset
   140
  }
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
   141
23471
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
   142
  if (_last == hr) {
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
   143
    _last = NULL;
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
   144
  }
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
   145
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23450
diff changeset
   146
  // remove() will verify the region and check mt safety.
23450
c7c6202fc7e2 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 13336
diff changeset
   147
  remove(hr);
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
   148
  return hr;
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
   149
}
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
   150
59060
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   151
inline HeapRegion* FreeRegionList::remove_region_with_node_index(bool from_head,
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   152
                                                                 const uint requested_node_index,
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   153
                                                                 uint* allocated_node_index) {
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   154
  assert(UseNUMA, "Invariant");
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   155
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   156
  const uint max_search_depth = G1NUMA::numa()->max_search_depth();
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   157
  HeapRegion* cur;
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   158
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   159
  // Find the region to use, searching from _head or _tail as requested.
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   160
  size_t cur_depth = 0;
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   161
  if (from_head) {
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   162
    for (cur = _head;
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   163
         cur != NULL && cur_depth < max_search_depth;
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   164
         cur = cur->next(), ++cur_depth) {
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   165
      if (requested_node_index == cur->node_index()) {
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   166
        break;
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   167
      }
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   168
    }
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   169
  } else {
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   170
    for (cur = _tail;
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   171
         cur != NULL && cur_depth < max_search_depth;
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   172
         cur = cur->prev(), ++cur_depth) {
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   173
      if (requested_node_index == cur->node_index()) {
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   174
        break;
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   175
      }
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   176
    }
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   177
  }
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   178
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   179
  // Didn't find a region to use.
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   180
  if (cur == NULL || cur_depth >= max_search_depth) {
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   181
    return NULL;
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   182
  }
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   183
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   184
  // Splice the region out of the list.
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   185
  HeapRegion* prev = cur->prev();
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   186
  HeapRegion* next = cur->next();
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   187
  if (prev == NULL) {
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   188
    _head = next;
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   189
  } else {
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   190
    prev->set_next(next);
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   191
  }
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   192
  if (next == NULL) {
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   193
    _tail = prev;
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   194
  } else {
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   195
    next->set_prev(prev);
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   196
  }
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   197
  cur->set_prev(NULL);
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   198
  cur->set_next(NULL);
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   199
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   200
  if (_last == cur) {
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   201
    _last = NULL;
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   202
  }
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   203
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   204
  remove(cur);
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   205
  if (allocated_node_index != NULL) {
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   206
    *allocated_node_index = cur->node_index();
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   207
  }
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   208
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   209
  return cur;
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   210
}
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 53244
diff changeset
   211
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
   212
#endif // SHARE_GC_G1_HEAPREGIONSET_INLINE_HPP