src/share/vm/runtime/thread.cpp

changeset 9858
b985cbb00e68
parent 9676
bf1c9a3312a4
child 9864
f066260954ae
     1.1 --- a/src/share/vm/runtime/thread.cpp	Thu Aug 01 03:44:03 2019 +0100
     1.2 +++ b/src/share/vm/runtime/thread.cpp	Mon Aug 12 18:30:40 2019 +0300
     1.3 @@ -32,6 +32,8 @@
     1.4  #include "interpreter/interpreter.hpp"
     1.5  #include "interpreter/linkResolver.hpp"
     1.6  #include "interpreter/oopMapCache.hpp"
     1.7 +#include "jfr/jfrEvents.hpp"
     1.8 +#include "jfr/support/jfrThreadId.hpp"
     1.9  #include "jvmtifiles/jvmtiEnv.hpp"
    1.10  #include "memory/gcLocker.inline.hpp"
    1.11  #include "memory/metaspaceShared.hpp"
    1.12 @@ -77,8 +79,6 @@
    1.13  #include "services/management.hpp"
    1.14  #include "services/memTracker.hpp"
    1.15  #include "services/threadService.hpp"
    1.16 -#include "trace/tracing.hpp"
    1.17 -#include "trace/traceMacros.hpp"
    1.18  #include "utilities/defaultStream.hpp"
    1.19  #include "utilities/dtrace.hpp"
    1.20  #include "utilities/events.hpp"
    1.21 @@ -111,6 +111,9 @@
    1.22  #if INCLUDE_RTM_OPT
    1.23  #include "runtime/rtmLocking.hpp"
    1.24  #endif
    1.25 +#if INCLUDE_JFR
    1.26 +#include "jfr/jfr.hpp"
    1.27 +#endif
    1.28  
    1.29  PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
    1.30  
    1.31 @@ -342,7 +345,7 @@
    1.32    // Reclaim the objectmonitors from the omFreeList of the moribund thread.
    1.33    ObjectSynchronizer::omFlush (this) ;
    1.34  
    1.35 -  EVENT_THREAD_DESTRUCT(this);
    1.36 +  JFR_ONLY(Jfr::on_thread_destruct(this);)
    1.37  
    1.38    // stack_base can be NULL if the thread is never started or exited before
    1.39    // record_stack_base_and_size called. Although, we would like to ensure
    1.40 @@ -1671,7 +1674,7 @@
    1.41  
    1.42    EventThreadStart event;
    1.43    if (event.should_commit()) {
    1.44 -     event.set_javalangthread(java_lang_Thread::thread_id(this->threadObj()));
    1.45 +    event.set_thread(JFR_THREAD_ID(this));
    1.46       event.commit();
    1.47    }
    1.48  
    1.49 @@ -1805,12 +1808,12 @@
    1.50      // from java_lang_Thread object
    1.51      EventThreadEnd event;
    1.52      if (event.should_commit()) {
    1.53 -        event.set_javalangthread(java_lang_Thread::thread_id(this->threadObj()));
    1.54 -        event.commit();
    1.55 +      event.set_thread(JFR_THREAD_ID(this));
    1.56 +      event.commit();
    1.57      }
    1.58  
    1.59      // Call after last event on thread
    1.60 -    EVENT_THREAD_EXIT(this);
    1.61 +    JFR_ONLY(Jfr::on_thread_exit(this);)
    1.62  
    1.63      // Call Thread.exit(). We try 3 times in case we got another Thread.stop during
    1.64      // the execution of the method. If that is not enough, then we don't really care. Thread.stop
    1.65 @@ -2186,6 +2189,8 @@
    1.66    if (check_asyncs) {
    1.67      check_and_handle_async_exceptions();
    1.68    }
    1.69 +
    1.70 +  JFR_ONLY(SUSPEND_THREAD_CONDITIONAL(this);)
    1.71  }
    1.72  
    1.73  void JavaThread::send_thread_stop(oop java_throwable)  {
    1.74 @@ -2424,6 +2429,8 @@
    1.75        fatal("missed deoptimization!");
    1.76      }
    1.77    }
    1.78 +
    1.79 +  JFR_ONLY(SUSPEND_THREAD_CONDITIONAL(thread);)
    1.80  }
    1.81  
    1.82  // Slow path when the native==>VM/Java barriers detect a safepoint is in
    1.83 @@ -3312,6 +3319,14 @@
    1.84    if (wt != NULL)
    1.85      tc->do_thread(wt);
    1.86  
    1.87 +#if INCLUDE_JFR
    1.88 +  Thread* sampler_thread = Jfr::sampler_thread();
    1.89 +  if (sampler_thread != NULL) {
    1.90 +    tc->do_thread(sampler_thread);
    1.91 +  }
    1.92 +
    1.93 +#endif
    1.94 +
    1.95    // If CompilerThreads ever become non-JavaThreads, add them here
    1.96  }
    1.97  
    1.98 @@ -3438,6 +3453,8 @@
    1.99      return status;
   1.100    }
   1.101  
   1.102 +  JFR_ONLY(Jfr::on_vm_init();)
   1.103 +
   1.104    // Should be done after the heap is fully created
   1.105    main_thread->cache_global_variables();
   1.106  
   1.107 @@ -3565,11 +3582,6 @@
   1.108  
   1.109    quicken_jni_functions();
   1.110  
   1.111 -  // Must be run after init_ft which initializes ft_enabled
   1.112 -  if (TRACE_INITIALIZE() != JNI_OK) {
   1.113 -    vm_exit_during_initialization("Failed to initialize tracing backend");
   1.114 -  }
   1.115 -
   1.116    // Set flag that basic initialization has completed. Used by exceptions and various
   1.117    // debug stuff, that does not work until all basic classes have been initialized.
   1.118    set_init_completed();
   1.119 @@ -3638,9 +3650,7 @@
   1.120    // Notify JVMTI agents that VM initialization is complete - nop if no agents.
   1.121    JvmtiExport::post_vm_initialized();
   1.122  
   1.123 -  if (TRACE_START() != JNI_OK) {
   1.124 -    vm_exit_during_initialization("Failed to start tracing backend.");
   1.125 -  }
   1.126 +  JFR_ONLY(Jfr::on_vm_start();)
   1.127  
   1.128    if (CleanChunkPoolAsync) {
   1.129      Chunk::start_chunk_pool_cleaner_task();

mercurial