8287281: adjust guarantee in Handshake::execute for the case of target thread being current
Reviewed-by: rehn, pchilanomate, dholmes, dcubed
This commit is contained in:
parent
64782a7524
commit
9dc9a64fa4
@ -396,13 +396,8 @@ void JvmtiEnvThreadState::reset_current_location(jvmtiEvent event_type, bool ena
|
||||
// The java thread stack may not be walkable for a running thread
|
||||
// so get current location with direct handshake.
|
||||
GetCurrentLocationClosure op;
|
||||
Thread *current = Thread::current();
|
||||
if (thread->is_handshake_safe_for(current)) {
|
||||
op.do_thread(thread);
|
||||
} else {
|
||||
Handshake::execute(&op, thread);
|
||||
guarantee(op.completed(), "Handshake failed. Target thread is not alive?");
|
||||
}
|
||||
Handshake::execute(&op, thread);
|
||||
guarantee(op.completed(), "Handshake failed. Target thread is not alive?");
|
||||
op.get_current_location(&method_id, &bci);
|
||||
set_current_location(method_id, bci);
|
||||
}
|
||||
|
@ -353,12 +353,11 @@ void VM_ChangeSingleStep::doit() {
|
||||
|
||||
|
||||
void JvmtiEventControllerPrivate::enter_interp_only_mode(JvmtiThreadState *state) {
|
||||
assert(state != NULL, "sanity check");
|
||||
EC_TRACE(("[%s] # Entering interpreter only mode",
|
||||
JvmtiTrace::safe_get_thread_name(state->get_thread_or_saved())));
|
||||
JavaThread *target = state->get_thread();
|
||||
Thread *current = Thread::current();
|
||||
|
||||
assert(state != NULL, "sanity check");
|
||||
if (state->is_pending_interp_only_mode()) {
|
||||
return; // An EnterInterpOnlyModeClosure handshake is already pending for execution.
|
||||
}
|
||||
@ -368,13 +367,8 @@ void JvmtiEventControllerPrivate::enter_interp_only_mode(JvmtiThreadState *state
|
||||
return; // EnterInterpOnlyModeClosure will be executed right after mount.
|
||||
}
|
||||
EnterInterpOnlyModeClosure hs;
|
||||
if (target->is_handshake_safe_for(current)) {
|
||||
hs.do_thread(target);
|
||||
} else {
|
||||
assert(state->get_thread() != NULL, "sanity check");
|
||||
Handshake::execute(&hs, target);
|
||||
guarantee(hs.completed(), "Handshake failed: Target thread is not alive?");
|
||||
}
|
||||
Handshake::execute(&hs, target);
|
||||
guarantee(hs.completed(), "Handshake failed: Target thread is not alive?");
|
||||
}
|
||||
|
||||
|
||||
|
@ -351,12 +351,17 @@ void Handshake::execute(HandshakeClosure* hs_cl, JavaThread* target) {
|
||||
}
|
||||
|
||||
void Handshake::execute(HandshakeClosure* hs_cl, ThreadsListHandle* tlh, JavaThread* target) {
|
||||
JavaThread* self = JavaThread::current();
|
||||
HandshakeOperation op(hs_cl, target, Thread::current());
|
||||
guarantee(target != nullptr, "must be");
|
||||
|
||||
JavaThread* current = JavaThread::current();
|
||||
if (target == current) {
|
||||
hs_cl->do_thread(target);
|
||||
return;
|
||||
}
|
||||
|
||||
HandshakeOperation op(hs_cl, target, current);
|
||||
|
||||
jlong start_time_ns = os::javaTimeNanos();
|
||||
|
||||
guarantee(target != nullptr, "must be");
|
||||
if (tlh == nullptr) {
|
||||
guarantee(Thread::is_JavaThread_protected_by_TLH(target),
|
||||
"missing ThreadsListHandle in calling context.");
|
||||
@ -389,9 +394,9 @@ void Handshake::execute(HandshakeClosure* hs_cl, ThreadsListHandle* tlh, JavaThr
|
||||
hsy.add_result(pr);
|
||||
// Check for pending handshakes to avoid possible deadlocks where our
|
||||
// target is trying to handshake us.
|
||||
if (SafepointMechanism::should_process(self)) {
|
||||
if (SafepointMechanism::should_process(current)) {
|
||||
// Will not suspend here.
|
||||
ThreadBlockInVM tbivm(self);
|
||||
ThreadBlockInVM tbivm(current);
|
||||
}
|
||||
hsy.process();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user