src/hotspot/share/runtime/thread.cpp
changeset 49756 129d60b5dac7
parent 49752 93d84f667d12
child 49800 69d7398038c5
equal deleted inserted replaced
49755:80e7764e4d09 49756:129d60b5dac7
   104 #include "services/management.hpp"
   104 #include "services/management.hpp"
   105 #include "services/memTracker.hpp"
   105 #include "services/memTracker.hpp"
   106 #include "services/threadService.hpp"
   106 #include "services/threadService.hpp"
   107 #include "trace/traceMacros.hpp"
   107 #include "trace/traceMacros.hpp"
   108 #include "trace/tracing.hpp"
   108 #include "trace/tracing.hpp"
       
   109 #include "trace/tracingExport.hpp"
   109 #include "utilities/align.hpp"
   110 #include "utilities/align.hpp"
   110 #include "utilities/copy.hpp"
   111 #include "utilities/copy.hpp"
   111 #include "utilities/defaultStream.hpp"
   112 #include "utilities/defaultStream.hpp"
   112 #include "utilities/dtrace.hpp"
   113 #include "utilities/dtrace.hpp"
   113 #include "utilities/events.hpp"
   114 #include "utilities/events.hpp"
  3433              X = (JavaThread*)prefetch_and_load_ptr((void**)MACRO_current_p, (intx)MACRO_scan_interval))
  3434              X = (JavaThread*)prefetch_and_load_ptr((void**)MACRO_current_p, (intx)MACRO_scan_interval))
  3434 
  3435 
  3435 // All JavaThreads
  3436 // All JavaThreads
  3436 #define ALL_JAVA_THREADS(X) DO_JAVA_THREADS(ThreadsSMRSupport::get_java_thread_list(), X)
  3437 #define ALL_JAVA_THREADS(X) DO_JAVA_THREADS(ThreadsSMRSupport::get_java_thread_list(), X)
  3437 
  3438 
  3438 // All JavaThreads + all non-JavaThreads (i.e., every thread in the system)
  3439 // All non-JavaThreads (i.e., every non-JavaThread in the system).
  3439 void Threads::threads_do(ThreadClosure* tc) {
  3440 void Threads::non_java_threads_do(ThreadClosure* tc) {
  3440   assert_locked_or_safepoint(Threads_lock);
       
  3441   // ALL_JAVA_THREADS iterates through all JavaThreads
       
  3442   ALL_JAVA_THREADS(p) {
       
  3443     tc->do_thread(p);
       
  3444   }
       
  3445   // Someday we could have a table or list of all non-JavaThreads.
  3441   // Someday we could have a table or list of all non-JavaThreads.
  3446   // For now, just manually iterate through them.
  3442   // For now, just manually iterate through them.
  3447   tc->do_thread(VMThread::vm_thread());
  3443   tc->do_thread(VMThread::vm_thread());
  3448   Universe::heap()->gc_threads_do(tc);
  3444   if (Universe::heap() != NULL) {
       
  3445     Universe::heap()->gc_threads_do(tc);
       
  3446   }
  3449   WatcherThread *wt = WatcherThread::watcher_thread();
  3447   WatcherThread *wt = WatcherThread::watcher_thread();
  3450   // Strictly speaking, the following NULL check isn't sufficient to make sure
  3448   // Strictly speaking, the following NULL check isn't sufficient to make sure
  3451   // the data for WatcherThread is still valid upon being examined. However,
  3449   // the data for WatcherThread is still valid upon being examined. However,
  3452   // considering that WatchThread terminates when the VM is on the way to
  3450   // considering that WatchThread terminates when the VM is on the way to
  3453   // exit at safepoint, the chance of the above is extremely small. The right
  3451   // exit at safepoint, the chance of the above is extremely small. The right
  3456   // checking in some cases.
  3454   // checking in some cases.
  3457   if (wt != NULL) {
  3455   if (wt != NULL) {
  3458     tc->do_thread(wt);
  3456     tc->do_thread(wt);
  3459   }
  3457   }
  3460 
  3458 
       
  3459 #if INCLUDE_TRACE
       
  3460   Thread* sampler_thread = TracingExport::sampler_thread_acquire();
       
  3461   if (sampler_thread != NULL) {
       
  3462     tc->do_thread(sampler_thread);
       
  3463   }
       
  3464 #endif
       
  3465 
  3461   // If CompilerThreads ever become non-JavaThreads, add them here
  3466   // If CompilerThreads ever become non-JavaThreads, add them here
       
  3467 }
       
  3468 
       
  3469 // All JavaThreads + all non-JavaThreads (i.e., every thread in the system).
       
  3470 void Threads::threads_do(ThreadClosure* tc) {
       
  3471   assert_locked_or_safepoint(Threads_lock);
       
  3472   // ALL_JAVA_THREADS iterates through all JavaThreads.
       
  3473   ALL_JAVA_THREADS(p) {
       
  3474     tc->do_thread(p);
       
  3475   }
       
  3476   non_java_threads_do(tc);
  3462 }
  3477 }
  3463 
  3478 
  3464 void Threads::possibly_parallel_threads_do(bool is_par, ThreadClosure* tc) {
  3479 void Threads::possibly_parallel_threads_do(bool is_par, ThreadClosure* tc) {
  3465   int cp = Threads::thread_claim_parity();
  3480   int cp = Threads::thread_claim_parity();
  3466   ALL_JAVA_THREADS(p) {
  3481   ALL_JAVA_THREADS(p) {