474 // aren't going to interfere -- for instance, this is permissible |
474 // aren't going to interfere -- for instance, this is permissible |
475 // if we are still single-threaded and have either not yet |
475 // if we are still single-threaded and have either not yet |
476 // started allocating (nothing much to verify) or we have |
476 // started allocating (nothing much to verify) or we have |
477 // started allocating but are now a full-fledged JavaThread |
477 // started allocating but are now a full-fledged JavaThread |
478 // (and have thus made our TLAB's) available for filling. |
478 // (and have thus made our TLAB's) available for filling. |
479 assert(SafepointSynchronize::is_at_safepoint() || |
479 assert(SafepointSynchronize::is_at_safepoint() || !is_init_completed(), |
480 !is_init_completed(), |
|
481 "Should only be called at a safepoint or at start-up" |
480 "Should only be called at a safepoint or at start-up" |
482 " otherwise concurrent mutator activity may make heap " |
481 " otherwise concurrent mutator activity may make heap " |
483 " unparsable again"); |
482 " unparsable again"); |
484 const bool use_tlab = UseTLAB; |
483 |
|
484 if (UseTLAB && retire_tlabs) { |
|
485 // Accumulate statistics before retiring |
|
486 ThreadLocalAllocBuffer::accumulate_statistics_before_gc(); |
|
487 } |
|
488 |
485 // The main thread starts allocating via a TLAB even before it |
489 // The main thread starts allocating via a TLAB even before it |
486 // has added itself to the threads list at vm boot-up. |
490 // has added itself to the threads list at vm boot-up. |
487 JavaThreadIteratorWithHandle jtiwh; |
491 JavaThreadIteratorWithHandle jtiwh; |
488 assert(!use_tlab || jtiwh.length() > 0, |
492 assert(jtiwh.length() > 0, |
489 "Attempt to fill tlabs before main thread has been added" |
493 "Attempt to fill tlabs before main thread has been added" |
490 " to threads list is doomed to failure!"); |
494 " to threads list is doomed to failure!"); |
491 BarrierSet *bs = BarrierSet::barrier_set(); |
495 BarrierSet *bs = BarrierSet::barrier_set(); |
492 for (; JavaThread *thread = jtiwh.next(); ) { |
496 for (; JavaThread *thread = jtiwh.next(); ) { |
493 if (use_tlab) thread->tlab().make_parsable(retire_tlabs); |
497 if (UseTLAB) { |
|
498 thread->tlab().make_parsable(retire_tlabs); |
|
499 } |
494 bs->make_parsable(thread); |
500 bs->make_parsable(thread); |
495 } |
|
496 } |
|
497 |
|
498 void CollectedHeap::accumulate_statistics_all_tlabs() { |
|
499 if (UseTLAB) { |
|
500 assert(SafepointSynchronize::is_at_safepoint() || |
|
501 !is_init_completed(), |
|
502 "should only accumulate statistics on tlabs at safepoint"); |
|
503 |
|
504 ThreadLocalAllocBuffer::accumulate_statistics_before_gc(); |
|
505 } |
501 } |
506 } |
502 } |
507 |
503 |
508 void CollectedHeap::resize_all_tlabs() { |
504 void CollectedHeap::resize_all_tlabs() { |
509 assert(SafepointSynchronize::is_at_safepoint() || !is_init_completed(), |
505 assert(SafepointSynchronize::is_at_safepoint() || !is_init_completed(), |