annotate src/share/vm/gc_implementation/g1/heapRegionSet.inline.hpp @ 17736:58fc1b1523dc

8034079: G1: Refactor the HeapRegionSet hierarchy Reviewed-by: tschatzl, pliden
author brutisso
date Fri, 14 Mar 2014 10:15:46 +0100
parents a2f7274eb6ef
children 8ee855b4e667
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
1 /*
6010
720b6a76dd9d 7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents: 3860
diff changeset
2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
4 *
0fa27f37d4d4 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
0fa27f37d4d4 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
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
7 * published by the Free Software Foundation.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
8 *
0fa27f37d4d4 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
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0fa27f37d4d4 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
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
13 * accompanied this code).
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
14 *
0fa27f37d4d4 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
0fa27f37d4d4 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,
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
18 *
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0fa27f37d4d4 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
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
21 * questions.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
22 *
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
23 */
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
24
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_INLINE_HPP
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_INLINE_HPP
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
27
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
28 #include "gc_implementation/g1/heapRegionSet.hpp"
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
29
17736
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
30 inline void HeapRegionSetBase::add(HeapRegion* hr) {
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
31 check_mt_safety();
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
32 assert(hr->containing_set() == NULL, hrs_ext_msg(this, "should not already have a containing set %u"));
2361
1216415d8e35 7014923: G1: code cleanup
tonyp
parents: 2152
diff changeset
33 assert(hr->next() == NULL, hrs_ext_msg(this, "should not already be linked"));
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
34
17736
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
35 _count.increment(1u, hr->capacity());
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
36 hr->set_containing_set(this);
17736
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
37 verify_region(hr);
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
38 }
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
39
17736
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
40 inline void HeapRegionSetBase::remove(HeapRegion* hr) {
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
41 check_mt_safety();
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
42 verify_region(hr);
2361
1216415d8e35 7014923: G1: code cleanup
tonyp
parents: 2152
diff changeset
43 assert(hr->next() == NULL, hrs_ext_msg(this, "should already be unlinked"));
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
44
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
45 hr->set_containing_set(NULL);
17736
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
46 assert(_count.length() > 0, hrs_ext_msg(this, "pre-condition"));
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
47 _count.decrement(1u, hr->capacity());
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
48 }
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
49
17736
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
50 inline void FreeRegionList::add_as_head(HeapRegion* hr) {
2432
455328d90876 7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents: 2361
diff changeset
51 assert((length() == 0 && _head == NULL && _tail == NULL) ||
455328d90876 7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents: 2361
diff changeset
52 (length() > 0 && _head != NULL && _tail != NULL),
455328d90876 7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents: 2361
diff changeset
53 hrs_ext_msg(this, "invariant"));
17736
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
54 // add() will verify the region and check mt safety.
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
55 add(hr);
2432
455328d90876 7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents: 2361
diff changeset
56
455328d90876 7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents: 2361
diff changeset
57 // Now link the region.
455328d90876 7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents: 2361
diff changeset
58 if (_head != NULL) {
455328d90876 7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents: 2361
diff changeset
59 hr->set_next(_head);
455328d90876 7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents: 2361
diff changeset
60 } else {
455328d90876 7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents: 2361
diff changeset
61 _tail = hr;
455328d90876 7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents: 2361
diff changeset
62 }
455328d90876 7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents: 2361
diff changeset
63 _head = hr;
455328d90876 7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents: 2361
diff changeset
64 }
455328d90876 7029458: G1: Add newly-reclaimed regions to the beginning of the region free list, not the end
tonyp
parents: 2361
diff changeset
65
17736
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
66 inline void FreeRegionList::add_as_tail(HeapRegion* hr) {
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
67 check_mt_safety();
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
68 assert((length() == 0 && _head == NULL && _tail == NULL) ||
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
69 (length() > 0 && _head != NULL && _tail != NULL),
2361
1216415d8e35 7014923: G1: code cleanup
tonyp
parents: 2152
diff changeset
70 hrs_ext_msg(this, "invariant"));
17736
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
71 // add() will verify the region and check mt safety
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
72 add(hr);
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
73
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
74 // Now link the region.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
75 if (_tail != NULL) {
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
76 _tail->set_next(hr);
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
77 } else {
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
78 _head = hr;
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
79 }
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
80 _tail = hr;
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
81 }
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
82
17736
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
83 inline HeapRegion* FreeRegionList::remove_head() {
2361
1216415d8e35 7014923: G1: code cleanup
tonyp
parents: 2152
diff changeset
84 assert(!is_empty(), hrs_ext_msg(this, "the list should not be empty"));
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
85 assert(length() > 0 && _head != NULL && _tail != NULL,
2361
1216415d8e35 7014923: G1: code cleanup
tonyp
parents: 2152
diff changeset
86 hrs_ext_msg(this, "invariant"));
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
87
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
88 // We need to unlink it first.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
89 HeapRegion* hr = _head;
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
90 _head = hr->next();
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
91 if (_head == NULL) {
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
92 _tail = NULL;
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
93 }
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
94 hr->set_next(NULL);
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
95
17736
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
96 // remove() will verify the region and check mt safety
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
97 remove(hr);
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
98 return hr;
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
99 }
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
100
17736
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
101 inline HeapRegion* FreeRegionList::remove_head_or_null() {
58fc1b1523dc 8034079: G1: Refactor the HeapRegionSet hierarchy
brutisso
parents: 6254
diff changeset
102 check_mt_safety();
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
103 if (!is_empty()) {
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
104 return remove_head();
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
105 } else {
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
106 return NULL;
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
107 }
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
108 }
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
109
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
110 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_INLINE_HPP