--- old/src/hotspot/share/gc/shared/collectedHeap.cpp 2018-09-13 13:42:20.696203182 +0200 +++ new/src/hotspot/share/gc/shared/collectedHeap.cpp 2018-09-13 13:42:20.398190163 +0200 @@ -476,35 +476,31 @@ // started allocating (nothing much to verify) or we have // started allocating but are now a full-fledged JavaThread // (and have thus made our TLAB's) available for filling. - assert(SafepointSynchronize::is_at_safepoint() || - !is_init_completed(), + assert(SafepointSynchronize::is_at_safepoint() || !is_init_completed(), "Should only be called at a safepoint or at start-up" " otherwise concurrent mutator activity may make heap " " unparsable again"); - const bool use_tlab = UseTLAB; + + if (UseTLAB && retire_tlabs) { + // Accumulate statistics before retiring + ThreadLocalAllocBuffer::accumulate_statistics_before_gc(); + } + // The main thread starts allocating via a TLAB even before it // has added itself to the threads list at vm boot-up. JavaThreadIteratorWithHandle jtiwh; - assert(!use_tlab || jtiwh.length() > 0, + assert(jtiwh.length() > 0, "Attempt to fill tlabs before main thread has been added" " to threads list is doomed to failure!"); BarrierSet *bs = BarrierSet::barrier_set(); for (; JavaThread *thread = jtiwh.next(); ) { - if (use_tlab) thread->tlab().make_parsable(retire_tlabs); + if (UseTLAB) { + thread->tlab().make_parsable(retire_tlabs); + } bs->make_parsable(thread); } } -void CollectedHeap::accumulate_statistics_all_tlabs() { - if (UseTLAB) { - assert(SafepointSynchronize::is_at_safepoint() || - !is_init_completed(), - "should only accumulate statistics on tlabs at safepoint"); - - ThreadLocalAllocBuffer::accumulate_statistics_before_gc(); - } -} - void CollectedHeap::resize_all_tlabs() { if (UseTLAB) { assert(SafepointSynchronize::is_at_safepoint() ||