336 JNIHandleBlock* _free_handle_block; |
336 JNIHandleBlock* _free_handle_block; |
337 |
337 |
338 // Point to the last handle mark |
338 // Point to the last handle mark |
339 HandleMark* _last_handle_mark; |
339 HandleMark* _last_handle_mark; |
340 |
340 |
341 // The parity of the last strong_roots iteration in which this thread was |
341 // Claim value for parallel iteration over threads. |
342 // claimed as a task. |
342 uintx _threads_do_token; |
343 int _oops_do_parity; |
|
344 |
343 |
345 // Support for GlobalCounter |
344 // Support for GlobalCounter |
346 private: |
345 private: |
347 volatile uintx _rcu_counter; |
346 volatile uintx _rcu_counter; |
348 public: |
347 public: |
645 // Apply "f->do_oop" to all root oops in "this". |
644 // Apply "f->do_oop" to all root oops in "this". |
646 // Used by JavaThread::oops_do. |
645 // Used by JavaThread::oops_do. |
647 // Apply "cf->do_code_blob" (if !NULL) to all code blobs active in frames |
646 // Apply "cf->do_code_blob" (if !NULL) to all code blobs active in frames |
648 virtual void oops_do(OopClosure* f, CodeBlobClosure* cf); |
647 virtual void oops_do(OopClosure* f, CodeBlobClosure* cf); |
649 |
648 |
650 // Handles the parallel case for the method below. |
649 // Handles the parallel case for claim_threads_do. |
651 private: |
650 private: |
652 bool claim_oops_do_par_case(int collection_parity); |
651 bool claim_par_threads_do(uintx claim_token); |
653 public: |
652 public: |
654 // Requires that "collection_parity" is that of the current roots |
653 // Requires that "claim_token" is that of the current iteration. |
655 // iteration. If "is_par" is false, sets the parity of "this" to |
654 // If "is_par" is false, sets the token of "this" to |
656 // "collection_parity", and returns "true". If "is_par" is true, |
655 // "claim_token", and returns "true". If "is_par" is true, |
657 // uses an atomic instruction to set the current threads parity to |
656 // uses an atomic instruction to set the current thread's token to |
658 // "collection_parity", if it is not already. Returns "true" iff the |
657 // "claim_token", if it is not already. Returns "true" iff the |
659 // calling thread does the update, this indicates that the calling thread |
658 // calling thread does the update, this indicates that the calling thread |
660 // has claimed the thread's stack as a root group in the current |
659 // has claimed the thread in the current iteration. |
661 // collection. |
660 bool claim_threads_do(bool is_par, uintx claim_token) { |
662 bool claim_oops_do(bool is_par, int collection_parity) { |
|
663 if (!is_par) { |
661 if (!is_par) { |
664 _oops_do_parity = collection_parity; |
662 _threads_do_token = claim_token; |
665 return true; |
663 return true; |
666 } else { |
664 } else { |
667 return claim_oops_do_par_case(collection_parity); |
665 return claim_par_threads_do(claim_token); |
668 } |
666 } |
669 } |
667 } |
|
668 |
|
669 uintx threads_do_token() const { return _threads_do_token; } |
670 |
670 |
671 // jvmtiRedefineClasses support |
671 // jvmtiRedefineClasses support |
672 void metadata_handles_do(void f(Metadata*)); |
672 void metadata_handles_do(void f(Metadata*)); |
673 |
673 |
674 // Used by fast lock support |
674 // Used by fast lock support |
748 void print_owned_locks_on(outputStream* st) const; |
748 void print_owned_locks_on(outputStream* st) const; |
749 void print_owned_locks() const { print_owned_locks_on(tty); } |
749 void print_owned_locks() const { print_owned_locks_on(tty); } |
750 Monitor* owned_locks() const { return _owned_locks; } |
750 Monitor* owned_locks() const { return _owned_locks; } |
751 bool owns_locks() const { return owned_locks() != NULL; } |
751 bool owns_locks() const { return owned_locks() != NULL; } |
752 bool owns_locks_but_compiled_lock() const; |
752 bool owns_locks_but_compiled_lock() const; |
753 int oops_do_parity() const { return _oops_do_parity; } |
|
754 |
753 |
755 // Deadlock detection |
754 // Deadlock detection |
756 bool allow_allocation() { return _allow_allocation_count == 0; } |
755 bool allow_allocation() { return _allow_allocation_count == 0; } |
757 ResourceMark* current_resource_mark() { return _current_resource_mark; } |
756 ResourceMark* current_resource_mark() { return _current_resource_mark; } |
758 void set_current_resource_mark(ResourceMark* rm) { _current_resource_mark = rm; } |
757 void set_current_resource_mark(ResourceMark* rm) { _current_resource_mark = rm; } |
2221 private: |
2220 private: |
2222 static JavaThread* _thread_list; |
2221 static JavaThread* _thread_list; |
2223 static int _number_of_threads; |
2222 static int _number_of_threads; |
2224 static int _number_of_non_daemon_threads; |
2223 static int _number_of_non_daemon_threads; |
2225 static int _return_code; |
2224 static int _return_code; |
2226 static int _thread_claim_parity; |
2225 static uintx _thread_claim_token; |
2227 #ifdef ASSERT |
2226 #ifdef ASSERT |
2228 static bool _vm_complete; |
2227 static bool _vm_complete; |
2229 #endif |
2228 #endif |
2230 |
2229 |
2231 static void initialize_java_lang_classes(JavaThread* main_thread, TRAPS); |
2230 static void initialize_java_lang_classes(JavaThread* main_thread, TRAPS); |
2254 // Includes JNI_VERSION_1_1 |
2253 // Includes JNI_VERSION_1_1 |
2255 static jboolean is_supported_jni_version_including_1_1(jint version); |
2254 static jboolean is_supported_jni_version_including_1_1(jint version); |
2256 // Does not include JNI_VERSION_1_1 |
2255 // Does not include JNI_VERSION_1_1 |
2257 static jboolean is_supported_jni_version(jint version); |
2256 static jboolean is_supported_jni_version(jint version); |
2258 |
2257 |
2259 // The "thread claim parity" provides a way for threads to be claimed |
2258 // The "thread claim token" provides a way for threads to be claimed |
2260 // by parallel worker tasks. |
2259 // by parallel worker tasks. |
2261 // |
2260 // |
2262 // Each thread contains a "parity" field. A task will claim the |
2261 // Each thread contains a "token" field. A task will claim the |
2263 // thread only if its parity field is the same as the global parity, |
2262 // thread only if its token is different from the global token, |
2264 // which is updated by calling change_thread_claim_parity(). |
2263 // which is updated by calling change_thread_claim_token(). When |
|
2264 // a thread is claimed, it's token is set to the global token value |
|
2265 // so other threads in the same iteration pass won't claim it. |
2265 // |
2266 // |
2266 // For this to work change_thread_claim_parity() needs to be called |
2267 // For this to work change_thread_claim_token() needs to be called |
2267 // exactly once in sequential code before starting parallel tasks |
2268 // exactly once in sequential code before starting parallel tasks |
2268 // that should claim threads. |
2269 // that should claim threads. |
2269 // |
2270 // |
2270 // New threads get their parity set to 0 and change_thread_claim_parity() |
2271 // New threads get their token set to 0 and change_thread_claim_token() |
2271 // never sets the global parity to 0. |
2272 // never sets the global token to 0. |
2272 static int thread_claim_parity() { return _thread_claim_parity; } |
2273 static uintx thread_claim_token() { return _thread_claim_token; } |
2273 static void change_thread_claim_parity(); |
2274 static void change_thread_claim_token(); |
2274 static void assert_all_threads_claimed() NOT_DEBUG_RETURN; |
2275 static void assert_all_threads_claimed() NOT_DEBUG_RETURN; |
2275 |
2276 |
2276 // Apply "f->do_oop" to all root oops in all threads. |
2277 // Apply "f->do_oop" to all root oops in all threads. |
2277 // This version may only be called by sequential code. |
2278 // This version may only be called by sequential code. |
2278 static void oops_do(OopClosure* f, CodeBlobClosure* cf); |
2279 static void oops_do(OopClosure* f, CodeBlobClosure* cf); |
2322 // Number of non-daemon threads on the active threads list |
2323 // Number of non-daemon threads on the active threads list |
2323 static int number_of_non_daemon_threads() { return _number_of_non_daemon_threads; } |
2324 static int number_of_non_daemon_threads() { return _number_of_non_daemon_threads; } |
2324 |
2325 |
2325 // Deoptimizes all frames tied to marked nmethods |
2326 // Deoptimizes all frames tied to marked nmethods |
2326 static void deoptimized_wrt_marked_nmethods(); |
2327 static void deoptimized_wrt_marked_nmethods(); |
|
2328 |
|
2329 struct Test; // For private gtest access. |
2327 }; |
2330 }; |
2328 |
2331 |
2329 |
2332 |
2330 // Thread iterator |
2333 // Thread iterator |
2331 class ThreadClosure: public StackObj { |
2334 class ThreadClosure: public StackObj { |