< prev index next >

src/share/vm/runtime/thread.cpp

Print this page




 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("\tFailed chunk allocs : %d", vtchunk_total_failed());
 850   st->print_cr("\tMemory buffered     : %ld", vtchunk_total_memory_buffered());
 851   st->print_cr("");
 852 }
 853 
 854 #ifdef ASSERT
 855 void Thread::print_owned_locks_on(outputStream* st) const {
 856   Monitor *cur = _owned_locks;
 857   if (cur == NULL) {
 858     st->print(" (no locks) ");
 859   } else {
 860     st->print_cr(" Locks owned:");
 861     while (cur) {
 862       cur->print_on(st);
 863       cur = cur->next();
 864     }
 865   }
 866 }
 867 
 868 static int ref_use_count  = 0;
 869 
 870 bool Thread::owns_locks_but_compiled_lock() const {
 871   for (Monitor *cur = _owned_locks; cur; cur = cur->next()) {
 872     if (cur != Compile_lock) return true;
 873   }


1505   if (FlatProfiler::is_active()) {
1506     // This is where we would decide to either give each thread it's own profiler
1507     // or use one global one from FlatProfiler,
1508     // or up to some count of the number of profiled threads, etc.
1509     ThreadProfiler* pp = new ThreadProfiler();
1510     pp->engage();
1511     set_thread_profiler(pp);
1512   }
1513 
1514   // Setup safepoint state info for this thread
1515   ThreadSafepointState::create(this);
1516 
1517   debug_only(_java_call_counter = 0);
1518 
1519   // JVMTI PopFrame support
1520   _popframe_condition = popframe_inactive;
1521   _popframe_preserved_args = NULL;
1522   _popframe_preserved_args_size = 0;
1523   _frames_to_pop_failed_realloc = 0;
1524 
1525   // Buffered value types support
1526   _vt_alloc_ptr = NULL;
1527   _vt_alloc_limit = NULL;
1528   _local_free_chunk = NULL;
1529   // Buffered value types instrumentation support
1530   _vtchunk_in_use = 0;
1531   _vtchunk_max = 0;
1532   _vtchunk_total_returned = 0;
1533   _vtchunk_total_failed = 0;
1534   _vtchunk_total_memory_buffered = 0;
1535 
1536   pd_initialize();
1537 }
1538 
1539 #if INCLUDE_ALL_GCS
1540 SATBMarkQueueSet JavaThread::_satb_mark_queue_set;
1541 DirtyCardQueueSet JavaThread::_dirty_card_queue_set;
1542 #endif // INCLUDE_ALL_GCS
1543 
1544 JavaThread::JavaThread(bool is_attaching_via_jni) :
1545                        Thread()
1546 #if INCLUDE_ALL_GCS
1547                        , _satb_mark_queue(&_satb_mark_queue_set),
1548                        _dirty_card_queue(&_dirty_card_queue_set)
1549 #endif // INCLUDE_ALL_GCS
1550 {
1551   initialize();
1552   if (is_attaching_via_jni) {
1553     _jni_attach_state = _attaching_via_jni;
1554   } else {
1555     _jni_attach_state = _not_attaching_via_jni;


2826   }
2827 
2828   // callee_target is never live across a gc point so NULL it here should
2829   // it still contain a methdOop.
2830 
2831   set_callee_target(NULL);
2832 
2833   assert(vframe_array_head() == NULL, "deopt in progress at a safepoint!");
2834   // If we have deferred set_locals there might be oops waiting to be
2835   // written
2836   GrowableArray<jvmtiDeferredLocalVariableSet*>* list = deferred_locals();
2837   if (list != NULL) {
2838     for (int i = 0; i < list->length(); i++) {
2839       list->at(i)->oops_do(f);
2840     }
2841   }
2842 
2843   // Traverse instance variables at the end since the GC may be moving things
2844   // around using this function
2845   f->do_oop((oop*) &_threadObj);
2846   // if (Universe::heap()->is_in_reserved_or_null((void*)_vm_result)) {
2847     if (!VTBufferChunk::check_buffered(&_vm_result)) {
2848     f->do_oop((oop*) &_vm_result);
2849   }
2850   f->do_oop((oop*) &_exception_oop);
2851   f->do_oop((oop*) &_pending_async_exception);
2852 
2853   if (jvmti_thread_state() != NULL) {
2854     jvmti_thread_state()->oops_do(f);
2855   }
2856 }
2857 
2858 void JavaThread::nmethods_do(CodeBlobClosure* cf) {
2859   assert((!has_last_Java_frame() && java_call_counter() == 0) ||
2860          (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!");
2861 
2862   if (has_last_Java_frame()) {
2863     // Traverse the execution stack
2864     for (StackFrameStream fst(this); !fst.is_done(); fst.next()) {
2865       fst.current()->nmethods_do(cf);
2866     }
2867   }
2868 }
2869 


4884 
4885     // The following CAS() releases the lock and pops the head element.
4886     // The CAS() also ratifies the previously fetched lock-word value.
4887     if (Atomic::cmpxchg_ptr (intptr_t(nxt), Lock, w) != w) {
4888       continue;
4889     }
4890     List->OnList = 0;
4891     OrderAccess::fence();
4892     List->unpark();
4893     return;
4894   }
4895 }
4896 
4897 
4898 void Threads::verify() {
4899   ALL_JAVA_THREADS(p) {
4900     p->verify();
4901   }
4902   VMThread* thread = VMThread::vm_thread();
4903   if (thread != NULL) thread->verify();
4904 }
4905 
4906 void Threads::print_vt_buffer_stats_on(outputStream* st) {
4907   ALL_JAVA_THREADS(p) {
4908     p->print_vt_buffer_stats_on(st);
4909   }
4910 }
< prev index next >