src/hotspot/share/gc/g1/g1BarrierSet.cpp
changeset 54366 2b48cedce327
parent 54255 c81fbf340ceb
child 58059 baa4dd528de0
equal deleted inserted replaced
54365:dd5c64326027 54366:2b48cedce327
   146   // the main thread, before it gets added to the threads list, which
   146   // the main thread, before it gets added to the threads list, which
   147   // is where this is called.  That execution may enqueue dirty cards.
   147   // is where this is called.  That execution may enqueue dirty cards.
   148 
   148 
   149   // If we are creating the thread during a marking cycle, we should
   149   // If we are creating the thread during a marking cycle, we should
   150   // set the active field of the SATB queue to true.  That involves
   150   // set the active field of the SATB queue to true.  That involves
   151   // copying the global is_active value to this thread's queue, which
   151   // copying the global is_active value to this thread's queue.
   152   // is done without any direct synchronization here.
       
   153   //
       
   154   // The activation and deactivation of the SATB queues occurs at the
       
   155   // beginning / end of a marking cycle, and is done during
       
   156   // safepoints.  This function is called just before a thread is
       
   157   // added to its corresponding threads list (for Java or non-Java
       
   158   // threads, respectively).
       
   159   //
       
   160   // For Java threads, that's done while holding the Threads_lock,
       
   161   // which ensures we're not at a safepoint, so reading the global
       
   162   // is_active state is synchronized against update.
       
   163   assert(!thread->is_Java_thread() || !SafepointSynchronize::is_at_safepoint(),
       
   164          "Should not be at a safepoint");
       
   165   // For non-Java threads, thread creation (and list addition) may,
       
   166   // and indeed usually does, occur during a safepoint.  But such
       
   167   // creation isn't concurrent with updating the global SATB active
       
   168   // state.
       
   169   bool is_satb_active = _satb_mark_queue_set.is_active();
   152   bool is_satb_active = _satb_mark_queue_set.is_active();
   170   G1ThreadLocalData::satb_mark_queue(thread).set_active(is_satb_active);
   153   G1ThreadLocalData::satb_mark_queue(thread).set_active(is_satb_active);
   171 }
   154 }
   172 
   155 
   173 void G1BarrierSet::on_thread_detach(Thread* thread) {
   156 void G1BarrierSet::on_thread_detach(Thread* thread) {