Print this page
rev 2691 : [mq]: g1-reference-processing

Split Close
Expand all
Collapse all
          --- old/src/share/vm/gc_implementation/g1/satbQueue.cpp
          +++ new/src/share/vm/gc_implementation/g1/satbQueue.cpp
↓ open down ↓ 21 lines elided ↑ open up ↑
  22   22   *
  23   23   */
  24   24  
  25   25  #include "precompiled.hpp"
  26   26  #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
  27   27  #include "gc_implementation/g1/satbQueue.hpp"
  28   28  #include "memory/allocation.inline.hpp"
  29   29  #include "memory/sharedHeap.hpp"
  30   30  #include "runtime/mutexLocker.hpp"
  31   31  #include "runtime/thread.hpp"
       32 +#include "runtime/vmThread.hpp"
  32   33  
  33   34  // This method removes entries from an SATB buffer that will not be
  34   35  // useful to the concurrent marking threads. An entry is removed if it
  35   36  // satisfies one of the following conditions:
  36   37  //
  37   38  // * it points to an object outside the G1 heap (G1's concurrent
  38   39  //     marking only visits objects inside the G1 heap),
  39   40  // * it points to an object that has been allocated since marking
  40   41  //     started (according to SATB those objects do not need to be
  41   42  //     visited during marking), or
↓ open down ↓ 203 lines elided ↑ open up ↑
 245  246  
 246  247  void SATBMarkQueueSet::par_iterate_closure_all_threads(int worker) {
 247  248    SharedHeap* sh = SharedHeap::heap();
 248  249    int parity = sh->strong_roots_parity();
 249  250  
 250  251    for(JavaThread* t = Threads::first(); t; t = t->next()) {
 251  252      if (t->claim_oops_do(true, parity)) {
 252  253        t->satb_mark_queue().apply_closure(_par_closures[worker]);
 253  254      }
 254  255    }
 255      -  // We'll have worker 0 do this one.
 256      -  if (worker == 0) {
 257      -    shared_satb_queue()->apply_closure(_par_closures[0]);
      256 +
      257 +  // We also need to claim the VMThread so that its parity is updated
      258 +  // otherwise the next call to Thread::possibly_parallel_oops_do inside
      259 +  // a StrongRootsScope might skip the VMThread because it has a stale
      260 +  // parity that matches the parity set by the StrongRootsScope
      261 +  //
      262 +  // Whichever worker succeeds in claiming the VMThread gets to do
      263 +  // the shared queue.
      264 +
      265 +  VMThread* vmt = VMThread::vm_thread();
      266 +  if (vmt->claim_oops_do(true, parity)) {
      267 +    shared_satb_queue()->apply_closure(_par_closures[worker]);
 258  268    }
 259  269  }
 260  270  
 261  271  bool SATBMarkQueueSet::apply_closure_to_completed_buffer_work(bool par,
 262  272                                                                int worker) {
 263  273    BufferNode* nd = NULL;
 264  274    {
 265  275      MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag);
 266  276      if (_completed_buffers_head != NULL) {
 267  277        nd = _completed_buffers_head;
↓ open down ↓ 43 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX