270
271 // verify_chunk_in_free_lists() is used to verify that an item is in this free list.
272 // It is used as a debugging aid.
273 template <class Chunk>
274 bool FreeList<Chunk>::verify_chunk_in_free_list(Chunk* fc) const {
275 // This is an internal consistency check, not part of the check that the
276 // chunk is in the free lists.
277 guarantee(fc->size() == size(), "Wrong list is being searched");
278 Chunk* curFC = head();
279 while (curFC) {
280 // This is an internal consistency check.
281 guarantee(size() == curFC->size(), "Chunk is in wrong list.");
282 if (fc == curFC) {
283 return true;
284 }
285 curFC = curFC->next();
286 }
287 return false;
288 }
289
290 #ifndef PRODUCT
291 template <class Chunk>
292 void FreeList<Chunk>::assert_proper_lock_protection_work() const {
293 assert(protecting_lock() != NULL, "Don't call this directly");
294 assert(ParallelGCThreads > 0, "Don't call this directly");
295 Thread* thr = Thread::current();
296 if (thr->is_VM_thread() || thr->is_ConcurrentGC_thread()) {
297 // assert that we are holding the freelist lock
298 } else if (thr->is_GC_task_thread()) {
299 assert(protecting_lock()->owned_by_self(), "FreeList RACE DETECTED");
300 } else if (thr->is_Java_thread()) {
301 assert(!SafepointSynchronize::is_at_safepoint(), "Should not be executing");
302 } else {
303 ShouldNotReachHere(); // unaccounted thread type?
304 }
305 }
306 #endif
307
308 // Print the "label line" for free list stats.
309 template <class Chunk>
310 void FreeList<Chunk>::print_labels_on(outputStream* st, const char* c) {
311 st->print("%16s\t", c);
312 st->print("%14s\t" "%14s\t" "%14s\t" "%14s\t" "%14s\t"
313 "%14s\t" "%14s\t" "%14s\t" "%14s\t" "%14s\t" "\n",
314 "bfrsurp", "surplus", "desired", "prvSwep", "bfrSwep",
315 "count", "cBirths", "cDeaths", "sBirths", "sDeaths");
316 }
317
318 // Print the AllocationStats for the given free list. If the second argument
319 // to the call is a non-null string, it is printed in the first column;
320 // otherwise, if the argument is null (the default), then the size of the
321 // (free list) block is printed in the first column.
322 template <class Chunk_t>
323 void FreeList<Chunk_t>::print_on(outputStream* st, const char* c) const {
324 if (c != NULL) {
325 st->print("%16s", c);
326 } else {
|
270
271 // verify_chunk_in_free_lists() is used to verify that an item is in this free list.
272 // It is used as a debugging aid.
273 template <class Chunk>
274 bool FreeList<Chunk>::verify_chunk_in_free_list(Chunk* fc) const {
275 // This is an internal consistency check, not part of the check that the
276 // chunk is in the free lists.
277 guarantee(fc->size() == size(), "Wrong list is being searched");
278 Chunk* curFC = head();
279 while (curFC) {
280 // This is an internal consistency check.
281 guarantee(size() == curFC->size(), "Chunk is in wrong list.");
282 if (fc == curFC) {
283 return true;
284 }
285 curFC = curFC->next();
286 }
287 return false;
288 }
289
290 template <class Chunk>
291 void FreeList<Chunk>::assert_proper_lock_protection() const {
292 #ifdef ASSERT
293 // Nothing to do if the list has no assigned protecting lock
294 if (protecting_lock() == NULL) {
295 return;
296 }
297
298 Thread* thr = Thread::current();
299 if (thr->is_VM_thread() || thr->is_ConcurrentGC_thread()) {
300 // assert that we are holding the freelist lock
301 } else if (thr->is_GC_task_thread()) {
302 assert(protecting_lock()->owned_by_self(), "FreeList RACE DETECTED");
303 } else if (thr->is_Java_thread()) {
304 assert(!SafepointSynchronize::is_at_safepoint(), "Should not be executing");
305 } else {
306 ShouldNotReachHere(); // unaccounted thread type?
307 }
308 #endif
309 }
310
311 // Print the "label line" for free list stats.
312 template <class Chunk>
313 void FreeList<Chunk>::print_labels_on(outputStream* st, const char* c) {
314 st->print("%16s\t", c);
315 st->print("%14s\t" "%14s\t" "%14s\t" "%14s\t" "%14s\t"
316 "%14s\t" "%14s\t" "%14s\t" "%14s\t" "%14s\t" "\n",
317 "bfrsurp", "surplus", "desired", "prvSwep", "bfrSwep",
318 "count", "cBirths", "cDeaths", "sBirths", "sDeaths");
319 }
320
321 // Print the AllocationStats for the given free list. If the second argument
322 // to the call is a non-null string, it is printed in the first column;
323 // otherwise, if the argument is null (the default), then the size of the
324 // (free list) block is printed in the first column.
325 template <class Chunk_t>
326 void FreeList<Chunk_t>::print_on(outputStream* st, const char* c) const {
327 if (c != NULL) {
328 st->print("%16s", c);
329 } else {
|