681 assert(SharedHeap::heap()->n_par_threads() > 0, |
681 assert(SharedHeap::heap()->n_par_threads() > 0, |
682 "Should only fail when parallel."); |
682 "Should only fail when parallel."); |
683 return false; |
683 return false; |
684 } |
684 } |
685 |
685 |
686 void Thread::oops_do(OopClosure* f) { |
686 void Thread::oops_do(OopClosure* f, CodeBlobClosure* cf) { |
687 active_handles()->oops_do(f); |
687 active_handles()->oops_do(f); |
688 // Do oop for ThreadShadow |
688 // Do oop for ThreadShadow |
689 f->do_oop((oop*)&_pending_exception); |
689 f->do_oop((oop*)&_pending_exception); |
690 handle_area()->oops_do(f); |
690 handle_area()->oops_do(f); |
691 } |
691 } |
692 |
692 |
693 void Thread::nmethods_do() { |
693 void Thread::nmethods_do(CodeBlobClosure* cf) { |
|
694 // no nmethods in a generic thread... |
694 } |
695 } |
695 |
696 |
696 void Thread::print_on(outputStream* st) const { |
697 void Thread::print_on(outputStream* st) const { |
697 // get_priority assumes osthread initialized |
698 // get_priority assumes osthread initialized |
698 if (osthread() != NULL) { |
699 if (osthread() != NULL) { |
2314 void JavaThread::gc_prologue() { |
2315 void JavaThread::gc_prologue() { |
2315 frames_do(frame_gc_prologue); |
2316 frames_do(frame_gc_prologue); |
2316 } |
2317 } |
2317 |
2318 |
2318 |
2319 |
2319 void JavaThread::oops_do(OopClosure* f) { |
2320 void JavaThread::oops_do(OopClosure* f, CodeBlobClosure* cf) { |
2320 // The ThreadProfiler oops_do is done from FlatProfiler::oops_do |
2321 // The ThreadProfiler oops_do is done from FlatProfiler::oops_do |
2321 // since there may be more than one thread using each ThreadProfiler. |
2322 // since there may be more than one thread using each ThreadProfiler. |
2322 |
2323 |
2323 // Traverse the GCHandles |
2324 // Traverse the GCHandles |
2324 Thread::oops_do(f); |
2325 Thread::oops_do(f, cf); |
2325 |
2326 |
2326 assert( (!has_last_Java_frame() && java_call_counter() == 0) || |
2327 assert( (!has_last_Java_frame() && java_call_counter() == 0) || |
2327 (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!"); |
2328 (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!"); |
2328 |
2329 |
2329 if (has_last_Java_frame()) { |
2330 if (has_last_Java_frame()) { |
2345 chunk->oops_do(f); |
2346 chunk->oops_do(f); |
2346 } |
2347 } |
2347 |
2348 |
2348 // Traverse the execution stack |
2349 // Traverse the execution stack |
2349 for(StackFrameStream fst(this); !fst.is_done(); fst.next()) { |
2350 for(StackFrameStream fst(this); !fst.is_done(); fst.next()) { |
2350 fst.current()->oops_do(f, fst.register_map()); |
2351 fst.current()->oops_do(f, cf, fst.register_map()); |
2351 } |
2352 } |
2352 } |
2353 } |
2353 |
2354 |
2354 // callee_target is never live across a gc point so NULL it here should |
2355 // callee_target is never live across a gc point so NULL it here should |
2355 // it still contain a methdOop. |
2356 // it still contain a methdOop. |
2377 if (jvmti_thread_state() != NULL) { |
2378 if (jvmti_thread_state() != NULL) { |
2378 jvmti_thread_state()->oops_do(f); |
2379 jvmti_thread_state()->oops_do(f); |
2379 } |
2380 } |
2380 } |
2381 } |
2381 |
2382 |
2382 void JavaThread::nmethods_do() { |
2383 void JavaThread::nmethods_do(CodeBlobClosure* cf) { |
2383 // Traverse the GCHandles |
2384 Thread::nmethods_do(cf); // (super method is a no-op) |
2384 Thread::nmethods_do(); |
|
2385 |
2385 |
2386 assert( (!has_last_Java_frame() && java_call_counter() == 0) || |
2386 assert( (!has_last_Java_frame() && java_call_counter() == 0) || |
2387 (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!"); |
2387 (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!"); |
2388 |
2388 |
2389 if (has_last_Java_frame()) { |
2389 if (has_last_Java_frame()) { |
2390 // Traverse the execution stack |
2390 // Traverse the execution stack |
2391 for(StackFrameStream fst(this); !fst.is_done(); fst.next()) { |
2391 for(StackFrameStream fst(this); !fst.is_done(); fst.next()) { |
2392 fst.current()->nmethods_do(); |
2392 fst.current()->nmethods_do(cf); |
2393 } |
2393 } |
2394 } |
2394 } |
2395 } |
2395 } |
2396 |
2396 |
2397 // Printing |
2397 // Printing |
2461 |
2461 |
2462 static void frame_verify(frame* f, const RegisterMap *map) { f->verify(map); } |
2462 static void frame_verify(frame* f, const RegisterMap *map) { f->verify(map); } |
2463 |
2463 |
2464 void JavaThread::verify() { |
2464 void JavaThread::verify() { |
2465 // Verify oops in the thread. |
2465 // Verify oops in the thread. |
2466 oops_do(&VerifyOopClosure::verify_oop); |
2466 oops_do(&VerifyOopClosure::verify_oop, NULL); |
2467 |
2467 |
2468 // Verify the stack frames. |
2468 // Verify the stack frames. |
2469 frames_do(frame_verify); |
2469 frames_do(frame_verify); |
2470 } |
2470 } |
2471 |
2471 |
3600 // In particular, these things should never be called when the Threads_lock |
3600 // In particular, these things should never be called when the Threads_lock |
3601 // is held by some other thread. (Note: the Safepoint abstraction also |
3601 // is held by some other thread. (Note: the Safepoint abstraction also |
3602 // uses the Threads_lock to gurantee this property. It also makes sure that |
3602 // uses the Threads_lock to gurantee this property. It also makes sure that |
3603 // all threads gets blocked when exiting or starting). |
3603 // all threads gets blocked when exiting or starting). |
3604 |
3604 |
3605 void Threads::oops_do(OopClosure* f) { |
3605 void Threads::oops_do(OopClosure* f, CodeBlobClosure* cf) { |
3606 ALL_JAVA_THREADS(p) { |
3606 ALL_JAVA_THREADS(p) { |
3607 p->oops_do(f); |
3607 p->oops_do(f, cf); |
3608 } |
3608 } |
3609 VMThread::vm_thread()->oops_do(f); |
3609 VMThread::vm_thread()->oops_do(f, cf); |
3610 } |
3610 } |
3611 |
3611 |
3612 void Threads::possibly_parallel_oops_do(OopClosure* f) { |
3612 void Threads::possibly_parallel_oops_do(OopClosure* f, CodeBlobClosure* cf) { |
3613 // Introduce a mechanism allowing parallel threads to claim threads as |
3613 // Introduce a mechanism allowing parallel threads to claim threads as |
3614 // root groups. Overhead should be small enough to use all the time, |
3614 // root groups. Overhead should be small enough to use all the time, |
3615 // even in sequential code. |
3615 // even in sequential code. |
3616 SharedHeap* sh = SharedHeap::heap(); |
3616 SharedHeap* sh = SharedHeap::heap(); |
3617 bool is_par = (sh->n_par_threads() > 0); |
3617 bool is_par = (sh->n_par_threads() > 0); |
3618 int cp = SharedHeap::heap()->strong_roots_parity(); |
3618 int cp = SharedHeap::heap()->strong_roots_parity(); |
3619 ALL_JAVA_THREADS(p) { |
3619 ALL_JAVA_THREADS(p) { |
3620 if (p->claim_oops_do(is_par, cp)) { |
3620 if (p->claim_oops_do(is_par, cp)) { |
3621 p->oops_do(f); |
3621 p->oops_do(f, cf); |
3622 } |
3622 } |
3623 } |
3623 } |
3624 VMThread* vmt = VMThread::vm_thread(); |
3624 VMThread* vmt = VMThread::vm_thread(); |
3625 if (vmt->claim_oops_do(is_par, cp)) |
3625 if (vmt->claim_oops_do(is_par, cp)) |
3626 vmt->oops_do(f); |
3626 vmt->oops_do(f, cf); |
3627 } |
3627 } |
3628 |
3628 |
3629 #ifndef SERIALGC |
3629 #ifndef SERIALGC |
3630 // Used by ParallelScavenge |
3630 // Used by ParallelScavenge |
3631 void Threads::create_thread_roots_tasks(GCTaskQueue* q) { |
3631 void Threads::create_thread_roots_tasks(GCTaskQueue* q) { |
3642 } |
3642 } |
3643 q->enqueue(new ThreadRootsMarkingTask(VMThread::vm_thread())); |
3643 q->enqueue(new ThreadRootsMarkingTask(VMThread::vm_thread())); |
3644 } |
3644 } |
3645 #endif // SERIALGC |
3645 #endif // SERIALGC |
3646 |
3646 |
3647 void Threads::nmethods_do() { |
3647 void Threads::nmethods_do(CodeBlobClosure* cf) { |
3648 ALL_JAVA_THREADS(p) { |
3648 ALL_JAVA_THREADS(p) { |
3649 p->nmethods_do(); |
3649 p->nmethods_do(cf); |
3650 } |
3650 } |
3651 VMThread::vm_thread()->nmethods_do(); |
3651 VMThread::vm_thread()->nmethods_do(cf); |
3652 } |
3652 } |
3653 |
3653 |
3654 void Threads::gc_epilogue() { |
3654 void Threads::gc_epilogue() { |
3655 ALL_JAVA_THREADS(p) { |
3655 ALL_JAVA_THREADS(p) { |
3656 p->gc_epilogue(); |
3656 p->gc_epilogue(); |