119 // const char* _exception_file; // file information for exception (debugging only) |
119 // const char* _exception_file; // file information for exception (debugging only) |
120 // int _exception_line; // line information for exception (debugging only) |
120 // int _exception_line; // line information for exception (debugging only) |
121 protected: |
121 protected: |
122 // Support for forcing alignment of thread objects for biased locking |
122 // Support for forcing alignment of thread objects for biased locking |
123 void* _real_malloc_address; |
123 void* _real_malloc_address; |
|
124 |
124 // JavaThread lifecycle support: |
125 // JavaThread lifecycle support: |
125 friend class ScanHazardPtrGatherProtectedThreadsClosure; |
126 friend class ScanHazardPtrGatherProtectedThreadsClosure; // for cmpxchg_threads_hazard_ptr(), get_threads_hazard_ptr(), is_hazard_ptr_tagged() access |
126 friend class ScanHazardPtrGatherThreadsListClosure; |
127 friend class ScanHazardPtrGatherThreadsListClosure; // for get_nested_threads_hazard_ptr(), get_threads_hazard_ptr(), untag_hazard_ptr() access |
127 friend class ScanHazardPtrPrintMatchingThreadsClosure; |
128 friend class ScanHazardPtrPrintMatchingThreadsClosure; // for get_threads_hazard_ptr(), is_hazard_ptr_tagged() access |
128 friend class ThreadsListHandle; |
129 friend class ThreadsListSetter; // for get_threads_hazard_ptr() access |
129 friend class ThreadsListSetter; |
130 friend class ThreadsSMRSupport; // for get_threads_hazard_ptr() access |
|
131 |
130 ThreadsList* volatile _threads_hazard_ptr; |
132 ThreadsList* volatile _threads_hazard_ptr; |
131 ThreadsList* cmpxchg_threads_hazard_ptr(ThreadsList* exchange_value, ThreadsList* compare_value); |
133 ThreadsList* cmpxchg_threads_hazard_ptr(ThreadsList* exchange_value, ThreadsList* compare_value); |
132 ThreadsList* get_threads_hazard_ptr(); |
134 ThreadsList* get_threads_hazard_ptr(); |
133 void set_threads_hazard_ptr(ThreadsList* new_list); |
135 void set_threads_hazard_ptr(ThreadsList* new_list); |
134 static bool is_hazard_ptr_tagged(ThreadsList* list) { |
136 static bool is_hazard_ptr_tagged(ThreadsList* list) { |
2124 // The active thread queue. It also keeps track of the current used |
2126 // The active thread queue. It also keeps track of the current used |
2125 // thread priorities. |
2127 // thread priorities. |
2126 class Threads: AllStatic { |
2128 class Threads: AllStatic { |
2127 friend class VMStructs; |
2129 friend class VMStructs; |
2128 private: |
2130 private: |
2129 // Safe Memory Reclamation (SMR) support: |
2131 static JavaThread* _thread_list; |
2130 // The coordination between Threads::release_stable_list() and |
2132 static int _number_of_threads; |
2131 // Threads::smr_delete() uses the smr_delete_lock in order to |
2133 static int _number_of_non_daemon_threads; |
2132 // reduce the traffic on the Threads_lock. |
2134 static int _return_code; |
2133 static Monitor* _smr_delete_lock; |
2135 static int _thread_claim_parity; |
2134 // The '_cnt', '_max' and '_times" fields are enabled via |
|
2135 // -XX:+EnableThreadSMRStatistics (see thread.cpp for a |
|
2136 // description about each field): |
|
2137 static uint _smr_delete_lock_wait_cnt; |
|
2138 static uint _smr_delete_lock_wait_max; |
|
2139 // The smr_delete_notify flag is used for proper double-check |
|
2140 // locking in order to reduce the traffic on the smr_delete_lock. |
|
2141 static volatile uint _smr_delete_notify; |
|
2142 static volatile uint _smr_deleted_thread_cnt; |
|
2143 static volatile uint _smr_deleted_thread_time_max; |
|
2144 static volatile uint _smr_deleted_thread_times; |
|
2145 static ThreadsList* volatile _smr_java_thread_list; |
|
2146 static uint64_t _smr_java_thread_list_alloc_cnt; |
|
2147 static uint64_t _smr_java_thread_list_free_cnt; |
|
2148 static uint _smr_java_thread_list_max; |
|
2149 static uint _smr_nested_thread_list_max; |
|
2150 static volatile uint _smr_tlh_cnt; |
|
2151 static volatile uint _smr_tlh_time_max; |
|
2152 static volatile uint _smr_tlh_times; |
|
2153 static ThreadsList* _smr_to_delete_list; |
|
2154 static uint _smr_to_delete_list_cnt; |
|
2155 static uint _smr_to_delete_list_max; |
|
2156 |
|
2157 static JavaThread* _thread_list; |
|
2158 static int _number_of_threads; |
|
2159 static int _number_of_non_daemon_threads; |
|
2160 static int _return_code; |
|
2161 static int _thread_claim_parity; |
|
2162 #ifdef ASSERT |
2136 #ifdef ASSERT |
2163 static bool _vm_complete; |
2137 static bool _vm_complete; |
2164 #endif |
2138 #endif |
2165 |
2139 |
2166 static void initialize_java_lang_classes(JavaThread* main_thread, TRAPS); |
2140 static void initialize_java_lang_classes(JavaThread* main_thread, TRAPS); |
2167 static void initialize_jsr292_core_classes(TRAPS); |
2141 static void initialize_jsr292_core_classes(TRAPS); |
2168 |
|
2169 static ThreadsList *acquire_stable_list_fast_path(Thread *self); |
|
2170 static ThreadsList *acquire_stable_list_nested_path(Thread *self); |
|
2171 static void add_smr_deleted_thread_times(uint add_value); |
|
2172 static void clear_smr_delete_notify(); |
|
2173 static ThreadsList* get_smr_java_thread_list(); |
|
2174 static void inc_smr_deleted_thread_cnt(); |
|
2175 static void release_stable_list_fast_path(Thread *self); |
|
2176 static void release_stable_list_nested_path(Thread *self); |
|
2177 static void release_stable_list_wake_up(char *log_str); |
|
2178 static void set_smr_delete_notify(); |
|
2179 static Monitor* smr_delete_lock() { return _smr_delete_lock; } |
|
2180 static bool smr_delete_notify(); |
|
2181 static void smr_free_list(ThreadsList* threads); |
|
2182 static void update_smr_deleted_thread_time_max(uint new_value); |
|
2183 static ThreadsList* xchg_smr_java_thread_list(ThreadsList* new_list); |
|
2184 |
2142 |
2185 public: |
2143 public: |
2186 // Thread management |
2144 // Thread management |
2187 // force_daemon is a concession to JNI, where we may need to add a |
2145 // force_daemon is a concession to JNI, where we may need to add a |
2188 // thread to the thread list before allocating its thread object |
2146 // thread to the thread list before allocating its thread object |
2189 static void add(JavaThread* p, bool force_daemon = false); |
2147 static void add(JavaThread* p, bool force_daemon = false); |
2190 static void remove(JavaThread* p); |
2148 static void remove(JavaThread* p); |
2191 static void threads_do(ThreadClosure* tc); |
2149 static void threads_do(ThreadClosure* tc); |
2192 static void possibly_parallel_threads_do(bool is_par, ThreadClosure* tc); |
2150 static void possibly_parallel_threads_do(bool is_par, ThreadClosure* tc); |
2193 |
|
2194 // SMR support: |
|
2195 static ThreadsList *acquire_stable_list(Thread *self, bool is_ThreadsListSetter); |
|
2196 static void release_stable_list(Thread *self); |
|
2197 static bool is_a_protected_JavaThread(JavaThread *thread); |
|
2198 static bool is_a_protected_JavaThread_with_lock(JavaThread *thread) { |
|
2199 MutexLockerEx ml(Threads_lock->owned_by_self() ? NULL : Threads_lock); |
|
2200 return is_a_protected_JavaThread(thread); |
|
2201 } |
|
2202 static void smr_delete(JavaThread *thread); |
|
2203 static void inc_smr_tlh_cnt(); |
|
2204 static void update_smr_tlh_time_max(uint new_value); |
|
2205 static void add_smr_tlh_times(uint add_value); |
|
2206 |
2151 |
2207 // Initializes the vm and creates the vm thread |
2152 // Initializes the vm and creates the vm thread |
2208 static jint create_vm(JavaVMInitArgs* args, bool* canTryAgain); |
2153 static jint create_vm(JavaVMInitArgs* args, bool* canTryAgain); |
2209 static void convert_vm_init_libraries_to_agents(); |
2154 static void convert_vm_init_libraries_to_agents(); |
2210 static void create_vm_init_libraries(); |
2155 static void create_vm_init_libraries(); |
2262 static bool is_vm_complete() { return _vm_complete; } |
2207 static bool is_vm_complete() { return _vm_complete; } |
2263 #endif |
2208 #endif |
2264 |
2209 |
2265 // Verification |
2210 // Verification |
2266 static void verify(); |
2211 static void verify(); |
2267 static void log_smr_statistics(); |
|
2268 static void print_on(outputStream* st, bool print_stacks, bool internal_format, bool print_concurrent_locks); |
2212 static void print_on(outputStream* st, bool print_stacks, bool internal_format, bool print_concurrent_locks); |
2269 static void print_smr_info_on(outputStream* st); |
|
2270 static void print_smr_info_elements_on(outputStream* st, ThreadsList* t_list); |
|
2271 static void print(bool print_stacks, bool internal_format) { |
2213 static void print(bool print_stacks, bool internal_format) { |
2272 // this function is only used by debug.cpp |
2214 // this function is only used by debug.cpp |
2273 print_on(tty, print_stacks, internal_format, false /* no concurrent lock printed */); |
2215 print_on(tty, print_stacks, internal_format, false /* no concurrent lock printed */); |
2274 } |
2216 } |
2275 static void print_on_error(outputStream* st, Thread* current, char* buf, int buflen); |
2217 static void print_on_error(outputStream* st, Thread* current, char* buf, int buflen); |