< prev index next >

src/hotspot/share/runtime/handshake.cpp

Print this page
rev 57126 : [mq]: 8234796-v2
rev 57127 : imported patch 8234742-v2
rev 57128 : [mq]: 8234742-v3

*** 49,58 **** --- 49,59 ---- public: HandshakeThreadsOperation(HandshakeClosure* cl) : _handshake_cl(cl), _executed(false) {} void do_handshake(JavaThread* thread); bool thread_has_completed() { return _done.trywait(); } bool executed() const { return _executed; } + const char* name() { return _handshake_cl->name(); } #ifdef ASSERT void check_state() { assert(!_done.trywait(), "Must be zero"); }
*** 105,119 **** } log_stream.flush(); fatal("Handshake operation timed out"); } ! static void log_handshake_info(jlong start_time_ns, const char* name, int targets, int vmt_executed, const char* extra) { if (start_time_ns != 0) { jlong completion_time = os::javaTimeNanos() - start_time_ns; ! log_info(handshake)("Handshake \"%s\", Targeted threads: %d, Executed by targeted threads: %d, Total completion time: " JLONG_FORMAT " ns%s", ! name, targets, targets - vmt_executed, completion_time, extra); } } class VM_HandshakeOneThread: public VM_Handshake { JavaThread* _target; --- 106,124 ---- } log_stream.flush(); fatal("Handshake operation timed out"); } ! static void log_handshake_info(jlong start_time_ns, const char* name, int targets, int vmt_executed, const char* extra = NULL) { if (start_time_ns != 0) { jlong completion_time = os::javaTimeNanos() - start_time_ns; ! log_info(handshake)("Handshake \"%s\", Targeted threads: %d, Executed by targeted threads: %d, Total completion time: " JLONG_FORMAT " ns%s%s", ! name, targets, ! targets - vmt_executed, ! completion_time, ! extra != NULL ? ", " : "", ! extra != NULL ? extra : ""); } } class VM_HandshakeOneThread: public VM_Handshake { JavaThread* _target;
*** 131,141 **** ThreadsListHandle tlh; if (tlh.includes(_target)) { set_handshake(_target); } else { ! log_handshake_info(start_time_ns, _op->name(), 0, 0, " (thread dead)"); return; } log_trace(handshake)("JavaThread " INTPTR_FORMAT " signaled, begin attempt to process by VMThtread", p2i(_target)); jlong timeout_start_time = os::elapsed_counter(); --- 136,146 ---- ThreadsListHandle tlh; if (tlh.includes(_target)) { set_handshake(_target); } else { ! log_handshake_info(start_time_ns, _op->name(), 0, 0, "(thread dead)"); return; } log_trace(handshake)("JavaThread " INTPTR_FORMAT " signaled, begin attempt to process by VMThtread", p2i(_target)); jlong timeout_start_time = os::elapsed_counter();
*** 148,162 **** // We need to re-think this with SMR ThreadsList. // There is an assumption in the code that the Threads_lock should be // locked during certain phases. { MutexLocker ml(Threads_lock); ! by_vm_thread = _target->handshake_process_by_vmthread(); } } while (!poll_for_completed_thread()); DEBUG_ONLY(_op->check_state();) ! log_handshake_info(start_time_ns, _op->name(), 1, by_vm_thread ? 1 : 0, ""); } VMOp_Type type() const { return VMOp_HandshakeOneThread; } bool executed() const { return _op->executed(); } --- 153,167 ---- // We need to re-think this with SMR ThreadsList. // There is an assumption in the code that the Threads_lock should be // locked during certain phases. { MutexLocker ml(Threads_lock); ! by_vm_thread = _target->handshake_try_process_by_vmThread(); } } while (!poll_for_completed_thread()); DEBUG_ONLY(_op->check_state();) ! log_handshake_info(start_time_ns, _op->name(), 1, by_vm_thread ? 1 : 0); } VMOp_Type type() const { return VMOp_HandshakeOneThread; } bool executed() const { return _op->executed(); }
*** 181,195 **** set_handshake(thr); number_of_threads_issued++; } if (number_of_threads_issued < 1) { ! log_handshake_info(start_time_ns, _op->name(), 0, 0, " (no threads)"); return; } ! log_trace(handshake)("Threads signaled, begin processing blocked threads by VMThtread"); const jlong start_time = os::elapsed_counter(); int number_of_threads_completed = 0; do { // Check if handshake operation has timed out if (handshake_has_timed_out(start_time)) { --- 186,200 ---- set_handshake(thr); number_of_threads_issued++; } if (number_of_threads_issued < 1) { ! log_handshake_info(start_time_ns, _op->name(), 0, 0); return; } ! log_trace(handshake)("Threads signaled, begin processing blocked threads by VMThread"); const jlong start_time = os::elapsed_counter(); int number_of_threads_completed = 0; do { // Check if handshake operation has timed out if (handshake_has_timed_out(start_time)) {
*** 206,216 **** jtiwh.rewind(); MutexLocker ml(Threads_lock); for (JavaThread *thr = jtiwh.next(); thr != NULL; thr = jtiwh.next()) { // A new thread on the ThreadsList will not have an operation, // hence it is skipped in handshake_process_by_vmthread. ! if (thr->handshake_process_by_vmthread()) { handshake_executed_by_vm_thread++; } } } --- 211,221 ---- jtiwh.rewind(); MutexLocker ml(Threads_lock); for (JavaThread *thr = jtiwh.next(); thr != NULL; thr = jtiwh.next()) { // A new thread on the ThreadsList will not have an operation, // hence it is skipped in handshake_process_by_vmthread. ! if (thr->handshake_try_process_by_vmThread()) { handshake_executed_by_vm_thread++; } } }
*** 221,231 **** } while (number_of_threads_issued > number_of_threads_completed); assert(number_of_threads_issued == number_of_threads_completed, "Must be the same"); DEBUG_ONLY(_op->check_state();) ! log_handshake_info(start_time_ns, _op->name(), number_of_threads_issued, handshake_executed_by_vm_thread, ""); } VMOp_Type type() const { return VMOp_HandshakeAllThreads; } }; --- 226,236 ---- } while (number_of_threads_issued > number_of_threads_completed); assert(number_of_threads_issued == number_of_threads_completed, "Must be the same"); DEBUG_ONLY(_op->check_state();) ! log_handshake_info(start_time_ns, _op->name(), number_of_threads_issued, handshake_executed_by_vm_thread); } VMOp_Type type() const { return VMOp_HandshakeAllThreads; } };
*** 376,386 **** } _semaphore.signal(); return false; } ! bool HandshakeState::process_by_vmthread(JavaThread* target) { assert(Thread::current()->is_VM_thread(), "should call from vm thread"); // Threads_lock must be held here, but that is assert()ed in // possibly_vmthread_can_process_handshake(). if (!has_operation()) { --- 381,391 ---- } _semaphore.signal(); return false; } ! bool HandshakeState::try_process_by_vmThread(JavaThread* target) { assert(Thread::current()->is_VM_thread(), "should call from vm thread"); // Threads_lock must be held here, but that is assert()ed in // possibly_vmthread_can_process_handshake(). if (!has_operation()) {
< prev index next >