Thu, 07 Aug 2014 22:28:53 +0200
8054341: Remove some obsolete code in G1CollectedHeap class
Summary: Remove dead code.
Reviewed-by: stefank, brutisso
1 /*
2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
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 */
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_INLINE_HPP
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_INLINE_HPP
28 #include "gc_implementation/g1/heapRegionSet.hpp"
30 inline void HeapRegionSetBase::add(HeapRegion* hr) {
31 check_mt_safety();
32 assert(hr->containing_set() == NULL, hrs_ext_msg(this, "should not already have a containing set %u"));
33 assert(hr->next() == NULL && hr->prev() == NULL, hrs_ext_msg(this, "should not already be linked"));
35 _count.increment(1u, hr->capacity());
36 hr->set_containing_set(this);
37 verify_region(hr);
38 }
40 inline void HeapRegionSetBase::remove(HeapRegion* hr) {
41 check_mt_safety();
42 verify_region(hr);
43 assert(hr->next() == NULL && hr->prev() == NULL, hrs_ext_msg(this, "should already be unlinked"));
45 hr->set_containing_set(NULL);
46 assert(_count.length() > 0, hrs_ext_msg(this, "pre-condition"));
47 _count.decrement(1u, hr->capacity());
48 }
50 inline void FreeRegionList::add_ordered(HeapRegion* hr) {
51 check_mt_safety();
52 assert((length() == 0 && _head == NULL && _tail == NULL) ||
53 (length() > 0 && _head != NULL && _tail != NULL),
54 hrs_ext_msg(this, "invariant"));
55 // add() will verify the region and check mt safety.
56 add(hr);
58 // Now link the region
59 if (_head != NULL) {
60 HeapRegion* curr;
62 if (_last != NULL && _last->hrs_index() < hr->hrs_index()) {
63 curr = _last;
64 } else {
65 curr = _head;
66 }
68 // Find first entry with a Region Index larger than entry to insert.
69 while (curr != NULL && curr->hrs_index() < hr->hrs_index()) {
70 curr = curr->next();
71 }
73 hr->set_next(curr);
75 if (curr == NULL) {
76 // Adding at the end
77 hr->set_prev(_tail);
78 _tail->set_next(hr);
79 _tail = hr;
80 } else if (curr->prev() == NULL) {
81 // Adding at the beginning
82 hr->set_prev(NULL);
83 _head = hr;
84 curr->set_prev(hr);
85 } else {
86 hr->set_prev(curr->prev());
87 hr->prev()->set_next(hr);
88 curr->set_prev(hr);
89 }
90 } else {
91 // The list was empty
92 _tail = hr;
93 _head = hr;
94 }
95 _last = hr;
96 }
98 inline void FreeRegionList::add_as_head(HeapRegion* hr) {
99 assert((length() == 0 && _head == NULL && _tail == NULL) ||
100 (length() > 0 && _head != NULL && _tail != NULL),
101 hrs_ext_msg(this, "invariant"));
102 // add() will verify the region and check mt safety.
103 add(hr);
105 // Now link the region.
106 if (_head != NULL) {
107 hr->set_next(_head);
108 _head->set_prev(hr);
109 } else {
110 _tail = hr;
111 }
112 _head = hr;
113 }
115 inline void FreeRegionList::add_as_tail(HeapRegion* hr) {
116 check_mt_safety();
117 assert((length() == 0 && _head == NULL && _tail == NULL) ||
118 (length() > 0 && _head != NULL && _tail != NULL),
119 hrs_ext_msg(this, "invariant"));
120 // add() will verify the region and check mt safety.
121 add(hr);
123 // Now link the region.
124 if (_tail != NULL) {
125 _tail->set_next(hr);
126 hr->set_prev(_tail);
127 } else {
128 _head = hr;
129 }
130 _tail = hr;
131 }
133 inline HeapRegion* FreeRegionList::remove_head() {
134 assert(!is_empty(), hrs_ext_msg(this, "the list should not be empty"));
135 assert(length() > 0 && _head != NULL && _tail != NULL,
136 hrs_ext_msg(this, "invariant"));
138 // We need to unlink it first.
139 HeapRegion* hr = _head;
140 _head = hr->next();
141 if (_head == NULL) {
142 _tail = NULL;
143 } else {
144 _head->set_prev(NULL);
145 }
146 hr->set_next(NULL);
148 if (_last == hr) {
149 _last = NULL;
150 }
152 // remove() will verify the region and check mt safety.
153 remove(hr);
154 return hr;
155 }
157 inline HeapRegion* FreeRegionList::remove_head_or_null() {
158 check_mt_safety();
159 if (!is_empty()) {
160 return remove_head();
161 } else {
162 return NULL;
163 }
164 }
166 inline HeapRegion* FreeRegionList::remove_tail() {
167 assert(!is_empty(), hrs_ext_msg(this, "The list should not be empty"));
168 assert(length() > 0 && _head != NULL && _tail != NULL,
169 hrs_ext_msg(this, "invariant"));
171 // We need to unlink it first
172 HeapRegion* hr = _tail;
174 _tail = hr->prev();
175 if (_tail == NULL) {
176 _head = NULL;
177 } else {
178 _tail->set_next(NULL);
179 }
180 hr->set_prev(NULL);
182 if (_last == hr) {
183 _last = NULL;
184 }
186 // remove() will verify the region and check mt safety.
187 remove(hr);
188 return hr;
189 }
191 inline HeapRegion* FreeRegionList::remove_tail_or_null() {
192 check_mt_safety();
194 if (!is_empty()) {
195 return remove_tail();
196 } else {
197 return NULL;
198 }
199 }
201 inline HeapRegion* FreeRegionList::remove_region(bool from_head) {
202 if (from_head) {
203 return remove_head_or_null();
204 } else {
205 return remove_tail_or_null();
206 }
207 }
209 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_INLINE_HPP