hotspot/src/share/vm/runtime/thread.cpp
changeset 30147 af9a41999c6e
parent 29802 d485440c958a
child 30174 01b674a7cb8f
equal deleted inserted replaced
29809:c59a5f161524 30147:af9a41999c6e
   752     jint res = Atomic::cmpxchg(strong_roots_parity, &_oops_do_parity, thread_parity);
   752     jint res = Atomic::cmpxchg(strong_roots_parity, &_oops_do_parity, thread_parity);
   753     if (res == thread_parity) {
   753     if (res == thread_parity) {
   754       return true;
   754       return true;
   755     } else {
   755     } else {
   756       guarantee(res == strong_roots_parity, "Or else what?");
   756       guarantee(res == strong_roots_parity, "Or else what?");
   757       assert(SharedHeap::heap()->workers()->active_workers() > 0,
       
   758              "Should only fail when parallel.");
       
   759       return false;
   757       return false;
   760     }
   758     }
   761   }
   759   }
   762   assert(SharedHeap::heap()->workers()->active_workers() > 0,
       
   763          "Should only fail when parallel.");
       
   764   return false;
   760   return false;
   765 }
   761 }
   766 
   762 
   767 void Thread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) {
   763 void Thread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) {
   768   active_handles()->oops_do(f);
   764   active_handles()->oops_do(f);
  4064         err_msg("Thread " PTR_FORMAT " has incorrect parity %d != %d", p2i(p), thread_parity, _thread_claim_parity));
  4060         err_msg("Thread " PTR_FORMAT " has incorrect parity %d != %d", p2i(p), thread_parity, _thread_claim_parity));
  4065   }
  4061   }
  4066 }
  4062 }
  4067 #endif // PRODUCT
  4063 #endif // PRODUCT
  4068 
  4064 
  4069 void Threads::possibly_parallel_oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) {
  4065 void Threads::possibly_parallel_oops_do(bool is_par, OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) {
  4070   // Introduce a mechanism allowing parallel threads to claim threads as
       
  4071   // root groups.  Overhead should be small enough to use all the time,
       
  4072   // even in sequential code.
       
  4073   SharedHeap* sh = SharedHeap::heap();
       
  4074   // Cannot yet substitute active_workers for n_par_threads
       
  4075   // because of G1CollectedHeap::verify() use of
       
  4076   // SharedHeap::process_roots().  n_par_threads == 0 will
       
  4077   // turn off parallelism in process_roots while active_workers
       
  4078   // is being used for parallelism elsewhere.
       
  4079   bool is_par = sh->n_par_threads() > 0;
       
  4080   assert(!is_par ||
       
  4081          (SharedHeap::heap()->n_par_threads() ==
       
  4082          SharedHeap::heap()->workers()->active_workers()), "Mismatch");
       
  4083   int cp = Threads::thread_claim_parity();
  4066   int cp = Threads::thread_claim_parity();
  4084   ALL_JAVA_THREADS(p) {
  4067   ALL_JAVA_THREADS(p) {
  4085     if (p->claim_oops_do(is_par, cp)) {
  4068     if (p->claim_oops_do(is_par, cp)) {
  4086       p->oops_do(f, cld_f, cf);
  4069       p->oops_do(f, cld_f, cf);
  4087     }
  4070     }