< prev index next >

src/hotspot/share/runtime/thread.hpp

Print this page
rev 47959 : imported patch 10.07.open.rebase_20171110.dcubed
rev 47962 : dholmes CR: Fix indents, trailing spaces and various typos. Add descriptions for the '_cnt', '_max' and '_times" fields, add impl notes to document the type choices.
rev 47963 : robinw CR: Fix some inefficient code, update some comments, fix some indents, and add some 'const' specifiers.
rev 47965 : misc CR updates; rebase to 2017.11.22 bits.


2112   void set_ideal_graph_printer(IdealGraphPrinter *n) { _ideal_graph_printer = n; }
2113 #endif
2114 
2115   // Get/set the thread's current task
2116   CompileTask* task()                      { return _task; }
2117   void         set_task(CompileTask* task) { _task = task; }
2118 };
2119 
2120 inline CompilerThread* CompilerThread::current() {
2121   return JavaThread::current()->as_CompilerThread();
2122 }
2123 
2124 // The active thread queue. It also keeps track of the current used
2125 // thread priorities.
2126 class Threads: AllStatic {
2127   friend class VMStructs;
2128  private:
2129   // Safe Memory Reclamation (SMR) support:
2130   static Monitor*              _smr_delete_lock;
2131   // The '_cnt', '_max' and '_times" fields are enabled via
2132   // -XX:+EnableThreadSMRStatistics:
2133                                        // # of parallel threads in _smr_delete_lock->wait().
2134   static uint                  _smr_delete_lock_wait_cnt;
2135                                        // Max # of parallel threads in _smr_delete_lock->wait().
2136   static uint                  _smr_delete_lock_wait_max;
2137                                        // Flag to indicate when an _smr_delete_lock->notify() is needed.
2138   static volatile uint         _smr_delete_notify;
2139                                        // # of threads deleted over VM lifetime.
2140   static volatile uint         _smr_deleted_thread_cnt;
2141                                        // Max time in millis to delete a thread.
2142   static volatile uint         _smr_deleted_thread_time_max;
2143                                        // Cumulative time in millis to delete threads.
2144   static volatile uint         _smr_deleted_thread_times;
2145   static ThreadsList* volatile _smr_java_thread_list;
2146   static ThreadsList*          get_smr_java_thread_list();
2147   static ThreadsList*          xchg_smr_java_thread_list(ThreadsList* new_list);
2148                                        // # of ThreadsLists allocated over VM lifetime.
2149   static uint64_t              _smr_java_thread_list_alloc_cnt;
2150                                        // # of ThreadsLists freed over VM lifetime.
2151   static uint64_t              _smr_java_thread_list_free_cnt;
2152                                        // Max size ThreadsList allocated.
2153   static uint                  _smr_java_thread_list_max;
2154                                        // Max # of nested ThreadsLists for a thread.
2155   static uint                  _smr_nested_thread_list_max;
2156                                        // # of ThreadsListHandles deleted over VM lifetime.
2157   static volatile uint         _smr_tlh_cnt;
2158                                        // Max time in millis to delete a ThreadsListHandle.
2159   static volatile uint         _smr_tlh_time_max;
2160                                        // Cumulative time in millis to delete ThreadsListHandles.
2161   static volatile uint         _smr_tlh_times;
2162   static ThreadsList*          _smr_to_delete_list;
2163                                        // # of parallel ThreadsLists on the to-delete list.
2164   static uint                  _smr_to_delete_list_cnt;
2165                                        // Max # of parallel ThreadsLists on the to-delete list.
2166   static uint                  _smr_to_delete_list_max;
2167 
2168   static JavaThread*           _thread_list;
2169   static int                   _number_of_threads;
2170   static int                   _number_of_non_daemon_threads;
2171   static int                   _return_code;
2172   static int                   _thread_claim_parity;
2173 #ifdef ASSERT
2174   static bool                  _vm_complete;
2175 #endif
2176 
2177   static void initialize_java_lang_classes(JavaThread* main_thread, TRAPS);
2178   static void initialize_jsr292_core_classes(TRAPS);
2179 
2180   static void smr_free_list(ThreadsList* threads);
2181 
2182  public:
2183   // Thread management
2184   // force_daemon is a concession to JNI, where we may need to add a
2185   // thread to the thread list before allocating its thread object
2186   static void add(JavaThread* p, bool force_daemon = false);
2187   static void remove(JavaThread* p);
2188   static void threads_do(ThreadClosure* tc);
2189   static void possibly_parallel_threads_do(bool is_par, ThreadClosure* tc);
2190 
2191   // SMR support:
2192   template <class T>
2193   static void threads_do_smr(T *tc, Thread *self);
2194   static ThreadsList *acquire_stable_list(Thread *self, bool is_ThreadsListSetter);
2195   static ThreadsList *acquire_stable_list_fast_path(Thread *self);
2196   static ThreadsList *acquire_stable_list_nested_path(Thread *self);
2197   static void release_stable_list(Thread *self);
2198   static void release_stable_list_fast_path(Thread *self);
2199   static void release_stable_list_nested_path(Thread *self);
2200   static void release_stable_list_wake_up(char *log_str);
2201   static bool is_a_protected_JavaThread(JavaThread *thread);
2202   static bool is_a_protected_JavaThread_with_lock(JavaThread *thread) {
2203     MutexLockerEx ml(Threads_lock->owned_by_self() ? NULL : Threads_lock);
2204     return is_a_protected_JavaThread(thread);
2205   }
2206   static void smr_delete(JavaThread *thread);
2207   // The coordination between Threads::release_stable_list() and
2208   // Threads::smr_delete() uses the smr_delete_lock in order to
2209   // reduce the traffic on the Threads_lock.
2210   static Monitor* smr_delete_lock() { return _smr_delete_lock; }
2211   // The smr_delete_notify flag is used for proper double-check
2212   // locking in order to reduce the traffic on the smr_delete_lock.
2213   static bool smr_delete_notify();




2112   void set_ideal_graph_printer(IdealGraphPrinter *n) { _ideal_graph_printer = n; }
2113 #endif
2114 
2115   // Get/set the thread's current task
2116   CompileTask* task()                      { return _task; }
2117   void         set_task(CompileTask* task) { _task = task; }
2118 };
2119 
2120 inline CompilerThread* CompilerThread::current() {
2121   return JavaThread::current()->as_CompilerThread();
2122 }
2123 
2124 // The active thread queue. It also keeps track of the current used
2125 // thread priorities.
2126 class Threads: AllStatic {
2127   friend class VMStructs;
2128  private:
2129   // Safe Memory Reclamation (SMR) support:
2130   static Monitor*              _smr_delete_lock;
2131   // The '_cnt', '_max' and '_times" fields are enabled via
2132   // -XX:+EnableThreadSMRStatistics (see thread.cpp for a
2133   // description about each field):
2134   static uint                  _smr_delete_lock_wait_cnt;

2135   static uint                  _smr_delete_lock_wait_max;

2136   static volatile uint         _smr_delete_notify;

2137   static volatile uint         _smr_deleted_thread_cnt;

2138   static volatile uint         _smr_deleted_thread_time_max;

2139   static volatile uint         _smr_deleted_thread_times;
2140   static ThreadsList* volatile _smr_java_thread_list;
2141   static ThreadsList*          get_smr_java_thread_list();
2142   static ThreadsList*          xchg_smr_java_thread_list(ThreadsList* new_list);

2143   static uint64_t              _smr_java_thread_list_alloc_cnt;

2144   static uint64_t              _smr_java_thread_list_free_cnt;

2145   static uint                  _smr_java_thread_list_max;

2146   static uint                  _smr_nested_thread_list_max;

2147   static volatile uint         _smr_tlh_cnt;

2148   static volatile uint         _smr_tlh_time_max;

2149   static volatile uint         _smr_tlh_times;
2150   static ThreadsList*          _smr_to_delete_list;

2151   static uint                  _smr_to_delete_list_cnt;

2152   static uint                  _smr_to_delete_list_max;
2153 
2154   static JavaThread*           _thread_list;
2155   static int                   _number_of_threads;
2156   static int                   _number_of_non_daemon_threads;
2157   static int                   _return_code;
2158   static int                   _thread_claim_parity;
2159 #ifdef ASSERT
2160   static bool                  _vm_complete;
2161 #endif
2162 
2163   static void initialize_java_lang_classes(JavaThread* main_thread, TRAPS);
2164   static void initialize_jsr292_core_classes(TRAPS);
2165 
2166   static void smr_free_list(ThreadsList* threads);
2167 
2168  public:
2169   // Thread management
2170   // force_daemon is a concession to JNI, where we may need to add a
2171   // thread to the thread list before allocating its thread object
2172   static void add(JavaThread* p, bool force_daemon = false);
2173   static void remove(JavaThread* p);
2174   static void threads_do(ThreadClosure* tc);
2175   static void possibly_parallel_threads_do(bool is_par, ThreadClosure* tc);
2176 
2177   // SMR support:


2178   static ThreadsList *acquire_stable_list(Thread *self, bool is_ThreadsListSetter);
2179   static ThreadsList *acquire_stable_list_fast_path(Thread *self);
2180   static ThreadsList *acquire_stable_list_nested_path(Thread *self);
2181   static void release_stable_list(Thread *self);
2182   static void release_stable_list_fast_path(Thread *self);
2183   static void release_stable_list_nested_path(Thread *self);
2184   static void release_stable_list_wake_up(char *log_str);
2185   static bool is_a_protected_JavaThread(JavaThread *thread);
2186   static bool is_a_protected_JavaThread_with_lock(JavaThread *thread) {
2187     MutexLockerEx ml(Threads_lock->owned_by_self() ? NULL : Threads_lock);
2188     return is_a_protected_JavaThread(thread);
2189   }
2190   static void smr_delete(JavaThread *thread);
2191   // The coordination between Threads::release_stable_list() and
2192   // Threads::smr_delete() uses the smr_delete_lock in order to
2193   // reduce the traffic on the Threads_lock.
2194   static Monitor* smr_delete_lock() { return _smr_delete_lock; }
2195   // The smr_delete_notify flag is used for proper double-check
2196   // locking in order to reduce the traffic on the smr_delete_lock.
2197   static bool smr_delete_notify();


< prev index next >