diff -r c7a3e57fdf4a -r b985cbb00e68 src/share/vm/runtime/thread.cpp --- a/src/share/vm/runtime/thread.cpp Thu Aug 01 03:44:03 2019 +0100 +++ b/src/share/vm/runtime/thread.cpp Mon Aug 12 18:30:40 2019 +0300 @@ -32,6 +32,8 @@ #include "interpreter/interpreter.hpp" #include "interpreter/linkResolver.hpp" #include "interpreter/oopMapCache.hpp" +#include "jfr/jfrEvents.hpp" +#include "jfr/support/jfrThreadId.hpp" #include "jvmtifiles/jvmtiEnv.hpp" #include "memory/gcLocker.inline.hpp" #include "memory/metaspaceShared.hpp" @@ -77,8 +79,6 @@ #include "services/management.hpp" #include "services/memTracker.hpp" #include "services/threadService.hpp" -#include "trace/tracing.hpp" -#include "trace/traceMacros.hpp" #include "utilities/defaultStream.hpp" #include "utilities/dtrace.hpp" #include "utilities/events.hpp" @@ -111,6 +111,9 @@ #if INCLUDE_RTM_OPT #include "runtime/rtmLocking.hpp" #endif +#if INCLUDE_JFR +#include "jfr/jfr.hpp" +#endif PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC @@ -342,7 +345,7 @@ // Reclaim the objectmonitors from the omFreeList of the moribund thread. ObjectSynchronizer::omFlush (this) ; - EVENT_THREAD_DESTRUCT(this); + JFR_ONLY(Jfr::on_thread_destruct(this);) // stack_base can be NULL if the thread is never started or exited before // record_stack_base_and_size called. Although, we would like to ensure @@ -1671,7 +1674,7 @@ EventThreadStart event; if (event.should_commit()) { - event.set_javalangthread(java_lang_Thread::thread_id(this->threadObj())); + event.set_thread(JFR_THREAD_ID(this)); event.commit(); } @@ -1805,12 +1808,12 @@ // from java_lang_Thread object EventThreadEnd event; if (event.should_commit()) { - event.set_javalangthread(java_lang_Thread::thread_id(this->threadObj())); - event.commit(); + event.set_thread(JFR_THREAD_ID(this)); + event.commit(); } // Call after last event on thread - EVENT_THREAD_EXIT(this); + JFR_ONLY(Jfr::on_thread_exit(this);) // Call Thread.exit(). We try 3 times in case we got another Thread.stop during // the execution of the method. If that is not enough, then we don't really care. Thread.stop @@ -2186,6 +2189,8 @@ if (check_asyncs) { check_and_handle_async_exceptions(); } + + JFR_ONLY(SUSPEND_THREAD_CONDITIONAL(this);) } void JavaThread::send_thread_stop(oop java_throwable) { @@ -2424,6 +2429,8 @@ fatal("missed deoptimization!"); } } + + JFR_ONLY(SUSPEND_THREAD_CONDITIONAL(thread);) } // Slow path when the native==>VM/Java barriers detect a safepoint is in @@ -3312,6 +3319,14 @@ if (wt != NULL) tc->do_thread(wt); +#if INCLUDE_JFR + Thread* sampler_thread = Jfr::sampler_thread(); + if (sampler_thread != NULL) { + tc->do_thread(sampler_thread); + } + +#endif + // If CompilerThreads ever become non-JavaThreads, add them here } @@ -3438,6 +3453,8 @@ return status; } + JFR_ONLY(Jfr::on_vm_init();) + // Should be done after the heap is fully created main_thread->cache_global_variables(); @@ -3565,11 +3582,6 @@ quicken_jni_functions(); - // Must be run after init_ft which initializes ft_enabled - if (TRACE_INITIALIZE() != JNI_OK) { - vm_exit_during_initialization("Failed to initialize tracing backend"); - } - // Set flag that basic initialization has completed. Used by exceptions and various // debug stuff, that does not work until all basic classes have been initialized. set_init_completed(); @@ -3638,9 +3650,7 @@ // Notify JVMTI agents that VM initialization is complete - nop if no agents. JvmtiExport::post_vm_initialized(); - if (TRACE_START() != JNI_OK) { - vm_exit_during_initialization("Failed to start tracing backend."); - } + JFR_ONLY(Jfr::on_vm_start();) if (CleanChunkPoolAsync) { Chunk::start_chunk_pool_cleaner_task();