--- old/src/share/vm/runtime/thread.cpp 2016-10-25 10:40:11.878779314 +0200 +++ new/src/share/vm/runtime/thread.cpp 2016-10-25 10:40:11.826779280 +0200 @@ -79,6 +79,7 @@ #include "services/threadService.hpp" #include "trace/tracing.hpp" #include "trace/traceMacros.hpp" +#include "evtrace/traceEvents.hpp" #include "utilities/defaultStream.hpp" #include "utilities/dtrace.hpp" #include "utilities/events.hpp" @@ -257,6 +258,13 @@ omFreeProvision = 32 ; omInUseList = NULL ; omInUseCount = 0 ; + _trace_buffer = NULL; + debug_only(_trace_active = false;) + _park_last_global_seq = 0; + _park_priority = 0; + _nesting_level = 0; + _memento_original_return_address = NULL; + _memento_stack_trace = NULL; #ifdef ASSERT _visited_for_critical_count = false; @@ -391,6 +399,8 @@ ThreadLocalStorage::invalidate_all(); } CHECK_UNHANDLED_OOPS_ONLY(if (CheckUnhandledOops) delete unhandled_oops();) + + assert (_trace_buffer == NULL, "leaking unsubmitted trace buffer"); } // NOTE: dummy function for assertion purpose. @@ -804,6 +814,9 @@ void Thread::interrupt(Thread* thread) { trace("interrupt", thread); debug_only(check_for_dangling_thread_pointer(thread);) + if (EnableEventTracing) { + TraceEvents::write_thread_interrupt(thread); + } os::interrupt(thread); } @@ -1658,6 +1671,10 @@ assert(JavaThread::current() == this, "sanity check"); assert(!Thread::current()->owns_locks(), "sanity check"); + if (EnableEventTracing) { + TraceEvents::write_thread_start(); + } + DTRACE_THREAD_PROBE(start, this); // This operation might block. We call that after all safepoint checks for a new thread has @@ -1701,6 +1718,10 @@ DTRACE_THREAD_PROBE(stop, this); + if (EnableEventTracing) { + TraceEvents::write_thread_exit(); + } + this->exit(false); delete this; } @@ -1925,6 +1946,14 @@ } #endif // INCLUDE_ALL_GCS + { // Submit trace buffer if we still hold one + No_Safepoint_Verifier nsv; + if (trace_buffer() != NULL) { + TraceManager::submit_buffer(trace_buffer()); + set_trace_buffer(NULL); + } + } + // Remove from list of active threads list, and notify VM thread if we are the last non-daemon thread Threads::remove(this); } @@ -3425,6 +3454,11 @@ return status; } + // Initialize event tracing + if (EnableEventTracing) { + TraceManager::initialize(); + } + // Should be done after the heap is fully created main_thread->cache_global_variables(); @@ -3666,6 +3700,10 @@ BiasedLocking::init(); + if (EnableEventTracing) { + TraceManager::start_threads(CHECK_0); // needs a fully functional Java environment + } + #if INCLUDE_RTM_OPT RTMLockingCounters::init(); #endif