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