Mercurial > hg > truffle
comparison src/share/vm/memory/freeList.cpp @ 6028:f69a5d43dc19
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
Summary: Fix naming style to be consistent with the predominant hotspot style.
Reviewed-by: ysr, brutisso
author | jmasa |
---|---|
date | Wed, 25 Apr 2012 09:55:55 -0700 |
parents | 9f059abe8cf2 |
children | b9a9ed0f8eeb |
comparison
equal
deleted
inserted
replaced
6026:9f059abe8cf2 | 6028:f69a5d43dc19 |
---|---|
63 _size = fc->size(); | 63 _size = fc->size(); |
64 _count = 1; | 64 _count = 1; |
65 _hint = 0; | 65 _hint = 0; |
66 init_statistics(); | 66 init_statistics(); |
67 #ifndef PRODUCT | 67 #ifndef PRODUCT |
68 _allocation_stats.set_returnedBytes(size() * HeapWordSize); | 68 _allocation_stats.set_returned_bytes(size() * HeapWordSize); |
69 #endif | 69 #endif |
70 } | 70 } |
71 | 71 |
72 template <class Chunk> | 72 template <class Chunk> |
73 void FreeList<Chunk>::reset(size_t hint) { | 73 void FreeList<Chunk>::reset(size_t hint) { |
81 void FreeList<Chunk>::init_statistics(bool split_birth) { | 81 void FreeList<Chunk>::init_statistics(bool split_birth) { |
82 _allocation_stats.initialize(split_birth); | 82 _allocation_stats.initialize(split_birth); |
83 } | 83 } |
84 | 84 |
85 template <class Chunk> | 85 template <class Chunk> |
86 Chunk* FreeList<Chunk>::getChunkAtHead() { | 86 Chunk* FreeList<Chunk>::get_chunk_at_head() { |
87 assert_proper_lock_protection(); | 87 assert_proper_lock_protection(); |
88 assert(head() == NULL || head()->prev() == NULL, "list invariant"); | 88 assert(head() == NULL || head()->prev() == NULL, "list invariant"); |
89 assert(tail() == NULL || tail()->next() == NULL, "list invariant"); | 89 assert(tail() == NULL || tail()->next() == NULL, "list invariant"); |
90 Chunk* fc = head(); | 90 Chunk* fc = head(); |
91 if (fc != NULL) { | 91 if (fc != NULL) { |
92 Chunk* nextFC = fc->next(); | 92 Chunk* nextFC = fc->next(); |
93 if (nextFC != NULL) { | 93 if (nextFC != NULL) { |
94 // The chunk fc being removed has a "next". Set the "next" to the | 94 // The chunk fc being removed has a "next". Set the "next" to the |
95 // "prev" of fc. | 95 // "prev" of fc. |
96 nextFC->linkPrev(NULL); | 96 nextFC->link_prev(NULL); |
97 } else { // removed tail of list | 97 } else { // removed tail of list |
98 link_tail(NULL); | 98 link_tail(NULL); |
99 } | 99 } |
100 link_head(nextFC); | 100 link_head(nextFC); |
101 decrement_count(); | 101 decrement_count(); |
124 set_head(new_head); | 124 set_head(new_head); |
125 set_count(count() - k); | 125 set_count(count() - k); |
126 if (new_head == NULL) { | 126 if (new_head == NULL) { |
127 set_tail(NULL); | 127 set_tail(NULL); |
128 } else { | 128 } else { |
129 new_head->linkPrev(NULL); | 129 new_head->link_prev(NULL); |
130 } | 130 } |
131 // Now we can fix up the tail. | 131 // Now we can fix up the tail. |
132 tl->linkNext(NULL); | 132 tl->link_next(NULL); |
133 // And return the result. | 133 // And return the result. |
134 fl->set_tail(tl); | 134 fl->set_tail(tl); |
135 fl->set_count(k); | 135 fl->set_count(k); |
136 } | 136 } |
137 } | 137 } |
138 | 138 |
139 // Remove this chunk from the list | 139 // Remove this chunk from the list |
140 template <class Chunk> | 140 template <class Chunk> |
141 void FreeList<Chunk>::removeChunk(Chunk*fc) { | 141 void FreeList<Chunk>::remove_chunk(Chunk*fc) { |
142 assert_proper_lock_protection(); | 142 assert_proper_lock_protection(); |
143 assert(head() != NULL, "Remove from empty list"); | 143 assert(head() != NULL, "Remove from empty list"); |
144 assert(fc != NULL, "Remove a NULL chunk"); | 144 assert(fc != NULL, "Remove a NULL chunk"); |
145 assert(size() == fc->size(), "Wrong list"); | 145 assert(size() == fc->size(), "Wrong list"); |
146 assert(head() == NULL || head()->prev() == NULL, "list invariant"); | 146 assert(head() == NULL || head()->prev() == NULL, "list invariant"); |
149 Chunk* prevFC = fc->prev(); | 149 Chunk* prevFC = fc->prev(); |
150 Chunk* nextFC = fc->next(); | 150 Chunk* nextFC = fc->next(); |
151 if (nextFC != NULL) { | 151 if (nextFC != NULL) { |
152 // The chunk fc being removed has a "next". Set the "next" to the | 152 // The chunk fc being removed has a "next". Set the "next" to the |
153 // "prev" of fc. | 153 // "prev" of fc. |
154 nextFC->linkPrev(prevFC); | 154 nextFC->link_prev(prevFC); |
155 } else { // removed tail of list | 155 } else { // removed tail of list |
156 link_tail(prevFC); | 156 link_tail(prevFC); |
157 } | 157 } |
158 if (prevFC == NULL) { // removed head of list | 158 if (prevFC == NULL) { // removed head of list |
159 link_head(nextFC); | 159 link_head(nextFC); |
160 assert(nextFC == NULL || nextFC->prev() == NULL, | 160 assert(nextFC == NULL || nextFC->prev() == NULL, |
161 "Prev of head should be NULL"); | 161 "Prev of head should be NULL"); |
162 } else { | 162 } else { |
163 prevFC->linkNext(nextFC); | 163 prevFC->link_next(nextFC); |
164 assert(tail() != prevFC || prevFC->next() == NULL, | 164 assert(tail() != prevFC || prevFC->next() == NULL, |
165 "Next of tail should be NULL"); | 165 "Next of tail should be NULL"); |
166 } | 166 } |
167 decrement_count(); | 167 decrement_count(); |
168 assert(((head() == NULL) + (tail() == NULL) + (count() == 0)) % 3 == 0, | 168 assert(((head() == NULL) + (tail() == NULL) + (count() == 0)) % 3 == 0, |
169 "H/T/C Inconsistency"); | 169 "H/T/C Inconsistency"); |
170 // clear next and prev fields of fc, debug only | 170 // clear next and prev fields of fc, debug only |
171 NOT_PRODUCT( | 171 NOT_PRODUCT( |
172 fc->linkPrev(NULL); | 172 fc->link_prev(NULL); |
173 fc->linkNext(NULL); | 173 fc->link_next(NULL); |
174 ) | 174 ) |
175 assert(fc->isFree(), "Should still be a free chunk"); | 175 assert(fc->is_free(), "Should still be a free chunk"); |
176 assert(head() == NULL || head()->prev() == NULL, "list invariant"); | 176 assert(head() == NULL || head()->prev() == NULL, "list invariant"); |
177 assert(tail() == NULL || tail()->next() == NULL, "list invariant"); | 177 assert(tail() == NULL || tail()->next() == NULL, "list invariant"); |
178 assert(head() == NULL || head()->size() == size(), "wrong item on list"); | 178 assert(head() == NULL || head()->size() == size(), "wrong item on list"); |
179 assert(tail() == NULL || tail()->size() == size(), "wrong item on list"); | 179 assert(tail() == NULL || tail()->size() == size(), "wrong item on list"); |
180 } | 180 } |
181 | 181 |
182 // Add this chunk at the head of the list. | 182 // Add this chunk at the head of the list. |
183 template <class Chunk> | 183 template <class Chunk> |
184 void FreeList<Chunk>::returnChunkAtHead(Chunk* chunk, bool record_return) { | 184 void FreeList<Chunk>::return_chunk_at_head(Chunk* chunk, bool record_return) { |
185 assert_proper_lock_protection(); | 185 assert_proper_lock_protection(); |
186 assert(chunk != NULL, "insert a NULL chunk"); | 186 assert(chunk != NULL, "insert a NULL chunk"); |
187 assert(size() == chunk->size(), "Wrong size"); | 187 assert(size() == chunk->size(), "Wrong size"); |
188 assert(head() == NULL || head()->prev() == NULL, "list invariant"); | 188 assert(head() == NULL || head()->prev() == NULL, "list invariant"); |
189 assert(tail() == NULL || tail()->next() == NULL, "list invariant"); | 189 assert(tail() == NULL || tail()->next() == NULL, "list invariant"); |
190 | 190 |
191 Chunk* oldHead = head(); | 191 Chunk* oldHead = head(); |
192 assert(chunk != oldHead, "double insertion"); | 192 assert(chunk != oldHead, "double insertion"); |
193 chunk->linkAfter(oldHead); | 193 chunk->link_after(oldHead); |
194 link_head(chunk); | 194 link_head(chunk); |
195 if (oldHead == NULL) { // only chunk in list | 195 if (oldHead == NULL) { // only chunk in list |
196 assert(tail() == NULL, "inconsistent FreeList"); | 196 assert(tail() == NULL, "inconsistent FreeList"); |
197 link_tail(chunk); | 197 link_tail(chunk); |
198 } | 198 } |
199 increment_count(); // of # of chunks in list | 199 increment_count(); // of # of chunks in list |
200 DEBUG_ONLY( | 200 DEBUG_ONLY( |
201 if (record_return) { | 201 if (record_return) { |
202 increment_returnedBytes_by(size()*HeapWordSize); | 202 increment_returned_bytes_by(size()*HeapWordSize); |
203 } | 203 } |
204 ) | 204 ) |
205 assert(head() == NULL || head()->prev() == NULL, "list invariant"); | 205 assert(head() == NULL || head()->prev() == NULL, "list invariant"); |
206 assert(tail() == NULL || tail()->next() == NULL, "list invariant"); | 206 assert(tail() == NULL || tail()->next() == NULL, "list invariant"); |
207 assert(head() == NULL || head()->size() == size(), "wrong item on list"); | 207 assert(head() == NULL || head()->size() == size(), "wrong item on list"); |
208 assert(tail() == NULL || tail()->size() == size(), "wrong item on list"); | 208 assert(tail() == NULL || tail()->size() == size(), "wrong item on list"); |
209 } | 209 } |
210 | 210 |
211 template <class Chunk> | 211 template <class Chunk> |
212 void FreeList<Chunk>::returnChunkAtHead(Chunk* chunk) { | 212 void FreeList<Chunk>::return_chunk_at_head(Chunk* chunk) { |
213 assert_proper_lock_protection(); | 213 assert_proper_lock_protection(); |
214 returnChunkAtHead(chunk, true); | 214 return_chunk_at_head(chunk, true); |
215 } | 215 } |
216 | 216 |
217 // Add this chunk at the tail of the list. | 217 // Add this chunk at the tail of the list. |
218 template <class Chunk> | 218 template <class Chunk> |
219 void FreeList<Chunk>::returnChunkAtTail(Chunk* chunk, bool record_return) { | 219 void FreeList<Chunk>::return_chunk_at_tail(Chunk* chunk, bool record_return) { |
220 assert_proper_lock_protection(); | 220 assert_proper_lock_protection(); |
221 assert(head() == NULL || head()->prev() == NULL, "list invariant"); | 221 assert(head() == NULL || head()->prev() == NULL, "list invariant"); |
222 assert(tail() == NULL || tail()->next() == NULL, "list invariant"); | 222 assert(tail() == NULL || tail()->next() == NULL, "list invariant"); |
223 assert(chunk != NULL, "insert a NULL chunk"); | 223 assert(chunk != NULL, "insert a NULL chunk"); |
224 assert(size() == chunk->size(), "wrong size"); | 224 assert(size() == chunk->size(), "wrong size"); |
225 | 225 |
226 Chunk* oldTail = tail(); | 226 Chunk* oldTail = tail(); |
227 assert(chunk != oldTail, "double insertion"); | 227 assert(chunk != oldTail, "double insertion"); |
228 if (oldTail != NULL) { | 228 if (oldTail != NULL) { |
229 oldTail->linkAfter(chunk); | 229 oldTail->link_after(chunk); |
230 } else { // only chunk in list | 230 } else { // only chunk in list |
231 assert(head() == NULL, "inconsistent FreeList"); | 231 assert(head() == NULL, "inconsistent FreeList"); |
232 link_head(chunk); | 232 link_head(chunk); |
233 } | 233 } |
234 link_tail(chunk); | 234 link_tail(chunk); |
235 increment_count(); // of # of chunks in list | 235 increment_count(); // of # of chunks in list |
236 DEBUG_ONLY( | 236 DEBUG_ONLY( |
237 if (record_return) { | 237 if (record_return) { |
238 increment_returnedBytes_by(size()*HeapWordSize); | 238 increment_returned_bytes_by(size()*HeapWordSize); |
239 } | 239 } |
240 ) | 240 ) |
241 assert(head() == NULL || head()->prev() == NULL, "list invariant"); | 241 assert(head() == NULL || head()->prev() == NULL, "list invariant"); |
242 assert(tail() == NULL || tail()->next() == NULL, "list invariant"); | 242 assert(tail() == NULL || tail()->next() == NULL, "list invariant"); |
243 assert(head() == NULL || head()->size() == size(), "wrong item on list"); | 243 assert(head() == NULL || head()->size() == size(), "wrong item on list"); |
244 assert(tail() == NULL || tail()->size() == size(), "wrong item on list"); | 244 assert(tail() == NULL || tail()->size() == size(), "wrong item on list"); |
245 } | 245 } |
246 | 246 |
247 template <class Chunk> | 247 template <class Chunk> |
248 void FreeList<Chunk>::returnChunkAtTail(Chunk* chunk) { | 248 void FreeList<Chunk>::return_chunk_at_tail(Chunk* chunk) { |
249 returnChunkAtTail(chunk, true); | 249 return_chunk_at_tail(chunk, true); |
250 } | 250 } |
251 | 251 |
252 template <class Chunk> | 252 template <class Chunk> |
253 void FreeList<Chunk>::prepend(FreeList<Chunk>* fl) { | 253 void FreeList<Chunk>::prepend(FreeList<Chunk>* fl) { |
254 assert_proper_lock_protection(); | 254 assert_proper_lock_protection(); |
260 } else { | 260 } else { |
261 // Both are non-empty. | 261 // Both are non-empty. |
262 Chunk* fl_tail = fl->tail(); | 262 Chunk* fl_tail = fl->tail(); |
263 Chunk* this_head = head(); | 263 Chunk* this_head = head(); |
264 assert(fl_tail->next() == NULL, "Well-formedness of fl"); | 264 assert(fl_tail->next() == NULL, "Well-formedness of fl"); |
265 fl_tail->linkNext(this_head); | 265 fl_tail->link_next(this_head); |
266 this_head->linkPrev(fl_tail); | 266 this_head->link_prev(fl_tail); |
267 set_head(fl->head()); | 267 set_head(fl->head()); |
268 set_count(count() + fl->count()); | 268 set_count(count() + fl->count()); |
269 } | 269 } |
270 fl->set_head(NULL); | 270 fl->set_head(NULL); |
271 fl->set_tail(NULL); | 271 fl->set_tail(NULL); |
272 fl->set_count(0); | 272 fl->set_count(0); |
273 } | 273 } |
274 } | 274 } |
275 | 275 |
276 // verifyChunkInFreeLists() is used to verify that an item is in this free list. | 276 // verify_chunk_in_free_list() is used to verify that an item is in this free list. |
277 // It is used as a debugging aid. | 277 // It is used as a debugging aid. |
278 template <class Chunk> | 278 template <class Chunk> |
279 bool FreeList<Chunk>::verifyChunkInFreeLists(Chunk* fc) const { | 279 bool FreeList<Chunk>::verify_chunk_in_free_list(Chunk* fc) const { |
280 // This is an internal consistency check, not part of the check that the | 280 // This is an internal consistency check, not part of the check that the |
281 // chunk is in the free lists. | 281 // chunk is in the free lists. |
282 guarantee(fc->size() == size(), "Wrong list is being searched"); | 282 guarantee(fc->size() == size(), "Wrong list is being searched"); |
283 Chunk* curFC = head(); | 283 Chunk* curFC = head(); |
284 while (curFC) { | 284 while (curFC) { |
300 // and we'll subsequently update the stats; we cannot update the | 300 // and we'll subsequently update the stats; we cannot update the |
301 // stats beforehand because in the case of the large-block BT | 301 // stats beforehand because in the case of the large-block BT |
302 // dictionary for example, this might be the first block and | 302 // dictionary for example, this might be the first block and |
303 // in that case there would be no place that we could record | 303 // in that case there would be no place that we could record |
304 // the stats (which are kept in the block itself). | 304 // the stats (which are kept in the block itself). |
305 assert((_allocation_stats.prevSweep() + _allocation_stats.splitBirths() | 305 assert((_allocation_stats.prev_sweep() + _allocation_stats.split_births() |
306 + _allocation_stats.coalBirths() + 1) // Total Production Stock + 1 | 306 + _allocation_stats.coal_births() + 1) // Total Production Stock + 1 |
307 >= (_allocation_stats.splitDeaths() + _allocation_stats.coalDeaths() | 307 >= (_allocation_stats.split_deaths() + _allocation_stats.coal_deaths() |
308 + (ssize_t)count()), // Total Current Stock + depletion | 308 + (ssize_t)count()), // Total Current Stock + depletion |
309 err_msg("FreeList " PTR_FORMAT " of size " SIZE_FORMAT | 309 err_msg("FreeList " PTR_FORMAT " of size " SIZE_FORMAT |
310 " violates Conservation Principle: " | 310 " violates Conservation Principle: " |
311 "prevSweep(" SIZE_FORMAT ")" | 311 "prev_sweep(" SIZE_FORMAT ")" |
312 " + splitBirths(" SIZE_FORMAT ")" | 312 " + split_births(" SIZE_FORMAT ")" |
313 " + coalBirths(" SIZE_FORMAT ") + 1 >= " | 313 " + coal_births(" SIZE_FORMAT ") + 1 >= " |
314 " splitDeaths(" SIZE_FORMAT ")" | 314 " split_deaths(" SIZE_FORMAT ")" |
315 " coalDeaths(" SIZE_FORMAT ")" | 315 " coal_deaths(" SIZE_FORMAT ")" |
316 " + count(" SSIZE_FORMAT ")", | 316 " + count(" SSIZE_FORMAT ")", |
317 this, _size, _allocation_stats.prevSweep(), _allocation_stats.splitBirths(), | 317 this, _size, _allocation_stats.prev_sweep(), _allocation_stats.split_births(), |
318 _allocation_stats.splitBirths(), _allocation_stats.splitDeaths(), | 318 _allocation_stats.split_births(), _allocation_stats.split_deaths(), |
319 _allocation_stats.coalDeaths(), count())); | 319 _allocation_stats.coal_deaths(), count())); |
320 } | 320 } |
321 | 321 |
322 template <class Chunk> | 322 template <class Chunk> |
323 void FreeList<Chunk>::assert_proper_lock_protection_work() const { | 323 void FreeList<Chunk>::assert_proper_lock_protection_work() const { |
324 assert(_protecting_lock != NULL, "Don't call this directly"); | 324 assert(_protecting_lock != NULL, "Don't call this directly"); |
358 st->print(SIZE_FORMAT_W(16), size()); | 358 st->print(SIZE_FORMAT_W(16), size()); |
359 } | 359 } |
360 st->print("\t" | 360 st->print("\t" |
361 SSIZE_FORMAT_W(14) "\t" SSIZE_FORMAT_W(14) "\t" SSIZE_FORMAT_W(14) "\t" SSIZE_FORMAT_W(14) "\t" SSIZE_FORMAT_W(14) "\t" | 361 SSIZE_FORMAT_W(14) "\t" SSIZE_FORMAT_W(14) "\t" SSIZE_FORMAT_W(14) "\t" SSIZE_FORMAT_W(14) "\t" SSIZE_FORMAT_W(14) "\t" |
362 SSIZE_FORMAT_W(14) "\t" SSIZE_FORMAT_W(14) "\t" SSIZE_FORMAT_W(14) "\t" SSIZE_FORMAT_W(14) "\t" SSIZE_FORMAT_W(14) "\n", | 362 SSIZE_FORMAT_W(14) "\t" SSIZE_FORMAT_W(14) "\t" SSIZE_FORMAT_W(14) "\t" SSIZE_FORMAT_W(14) "\t" SSIZE_FORMAT_W(14) "\n", |
363 bfrSurp(), surplus(), desired(), prevSweep(), beforeSweep(), | 363 bfr_surp(), surplus(), desired(), prev_sweep(), before_sweep(), |
364 count(), coalBirths(), coalDeaths(), splitBirths(), splitDeaths()); | 364 count(), coal_births(), coal_deaths(), split_births(), split_deaths()); |
365 } | 365 } |
366 | 366 |
367 #ifndef SERIALGC | 367 #ifndef SERIALGC |
368 // Needs to be after the definitions have been seen. | 368 // Needs to be after the definitions have been seen. |
369 template class FreeList<FreeChunk>; | 369 template class FreeList<FreeChunk>; |