--- old/src/hotspot/share/runtime/handshake.cpp 2019-11-27 16:36:55.137593050 +0100 +++ new/src/hotspot/share/runtime/handshake.cpp 2019-11-27 16:36:54.811581902 +0100 @@ -51,6 +51,7 @@ 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() { @@ -107,11 +108,15 @@ 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) { +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", - name, targets, targets - vmt_executed, completion_time, extra); + 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 : ""); } } @@ -133,7 +138,7 @@ if (tlh.includes(_target)) { set_handshake(_target); } else { - log_handshake_info(start_time_ns, _op->name(), 0, 0, " (thread dead)"); + log_handshake_info(start_time_ns, _op->name(), 0, 0, "(thread dead)"); return; } @@ -150,11 +155,11 @@ // locked during certain phases. { MutexLocker ml(Threads_lock); - by_vm_thread = _target->handshake_process_by_vmthread(); + 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, ""); + log_handshake_info(start_time_ns, _op->name(), 1, by_vm_thread ? 1 : 0); } VMOp_Type type() const { return VMOp_HandshakeOneThread; } @@ -183,11 +188,11 @@ } if (number_of_threads_issued < 1) { - log_handshake_info(start_time_ns, _op->name(), 0, 0, " (no threads)"); + log_handshake_info(start_time_ns, _op->name(), 0, 0); return; } - log_trace(handshake)("Threads signaled, begin processing blocked threads by VMThtread"); + 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 { @@ -208,7 +213,7 @@ 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()) { + if (thr->handshake_try_process_by_vmThread()) { handshake_executed_by_vm_thread++; } } @@ -223,7 +228,7 @@ 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, ""); + log_handshake_info(start_time_ns, _op->name(), number_of_threads_issued, handshake_executed_by_vm_thread); } VMOp_Type type() const { return VMOp_HandshakeAllThreads; } @@ -378,7 +383,7 @@ return false; } -bool HandshakeState::process_by_vmthread(JavaThread* target) { +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().