< prev index next >

src/share/vm/runtime/thread.cpp

Print this page

        

*** 30,39 **** --- 30,40 ---- #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 "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" --- 76,85 ----
*** 109,118 **** --- 108,120 ---- #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,351 **** 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. #if INCLUDE_NMT --- 342,351 ----
*** 1210,1219 **** --- 1210,1220 ---- _name = NULL; _processed_thread = NULL; } NamedThread::~NamedThread() { + JFR_ONLY(Jfr::on_thread_exit(this);) if (_name != NULL) { FREE_C_HEAP_ARRAY(char, _name, mtThread); _name = NULL; } }
*** 1236,1246 **** WatcherThread* WatcherThread::_watcher_thread = NULL; bool WatcherThread::_startable = false; volatile bool WatcherThread::_should_terminate = false; ! WatcherThread::WatcherThread() : Thread(), _crash_protection(NULL) { assert(watcher_thread() == NULL, "we can only allocate one WatcherThread"); if (os::create_thread(this, os::watcher_thread)) { _watcher_thread = this; // Set the watcher thread to the highest OS priority which should not be --- 1237,1247 ---- WatcherThread* WatcherThread::_watcher_thread = NULL; bool WatcherThread::_startable = false; volatile bool WatcherThread::_should_terminate = false; ! WatcherThread::WatcherThread() : Thread() { assert(watcher_thread() == NULL, "we can only allocate one WatcherThread"); if (os::create_thread(this, os::watcher_thread)) { _watcher_thread = this; // Set the watcher thread to the highest OS priority which should not be
*** 1667,1681 **** if (JvmtiExport::should_post_thread_life()) { 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 thread_main_inner(); --- 1668,1678 ---- if (JvmtiExport::should_post_thread_life()) { JvmtiExport::post_thread_start(this); } ! JFR_ONLY(Jfr::on_thread_start(this);) // 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 thread_main_inner();
*** 1798,1818 **** get_thread_name()); CLEAR_PENDING_EXCEPTION; } } } ! ! // 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()) { --- 1795,1805 ---- get_thread_name()); CLEAR_PENDING_EXCEPTION; } } } ! JFR_ONLY(Jfr::on_java_thread_dismantle(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()) {
*** 1885,1894 **** --- 1872,1882 ---- } // These things needs to be done while we are still a Java Thread. Make sure that thread // is in a consistent state, in case GC happens assert(_privileged_stack_top == NULL, "must be NULL when we get here"); + JFR_ONLY(Jfr::on_thread_exit(this);) if (active_handles() != NULL) { JNIHandleBlock* block = active_handles(); set_active_handles(NULL); JNIHandleBlock::release_block(block);
*** 2184,2193 **** --- 2172,2183 ---- } 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");
*** 2422,2431 **** --- 2412,2423 ---- 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
*** 3310,3319 **** --- 3302,3319 ---- // 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) {
*** 3436,3445 **** --- 3436,3447 ---- 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;
*** 3563,3577 **** // 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(); --- 3565,3574 ----
*** 3636,3648 **** } // 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(); } --- 3633,3643 ---- } // 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(); }
*** 4000,4009 **** --- 3995,4010 ---- // Threads_lock->wait(!Mutex::_no_safepoint_check_flag, 0, Mutex::_as_suspend_equivalent_flag); } + EventShutdown e; + if (e.should_commit()) { + e.set_reason("No remaining non-daemon Java threads"); + e.commit(); + } + // Hang forever on exit if we are reporting an error. if (ShowMessageBoxOnError && is_error_reported()) { os::infinite_sleep(); } os::wait_for_keypress_at_exit();
< prev index next >