--- old/src/share/vm/runtime/thread.cpp 2017-04-25 16:45:55.199172399 +0200 +++ new/src/share/vm/runtime/thread.cpp 2017-04-25 16:45:55.039172405 +0200 @@ -49,6 +49,7 @@ #include "oops/objArrayOop.hpp" #include "oops/oop.inline.hpp" #include "oops/symbol.hpp" +#include "oops/typeArrayOop.inline.hpp" #include "oops/verifyOopClosure.hpp" #include "prims/jvm_misc.hpp" #include "prims/jvmtiExport.hpp" @@ -1514,17 +1515,8 @@ pd_initialize(); } -#if INCLUDE_ALL_GCS -SATBMarkQueueSet JavaThread::_satb_mark_queue_set; -DirtyCardQueueSet JavaThread::_dirty_card_queue_set; -#endif // INCLUDE_ALL_GCS - JavaThread::JavaThread(bool is_attaching_via_jni) : Thread() -#if INCLUDE_ALL_GCS - , _satb_mark_queue(&_satb_mark_queue_set), - _dirty_card_queue(&_dirty_card_queue_set) -#endif // INCLUDE_ALL_GCS { initialize(); if (is_attaching_via_jni) { @@ -1588,10 +1580,6 @@ JavaThread::JavaThread(ThreadFunction entry_point, size_t stack_sz) : Thread() -#if INCLUDE_ALL_GCS - , _satb_mark_queue(&_satb_mark_queue_set), - _dirty_card_queue(&_dirty_card_queue_set) -#endif // INCLUDE_ALL_GCS { initialize(); _jni_attach_state = _not_attaching_via_jni; @@ -1914,20 +1902,8 @@ JvmtiExport::cleanup_thread(this); } - // We must flush any deferred card marks before removing a thread from - // the list of active threads. - Universe::heap()->flush_deferred_store_barrier(this); - assert(deferred_card_mark().is_empty(), "Should have been flushed"); - -#if INCLUDE_ALL_GCS - // We must flush the G1-related buffers before removing a thread - // from the list of active threads. We must do this after any deferred - // card marks have been flushed (above) so that any entries that are - // added to the thread's dirty card queue as a result are not lost. - if (UseG1GC) { - flush_barrier_queues(); - } -#endif // INCLUDE_ALL_GCS + BarrierSet *bs = Universe::heap()->barrier_set(); + bs->on_destroy_thread(this); log_info(os, thread)("JavaThread %s (tid: " UINTX_FORMAT ").", exit_type == JavaThread::normal_exit ? "exiting" : "detaching", @@ -1937,36 +1913,6 @@ Threads::remove(this); } -#if INCLUDE_ALL_GCS -// Flush G1-related queues. -void JavaThread::flush_barrier_queues() { - satb_mark_queue().flush(); - dirty_card_queue().flush(); -} - -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 (get_thread_profiler() != NULL) { get_thread_profiler()->disengage(); @@ -1993,11 +1939,8 @@ tlab().make_parsable(true); // retire TLAB, if any } -#if INCLUDE_ALL_GCS - if (UseG1GC) { - flush_barrier_queues(); - } -#endif // INCLUDE_ALL_GCS + BarrierSet *bs = Universe::heap()->barrier_set(); + bs->on_destroy_thread(this); Threads::remove(this); delete this; @@ -4225,7 +4168,9 @@ // See the comment for this method in thread.hpp for its purpose and // why it is called here. - p->initialize_queues(); + BarrierSet* bs = Universe::heap()->barrier_set(); + bs->on_add_thread(p); + p->set_next(_thread_list); _thread_list = p; _number_of_threads++;