hotspot/src/share/vm/runtime/thread.cpp
changeset 11174 fccee5238e70
parent 10966 0c9ed2dfc6a2
child 11480 1bf714e8adb4
equal deleted inserted replaced
11173:af2bc14f35f8 11174:fccee5238e70
   776     jint res = Atomic::cmpxchg(strong_roots_parity, &_oops_do_parity, thread_parity);
   776     jint res = Atomic::cmpxchg(strong_roots_parity, &_oops_do_parity, thread_parity);
   777     if (res == thread_parity) {
   777     if (res == thread_parity) {
   778       return true;
   778       return true;
   779     } else {
   779     } else {
   780       guarantee(res == strong_roots_parity, "Or else what?");
   780       guarantee(res == strong_roots_parity, "Or else what?");
   781       assert(SharedHeap::heap()->n_par_threads() > 0,
   781       assert(SharedHeap::heap()->workers()->active_workers() > 0,
   782              "Should only fail when parallel.");
   782          "Should only fail when parallel.");
   783       return false;
   783       return false;
   784     }
   784     }
   785   }
   785   }
   786   assert(SharedHeap::heap()->n_par_threads() > 0,
   786   assert(SharedHeap::heap()->workers()->active_workers() > 0,
   787          "Should only fail when parallel.");
   787          "Should only fail when parallel.");
   788   return false;
   788   return false;
   789 }
   789 }
   790 
   790 
   791 void Thread::oops_do(OopClosure* f, CodeBlobClosure* cf) {
   791 void Thread::oops_do(OopClosure* f, CodeBlobClosure* cf) {
  3937 void Threads::possibly_parallel_oops_do(OopClosure* f, CodeBlobClosure* cf) {
  3937 void Threads::possibly_parallel_oops_do(OopClosure* f, CodeBlobClosure* cf) {
  3938   // Introduce a mechanism allowing parallel threads to claim threads as
  3938   // Introduce a mechanism allowing parallel threads to claim threads as
  3939   // root groups.  Overhead should be small enough to use all the time,
  3939   // root groups.  Overhead should be small enough to use all the time,
  3940   // even in sequential code.
  3940   // even in sequential code.
  3941   SharedHeap* sh = SharedHeap::heap();
  3941   SharedHeap* sh = SharedHeap::heap();
  3942   bool is_par = (sh->n_par_threads() > 0);
  3942   // Cannot yet substitute active_workers for n_par_threads
       
  3943   // because of G1CollectedHeap::verify() use of
       
  3944   // SharedHeap::process_strong_roots().  n_par_threads == 0 will
       
  3945   // turn off parallelism in process_strong_roots while active_workers
       
  3946   // is being used for parallelism elsewhere.
       
  3947   bool is_par = sh->n_par_threads() > 0;
       
  3948   assert(!is_par ||
       
  3949          (SharedHeap::heap()->n_par_threads() ==
       
  3950           SharedHeap::heap()->workers()->active_workers()), "Mismatch");
  3943   int cp = SharedHeap::heap()->strong_roots_parity();
  3951   int cp = SharedHeap::heap()->strong_roots_parity();
  3944   ALL_JAVA_THREADS(p) {
  3952   ALL_JAVA_THREADS(p) {
  3945     if (p->claim_oops_do(is_par, cp)) {
  3953     if (p->claim_oops_do(is_par, cp)) {
  3946       p->oops_do(f, cf);
  3954       p->oops_do(f, cf);
  3947     }
  3955     }