8199712: Flight Recorder

Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Reviewed-by: coleenp, ihse, erikj, dsamersoff, mseledtsov, egahlin, mgronlun
This commit is contained in:
Erik Gahlin 2018-05-15 20:24:34 +02:00
parent f575533a17
commit a060be188d
1062 changed files with 119159 additions and 3164 deletions

View file

@ -40,6 +40,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 "logging/log.hpp"
#include "logging/logConfiguration.hpp"
@ -103,9 +105,6 @@
#include "services/management.hpp"
#include "services/memTracker.hpp"
#include "services/threadService.hpp"
#include "trace/traceMacros.hpp"
#include "trace/tracing.hpp"
#include "trace/tracingExport.hpp"
#include "utilities/align.hpp"
#include "utilities/copy.hpp"
#include "utilities/defaultStream.hpp"
@ -129,6 +128,9 @@
#if INCLUDE_RTM_OPT
#include "runtime/rtmLocking.hpp"
#endif
#if INCLUDE_JFR
#include "jfr/jfr.hpp"
#endif
// Initialization after module runtime initialization
void universe_post_module_init(); // must happen after call_initPhase2
@ -365,7 +367,7 @@ void Thread::record_stack_base_and_size() {
Thread::~Thread() {
EVENT_THREAD_DESTRUCT(this);
JFR_ONLY(Jfr::on_thread_destruct(this);)
// Notify the barrier set that a thread is being destroyed. Note that a barrier
// set might not be available if we encountered errors during bootstrapping.
@ -374,6 +376,7 @@ Thread::~Thread() {
barrier_set->on_thread_destroy(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
// that all started threads do call record_stack_base_and_size(), there is
@ -1738,7 +1741,7 @@ void JavaThread::run() {
EventThreadStart event;
if (event.should_commit()) {
event.set_thread(THREAD_TRACE_ID(this));
event.set_thread(JFR_THREAD_ID(this));
event.commit();
}
@ -1845,12 +1848,12 @@ void JavaThread::exit(bool destroy_vm, ExitType exit_type) {
// from java_lang_Thread object
EventThreadEnd event;
if (event.should_commit()) {
event.set_thread(THREAD_TRACE_ID(this));
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
@ -2207,11 +2210,8 @@ void JavaThread::handle_special_runtime_exit_condition(bool check_asyncs) {
if (check_asyncs) {
check_and_handle_async_exceptions();
}
#if INCLUDE_TRACE
if (is_trace_suspend()) {
TRACE_SUSPEND_THREAD(this);
}
#endif
JFR_ONLY(SUSPEND_THREAD_CONDITIONAL(this);)
}
void JavaThread::send_thread_stop(oop java_throwable) {
@ -2433,11 +2433,8 @@ void JavaThread::check_safepoint_and_suspend_for_native_trans(JavaThread *thread
fatal("missed deoptimization!");
}
}
#if INCLUDE_TRACE
if (thread->is_trace_suspend()) {
TRACE_SUSPEND_THREAD(thread);
}
#endif
JFR_ONLY(SUSPEND_THREAD_CONDITIONAL(thread);)
}
// Slow path when the native==>VM/Java barriers detect a safepoint is in
@ -3422,11 +3419,12 @@ void Threads::non_java_threads_do(ThreadClosure* tc) {
tc->do_thread(wt);
}
#if INCLUDE_TRACE
Thread* sampler_thread = TracingExport::sampler_thread_acquire();
#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
@ -3735,9 +3733,7 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
return status;
}
if (TRACE_INITIALIZE() != JNI_OK) {
vm_exit_during_initialization("Failed to initialize tracing backend");
}
JFR_ONLY(Jfr::on_vm_init();)
// Should be done after the heap is fully created
main_thread->cache_global_variables();
@ -3908,9 +3904,7 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
// 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 INCLUDE_MANAGEMENT
Management::initialize(THREAD);