< prev index next >
src/share/vm/runtime/thread.cpp
Print this page
rev 8957 : 8223147: JFR Backport
8199712: Flight Recorder
8203346: JFR: Inconsistent signature of jfr_add_string_constant
8195817: JFR.stop should require name of recording
8195818: JFR.start should increase autogenerated name by one
8195819: Remove recording=x from jcmd JFR.check output
8203921: JFR thread sampling is missing fixes from JDK-8194552
8203929: Limit amount of data for JFR.dump
8203664: JFR start failure after AppCDS archive created with JFR StartFlightRecording
8003209: JFR events for network utilization
8207392: [PPC64] Implement JFR profiling
*** 30,39 ****
--- 30,41 ----
#include "code/scopeDesc.hpp"
#include "compiler/compileBroker.hpp"
#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"
#include "memory/oopFactory.hpp"
#include "memory/universe.inline.hpp"
*** 75,86 ****
#include "runtime/vm_operations.hpp"
#include "services/attachListener.hpp"
#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"
#include "utilities/preserveException.hpp"
#include "utilities/macros.hpp"
--- 77,86 ----
*** 109,118 ****
--- 109,121 ----
#include "opto/idealGraphPrinter.hpp"
#endif
#if INCLUDE_RTM_OPT
#include "runtime/rtmLocking.hpp"
#endif
+ #if INCLUDE_JFR
+ #include "jfr/jfr.hpp"
+ #endif
PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
#ifdef DTRACE_ENABLED
*** 340,350 ****
Thread::~Thread() {
// Reclaim the objectmonitors from the omFreeList of the moribund thread.
ObjectSynchronizer::omFlush (this) ;
! EVENT_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
// that all started threads do call record_stack_base_and_size(), there is
// not proper way to enforce that.
--- 343,353 ----
Thread::~Thread() {
// Reclaim the objectmonitors from the omFreeList of the moribund thread.
ObjectSynchronizer::omFlush (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
// that all started threads do call record_stack_base_and_size(), there is
// not proper way to enforce that.
*** 1668,1678 ****
JvmtiExport::post_thread_start(this);
}
EventThreadStart event;
if (event.should_commit()) {
! event.set_javalangthread(java_lang_Thread::thread_id(this->threadObj()));
event.commit();
}
// We call another function to do the rest so we are sure that the stack addresses used
// from there will be lower than the stack base just computed
--- 1671,1681 ----
JvmtiExport::post_thread_start(this);
}
EventThreadStart event;
if (event.should_commit()) {
! event.set_thread(JFR_THREAD_ID(this));
event.commit();
}
// We call another function to do the rest so we are sure that the stack addresses used
// from there will be lower than the stack base just computed
*** 1802,1817 ****
// Called before the java thread exit since we want to read info
// from java_lang_Thread object
EventThreadEnd event;
if (event.should_commit()) {
! event.set_javalangthread(java_lang_Thread::thread_id(this->threadObj()));
event.commit();
}
// Call after last event on thread
! EVENT_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
// is deprecated anyhow.
if (!is_Compiler_thread()) {
--- 1805,1820 ----
// Called before the java thread exit since we want to read info
// from java_lang_Thread object
EventThreadEnd event;
if (event.should_commit()) {
! event.set_thread(JFR_THREAD_ID(this));
event.commit();
}
// Call after last event on thread
! 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
// is deprecated anyhow.
if (!is_Compiler_thread()) {
*** 2183,2192 ****
--- 2186,2197 ----
}
if (check_asyncs) {
check_and_handle_async_exceptions();
}
+
+ JFR_ONLY(SUSPEND_THREAD_CONDITIONAL(this);)
}
void JavaThread::send_thread_stop(oop java_throwable) {
assert(Thread::current()->is_VM_thread(), "should be in the vm thread");
assert(Threads_lock->is_locked(), "Threads_lock should be locked by safepoint code");
*** 2421,2430 ****
--- 2426,2437 ----
f.deoptimize(thread);
} else {
fatal("missed deoptimization!");
}
}
+
+ JFR_ONLY(SUSPEND_THREAD_CONDITIONAL(thread);)
}
// Slow path when the native==>VM/Java barriers detect a safepoint is in
// progress or when _suspend_flags is non-zero.
// Current thread needs to self-suspend if there is a suspend request and/or
*** 3309,3318 ****
--- 3316,3333 ----
// Terminator_lock, but we can't do that without violating the lock rank
// checking in some cases.
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
}
jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
*** 3435,3444 ****
--- 3450,3461 ----
delete main_thread;
*canTryAgain = false; // don't let caller call JNI_CreateJavaVM again
return status;
}
+ JFR_ONLY(Jfr::on_vm_init();)
+
// Should be done after the heap is fully created
main_thread->cache_global_variables();
HandleMark hm;
*** 3562,3576 ****
// This should also be taken out as soon as 4211383 gets fixed.
reset_vm_info_property(CHECK_0);
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();
Metaspace::post_initialize();
--- 3579,3588 ----
*** 3635,3647 ****
}
// 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.");
! }
if (CleanChunkPoolAsync) {
Chunk::start_chunk_pool_cleaner_task();
}
--- 3647,3657 ----
}
// Notify JVMTI agents that VM initialization is complete - nop if no agents.
JvmtiExport::post_vm_initialized();
! JFR_ONLY(Jfr::on_vm_start();)
if (CleanChunkPoolAsync) {
Chunk::start_chunk_pool_cleaner_task();
}
< prev index next >