hotspot/src/share/vm/runtime/thread.cpp
changeset 29802 d485440c958a
parent 29699 d04568cd189a
child 30147 af9a41999c6e
equal deleted inserted replaced
29801:2e4a5be5a595 29802:d485440c958a
  3181 
  3181 
  3182 JavaThread* Threads::_thread_list = NULL;
  3182 JavaThread* Threads::_thread_list = NULL;
  3183 int         Threads::_number_of_threads = 0;
  3183 int         Threads::_number_of_threads = 0;
  3184 int         Threads::_number_of_non_daemon_threads = 0;
  3184 int         Threads::_number_of_non_daemon_threads = 0;
  3185 int         Threads::_return_code = 0;
  3185 int         Threads::_return_code = 0;
       
  3186 int         Threads::_thread_claim_parity = 0;
  3186 size_t      JavaThread::_stack_size_at_create = 0;
  3187 size_t      JavaThread::_stack_size_at_create = 0;
  3187 #ifdef ASSERT
  3188 #ifdef ASSERT
  3188 bool        Threads::_vm_complete = false;
  3189 bool        Threads::_vm_complete = false;
  3189 #endif
  3190 #endif
  3190 
  3191 
  3214     tc->do_thread(wt);
  3215     tc->do_thread(wt);
  3215   }
  3216   }
  3216 
  3217 
  3217   // If CompilerThreads ever become non-JavaThreads, add them here
  3218   // If CompilerThreads ever become non-JavaThreads, add them here
  3218 }
  3219 }
  3219 
       
  3220 
  3220 
  3221 void Threads::initialize_java_lang_classes(JavaThread* main_thread, TRAPS) {
  3221 void Threads::initialize_java_lang_classes(JavaThread* main_thread, TRAPS) {
  3222   TraceTime timer("Initialize java.lang classes", TraceStartupTime);
  3222   TraceTime timer("Initialize java.lang classes", TraceStartupTime);
  3223 
  3223 
  3224   if (EagerXrunInit && Arguments::init_libraries_at_startup()) {
  3224   if (EagerXrunInit && Arguments::init_libraries_at_startup()) {
  4044     p->oops_do(f, cld_f, cf);
  4044     p->oops_do(f, cld_f, cf);
  4045   }
  4045   }
  4046   VMThread::vm_thread()->oops_do(f, cld_f, cf);
  4046   VMThread::vm_thread()->oops_do(f, cld_f, cf);
  4047 }
  4047 }
  4048 
  4048 
       
  4049 void Threads::change_thread_claim_parity() {
       
  4050   // Set the new claim parity.
       
  4051   assert(_thread_claim_parity >= 0 && _thread_claim_parity <= 2,
       
  4052          "Not in range.");
       
  4053   _thread_claim_parity++;
       
  4054   if (_thread_claim_parity == 3) _thread_claim_parity = 1;
       
  4055   assert(_thread_claim_parity >= 1 && _thread_claim_parity <= 2,
       
  4056          "Not in range.");
       
  4057 }
       
  4058 
       
  4059 #ifndef PRODUCT
       
  4060 void Threads::assert_all_threads_claimed() {
       
  4061   ALL_JAVA_THREADS(p) {
       
  4062     const int thread_parity = p->oops_do_parity();
       
  4063     assert((thread_parity == _thread_claim_parity),
       
  4064         err_msg("Thread " PTR_FORMAT " has incorrect parity %d != %d", p2i(p), thread_parity, _thread_claim_parity));
       
  4065   }
       
  4066 }
       
  4067 #endif // PRODUCT
       
  4068 
  4049 void Threads::possibly_parallel_oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) {
  4069 void Threads::possibly_parallel_oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) {
  4050   // Introduce a mechanism allowing parallel threads to claim threads as
  4070   // Introduce a mechanism allowing parallel threads to claim threads as
  4051   // root groups.  Overhead should be small enough to use all the time,
  4071   // root groups.  Overhead should be small enough to use all the time,
  4052   // even in sequential code.
  4072   // even in sequential code.
  4053   SharedHeap* sh = SharedHeap::heap();
  4073   SharedHeap* sh = SharedHeap::heap();
  4058   // is being used for parallelism elsewhere.
  4078   // is being used for parallelism elsewhere.
  4059   bool is_par = sh->n_par_threads() > 0;
  4079   bool is_par = sh->n_par_threads() > 0;
  4060   assert(!is_par ||
  4080   assert(!is_par ||
  4061          (SharedHeap::heap()->n_par_threads() ==
  4081          (SharedHeap::heap()->n_par_threads() ==
  4062          SharedHeap::heap()->workers()->active_workers()), "Mismatch");
  4082          SharedHeap::heap()->workers()->active_workers()), "Mismatch");
  4063   int cp = SharedHeap::heap()->strong_roots_parity();
  4083   int cp = Threads::thread_claim_parity();
  4064   ALL_JAVA_THREADS(p) {
  4084   ALL_JAVA_THREADS(p) {
  4065     if (p->claim_oops_do(is_par, cp)) {
  4085     if (p->claim_oops_do(is_par, cp)) {
  4066       p->oops_do(f, cld_f, cf);
  4086       p->oops_do(f, cld_f, cf);
  4067     }
  4087     }
  4068   }
  4088   }