src/hotspot/share/jfr/periodic/sampling/jfrThreadSampler.cpp
changeset 54623 1126f0607c70
parent 54562 1af5c0e68381
child 54645 05aaccf7d558
equal deleted inserted replaced
54622:a8dcacf95bff 54623:1126f0607c70
   345 
   345 
   346 static void clear_transition_block(JavaThread* jt) {
   346 static void clear_transition_block(JavaThread* jt) {
   347   jt->clear_trace_flag();
   347   jt->clear_trace_flag();
   348   JfrThreadLocal* const tl = jt->jfr_thread_local();
   348   JfrThreadLocal* const tl = jt->jfr_thread_local();
   349   if (tl->is_trace_block()) {
   349   if (tl->is_trace_block()) {
   350     MutexLockerEx ml(JfrThreadSampler::transition_block(), Mutex::_no_safepoint_check_flag);
   350     MutexLocker ml(JfrThreadSampler::transition_block(), Mutex::_no_safepoint_check_flag);
   351     JfrThreadSampler::transition_block()->notify_all();
   351     JfrThreadSampler::transition_block()->notify_all();
   352   }
   352   }
   353 }
   353 }
   354 
   354 
   355 bool JfrThreadSampleClosure::do_sample_thread(JavaThread* thread, JfrStackFrame* frames, u4 max_frames, JfrSampleType type) {
   355 bool JfrThreadSampleClosure::do_sample_thread(JavaThread* thread, JfrStackFrame* frames, u4 max_frames, JfrSampleType type) {
   393 
   393 
   394 void JfrThreadSampler::on_javathread_suspend(JavaThread* thread) {
   394 void JfrThreadSampler::on_javathread_suspend(JavaThread* thread) {
   395   JfrThreadLocal* const tl = thread->jfr_thread_local();
   395   JfrThreadLocal* const tl = thread->jfr_thread_local();
   396   tl->set_trace_block();
   396   tl->set_trace_block();
   397   {
   397   {
   398     MutexLockerEx ml(transition_block(), Mutex::_no_safepoint_check_flag);
   398     MutexLocker ml(transition_block(), Mutex::_no_safepoint_check_flag);
   399     while (thread->is_trace_suspend()) {
   399     while (thread->is_trace_suspend()) {
   400       transition_block()->wait(true);
   400       transition_block()->wait_without_safepoint_check();
   401     }
   401     }
   402     tl->clear_trace_block();
   402     tl->clear_trace_block();
   403   }
   403   }
   404 }
   404 }
   405 
   405 
   514 
   514 
   515   {
   515   {
   516     elapsedTimer sample_time;
   516     elapsedTimer sample_time;
   517     sample_time.start();
   517     sample_time.start();
   518     {
   518     {
   519       MonitorLockerEx tlock(Threads_lock, Mutex::_allow_vm_block_flag);
   519       MutexLocker tlock(Threads_lock, Mutex::_no_safepoint_check_flag);
   520       ThreadsListHandle tlh;
   520       ThreadsListHandle tlh;
   521       // Resolve a sample session relative start position index into the thread list array.
   521       // Resolve a sample session relative start position index into the thread list array.
   522       // In cases where the last sampled thread is NULL or not-NULL but stale, find_index() returns -1.
   522       // In cases where the last sampled thread is NULL or not-NULL but stale, find_index() returns -1.
   523       _cur_index = tlh.list()->find_index_of_JavaThread(*last_thread);
   523       _cur_index = tlh.list()->find_index_of_JavaThread(*last_thread);
   524       JavaThread* current = _cur_index != -1 ? *last_thread : NULL;
   524       JavaThread* current = _cur_index != -1 ? *last_thread : NULL;