< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp

Print this page
rev 54185 : 8220671: Initialization race for non-JavaThread PtrQueues

@@ -350,10 +350,13 @@
 }
 
 void ShenandoahBarrierSet::on_thread_attach(Thread *thread) {
   assert(!thread->is_Java_thread() || !SafepointSynchronize::is_at_safepoint(),
          "We should not be at a safepoint");
+  SuspendibleThreadSetJoiner sts(!thread->is_Java_thread() && // Already syncs with safepoints
+                                 !thread->is_VM_thread() &&   // Drives the safepoint itself
+                                 !thread->is_Worker_thread());// Might block if used at SP, syncs otherwise
   SATBMarkQueue& queue = ShenandoahThreadLocalData::satb_mark_queue(thread);
   assert(!queue.is_active(), "SATB queue should not be active");
   assert( queue.is_empty(),  "SATB queue should be empty");
   queue.set_active(_satb_mark_queue_set.is_active());
   if (thread->is_Java_thread()) {

@@ -361,10 +364,13 @@
     ShenandoahThreadLocalData::initialize_gclab(thread);
   }
 }
 
 void ShenandoahBarrierSet::on_thread_detach(Thread *thread) {
+  SuspendibleThreadSetJoiner sts(!thread->is_Java_thread() && // Already syncs with safepoints
+                                 !thread->is_VM_thread() &&   // Drives the safepoint itself
+                                 !thread->is_Worker_thread());// Might block if used at SP, syncs otherwise
   SATBMarkQueue& queue = ShenandoahThreadLocalData::satb_mark_queue(thread);
   queue.flush();
   if (thread->is_Java_thread()) {
     PLAB* gclab = ShenandoahThreadLocalData::gclab(thread);
     if (gclab != NULL) {
< prev index next >