< prev index next >

src/hotspot/share/runtime/vm_operations.cpp

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

*** 36,45 **** --- 36,46 ---- #include "runtime/arguments.hpp" #include "runtime/deoptimization.hpp" #include "runtime/interfaceSupport.hpp" #include "runtime/sweeper.hpp" #include "runtime/thread.inline.hpp" + #include "runtime/threadSMR.inline.hpp" #include "runtime/vm_operations.hpp" #include "services/threadService.hpp" #include "trace/tracing.hpp" #define VM_OP_NAME_INITIALIZE(name) #name,
*** 94,108 **** } } void VM_ThreadStop::doit() { assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint"); JavaThread* target = java_lang_Thread::thread(target_thread()); // Note that this now allows multiple ThreadDeath exceptions to be // thrown at a thread. ! if (target != NULL) { ! // the thread has run and is not already in the process of exiting target->send_thread_stop(throwable()); } } void VM_ClearICs::doit() { --- 95,110 ---- } } void VM_ThreadStop::doit() { assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint"); + ThreadsListHandle tlh; JavaThread* target = java_lang_Thread::thread(target_thread()); // Note that this now allows multiple ThreadDeath exceptions to be // thrown at a thread. ! if (target != NULL && (!EnableThreadSMRExtraValidityChecks || tlh.includes(target))) { ! // The target thread has run and has not exited yet. target->send_thread_stop(throwable()); } } void VM_ClearICs::doit() {
*** 144,156 **** #ifndef PRODUCT void VM_DeoptimizeAll::doit() { DeoptimizationMarker dm; // deoptimize all java threads in the system if (DeoptimizeALot) { ! for (JavaThread* thread = Threads::first(); thread != NULL; thread = thread->next()) { if (thread->has_last_Java_frame()) { thread->deoptimize(); } } } else if (DeoptimizeRandom) { --- 146,159 ---- #ifndef PRODUCT void VM_DeoptimizeAll::doit() { DeoptimizationMarker dm; + JavaThreadIteratorWithHandle jtiwh; // deoptimize all java threads in the system if (DeoptimizeALot) { ! for (; JavaThread *thread = jtiwh.next(); ) { if (thread->has_last_Java_frame()) { thread->deoptimize(); } } } else if (DeoptimizeRandom) {
*** 157,167 **** // Deoptimize some selected threads and frames int tnum = os::random() & 0x3; int fnum = os::random() & 0x3; int tcount = 0; ! for (JavaThread* thread = Threads::first(); thread != NULL; thread = thread->next()) { if (thread->has_last_Java_frame()) { if (tcount++ == tnum) { tcount = 0; int fcount = 0; // Deoptimize some selected frames. --- 160,170 ---- // Deoptimize some selected threads and frames int tnum = os::random() & 0x3; int fnum = os::random() & 0x3; int tcount = 0; ! for (; JavaThread *thread = jtiwh.next(); ) { if (thread->has_last_Java_frame()) { if (tcount++ == tnum) { tcount = 0; int fcount = 0; // Deoptimize some selected frames.
*** 257,272 **** return true; } void VM_FindDeadlocks::doit() { ! _deadlocks = ThreadService::find_deadlocks_at_safepoint(_concurrent_locks); if (_out != NULL) { int num_deadlocks = 0; for (DeadlockCycle* cycle = _deadlocks; cycle != NULL; cycle = cycle->next()) { num_deadlocks++; ! cycle->print_on(_out); } if (num_deadlocks == 1) { _out->print_cr("\nFound 1 deadlock.\n"); _out->flush(); --- 260,282 ---- return true; } void VM_FindDeadlocks::doit() { ! // Update the hazard ptr in the originating thread to the current ! // list of threads. This VM operation needs the current list of ! // threads for proper deadlock detection and those are the ! // JavaThreads we need to be protected when we return info to the ! // originating thread. ! _setter.set(); ! ! _deadlocks = ThreadService::find_deadlocks_at_safepoint(_setter.list(), _concurrent_locks); if (_out != NULL) { int num_deadlocks = 0; for (DeadlockCycle* cycle = _deadlocks; cycle != NULL; cycle = cycle->next()) { num_deadlocks++; ! cycle->print_on_with(_setter.list(), _out); } if (num_deadlocks == 1) { _out->print_cr("\nFound 1 deadlock.\n"); _out->flush();
*** 329,346 **** } void VM_ThreadDump::doit() { ResourceMark rm; ConcurrentLocksDump concurrent_locks(true); if (_with_locked_synchronizers) { concurrent_locks.dump_at_safepoint(); } if (_num_threads == 0) { // Snapshot all live threads ! for (JavaThread* jt = Threads::first(); jt != NULL; jt = jt->next()) { if (jt->is_exiting() || jt->is_hidden_from_external_view()) { // skip terminating threads and hidden threads continue; } --- 339,364 ---- } void VM_ThreadDump::doit() { ResourceMark rm; + // Set the hazard ptr in the originating thread to protect the + // current list of threads. This VM operation needs the current list + // of threads for a proper dump and those are the JavaThreads we need + // to be protected when we return info to the originating thread. + _result->set_t_list(); + ConcurrentLocksDump concurrent_locks(true); if (_with_locked_synchronizers) { concurrent_locks.dump_at_safepoint(); } if (_num_threads == 0) { // Snapshot all live threads ! ! for (uint i = 0; i < _result->t_list()->length(); i++) { ! JavaThread* jt = _result->t_list()->thread_at(i); if (jt->is_exiting() || jt->is_hidden_from_external_view()) { // skip terminating threads and hidden threads continue; }
*** 352,361 **** --- 370,380 ---- _result->add_thread_snapshot(ts); } } else { // Snapshot threads in the given _threads array // A dummy snapshot is created if a thread doesn't exist + for (int i = 0; i < _num_threads; i++) { instanceHandle th = _threads->at(i); if (th() == NULL) { // skip if the thread doesn't exist // Add a dummy snapshot
*** 364,373 **** --- 383,398 ---- } // Dump thread stack only if the thread is alive and not exiting // and not VM internal thread. JavaThread* jt = java_lang_Thread::thread(th()); + if (jt != NULL && !_result->t_list()->includes(jt)) { + // _threads[i] doesn't refer to a valid JavaThread; this check + // is primarily for JVM_DumpThreads() which doesn't have a good + // way to validate the _threads array. + jt = NULL; + } if (jt == NULL || /* thread not alive */ jt->is_exiting() || jt->is_hidden_from_external_view()) { // add a NULL snapshot if skipped _result->add_thread_snapshot(new ThreadSnapshot());
*** 382,392 **** } } } ThreadSnapshot* VM_ThreadDump::snapshot_thread(JavaThread* java_thread, ThreadConcurrentLocks* tcl) { ! ThreadSnapshot* snapshot = new ThreadSnapshot(java_thread); snapshot->dump_stack_at_safepoint(_max_depth, _with_locked_monitors); snapshot->set_concurrent_locks(tcl); return snapshot; } --- 407,417 ---- } } } ThreadSnapshot* VM_ThreadDump::snapshot_thread(JavaThread* java_thread, ThreadConcurrentLocks* tcl) { ! ThreadSnapshot* snapshot = new ThreadSnapshot(_result->t_list(), java_thread); snapshot->dump_stack_at_safepoint(_max_depth, _with_locked_monitors); snapshot->set_concurrent_locks(tcl); return snapshot; }
*** 401,415 **** int num_active = 0; _shutdown_thread = thr_cur; _vm_exited = true; // global flag ! for(JavaThread *thr = Threads::first(); thr != NULL; thr = thr->next()) if (thr!=thr_cur && thr->thread_state() == _thread_in_native) { ++num_active; thr->set_terminated(JavaThread::_vm_exited); // per-thread flag } return num_active; } int VM_Exit::wait_for_threads_in_native_to_block() { --- 426,441 ---- int num_active = 0; _shutdown_thread = thr_cur; _vm_exited = true; // global flag ! for (JavaThreadIteratorWithHandle jtiwh; JavaThread *thr = jtiwh.next(); ) { if (thr!=thr_cur && thr->thread_state() == _thread_in_native) { ++num_active; thr->set_terminated(JavaThread::_vm_exited); // per-thread flag } + } return num_active; } int VM_Exit::wait_for_threads_in_native_to_block() {
*** 433,447 **** int max_wait_compiler_thread = 1000; // at least 10 seconds int max_wait = max_wait_compiler_thread; int attempts = 0; while (true) { int num_active = 0; int num_active_compiler_thread = 0; ! for(JavaThread *thr = Threads::first(); thr != NULL; thr = thr->next()) { if (thr!=thr_cur && thr->thread_state() == _thread_in_native) { num_active++; if (thr->is_Compiler_thread()) { num_active_compiler_thread++; } --- 459,475 ---- int max_wait_compiler_thread = 1000; // at least 10 seconds int max_wait = max_wait_compiler_thread; int attempts = 0; + JavaThreadIteratorWithHandle jtiwh; while (true) { int num_active = 0; int num_active_compiler_thread = 0; ! jtiwh.rewind(); ! for (; JavaThread *thr = jtiwh.next(); ) { if (thr!=thr_cur && thr->thread_state() == _thread_in_native) { num_active++; if (thr->is_Compiler_thread()) { num_active_compiler_thread++; }
< prev index next >