< prev index next >

src/hotspot/share/services/management.cpp

Print this page
rev 47862 : imported patch 10.07.open.rebase_20171110.dcubed

*** 39,48 **** --- 39,49 ---- #include "runtime/javaCalls.hpp" #include "runtime/jniHandles.hpp" #include "runtime/os.hpp" #include "runtime/serviceThread.hpp" #include "runtime/thread.inline.hpp" + #include "runtime/threadSMR.hpp" #include "services/classLoadingService.hpp" #include "services/diagnosticCommand.hpp" #include "services/diagnosticFramework.hpp" #include "services/writeableFlags.hpp" #include "services/heapDumper.hpp"
*** 1023,1037 **** if (num_threads == 0) return; // First get an array of threadObj handles. // A JavaThread may terminate before we get the stack trace. GrowableArray<instanceHandle>* thread_handle_array = new GrowableArray<instanceHandle>(num_threads); { ! MutexLockerEx ml(Threads_lock); for (int i = 0; i < num_threads; i++) { jlong tid = ids_ah->long_at(i); ! JavaThread* jt = Threads::find_java_thread_from_java_tid(tid); oop thread_obj = (jt != NULL ? jt->threadObj() : (oop)NULL); instanceHandle threadObj_h(THREAD, (instanceOop) thread_obj); thread_handle_array->append(threadObj_h); } } --- 1024,1042 ---- if (num_threads == 0) return; // First get an array of threadObj handles. // A JavaThread may terminate before we get the stack trace. GrowableArray<instanceHandle>* thread_handle_array = new GrowableArray<instanceHandle>(num_threads); + { ! // Need this ThreadsListHandle for converting Java thread IDs into ! // threadObj handles; dump_result->set_t_list() is called in the ! // VM op below so we can't use it yet. ! ThreadsListHandle tlh; for (int i = 0; i < num_threads; i++) { jlong tid = ids_ah->long_at(i); ! JavaThread* jt = tlh.list()->find_JavaThread_from_java_tid(tid); oop thread_obj = (jt != NULL ? jt->threadObj() : (oop)NULL); instanceHandle threadObj_h(THREAD, (instanceOop) thread_obj); thread_handle_array->append(threadObj_h); } }
*** 1099,1125 **** // this function returns. The threadObj and other oops kept // in the ThreadSnapshot are marked and adjusted during GC. ThreadDumpResult dump_result(num_threads); if (maxDepth == 0) { ! // no stack trace dumped - do not need to stop the world ! { ! MutexLockerEx ml(Threads_lock); for (int i = 0; i < num_threads; i++) { jlong tid = ids_ah->long_at(i); ! JavaThread* jt = Threads::find_java_thread_from_java_tid(tid); ThreadSnapshot* ts; if (jt == NULL) { // if the thread does not exist or now it is terminated, // create dummy snapshot ts = new ThreadSnapshot(); } else { ! ts = new ThreadSnapshot(jt); } dump_result.add_thread_snapshot(ts); } - } } else { // obtain thread dump with the specific list of threads with stack trace do_thread_dump(&dump_result, ids_ah, num_threads, --- 1104,1129 ---- // this function returns. The threadObj and other oops kept // in the ThreadSnapshot are marked and adjusted during GC. ThreadDumpResult dump_result(num_threads); if (maxDepth == 0) { ! // No stack trace to dump so we do not need to stop the world. ! // Since we never do the VM op here we must set the threads list. ! dump_result.set_t_list(); for (int i = 0; i < num_threads; i++) { jlong tid = ids_ah->long_at(i); ! JavaThread* jt = dump_result.t_list()->find_JavaThread_from_java_tid(tid); ThreadSnapshot* ts; if (jt == NULL) { // if the thread does not exist or now it is terminated, // create dummy snapshot ts = new ThreadSnapshot(); } else { ! ts = new ThreadSnapshot(dump_result.t_list(), jt); } dump_result.add_thread_snapshot(ts); } } else { // obtain thread dump with the specific list of threads with stack trace do_thread_dump(&dump_result, ids_ah, num_threads,
*** 1129,1138 **** --- 1133,1143 ---- CHECK_0); } int num_snapshots = dump_result.num_snapshots(); assert(num_snapshots == num_threads, "Must match the number of thread snapshots"); + assert(num_snapshots == 0 || dump_result.t_list_has_been_set(), "ThreadsList must have been set if we have a snapshot"); int index = 0; for (ThreadSnapshot* ts = dump_result.snapshots(); ts != NULL; index++, ts = ts->next()) { // For each thread, create an java/lang/management/ThreadInfo object // and fill with the thread information
*** 1194,1203 **** --- 1199,1209 ---- (locked_synchronizers ? true : false) /* with locked synchronizers */); VMThread::execute(&op); } int num_snapshots = dump_result.num_snapshots(); + assert(num_snapshots == 0 || dump_result.t_list_has_been_set(), "ThreadsList must have been set if we have a snapshot"); // create the result ThreadInfo[] object InstanceKlass* ik = Management::java_lang_management_ThreadInfo_klass(CHECK_NULL); objArrayOop r = oopFactory::new_objArray(ik, num_snapshots, CHECK_NULL); objArrayHandle result_h(THREAD, r);
*** 1317,1339 **** if (tid < 0) { THROW_(vmSymbols::java_lang_IllegalArgumentException(), JNI_FALSE); } // Look for the JavaThread of this given tid ! MutexLockerEx ml(Threads_lock); if (tid == 0) { // reset contention statistics for all threads if tid == 0 ! for (JavaThread* java_thread = Threads::first(); java_thread != NULL; java_thread = java_thread->next()) { if (type == JMM_STAT_THREAD_CONTENTION_COUNT) { ThreadService::reset_contention_count_stat(java_thread); } else { ThreadService::reset_contention_time_stat(java_thread); } } } else { // reset contention statistics for a given thread ! JavaThread* java_thread = Threads::find_java_thread_from_java_tid(tid); if (java_thread == NULL) { return false; } if (type == JMM_STAT_THREAD_CONTENTION_COUNT) { --- 1323,1345 ---- if (tid < 0) { THROW_(vmSymbols::java_lang_IllegalArgumentException(), JNI_FALSE); } // Look for the JavaThread of this given tid ! JavaThreadIteratorWithHandle jtiwh; if (tid == 0) { // reset contention statistics for all threads if tid == 0 ! for (; JavaThread *java_thread = jtiwh.next(); ) { if (type == JMM_STAT_THREAD_CONTENTION_COUNT) { ThreadService::reset_contention_count_stat(java_thread); } else { ThreadService::reset_contention_time_stat(java_thread); } } } else { // reset contention statistics for a given thread ! JavaThread* java_thread = jtiwh.list()->find_JavaThread_from_java_tid(tid); if (java_thread == NULL) { return false; } if (type == JMM_STAT_THREAD_CONTENTION_COUNT) {
*** 1397,1408 **** JavaThread* java_thread = NULL; if (thread_id == 0) { // current thread return os::current_thread_cpu_time(); } else { ! MutexLockerEx ml(Threads_lock); ! java_thread = Threads::find_java_thread_from_java_tid(thread_id); if (java_thread != NULL) { return os::thread_cpu_time((Thread*) java_thread); } } return -1; --- 1403,1414 ---- JavaThread* java_thread = NULL; if (thread_id == 0) { // current thread return os::current_thread_cpu_time(); } else { ! ThreadsListHandle tlh; ! java_thread = tlh.list()->find_JavaThread_from_java_tid(thread_id); if (java_thread != NULL) { return os::thread_cpu_time((Thread*) java_thread); } } return -1;
*** 1647,1656 **** --- 1653,1663 ---- // // Called with Threads_lock held // void ThreadTimesClosure::do_thread(Thread* thread) { + assert(Threads_lock->owned_by_self(), "Must hold Threads_lock"); assert(thread != NULL, "thread was NULL"); // exclude externally visible JavaThreads if (thread->is_Java_thread() && !thread->is_hidden_from_external_view()) { return;
*** 2107,2119 **** THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "The length of the given long array does not match the length of " "the given array of thread IDs"); } ! MutexLockerEx ml(Threads_lock); for (int i = 0; i < num_threads; i++) { ! JavaThread* java_thread = Threads::find_java_thread_from_java_tid(ids_ah->long_at(i)); if (java_thread != NULL) { sizeArray_h->long_at_put(i, java_thread->cooked_allocated_bytes()); } } JVM_END --- 2114,2126 ---- THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "The length of the given long array does not match the length of " "the given array of thread IDs"); } ! ThreadsListHandle tlh; for (int i = 0; i < num_threads; i++) { ! JavaThread* java_thread = tlh.list()->find_JavaThread_from_java_tid(ids_ah->long_at(i)); if (java_thread != NULL) { sizeArray_h->long_at_put(i, java_thread->cooked_allocated_bytes()); } } JVM_END
*** 2136,2147 **** JavaThread* java_thread = NULL; if (thread_id == 0) { // current thread return os::current_thread_cpu_time(user_sys_cpu_time != 0); } else { ! MutexLockerEx ml(Threads_lock); ! java_thread = Threads::find_java_thread_from_java_tid(thread_id); if (java_thread != NULL) { return os::thread_cpu_time((Thread*) java_thread, user_sys_cpu_time != 0); } } return -1; --- 2143,2154 ---- JavaThread* java_thread = NULL; if (thread_id == 0) { // current thread return os::current_thread_cpu_time(user_sys_cpu_time != 0); } else { ! ThreadsListHandle tlh; ! java_thread = tlh.list()->find_JavaThread_from_java_tid(thread_id); if (java_thread != NULL) { return os::thread_cpu_time((Thread*) java_thread, user_sys_cpu_time != 0); } } return -1;
*** 2178,2190 **** THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "The length of the given long array does not match the length of " "the given array of thread IDs"); } ! MutexLockerEx ml(Threads_lock); for (int i = 0; i < num_threads; i++) { ! JavaThread* java_thread = Threads::find_java_thread_from_java_tid(ids_ah->long_at(i)); if (java_thread != NULL) { timeArray_h->long_at_put(i, os::thread_cpu_time((Thread*)java_thread, user_sys_cpu_time != 0)); } } --- 2185,2197 ---- THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "The length of the given long array does not match the length of " "the given array of thread IDs"); } ! ThreadsListHandle tlh; for (int i = 0; i < num_threads; i++) { ! JavaThread* java_thread = tlh.list()->find_JavaThread_from_java_tid(ids_ah->long_at(i)); if (java_thread != NULL) { timeArray_h->long_at_put(i, os::thread_cpu_time((Thread*)java_thread, user_sys_cpu_time != 0)); } }
< prev index next >