src/share/vm/gc_implementation/g1/satbQueue.cpp

changeset 3175
4dfb2df418f2
parent 2469
7e37af9d69ef
child 3416
2ace1c4ee8da
     1.1 --- a/src/share/vm/gc_implementation/g1/satbQueue.cpp	Thu Sep 22 07:18:51 2011 -0400
     1.2 +++ b/src/share/vm/gc_implementation/g1/satbQueue.cpp	Thu Sep 22 10:57:37 2011 -0700
     1.3 @@ -29,6 +29,7 @@
     1.4  #include "memory/sharedHeap.hpp"
     1.5  #include "runtime/mutexLocker.hpp"
     1.6  #include "runtime/thread.hpp"
     1.7 +#include "runtime/vmThread.hpp"
     1.8  
     1.9  // This method removes entries from an SATB buffer that will not be
    1.10  // useful to the concurrent marking threads. An entry is removed if it
    1.11 @@ -252,9 +253,18 @@
    1.12        t->satb_mark_queue().apply_closure(_par_closures[worker]);
    1.13      }
    1.14    }
    1.15 -  // We'll have worker 0 do this one.
    1.16 -  if (worker == 0) {
    1.17 -    shared_satb_queue()->apply_closure(_par_closures[0]);
    1.18 +
    1.19 +  // We also need to claim the VMThread so that its parity is updated
    1.20 +  // otherwise the next call to Thread::possibly_parallel_oops_do inside
    1.21 +  // a StrongRootsScope might skip the VMThread because it has a stale
    1.22 +  // parity that matches the parity set by the StrongRootsScope
    1.23 +  //
    1.24 +  // Whichever worker succeeds in claiming the VMThread gets to do
    1.25 +  // the shared queue.
    1.26 +
    1.27 +  VMThread* vmt = VMThread::vm_thread();
    1.28 +  if (vmt->claim_oops_do(true, parity)) {
    1.29 +    shared_satb_queue()->apply_closure(_par_closures[worker]);
    1.30    }
    1.31  }
    1.32  

mercurial