src/hotspot/share/runtime/thread.cpp
changeset 54955 46409371a691
parent 54927 1512d88b24c6
child 55005 9b70ebd131b4
equal deleted inserted replaced
54954:6ec71a88b68e 54955:46409371a691
  1611   set_deferred_locals(NULL);
  1611   set_deferred_locals(NULL);
  1612   set_deopt_mark(NULL);
  1612   set_deopt_mark(NULL);
  1613   set_deopt_compiled_method(NULL);
  1613   set_deopt_compiled_method(NULL);
  1614   clear_must_deopt_id();
  1614   clear_must_deopt_id();
  1615   set_monitor_chunks(NULL);
  1615   set_monitor_chunks(NULL);
  1616   set_next(NULL);
       
  1617   _on_thread_list = false;
  1616   _on_thread_list = false;
  1618   set_thread_state(_thread_new);
  1617   set_thread_state(_thread_new);
  1619   _terminated = _not_terminated;
  1618   _terminated = _not_terminated;
  1620   _array_for_gc = NULL;
  1619   _array_for_gc = NULL;
  1621   _suspend_equivalent = false;
  1620   _suspend_equivalent = false;
  3455 //
  3454 //
  3456 // Note: The Threads_lock is currently more widely used than we
  3455 // Note: The Threads_lock is currently more widely used than we
  3457 // would like. We are actively migrating Threads_lock uses to other
  3456 // would like. We are actively migrating Threads_lock uses to other
  3458 // mechanisms in order to reduce Threads_lock contention.
  3457 // mechanisms in order to reduce Threads_lock contention.
  3459 
  3458 
  3460 JavaThread* Threads::_thread_list = NULL;
       
  3461 int         Threads::_number_of_threads = 0;
  3459 int         Threads::_number_of_threads = 0;
  3462 int         Threads::_number_of_non_daemon_threads = 0;
  3460 int         Threads::_number_of_non_daemon_threads = 0;
  3463 int         Threads::_return_code = 0;
  3461 int         Threads::_return_code = 0;
  3464 uintx       Threads::_thread_claim_token = 1; // Never zero.
  3462 uintx       Threads::_thread_claim_token = 1; // Never zero.
  3465 size_t      JavaThread::_stack_size_at_create = 0;
  3463 size_t      JavaThread::_stack_size_at_create = 0;
  3762   if (Arguments::init_agents_at_startup()) {
  3760   if (Arguments::init_agents_at_startup()) {
  3763     create_vm_init_agents();
  3761     create_vm_init_agents();
  3764   }
  3762   }
  3765 
  3763 
  3766   // Initialize Threads state
  3764   // Initialize Threads state
  3767   _thread_list = NULL;
       
  3768   _number_of_threads = 0;
  3765   _number_of_threads = 0;
  3769   _number_of_non_daemon_threads = 0;
  3766   _number_of_non_daemon_threads = 0;
  3770 
  3767 
  3771   // Initialize global data structures and create system classes in heap
  3768   // Initialize global data structures and create system classes in heap
  3772   vm_init_globals();
  3769   vm_init_globals();
  4421   // The threads lock must be owned at this point
  4418   // The threads lock must be owned at this point
  4422   assert(Threads_lock->owned_by_self(), "must have threads lock");
  4419   assert(Threads_lock->owned_by_self(), "must have threads lock");
  4423 
  4420 
  4424   BarrierSet::barrier_set()->on_thread_attach(p);
  4421   BarrierSet::barrier_set()->on_thread_attach(p);
  4425 
  4422 
  4426   p->set_next(_thread_list);
       
  4427   _thread_list = p;
       
  4428 
       
  4429   // Once a JavaThread is added to the Threads list, smr_delete() has
  4423   // Once a JavaThread is added to the Threads list, smr_delete() has
  4430   // to be used to delete it. Otherwise we can just delete it directly.
  4424   // to be used to delete it. Otherwise we can just delete it directly.
  4431   p->set_on_thread_list();
  4425   p->set_on_thread_list();
  4432 
  4426 
  4433   _number_of_threads++;
  4427   _number_of_threads++;
  4460 
  4454 
  4461     assert(ThreadsSMRSupport::get_java_thread_list()->includes(p), "p must be present");
  4455     assert(ThreadsSMRSupport::get_java_thread_list()->includes(p), "p must be present");
  4462 
  4456 
  4463     // Maintain fast thread list
  4457     // Maintain fast thread list
  4464     ThreadsSMRSupport::remove_thread(p);
  4458     ThreadsSMRSupport::remove_thread(p);
  4465 
       
  4466     JavaThread* current = _thread_list;
       
  4467     JavaThread* prev    = NULL;
       
  4468 
       
  4469     while (current != p) {
       
  4470       prev    = current;
       
  4471       current = current->next();
       
  4472     }
       
  4473 
       
  4474     if (prev) {
       
  4475       prev->set_next(current->next());
       
  4476     } else {
       
  4477       _thread_list = p->next();
       
  4478     }
       
  4479 
  4459 
  4480     _number_of_threads--;
  4460     _number_of_threads--;
  4481     if (!is_daemon) {
  4461     if (!is_daemon) {
  4482       _number_of_non_daemon_threads--;
  4462       _number_of_non_daemon_threads--;
  4483 
  4463