783 } |
783 } |
784 } |
784 } |
785 return false; |
785 return false; |
786 } |
786 } |
787 |
787 |
788 void Thread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) { |
788 void Thread::oops_do(OopClosure* f, CodeBlobClosure* cf) { |
789 active_handles()->oops_do(f); |
789 active_handles()->oops_do(f); |
790 // Do oop for ThreadShadow |
790 // Do oop for ThreadShadow |
791 f->do_oop((oop*)&_pending_exception); |
791 f->do_oop((oop*)&_pending_exception); |
792 handle_area()->oops_do(f); |
792 handle_area()->oops_do(f); |
793 } |
793 } |
2756 _cur_thr->set_processed_thread(NULL); |
2756 _cur_thr->set_processed_thread(NULL); |
2757 } |
2757 } |
2758 } |
2758 } |
2759 }; |
2759 }; |
2760 |
2760 |
2761 void JavaThread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) { |
2761 void JavaThread::oops_do(OopClosure* f, CodeBlobClosure* cf) { |
2762 // Verify that the deferred card marks have been flushed. |
2762 // Verify that the deferred card marks have been flushed. |
2763 assert(deferred_card_mark().is_empty(), "Should be empty during GC"); |
2763 assert(deferred_card_mark().is_empty(), "Should be empty during GC"); |
2764 |
2764 |
2765 // The ThreadProfiler oops_do is done from FlatProfiler::oops_do |
2765 // The ThreadProfiler oops_do is done from FlatProfiler::oops_do |
2766 // since there may be more than one thread using each ThreadProfiler. |
2766 // since there may be more than one thread using each ThreadProfiler. |
2767 |
2767 |
2768 // Traverse the GCHandles |
2768 // Traverse the GCHandles |
2769 Thread::oops_do(f, cld_f, cf); |
2769 Thread::oops_do(f, cf); |
2770 |
2770 |
2771 JVMCI_ONLY(f->do_oop((oop*)&_pending_failed_speculation);) |
2771 JVMCI_ONLY(f->do_oop((oop*)&_pending_failed_speculation);) |
2772 |
2772 |
2773 assert((!has_last_Java_frame() && java_call_counter() == 0) || |
2773 assert((!has_last_Java_frame() && java_call_counter() == 0) || |
2774 (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!"); |
2774 (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!"); |
2794 chunk->oops_do(f); |
2794 chunk->oops_do(f); |
2795 } |
2795 } |
2796 |
2796 |
2797 // Traverse the execution stack |
2797 // Traverse the execution stack |
2798 for (StackFrameStream fst(this); !fst.is_done(); fst.next()) { |
2798 for (StackFrameStream fst(this); !fst.is_done(); fst.next()) { |
2799 fst.current()->oops_do(f, cld_f, cf, fst.register_map()); |
2799 fst.current()->oops_do(f, cf, fst.register_map()); |
2800 } |
2800 } |
2801 } |
2801 } |
2802 |
2802 |
2803 // callee_target is never live across a gc point so NULL it here should |
2803 // callee_target is never live across a gc point so NULL it here should |
2804 // it still contain a methdOop. |
2804 // it still contain a methdOop. |
2944 |
2944 |
2945 static void frame_verify(frame* f, const RegisterMap *map) { f->verify(map); } |
2945 static void frame_verify(frame* f, const RegisterMap *map) { f->verify(map); } |
2946 |
2946 |
2947 void JavaThread::verify() { |
2947 void JavaThread::verify() { |
2948 // Verify oops in the thread. |
2948 // Verify oops in the thread. |
2949 oops_do(&VerifyOopClosure::verify_oop, NULL, NULL); |
2949 oops_do(&VerifyOopClosure::verify_oop, NULL); |
2950 |
2950 |
2951 // Verify the stack frames. |
2951 // Verify the stack frames. |
2952 frames_do(frame_verify); |
2952 frames_do(frame_verify); |
2953 } |
2953 } |
2954 |
2954 |
3184 |
3184 |
3185 |
3185 |
3186 static void oops_print(frame* f, const RegisterMap *map) { |
3186 static void oops_print(frame* f, const RegisterMap *map) { |
3187 PrintAndVerifyOopClosure print; |
3187 PrintAndVerifyOopClosure print; |
3188 f->print_value(); |
3188 f->print_value(); |
3189 f->oops_do(&print, NULL, NULL, (RegisterMap*)map); |
3189 f->oops_do(&print, NULL, (RegisterMap*)map); |
3190 } |
3190 } |
3191 |
3191 |
3192 // Print our all the locations that contain oops and whether they are |
3192 // Print our all the locations that contain oops and whether they are |
3193 // valid or not. This useful when trying to find the oldest frame |
3193 // valid or not. This useful when trying to find the oldest frame |
3194 // where an oop has gone bad since the frame walk is from youngest to |
3194 // where an oop has gone bad since the frame walk is from youngest to |
3301 CodeCacheSweeperThread::CodeCacheSweeperThread() |
3301 CodeCacheSweeperThread::CodeCacheSweeperThread() |
3302 : JavaThread(&sweeper_thread_entry) { |
3302 : JavaThread(&sweeper_thread_entry) { |
3303 _scanned_compiled_method = NULL; |
3303 _scanned_compiled_method = NULL; |
3304 } |
3304 } |
3305 |
3305 |
3306 void CodeCacheSweeperThread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) { |
3306 void CodeCacheSweeperThread::oops_do(OopClosure* f, CodeBlobClosure* cf) { |
3307 JavaThread::oops_do(f, cld_f, cf); |
3307 JavaThread::oops_do(f, cf); |
3308 if (_scanned_compiled_method != NULL && cf != NULL) { |
3308 if (_scanned_compiled_method != NULL && cf != NULL) { |
3309 // Safepoints can occur when the sweeper is scanning an nmethod so |
3309 // Safepoints can occur when the sweeper is scanning an nmethod so |
3310 // process it here to make sure it isn't unloaded in the middle of |
3310 // process it here to make sure it isn't unloaded in the middle of |
3311 // a scan. |
3311 // a scan. |
3312 cf->do_code_blob(_scanned_compiled_method); |
3312 cf->do_code_blob(_scanned_compiled_method); |
4289 // In particular, these things should never be called when the Threads_lock |
4289 // In particular, these things should never be called when the Threads_lock |
4290 // is held by some other thread. (Note: the Safepoint abstraction also |
4290 // is held by some other thread. (Note: the Safepoint abstraction also |
4291 // uses the Threads_lock to guarantee this property. It also makes sure that |
4291 // uses the Threads_lock to guarantee this property. It also makes sure that |
4292 // all threads gets blocked when exiting or starting). |
4292 // all threads gets blocked when exiting or starting). |
4293 |
4293 |
4294 void Threads::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) { |
4294 void Threads::oops_do(OopClosure* f, CodeBlobClosure* cf) { |
4295 ALL_JAVA_THREADS(p) { |
4295 ALL_JAVA_THREADS(p) { |
4296 p->oops_do(f, cld_f, cf); |
4296 p->oops_do(f, cf); |
4297 } |
4297 } |
4298 VMThread::vm_thread()->oops_do(f, cld_f, cf); |
4298 VMThread::vm_thread()->oops_do(f, cf); |
4299 } |
4299 } |
4300 |
4300 |
4301 void Threads::change_thread_claim_parity() { |
4301 void Threads::change_thread_claim_parity() { |
4302 // Set the new claim parity. |
4302 // Set the new claim parity. |
4303 assert(_thread_claim_parity >= 0 && _thread_claim_parity <= 2, |
4303 assert(_thread_claim_parity >= 0 && _thread_claim_parity <= 2, |
4316 "Thread " PTR_FORMAT " has incorrect parity %d != %d", p2i(p), thread_parity, _thread_claim_parity); |
4316 "Thread " PTR_FORMAT " has incorrect parity %d != %d", p2i(p), thread_parity, _thread_claim_parity); |
4317 } |
4317 } |
4318 } |
4318 } |
4319 #endif // ASSERT |
4319 #endif // ASSERT |
4320 |
4320 |
4321 void Threads::possibly_parallel_oops_do(bool is_par, OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) { |
4321 void Threads::possibly_parallel_oops_do(bool is_par, OopClosure* f, CodeBlobClosure* cf) { |
4322 int cp = Threads::thread_claim_parity(); |
4322 int cp = Threads::thread_claim_parity(); |
4323 ALL_JAVA_THREADS(p) { |
4323 ALL_JAVA_THREADS(p) { |
4324 if (p->claim_oops_do(is_par, cp)) { |
4324 if (p->claim_oops_do(is_par, cp)) { |
4325 p->oops_do(f, cld_f, cf); |
4325 p->oops_do(f, cf); |
4326 } |
4326 } |
4327 } |
4327 } |
4328 VMThread* vmt = VMThread::vm_thread(); |
4328 VMThread* vmt = VMThread::vm_thread(); |
4329 if (vmt->claim_oops_do(is_par, cp)) { |
4329 if (vmt->claim_oops_do(is_par, cp)) { |
4330 vmt->oops_do(f, cld_f, cf); |
4330 vmt->oops_do(f, cf); |
4331 } |
4331 } |
4332 } |
4332 } |
4333 |
4333 |
4334 #if INCLUDE_ALL_GCS |
4334 #if INCLUDE_ALL_GCS |
4335 // Used by ParallelScavenge |
4335 // Used by ParallelScavenge |