3332 }
3333 // Someday we could have a table or list of all non-JavaThreads.
3334 // For now, just manually iterate through them.
3335 tc->do_thread(VMThread::vm_thread());
3336 Universe::heap()->gc_threads_do(tc);
3337 WatcherThread *wt = WatcherThread::watcher_thread();
3338 // Strictly speaking, the following NULL check isn't sufficient to make sure
3339 // the data for WatcherThread is still valid upon being examined. However,
3340 // considering that WatchThread terminates when the VM is on the way to
3341 // exit at safepoint, the chance of the above is extremely small. The right
3342 // way to prevent termination of WatcherThread would be to acquire
3343 // Terminator_lock, but we can't do that without violating the lock rank
3344 // checking in some cases.
3345 if (wt != NULL) {
3346 tc->do_thread(wt);
3347 }
3348
3349 // If CompilerThreads ever become non-JavaThreads, add them here
3350 }
3351
3352 void Threads::parallel_threads_do(bool is_par, ThreadClosure* tc) {
3353 int cp = Threads::thread_claim_parity();
3354 ALL_JAVA_THREADS(p) {
3355 if (p->claim_oops_do(is_par, cp)) {
3356 tc->do_thread(p);
3357 }
3358 }
3359 VMThread* vmt = VMThread::vm_thread();
3360 if (vmt->claim_oops_do(is_par, cp)) {
3361 tc->do_thread(vmt);
3362 }
3363 }
3364
3365 // The system initialization in the library has three phases.
3366 //
3367 // Phase 1: java.lang.System class initialization
3368 // java.lang.System is a primordial class loaded and initialized
3369 // by the VM early during startup. java.lang.System.<clinit>
3370 // only does registerNatives and keeps the rest of the class
3371 // initialization work later until thread initialization completes.
3372 //
4317 VMThread* vmt = VMThread::vm_thread();
4318 const int thread_parity = vmt->oops_do_parity();
4319 assert((thread_parity == _thread_claim_parity),
4320 "VMThread " PTR_FORMAT " has incorrect parity %d != %d", p2i(vmt), thread_parity, _thread_claim_parity);
4321 }
4322 #endif // ASSERT
4323
4324 class ParallelOopsDoThreadClosure : public ThreadClosure {
4325 private:
4326 OopClosure* _f;
4327 CodeBlobClosure* _cf;
4328 public:
4329 ParallelOopsDoThreadClosure(OopClosure* f, CodeBlobClosure* cf) : _f(f), _cf(cf) {}
4330 void do_thread(Thread* t) {
4331 t->oops_do(_f, _cf);
4332 }
4333 };
4334
4335 void Threads::possibly_parallel_oops_do(bool is_par, OopClosure* f, CodeBlobClosure* cf) {
4336 ParallelOopsDoThreadClosure tc(f, cf);
4337 parallel_threads_do(is_par, &tc);
4338 }
4339
4340 #if INCLUDE_ALL_GCS
4341 // Used by ParallelScavenge
4342 void Threads::create_thread_roots_tasks(GCTaskQueue* q) {
4343 ALL_JAVA_THREADS(p) {
4344 q->enqueue(new ThreadRootsTask(p));
4345 }
4346 q->enqueue(new ThreadRootsTask(VMThread::vm_thread()));
4347 }
4348
4349 // Used by Parallel Old
4350 void Threads::create_thread_roots_marking_tasks(GCTaskQueue* q) {
4351 ALL_JAVA_THREADS(p) {
4352 q->enqueue(new ThreadRootsMarkingTask(p));
4353 }
4354 q->enqueue(new ThreadRootsMarkingTask(VMThread::vm_thread()));
4355 }
4356 #endif // INCLUDE_ALL_GCS
4357
|
3332 }
3333 // Someday we could have a table or list of all non-JavaThreads.
3334 // For now, just manually iterate through them.
3335 tc->do_thread(VMThread::vm_thread());
3336 Universe::heap()->gc_threads_do(tc);
3337 WatcherThread *wt = WatcherThread::watcher_thread();
3338 // Strictly speaking, the following NULL check isn't sufficient to make sure
3339 // the data for WatcherThread is still valid upon being examined. However,
3340 // considering that WatchThread terminates when the VM is on the way to
3341 // exit at safepoint, the chance of the above is extremely small. The right
3342 // way to prevent termination of WatcherThread would be to acquire
3343 // Terminator_lock, but we can't do that without violating the lock rank
3344 // checking in some cases.
3345 if (wt != NULL) {
3346 tc->do_thread(wt);
3347 }
3348
3349 // If CompilerThreads ever become non-JavaThreads, add them here
3350 }
3351
3352 void Threads::possibly_parallel_threads_do(bool is_par, ThreadClosure* tc) {
3353 int cp = Threads::thread_claim_parity();
3354 ALL_JAVA_THREADS(p) {
3355 if (p->claim_oops_do(is_par, cp)) {
3356 tc->do_thread(p);
3357 }
3358 }
3359 VMThread* vmt = VMThread::vm_thread();
3360 if (vmt->claim_oops_do(is_par, cp)) {
3361 tc->do_thread(vmt);
3362 }
3363 }
3364
3365 // The system initialization in the library has three phases.
3366 //
3367 // Phase 1: java.lang.System class initialization
3368 // java.lang.System is a primordial class loaded and initialized
3369 // by the VM early during startup. java.lang.System.<clinit>
3370 // only does registerNatives and keeps the rest of the class
3371 // initialization work later until thread initialization completes.
3372 //
4317 VMThread* vmt = VMThread::vm_thread();
4318 const int thread_parity = vmt->oops_do_parity();
4319 assert((thread_parity == _thread_claim_parity),
4320 "VMThread " PTR_FORMAT " has incorrect parity %d != %d", p2i(vmt), thread_parity, _thread_claim_parity);
4321 }
4322 #endif // ASSERT
4323
4324 class ParallelOopsDoThreadClosure : public ThreadClosure {
4325 private:
4326 OopClosure* _f;
4327 CodeBlobClosure* _cf;
4328 public:
4329 ParallelOopsDoThreadClosure(OopClosure* f, CodeBlobClosure* cf) : _f(f), _cf(cf) {}
4330 void do_thread(Thread* t) {
4331 t->oops_do(_f, _cf);
4332 }
4333 };
4334
4335 void Threads::possibly_parallel_oops_do(bool is_par, OopClosure* f, CodeBlobClosure* cf) {
4336 ParallelOopsDoThreadClosure tc(f, cf);
4337 possibly_parallel_threads_do(is_par, &tc);
4338 }
4339
4340 #if INCLUDE_ALL_GCS
4341 // Used by ParallelScavenge
4342 void Threads::create_thread_roots_tasks(GCTaskQueue* q) {
4343 ALL_JAVA_THREADS(p) {
4344 q->enqueue(new ThreadRootsTask(p));
4345 }
4346 q->enqueue(new ThreadRootsTask(VMThread::vm_thread()));
4347 }
4348
4349 // Used by Parallel Old
4350 void Threads::create_thread_roots_marking_tasks(GCTaskQueue* q) {
4351 ALL_JAVA_THREADS(p) {
4352 q->enqueue(new ThreadRootsMarkingTask(p));
4353 }
4354 q->enqueue(new ThreadRootsMarkingTask(VMThread::vm_thread()));
4355 }
4356 #endif // INCLUDE_ALL_GCS
4357
|