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 */
24
25 #ifndef SHARE_VM_GC_G1_HEAPREGIONSET_INLINE_HPP
26 #define SHARE_VM_GC_G1_HEAPREGIONSET_INLINE_HPP
27
28 #include "gc/g1/heapRegionSet.hpp"
29
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, hrs_ext_msg(this, "should not already be linked"));
34 assert(hr->prev() == NULL, hrs_ext_msg(this, "should not already be linked"));
35
36 _count.increment(1u, hr->capacity());
37 hr->set_containing_set(this);
38 verify_region(hr);
39 }
40
41 inline void HeapRegionSetBase::remove(HeapRegion* hr) {
42 check_mt_safety();
43 verify_region(hr);
44 assert(hr->next() == NULL, hrs_ext_msg(this, "should already be unlinked"));
45 assert(hr->prev() == NULL, hrs_ext_msg(this, "should already be unlinked"));
46
47 hr->set_containing_set(NULL);
48 assert(_count.length() > 0, hrs_ext_msg(this, "pre-condition"));
49 _count.decrement(1u, hr->capacity());
50 }
51
52 inline void FreeRegionList::add_ordered(HeapRegion* hr) {
53 assert((length() == 0 && _head == NULL && _tail == NULL && _last == NULL) ||
54 (length() > 0 && _head != NULL && _tail != NULL),
55 hrs_ext_msg(this, "invariant"));
56 // add() will verify the region and check mt safety.
57 add(hr);
58
59 // Now link the region
60 if (_head != NULL) {
61 HeapRegion* curr;
62
63 if (_last != NULL && _last->hrm_index() < hr->hrm_index()) {
64 curr = _last;
65 } else {
66 curr = _head;
67 }
68
69 // Find first entry with a Region Index larger than entry to insert.
70 while (curr != NULL && curr->hrm_index() < hr->hrm_index()) {
71 curr = curr->next();
72 }
73
74 hr->set_next(curr);
75
112 HeapRegion* result = _tail;
113
114 _tail = result->prev();
115 if (_tail == NULL) {
116 _head = NULL;
117 } else {
118 _tail->set_next(NULL);
119 }
120 result->set_prev(NULL);
121 return result;
122 }
123
124 inline HeapRegion* FreeRegionList::remove_region(bool from_head) {
125 check_mt_safety();
126 verify_optional();
127
128 if (is_empty()) {
129 return NULL;
130 }
131 assert(length() > 0 && _head != NULL && _tail != NULL,
132 hrs_ext_msg(this, "invariant"));
133
134 HeapRegion* hr;
135
136 if (from_head) {
137 hr = remove_from_head_impl();
138 } else {
139 hr = remove_from_tail_impl();
140 }
141
142 if (_last == hr) {
143 _last = NULL;
144 }
145
146 // remove() will verify the region and check mt safety.
147 remove(hr);
148 return hr;
149 }
150
151 #endif // SHARE_VM_GC_G1_HEAPREGIONSET_INLINE_HPP
152
|
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 */
24
25 #ifndef SHARE_VM_GC_G1_HEAPREGIONSET_INLINE_HPP
26 #define SHARE_VM_GC_G1_HEAPREGIONSET_INLINE_HPP
27
28 #include "gc/g1/heapRegionSet.hpp"
29
30 inline void HeapRegionSetBase::add(HeapRegion* hr) {
31 check_mt_safety();
32 assert(hr->containing_set() == NULL, "%s", hrs_ext_msg(this, "should not already have a containing set %u").buffer());
33 assert(hr->next() == NULL, "%s", hrs_ext_msg(this, "should not already be linked").buffer());
34 assert(hr->prev() == NULL, "%s", hrs_ext_msg(this, "should not already be linked").buffer());
35
36 _count.increment(1u, hr->capacity());
37 hr->set_containing_set(this);
38 verify_region(hr);
39 }
40
41 inline void HeapRegionSetBase::remove(HeapRegion* hr) {
42 check_mt_safety();
43 verify_region(hr);
44 assert(hr->next() == NULL, "%s", hrs_ext_msg(this, "should already be unlinked").buffer());
45 assert(hr->prev() == NULL, "%s", hrs_ext_msg(this, "should already be unlinked").buffer());
46
47 hr->set_containing_set(NULL);
48 assert(_count.length() > 0, "%s", hrs_ext_msg(this, "pre-condition").buffer());
49 _count.decrement(1u, hr->capacity());
50 }
51
52 inline void FreeRegionList::add_ordered(HeapRegion* hr) {
53 assert((length() == 0 && _head == NULL && _tail == NULL && _last == NULL) ||
54 (length() > 0 && _head != NULL && _tail != NULL),
55 "%s", hrs_ext_msg(this, "invariant").buffer());
56 // add() will verify the region and check mt safety.
57 add(hr);
58
59 // Now link the region
60 if (_head != NULL) {
61 HeapRegion* curr;
62
63 if (_last != NULL && _last->hrm_index() < hr->hrm_index()) {
64 curr = _last;
65 } else {
66 curr = _head;
67 }
68
69 // Find first entry with a Region Index larger than entry to insert.
70 while (curr != NULL && curr->hrm_index() < hr->hrm_index()) {
71 curr = curr->next();
72 }
73
74 hr->set_next(curr);
75
112 HeapRegion* result = _tail;
113
114 _tail = result->prev();
115 if (_tail == NULL) {
116 _head = NULL;
117 } else {
118 _tail->set_next(NULL);
119 }
120 result->set_prev(NULL);
121 return result;
122 }
123
124 inline HeapRegion* FreeRegionList::remove_region(bool from_head) {
125 check_mt_safety();
126 verify_optional();
127
128 if (is_empty()) {
129 return NULL;
130 }
131 assert(length() > 0 && _head != NULL && _tail != NULL,
132 "%s", hrs_ext_msg(this, "invariant").buffer());
133
134 HeapRegion* hr;
135
136 if (from_head) {
137 hr = remove_from_head_impl();
138 } else {
139 hr = remove_from_tail_impl();
140 }
141
142 if (_last == hr) {
143 _last = NULL;
144 }
145
146 // remove() will verify the region and check mt safety.
147 remove(hr);
148 return hr;
149 }
150
151 #endif // SHARE_VM_GC_G1_HEAPREGIONSET_INLINE_HPP
152
|