823 assert(!(is_Compiler_thread() || is_Java_thread()), "Can't call name() here if it allocates"); 824 825 if (is_VM_thread()) { st->print("VMThread"); } 826 else if (is_GC_task_thread()) { st->print("GCTaskThread"); } 827 else if (is_Watcher_thread()) { st->print("WatcherThread"); } 828 else if (is_ConcurrentGC_thread()) { st->print("ConcurrentGCThread"); } 829 else { st->print("Thread"); } 830 831 if (is_Named_thread()) { 832 st->print(" \"%s\"", name()); 833 } 834 835 st->print(" [stack: " PTR_FORMAT "," PTR_FORMAT "]", 836 p2i(stack_end()), p2i(stack_base())); 837 838 if (osthread()) { 839 st->print(" [id=%d]", osthread()->thread_id()); 840 } 841 } 842 843 #ifdef ASSERT 844 void Thread::print_owned_locks_on(outputStream* st) const { 845 Monitor *cur = _owned_locks; 846 if (cur == NULL) { 847 st->print(" (no locks) "); 848 } else { 849 st->print_cr(" Locks owned:"); 850 while (cur) { 851 cur->print_on(st); 852 cur = cur->next(); 853 } 854 } 855 } 856 857 static int ref_use_count = 0; 858 859 bool Thread::owns_locks_but_compiled_lock() const { 860 for (Monitor *cur = _owned_locks; cur; cur = cur->next()) { 861 if (cur != Compile_lock) return true; 862 } 1494 if (FlatProfiler::is_active()) { 1495 // This is where we would decide to either give each thread it's own profiler 1496 // or use one global one from FlatProfiler, 1497 // or up to some count of the number of profiled threads, etc. 1498 ThreadProfiler* pp = new ThreadProfiler(); 1499 pp->engage(); 1500 set_thread_profiler(pp); 1501 } 1502 1503 // Setup safepoint state info for this thread 1504 ThreadSafepointState::create(this); 1505 1506 debug_only(_java_call_counter = 0); 1507 1508 // JVMTI PopFrame support 1509 _popframe_condition = popframe_inactive; 1510 _popframe_preserved_args = NULL; 1511 _popframe_preserved_args_size = 0; 1512 _frames_to_pop_failed_realloc = 0; 1513 1514 pd_initialize(); 1515 } 1516 1517 #if INCLUDE_ALL_GCS 1518 SATBMarkQueueSet JavaThread::_satb_mark_queue_set; 1519 DirtyCardQueueSet JavaThread::_dirty_card_queue_set; 1520 #endif // INCLUDE_ALL_GCS 1521 1522 JavaThread::JavaThread(bool is_attaching_via_jni) : 1523 Thread() 1524 #if INCLUDE_ALL_GCS 1525 , _satb_mark_queue(&_satb_mark_queue_set), 1526 _dirty_card_queue(&_dirty_card_queue_set) 1527 #endif // INCLUDE_ALL_GCS 1528 { 1529 initialize(); 1530 if (is_attaching_via_jni) { 1531 _jni_attach_state = _attaching_via_jni; 1532 } else { 1533 _jni_attach_state = _not_attaching_via_jni; 2804 } 2805 2806 // callee_target is never live across a gc point so NULL it here should 2807 // it still contain a methdOop. 2808 2809 set_callee_target(NULL); 2810 2811 assert(vframe_array_head() == NULL, "deopt in progress at a safepoint!"); 2812 // If we have deferred set_locals there might be oops waiting to be 2813 // written 2814 GrowableArray<jvmtiDeferredLocalVariableSet*>* list = deferred_locals(); 2815 if (list != NULL) { 2816 for (int i = 0; i < list->length(); i++) { 2817 list->at(i)->oops_do(f); 2818 } 2819 } 2820 2821 // Traverse instance variables at the end since the GC may be moving things 2822 // around using this function 2823 f->do_oop((oop*) &_threadObj); 2824 f->do_oop((oop*) &_vm_result); 2825 f->do_oop((oop*) &_exception_oop); 2826 f->do_oop((oop*) &_pending_async_exception); 2827 2828 if (jvmti_thread_state() != NULL) { 2829 jvmti_thread_state()->oops_do(f); 2830 } 2831 } 2832 2833 void JavaThread::nmethods_do(CodeBlobClosure* cf) { 2834 assert((!has_last_Java_frame() && java_call_counter() == 0) || 2835 (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!"); 2836 2837 if (has_last_Java_frame()) { 2838 // Traverse the execution stack 2839 for (StackFrameStream fst(this); !fst.is_done(); fst.next()) { 2840 fst.current()->nmethods_do(cf); 2841 } 2842 } 2843 } 2844 4859 4860 // The following CAS() releases the lock and pops the head element. 4861 // The CAS() also ratifies the previously fetched lock-word value. 4862 if (Atomic::cmpxchg_ptr (intptr_t(nxt), Lock, w) != w) { 4863 continue; 4864 } 4865 List->OnList = 0; 4866 OrderAccess::fence(); 4867 List->unpark(); 4868 return; 4869 } 4870 } 4871 4872 4873 void Threads::verify() { 4874 ALL_JAVA_THREADS(p) { 4875 p->verify(); 4876 } 4877 VMThread* thread = VMThread::vm_thread(); 4878 if (thread != NULL) thread->verify(); 4879 } | 823 assert(!(is_Compiler_thread() || is_Java_thread()), "Can't call name() here if it allocates"); 824 825 if (is_VM_thread()) { st->print("VMThread"); } 826 else if (is_GC_task_thread()) { st->print("GCTaskThread"); } 827 else if (is_Watcher_thread()) { st->print("WatcherThread"); } 828 else if (is_ConcurrentGC_thread()) { st->print("ConcurrentGCThread"); } 829 else { st->print("Thread"); } 830 831 if (is_Named_thread()) { 832 st->print(" \"%s\"", name()); 833 } 834 835 st->print(" [stack: " PTR_FORMAT "," PTR_FORMAT "]", 836 p2i(stack_end()), p2i(stack_base())); 837 838 if (osthread()) { 839 st->print(" [id=%d]", osthread()->thread_id()); 840 } 841 } 842 843 void JavaThread::print_vt_buffer_stats_on(outputStream* st) const { 844 st->print_cr("%s:", this->name()); 845 st->print_cr("\tChunks in use : %d", vtchunk_in_use()); 846 st->print_cr("\tCached chunk : %d", local_free_chunk() == NULL ? 0 : 1); 847 st->print_cr("\tMax chunks : %d", vtchunk_max()); 848 st->print_cr("\tReturned chunks: %d", vtchunk_total_returned()); 849 st->print_cr("\tMemory buffered: %ld", vtchunk_total_memory_buffered()); 850 st->print_cr(""); 851 } 852 853 #ifdef ASSERT 854 void Thread::print_owned_locks_on(outputStream* st) const { 855 Monitor *cur = _owned_locks; 856 if (cur == NULL) { 857 st->print(" (no locks) "); 858 } else { 859 st->print_cr(" Locks owned:"); 860 while (cur) { 861 cur->print_on(st); 862 cur = cur->next(); 863 } 864 } 865 } 866 867 static int ref_use_count = 0; 868 869 bool Thread::owns_locks_but_compiled_lock() const { 870 for (Monitor *cur = _owned_locks; cur; cur = cur->next()) { 871 if (cur != Compile_lock) return true; 872 } 1504 if (FlatProfiler::is_active()) { 1505 // This is where we would decide to either give each thread it's own profiler 1506 // or use one global one from FlatProfiler, 1507 // or up to some count of the number of profiled threads, etc. 1508 ThreadProfiler* pp = new ThreadProfiler(); 1509 pp->engage(); 1510 set_thread_profiler(pp); 1511 } 1512 1513 // Setup safepoint state info for this thread 1514 ThreadSafepointState::create(this); 1515 1516 debug_only(_java_call_counter = 0); 1517 1518 // JVMTI PopFrame support 1519 _popframe_condition = popframe_inactive; 1520 _popframe_preserved_args = NULL; 1521 _popframe_preserved_args_size = 0; 1522 _frames_to_pop_failed_realloc = 0; 1523 1524 // Buffered value types support 1525 _vt_alloc_ptr = NULL; 1526 _vt_alloc_limit = NULL; 1527 _local_free_chunk = NULL; 1528 // Buffered value types instrumentation support 1529 _vtchunk_in_use = 0; 1530 _vtchunk_max = 0; 1531 _vtchunk_total_returned = 0; 1532 _vtchunk_total_memory_buffered = 0; 1533 1534 pd_initialize(); 1535 } 1536 1537 #if INCLUDE_ALL_GCS 1538 SATBMarkQueueSet JavaThread::_satb_mark_queue_set; 1539 DirtyCardQueueSet JavaThread::_dirty_card_queue_set; 1540 #endif // INCLUDE_ALL_GCS 1541 1542 JavaThread::JavaThread(bool is_attaching_via_jni) : 1543 Thread() 1544 #if INCLUDE_ALL_GCS 1545 , _satb_mark_queue(&_satb_mark_queue_set), 1546 _dirty_card_queue(&_dirty_card_queue_set) 1547 #endif // INCLUDE_ALL_GCS 1548 { 1549 initialize(); 1550 if (is_attaching_via_jni) { 1551 _jni_attach_state = _attaching_via_jni; 1552 } else { 1553 _jni_attach_state = _not_attaching_via_jni; 2824 } 2825 2826 // callee_target is never live across a gc point so NULL it here should 2827 // it still contain a methdOop. 2828 2829 set_callee_target(NULL); 2830 2831 assert(vframe_array_head() == NULL, "deopt in progress at a safepoint!"); 2832 // If we have deferred set_locals there might be oops waiting to be 2833 // written 2834 GrowableArray<jvmtiDeferredLocalVariableSet*>* list = deferred_locals(); 2835 if (list != NULL) { 2836 for (int i = 0; i < list->length(); i++) { 2837 list->at(i)->oops_do(f); 2838 } 2839 } 2840 2841 // Traverse instance variables at the end since the GC may be moving things 2842 // around using this function 2843 f->do_oop((oop*) &_threadObj); 2844 // if (Universe::heap()->is_in_reserved_or_null((void*)_vm_result)) { 2845 if (!VTBufferChunk::check_buffered(&_vm_result)) { 2846 f->do_oop((oop*) &_vm_result); 2847 } 2848 f->do_oop((oop*) &_exception_oop); 2849 f->do_oop((oop*) &_pending_async_exception); 2850 2851 if (jvmti_thread_state() != NULL) { 2852 jvmti_thread_state()->oops_do(f); 2853 } 2854 } 2855 2856 void JavaThread::nmethods_do(CodeBlobClosure* cf) { 2857 assert((!has_last_Java_frame() && java_call_counter() == 0) || 2858 (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!"); 2859 2860 if (has_last_Java_frame()) { 2861 // Traverse the execution stack 2862 for (StackFrameStream fst(this); !fst.is_done(); fst.next()) { 2863 fst.current()->nmethods_do(cf); 2864 } 2865 } 2866 } 2867 4882 4883 // The following CAS() releases the lock and pops the head element. 4884 // The CAS() also ratifies the previously fetched lock-word value. 4885 if (Atomic::cmpxchg_ptr (intptr_t(nxt), Lock, w) != w) { 4886 continue; 4887 } 4888 List->OnList = 0; 4889 OrderAccess::fence(); 4890 List->unpark(); 4891 return; 4892 } 4893 } 4894 4895 4896 void Threads::verify() { 4897 ALL_JAVA_THREADS(p) { 4898 p->verify(); 4899 } 4900 VMThread* thread = VMThread::vm_thread(); 4901 if (thread != NULL) thread->verify(); 4902 } 4903 4904 void Threads::print_vt_buffer_stats_on(outputStream* st) { 4905 ALL_JAVA_THREADS(p) { 4906 p->print_vt_buffer_stats_on(st); 4907 } 4908 } |