src/share/vm/runtime/thread.cpp

Print this page




4084 // but the garbage collector must provide a safe context for them to run.
4085 // In particular, these things should never be called when the Threads_lock
4086 // is held by some other thread. (Note: the Safepoint abstraction also
4087 // uses the Threads_lock to guarantee this property. It also makes sure that
4088 // all threads gets blocked when exiting or starting).
4089 
4090 void Threads::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) {
4091   ALL_JAVA_THREADS(p) {
4092     p->oops_do(f, cld_f, cf);
4093   }
4094   VMThread::vm_thread()->oops_do(f, cld_f, cf);
4095 }
4096 
4097 void Threads::possibly_parallel_oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) {
4098   // Introduce a mechanism allowing parallel threads to claim threads as
4099   // root groups.  Overhead should be small enough to use all the time,
4100   // even in sequential code.
4101   SharedHeap* sh = SharedHeap::heap();
4102   // Cannot yet substitute active_workers for n_par_threads
4103   // because of G1CollectedHeap::verify() use of
4104   // SharedHeap::process_strong_roots().  n_par_threads == 0 will
4105   // turn off parallelism in process_strong_roots while active_workers
4106   // is being used for parallelism elsewhere.
4107   bool is_par = sh->n_par_threads() > 0;
4108   assert(!is_par ||
4109          (SharedHeap::heap()->n_par_threads() ==
4110           SharedHeap::heap()->workers()->active_workers()), "Mismatch");
4111   int cp = SharedHeap::heap()->strong_roots_parity();
4112   ALL_JAVA_THREADS(p) {
4113     if (p->claim_oops_do(is_par, cp)) {
4114       p->oops_do(f, cld_f, cf);
4115     }
4116   }
4117   VMThread* vmt = VMThread::vm_thread();
4118   if (vmt->claim_oops_do(is_par, cp)) {
4119     vmt->oops_do(f, cld_f, cf);
4120   }
4121 }
4122 
4123 #if INCLUDE_ALL_GCS
4124 // Used by ParallelScavenge
4125 void Threads::create_thread_roots_tasks(GCTaskQueue* q) {




4084 // but the garbage collector must provide a safe context for them to run.
4085 // In particular, these things should never be called when the Threads_lock
4086 // is held by some other thread. (Note: the Safepoint abstraction also
4087 // uses the Threads_lock to guarantee this property. It also makes sure that
4088 // all threads gets blocked when exiting or starting).
4089 
4090 void Threads::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) {
4091   ALL_JAVA_THREADS(p) {
4092     p->oops_do(f, cld_f, cf);
4093   }
4094   VMThread::vm_thread()->oops_do(f, cld_f, cf);
4095 }
4096 
4097 void Threads::possibly_parallel_oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) {
4098   // Introduce a mechanism allowing parallel threads to claim threads as
4099   // root groups.  Overhead should be small enough to use all the time,
4100   // even in sequential code.
4101   SharedHeap* sh = SharedHeap::heap();
4102   // Cannot yet substitute active_workers for n_par_threads
4103   // because of G1CollectedHeap::verify() use of
4104   // SharedHeap::process_roots().  n_par_threads == 0 will
4105   // turn off parallelism in process_roots while active_workers
4106   // is being used for parallelism elsewhere.
4107   bool is_par = sh->n_par_threads() > 0;
4108   assert(!is_par ||
4109          (SharedHeap::heap()->n_par_threads() ==
4110           SharedHeap::heap()->workers()->active_workers()), "Mismatch");
4111   int cp = SharedHeap::heap()->strong_roots_parity();
4112   ALL_JAVA_THREADS(p) {
4113     if (p->claim_oops_do(is_par, cp)) {
4114       p->oops_do(f, cld_f, cf);
4115     }
4116   }
4117   VMThread* vmt = VMThread::vm_thread();
4118   if (vmt->claim_oops_do(is_par, cp)) {
4119     vmt->oops_do(f, cld_f, cf);
4120   }
4121 }
4122 
4123 #if INCLUDE_ALL_GCS
4124 // Used by ParallelScavenge
4125 void Threads::create_thread_roots_tasks(GCTaskQueue* q) {