src/share/vm/runtime/thread.cpp

Print this page
rev 2661 : [mq]: g1-reference-processing


 732 void Thread::interrupt(Thread* thread) {
 733   trace("interrupt", thread);
 734   debug_only(check_for_dangling_thread_pointer(thread);)
 735   os::interrupt(thread);
 736 }
 737 
 738 bool Thread::is_interrupted(Thread* thread, bool clear_interrupted) {
 739   trace("is_interrupted", thread);
 740   debug_only(check_for_dangling_thread_pointer(thread);)
 741   // Note:  If clear_interrupted==false, this simply fetches and
 742   // returns the value of the field osthread()->interrupted().
 743   return os::is_interrupted(thread, clear_interrupted);
 744 }
 745 
 746 
 747 // GC Support
 748 bool Thread::claim_oops_do_par_case(int strong_roots_parity) {
 749   jint thread_parity = _oops_do_parity;
 750   if (thread_parity != strong_roots_parity) {
 751     jint res = Atomic::cmpxchg(strong_roots_parity, &_oops_do_parity, thread_parity);
 752     if (res == thread_parity) return true;
 753     else {

 754       guarantee(res == strong_roots_parity, "Or else what?");
 755       assert(SharedHeap::heap()->n_par_threads() > 0,
 756              "Should only fail when parallel.");
 757       return false;
 758     }
 759   }
 760   assert(SharedHeap::heap()->n_par_threads() > 0,
 761          "Should only fail when parallel.");
 762   return false;
 763 }
 764 
 765 void Thread::oops_do(OopClosure* f, CodeBlobClosure* cf) {
 766   active_handles()->oops_do(f);
 767   // Do oop for ThreadShadow
 768   f->do_oop((oop*)&_pending_exception);
 769   handle_area()->oops_do(f);
 770 }
 771 
 772 void Thread::nmethods_do(CodeBlobClosure* cf) {
 773   // no nmethods in a generic thread...


3851 void Threads::oops_do(OopClosure* f, CodeBlobClosure* cf) {
3852   ALL_JAVA_THREADS(p) {
3853     p->oops_do(f, cf);
3854   }
3855   VMThread::vm_thread()->oops_do(f, cf);
3856 }
3857 
3858 void Threads::possibly_parallel_oops_do(OopClosure* f, CodeBlobClosure* cf) {
3859   // Introduce a mechanism allowing parallel threads to claim threads as
3860   // root groups.  Overhead should be small enough to use all the time,
3861   // even in sequential code.
3862   SharedHeap* sh = SharedHeap::heap();
3863   bool is_par = (sh->n_par_threads() > 0);
3864   int cp = SharedHeap::heap()->strong_roots_parity();
3865   ALL_JAVA_THREADS(p) {
3866     if (p->claim_oops_do(is_par, cp)) {
3867       p->oops_do(f, cf);
3868     }
3869   }
3870   VMThread* vmt = VMThread::vm_thread();
3871   if (vmt->claim_oops_do(is_par, cp))
3872     vmt->oops_do(f, cf);

3873 }
3874 
3875 #ifndef SERIALGC
3876 // Used by ParallelScavenge
3877 void Threads::create_thread_roots_tasks(GCTaskQueue* q) {
3878   ALL_JAVA_THREADS(p) {
3879     q->enqueue(new ThreadRootsTask(p));
3880   }
3881   q->enqueue(new ThreadRootsTask(VMThread::vm_thread()));
3882 }
3883 
3884 // Used by Parallel Old
3885 void Threads::create_thread_roots_marking_tasks(GCTaskQueue* q) {
3886   ALL_JAVA_THREADS(p) {
3887     q->enqueue(new ThreadRootsMarkingTask(p));
3888   }
3889   q->enqueue(new ThreadRootsMarkingTask(VMThread::vm_thread()));
3890 }
3891 #endif // SERIALGC
3892 




 732 void Thread::interrupt(Thread* thread) {
 733   trace("interrupt", thread);
 734   debug_only(check_for_dangling_thread_pointer(thread);)
 735   os::interrupt(thread);
 736 }
 737 
 738 bool Thread::is_interrupted(Thread* thread, bool clear_interrupted) {
 739   trace("is_interrupted", thread);
 740   debug_only(check_for_dangling_thread_pointer(thread);)
 741   // Note:  If clear_interrupted==false, this simply fetches and
 742   // returns the value of the field osthread()->interrupted().
 743   return os::is_interrupted(thread, clear_interrupted);
 744 }
 745 
 746 
 747 // GC Support
 748 bool Thread::claim_oops_do_par_case(int strong_roots_parity) {
 749   jint thread_parity = _oops_do_parity;
 750   if (thread_parity != strong_roots_parity) {
 751     jint res = Atomic::cmpxchg(strong_roots_parity, &_oops_do_parity, thread_parity);
 752     if (res == thread_parity) {
 753       return true;
 754     } else {
 755       guarantee(res == strong_roots_parity, "Or else what?");
 756       assert(SharedHeap::heap()->n_par_threads() > 0,
 757              "Should only fail when parallel.");
 758       return false;
 759     }
 760   }
 761   assert(SharedHeap::heap()->n_par_threads() > 0,
 762          "Should only fail when parallel.");
 763   return false;
 764 }
 765 
 766 void Thread::oops_do(OopClosure* f, CodeBlobClosure* cf) {
 767   active_handles()->oops_do(f);
 768   // Do oop for ThreadShadow
 769   f->do_oop((oop*)&_pending_exception);
 770   handle_area()->oops_do(f);
 771 }
 772 
 773 void Thread::nmethods_do(CodeBlobClosure* cf) {
 774   // no nmethods in a generic thread...


3852 void Threads::oops_do(OopClosure* f, CodeBlobClosure* cf) {
3853   ALL_JAVA_THREADS(p) {
3854     p->oops_do(f, cf);
3855   }
3856   VMThread::vm_thread()->oops_do(f, cf);
3857 }
3858 
3859 void Threads::possibly_parallel_oops_do(OopClosure* f, CodeBlobClosure* cf) {
3860   // Introduce a mechanism allowing parallel threads to claim threads as
3861   // root groups.  Overhead should be small enough to use all the time,
3862   // even in sequential code.
3863   SharedHeap* sh = SharedHeap::heap();
3864   bool is_par = (sh->n_par_threads() > 0);
3865   int cp = SharedHeap::heap()->strong_roots_parity();
3866   ALL_JAVA_THREADS(p) {
3867     if (p->claim_oops_do(is_par, cp)) {
3868       p->oops_do(f, cf);
3869     }
3870   }
3871   VMThread* vmt = VMThread::vm_thread();
3872   if (vmt->claim_oops_do(is_par, cp)) {
3873     vmt->oops_do(f, cf);
3874   }
3875 }
3876 
3877 #ifndef SERIALGC
3878 // Used by ParallelScavenge
3879 void Threads::create_thread_roots_tasks(GCTaskQueue* q) {
3880   ALL_JAVA_THREADS(p) {
3881     q->enqueue(new ThreadRootsTask(p));
3882   }
3883   q->enqueue(new ThreadRootsTask(VMThread::vm_thread()));
3884 }
3885 
3886 // Used by Parallel Old
3887 void Threads::create_thread_roots_marking_tasks(GCTaskQueue* q) {
3888   ALL_JAVA_THREADS(p) {
3889     q->enqueue(new ThreadRootsMarkingTask(p));
3890   }
3891   q->enqueue(new ThreadRootsMarkingTask(VMThread::vm_thread()));
3892 }
3893 #endif // SERIALGC
3894