--- old/src/hotspot/share/runtime/thread.cpp 2018-02-15 12:33:10.192649616 +0100 +++ new/src/hotspot/share/runtime/thread.cpp 2018-02-15 12:33:09.955639407 +0100 @@ -1994,10 +1994,7 @@ JvmtiExport::cleanup_thread(this); } - // We must flush any deferred card marks and other various GC barrier - // related buffers (e.g. G1 SATB buffer and G1 dirty card queue buffer) - // before removing a thread from the list of active threads. - BarrierSet::barrier_set()->flush_deferred_barriers(this); + BarrierSet::barrier_set()->on_thread_detach(this); log_info(os, thread)("JavaThread %s (tid: " UINTX_FORMAT ").", exit_type == JavaThread::normal_exit ? "exiting" : "detaching", @@ -2026,30 +2023,6 @@ } } -#if INCLUDE_ALL_GCS -void JavaThread::initialize_queues() { - assert(!SafepointSynchronize::is_at_safepoint(), - "we should not be at a safepoint"); - - SATBMarkQueue& satb_queue = satb_mark_queue(); - SATBMarkQueueSet& satb_queue_set = satb_mark_queue_set(); - // The SATB queue should have been constructed with its active - // field set to false. - assert(!satb_queue.is_active(), "SATB queue should not be active"); - assert(satb_queue.is_empty(), "SATB queue should be empty"); - // If we are creating the thread during a marking cycle, we should - // set the active field of the SATB queue to true. - if (satb_queue_set.is_active()) { - satb_queue.set_active(true); - } - - DirtyCardQueue& dirty_queue = dirty_card_queue(); - // The dirty card queue should have been constructed with its - // active field set to true. - assert(dirty_queue.is_active(), "dirty card queue should be active"); -} -#endif // INCLUDE_ALL_GCS - void JavaThread::cleanup_failed_attach_current_thread() { if (active_handles() != NULL) { JNIHandleBlock* block = active_handles(); @@ -2070,15 +2043,12 @@ tlab().make_parsable(true); // retire TLAB, if any } - BarrierSet::barrier_set()->flush_deferred_barriers(this); + BarrierSet::barrier_set()->on_thread_detach(this); Threads::remove(this); this->smr_delete(); } - - - JavaThread* JavaThread::active() { Thread* thread = Thread::current(); if (thread->is_Java_thread()) { @@ -4332,9 +4302,8 @@ // The threads lock must be owned at this point assert_locked_or_safepoint(Threads_lock); - // See the comment for this method in thread.hpp for its purpose and - // why it is called here. - p->initialize_queues(); + BarrierSet::barrier_set()->on_thread_attach(p); + p->set_next(_thread_list); _thread_list = p;