Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/g1/heapRegionSet.inline.hpp @ 2361:1216415d8e35
7014923: G1: code cleanup
Summary: Some G1 code cleanup.
Reviewed-by: johnc, jcoomes, jwilhelm
author | tonyp |
---|---|
date | Fri, 04 Mar 2011 17:13:19 -0500 |
parents | 0fa27f37d4d4 |
children | 455328d90876 |
comparison
equal
deleted
inserted
replaced
2312:11303bede852 | 2361:1216415d8e35 |
---|---|
40 } | 40 } |
41 _total_used_bytes += hr->used(); | 41 _total_used_bytes += hr->used(); |
42 } | 42 } |
43 | 43 |
44 inline void HeapRegionSetBase::add_internal(HeapRegion* hr) { | 44 inline void HeapRegionSetBase::add_internal(HeapRegion* hr) { |
45 hrl_assert_region_ok(this, hr, NULL); | 45 hrs_assert_region_ok(this, hr, NULL); |
46 assert(hr->next() == NULL, hrl_ext_msg(this, "should not already be linked")); | 46 assert(hr->next() == NULL, hrs_ext_msg(this, "should not already be linked")); |
47 | 47 |
48 update_for_addition(hr); | 48 update_for_addition(hr); |
49 hr->set_containing_set(this); | 49 hr->set_containing_set(this); |
50 } | 50 } |
51 | 51 |
52 inline void HeapRegionSetBase::update_for_removal(HeapRegion* hr) { | 52 inline void HeapRegionSetBase::update_for_removal(HeapRegion* hr) { |
53 // Assumes the caller has already verified the region. | 53 // Assumes the caller has already verified the region. |
54 assert(_length > 0, hrl_ext_msg(this, "pre-condition")); | 54 assert(_length > 0, hrs_ext_msg(this, "pre-condition")); |
55 _length -= 1; | 55 _length -= 1; |
56 | 56 |
57 size_t region_num_diff; | 57 size_t region_num_diff; |
58 if (!hr->isHumongous()) { | 58 if (!hr->isHumongous()) { |
59 region_num_diff = 1; | 59 region_num_diff = 1; |
60 } else { | 60 } else { |
61 region_num_diff = calculate_region_num(hr); | 61 region_num_diff = calculate_region_num(hr); |
62 } | 62 } |
63 assert(region_num_diff <= _region_num, | 63 assert(region_num_diff <= _region_num, |
64 hrl_err_msg("[%s] region's region num: "SIZE_FORMAT" " | 64 hrs_err_msg("[%s] region's region num: "SIZE_FORMAT" " |
65 "should be <= region num: "SIZE_FORMAT, | 65 "should be <= region num: "SIZE_FORMAT, |
66 name(), region_num_diff, _region_num)); | 66 name(), region_num_diff, _region_num)); |
67 _region_num -= region_num_diff; | 67 _region_num -= region_num_diff; |
68 | 68 |
69 size_t used_bytes = hr->used(); | 69 size_t used_bytes = hr->used(); |
70 assert(used_bytes <= _total_used_bytes, | 70 assert(used_bytes <= _total_used_bytes, |
71 hrl_err_msg("[%s] region's used bytes: "SIZE_FORMAT" " | 71 hrs_err_msg("[%s] region's used bytes: "SIZE_FORMAT" " |
72 "should be <= used bytes: "SIZE_FORMAT, | 72 "should be <= used bytes: "SIZE_FORMAT, |
73 name(), used_bytes, _total_used_bytes)); | 73 name(), used_bytes, _total_used_bytes)); |
74 _total_used_bytes -= used_bytes; | 74 _total_used_bytes -= used_bytes; |
75 } | 75 } |
76 | 76 |
77 inline void HeapRegionSetBase::remove_internal(HeapRegion* hr) { | 77 inline void HeapRegionSetBase::remove_internal(HeapRegion* hr) { |
78 hrl_assert_region_ok(this, hr, this); | 78 hrs_assert_region_ok(this, hr, this); |
79 assert(hr->next() == NULL, hrl_ext_msg(this, "should already be unlinked")); | 79 assert(hr->next() == NULL, hrs_ext_msg(this, "should already be unlinked")); |
80 | 80 |
81 hr->set_containing_set(NULL); | 81 hr->set_containing_set(NULL); |
82 update_for_removal(hr); | 82 update_for_removal(hr); |
83 } | 83 } |
84 | 84 |
85 //////////////////// HeapRegionSet //////////////////// | 85 //////////////////// HeapRegionSet //////////////////// |
86 | 86 |
87 inline void HeapRegionSet::add(HeapRegion* hr) { | 87 inline void HeapRegionSet::add(HeapRegion* hr) { |
88 hrl_assert_mt_safety_ok(this); | 88 hrs_assert_mt_safety_ok(this); |
89 // add_internal() will verify the region. | 89 // add_internal() will verify the region. |
90 add_internal(hr); | 90 add_internal(hr); |
91 } | 91 } |
92 | 92 |
93 inline void HeapRegionSet::remove(HeapRegion* hr) { | 93 inline void HeapRegionSet::remove(HeapRegion* hr) { |
94 hrl_assert_mt_safety_ok(this); | 94 hrs_assert_mt_safety_ok(this); |
95 // remove_internal() will verify the region. | 95 // remove_internal() will verify the region. |
96 remove_internal(hr); | 96 remove_internal(hr); |
97 } | 97 } |
98 | 98 |
99 inline void HeapRegionSet::remove_with_proxy(HeapRegion* hr, | 99 inline void HeapRegionSet::remove_with_proxy(HeapRegion* hr, |
100 HeapRegionSet* proxy_set) { | 100 HeapRegionSet* proxy_set) { |
101 // No need to fo the MT safety check here given that this method | 101 // No need to fo the MT safety check here given that this method |
102 // does not update the contents of the set but instead accumulates | 102 // does not update the contents of the set but instead accumulates |
103 // the changes in proxy_set which is assumed to be thread-local. | 103 // the changes in proxy_set which is assumed to be thread-local. |
104 hrl_assert_sets_match(this, proxy_set); | 104 hrs_assert_sets_match(this, proxy_set); |
105 hrl_assert_region_ok(this, hr, this); | 105 hrs_assert_region_ok(this, hr, this); |
106 | 106 |
107 hr->set_containing_set(NULL); | 107 hr->set_containing_set(NULL); |
108 proxy_set->update_for_addition(hr); | 108 proxy_set->update_for_addition(hr); |
109 } | 109 } |
110 | 110 |
111 //////////////////// HeapRegionLinkedList //////////////////// | 111 //////////////////// HeapRegionLinkedList //////////////////// |
112 | 112 |
113 inline void HeapRegionLinkedList::add_as_tail(HeapRegion* hr) { | 113 inline void HeapRegionLinkedList::add_as_tail(HeapRegion* hr) { |
114 hrl_assert_mt_safety_ok(this); | 114 hrs_assert_mt_safety_ok(this); |
115 assert((length() == 0 && _head == NULL && _tail == NULL) || | 115 assert((length() == 0 && _head == NULL && _tail == NULL) || |
116 (length() > 0 && _head != NULL && _tail != NULL), | 116 (length() > 0 && _head != NULL && _tail != NULL), |
117 hrl_ext_msg(this, "invariant")); | 117 hrs_ext_msg(this, "invariant")); |
118 // add_internal() will verify the region. | 118 // add_internal() will verify the region. |
119 add_internal(hr); | 119 add_internal(hr); |
120 | 120 |
121 // Now link the region. | 121 // Now link the region. |
122 if (_tail != NULL) { | 122 if (_tail != NULL) { |
126 } | 126 } |
127 _tail = hr; | 127 _tail = hr; |
128 } | 128 } |
129 | 129 |
130 inline HeapRegion* HeapRegionLinkedList::remove_head() { | 130 inline HeapRegion* HeapRegionLinkedList::remove_head() { |
131 hrl_assert_mt_safety_ok(this); | 131 hrs_assert_mt_safety_ok(this); |
132 assert(!is_empty(), hrl_ext_msg(this, "the list should not be empty")); | 132 assert(!is_empty(), hrs_ext_msg(this, "the list should not be empty")); |
133 assert(length() > 0 && _head != NULL && _tail != NULL, | 133 assert(length() > 0 && _head != NULL && _tail != NULL, |
134 hrl_ext_msg(this, "invariant")); | 134 hrs_ext_msg(this, "invariant")); |
135 | 135 |
136 // We need to unlink it first. | 136 // We need to unlink it first. |
137 HeapRegion* hr = _head; | 137 HeapRegion* hr = _head; |
138 _head = hr->next(); | 138 _head = hr->next(); |
139 if (_head == NULL) { | 139 if (_head == NULL) { |
145 remove_internal(hr); | 145 remove_internal(hr); |
146 return hr; | 146 return hr; |
147 } | 147 } |
148 | 148 |
149 inline HeapRegion* HeapRegionLinkedList::remove_head_or_null() { | 149 inline HeapRegion* HeapRegionLinkedList::remove_head_or_null() { |
150 hrl_assert_mt_safety_ok(this); | 150 hrs_assert_mt_safety_ok(this); |
151 | 151 |
152 if (!is_empty()) { | 152 if (!is_empty()) { |
153 return remove_head(); | 153 return remove_head(); |
154 } else { | 154 } else { |
155 return NULL; | 155 return NULL; |