--- old/src/share/vm/runtime/thread.cpp 2019-02-15 19:02:45.358556302 +0300 +++ new/src/share/vm/runtime/thread.cpp 2019-02-15 19:02:45.242560353 +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 @@ -1670,7 +1673,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(); } @@ -1804,12 +1807,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 @@ -2185,6 +2188,8 @@ if (check_asyncs) { check_and_handle_async_exceptions(); } + + JFR_ONLY(SUSPEND_THREAD_CONDITIONAL(this);) } void JavaThread::send_thread_stop(oop java_throwable) { @@ -2423,6 +2428,8 @@ fatal("missed deoptimization!"); } } + + JFR_ONLY(SUSPEND_THREAD_CONDITIONAL(thread);) } // Slow path when the native==>VM/Java barriers detect a safepoint is in @@ -3311,6 +3318,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 } @@ -3437,6 +3452,8 @@ return status; } + JFR_ONLY(Jfr::on_vm_init();) + // Should be done after the heap is fully created main_thread->cache_global_variables(); @@ -3564,11 +3581,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(); @@ -3637,9 +3649,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();