< prev index next >

src/hotspot/share/runtime/handshake.cpp

Print this page

296   }
297   if (current_target != executing_thread) {
298     // Only when the target is not executing the handshake itself.
299     StackWatermarkSet::start_processing(current_target, StackWatermarkKind::gc);
300   }
301   if (_requester != NULL && _requester != executing_thread && _requester->is_Java_thread()) {
302     // The handshake closure may contain oop Handles from the _requester.
303     // We must make sure we can use them.
304     StackWatermarkSet::start_processing(JavaThread::cast(_requester), StackWatermarkKind::gc);
305   }
306 }
307 
308 void HandshakeOperation::do_handshake(JavaThread* thread) {
309   jlong start_time_ns = 0;
310   if (log_is_enabled(Debug, handshake, task)) {
311     start_time_ns = os::javaTimeNanos();
312   }
313 
314   // Only actually execute the operation for non terminated threads.
315   if (!thread->is_terminated()) {
316     NoSafepointVerifier nsv;
317     _handshake_cl->do_thread(thread);
318   }
319 
320   if (start_time_ns != 0) {
321     jlong completion_time = os::javaTimeNanos() - start_time_ns;
322     log_debug(handshake, task)("Operation: %s for thread " PTR_FORMAT ", is_vm_thread: %s, completed in " JLONG_FORMAT " ns",
323                                name(), p2i(thread), BOOL_TO_STR(Thread::current()->is_VM_thread()), completion_time);
324   }
325 
326   // Inform VMThread/Handshaker that we have completed the operation.
327   // When this is executed by the Handshakee we need a release store
328   // here to make sure memory operations executed in the handshake
329   // closure are visible to the VMThread/Handshaker after it reads
330   // that the operation has completed.
331   Atomic::dec(&_pending_threads);
332   // Trailing fence, used to make sure removal of the operation strictly
333   // happened after we completed the operation.
334 
335   // It is no longer safe to refer to 'this' as the VMThread/Handshaker may have destroyed this operation
336 }

393 }
394 
395 void Handshake::execute(AsyncHandshakeClosure* hs_cl, JavaThread* target) {
396   jlong start_time_ns = os::javaTimeNanos();
397   AsyncHandshakeOperation* op = new AsyncHandshakeOperation(hs_cl, target, start_time_ns);
398 
399   ThreadsListHandle tlh;
400   if (tlh.includes(target)) {
401     target->handshake_state()->add_operation(op);
402   } else {
403     log_handshake_info(start_time_ns, op->name(), 0, 0, "(thread dead)");
404     delete op;
405   }
406 }
407 
408 HandshakeState::HandshakeState(JavaThread* target) :
409   _handshakee(target),
410   _queue(),
411   _lock(Monitor::nosafepoint, "HandshakeState_lock"),
412   _active_handshaker(),

413   _suspended(false),
414   _async_suspend_handshake(false)
415 {
416 }
417 
418 void HandshakeState::add_operation(HandshakeOperation* op) {
419   // Adds are done lock free and so is arming.
420   _queue.push(op);
421   SafepointMechanism::arm_local_poll_release(_handshakee);
422 }
423 
424 bool HandshakeState::operation_pending(HandshakeOperation* op) {
425   MutexLocker ml(&_lock, Mutex::_no_safepoint_check_flag);
426   MatchOp mo(op);
427   return _queue.contains(mo);
428 }
429 
430 static bool no_suspend_filter(HandshakeOperation* op) {
431   return !op->is_suspend();
432 }
433 
434 HandshakeOperation* HandshakeState::get_op_for_self(bool allow_suspend) {
435   assert(_handshakee == Thread::current(), "Must be called by self");
436   assert(_lock.owned_by_self(), "Lock must be held");
437   if (allow_suspend) {
438     return _queue.peek();
439   } else {
440     return _queue.peek(no_suspend_filter);
441   }
442 }
443 
444 static bool non_self_queue_filter(HandshakeOperation* op) {
445   return !op->is_async();



446 }
447 
448 bool HandshakeState::have_non_self_executable_operation() {
449   assert(_handshakee != Thread::current(), "Must not be called by self");
450   assert(_lock.owned_by_self(), "Lock must be held");
451   return _queue.contains(non_self_queue_filter);
452 }
453 
454 bool HandshakeState::has_a_non_suspend_operation() {
455   MutexLocker ml(&_lock, Mutex::_no_safepoint_check_flag);
456   return _queue.contains(no_suspend_filter);
457 }
458 
459 HandshakeOperation* HandshakeState::get_op() {
460   assert(_handshakee != Thread::current(), "Must not be called by self");
461   assert(_lock.owned_by_self(), "Lock must be held");
462   return _queue.peek(non_self_queue_filter);
463 };
464 
465 void HandshakeState::remove_op(HandshakeOperation* op) {
466   assert(_lock.owned_by_self(), "Lock must be held");
467   MatchOp mo(op);
468   HandshakeOperation* ret = _queue.pop(mo);
469   assert(ret == op, "Popped op must match requested op");
470 };
471 
472 bool HandshakeState::process_by_self(bool allow_suspend) {
473   assert(Thread::current() == _handshakee, "should call from _handshakee");
474   assert(!_handshakee->is_terminated(), "should not be a terminated thread");
475   assert(_handshakee->thread_state() != _thread_blocked, "should not be in a blocked state");
476   assert(_handshakee->thread_state() != _thread_in_native, "should not be in native");
477 
478   ThreadInVMForHandshake tivm(_handshakee);
479   // Handshakes cannot safely safepoint.
480   // The exception to this rule is the asynchronous suspension handshake.
481   // It by-passes the NSV by manually doing the transition.
482   NoSafepointVerifier nsv;
483 
484   while (has_operation()) {
485     MutexLocker ml(&_lock, Mutex::_no_safepoint_check_flag);
486 
487     HandshakeOperation* op = get_op_for_self(allow_suspend);
488     if (op != NULL) {
489       assert(op->_target == NULL || op->_target == Thread::current(), "Wrong thread");
490       bool async = op->is_async();
491       log_trace(handshake)("Proc handshake %s " INTPTR_FORMAT " on " INTPTR_FORMAT " by self",
492                            async ? "asynchronous" : "synchronous", p2i(op), p2i(_handshakee));
493       op->prepare(_handshakee, _handshakee);
494       if (!async) {
495         HandleMark hm(_handshakee);
496         PreserveExceptionMark pem(_handshakee);
497         op->do_handshake(_handshakee); // acquire, op removed after
498         remove_op(op);
499       } else {
500         // An asynchronous handshake may put the JavaThread in blocked state (safepoint safe).
501         // The destructor ~PreserveExceptionMark touches the exception oop so it must not be executed,
502         // since a safepoint may be in-progress when returning from the async handshake.

597   op->do_handshake(_handshakee); // acquire, op removed after
598   set_active_handshaker(NULL);
599   remove_op(op);
600 
601   _lock.unlock();
602 
603   log_trace(handshake)("%s(" INTPTR_FORMAT ") executed an op for JavaThread: " INTPTR_FORMAT " %s target op: " INTPTR_FORMAT,
604                        current_thread->is_VM_thread() ? "VM Thread" : "JavaThread",
605                        p2i(current_thread), p2i(_handshakee),
606                        op == match_op ? "including" : "excluding", p2i(match_op));
607 
608   return op == match_op ? HandshakeState::_succeeded : HandshakeState::_processed;
609 }
610 
611 void HandshakeState::do_self_suspend() {
612   assert(Thread::current() == _handshakee, "should call from _handshakee");
613   assert(_lock.owned_by_self(), "Lock must be held");
614   assert(!_handshakee->has_last_Java_frame() || _handshakee->frame_anchor()->walkable(), "should have walkable stack");
615   assert(_handshakee->thread_state() == _thread_blocked, "Caller should have transitioned to _thread_blocked");
616 
617   while (is_suspended()) {

618     log_trace(thread, suspend)("JavaThread:" INTPTR_FORMAT " suspended", p2i(_handshakee));
619     _lock.wait_without_safepoint_check();
620   }
621   log_trace(thread, suspend)("JavaThread:" INTPTR_FORMAT " resumed", p2i(_handshakee));
622 }
623 
624 // This is the closure that prevents a suspended JavaThread from
625 // escaping the suspend request.
626 class ThreadSelfSuspensionHandshake : public AsyncHandshakeClosure {
627  public:
628   ThreadSelfSuspensionHandshake() : AsyncHandshakeClosure("ThreadSelfSuspensionHandshake") {}
629   void do_thread(Thread* thr) {
630     JavaThread* current = JavaThread::cast(thr);
631     assert(current == Thread::current(), "Must be self executed.");
632     JavaThreadState jts = current->thread_state();
633 
634     current->set_thread_state(_thread_blocked);
635     current->handshake_state()->do_self_suspend();
636     current->set_thread_state(jts);
637     current->handshake_state()->set_async_suspend_handshake(false);
638   }
639   virtual bool is_suspend() { return true; }
640 };
641 
642 bool HandshakeState::suspend_with_handshake() {
643   assert(_handshakee->threadObj() != NULL, "cannot suspend with a NULL threadObj");

644   if (_handshakee->is_exiting()) {
645     log_trace(thread, suspend)("JavaThread:" INTPTR_FORMAT " exiting", p2i(_handshakee));
646     return false;
647   }



648   if (has_async_suspend_handshake()) {
649     if (is_suspended()) {
650       // Target is already suspended.
651       log_trace(thread, suspend)("JavaThread:" INTPTR_FORMAT " already suspended", p2i(_handshakee));
652       return false;
653     } else {
654       // Target is going to wake up and leave suspension.
655       // Let's just stop the thread from doing that.
656       log_trace(thread, suspend)("JavaThread:" INTPTR_FORMAT " re-suspended", p2i(_handshakee));
657       set_suspended(true);
658       return true;







659     }
660   }
661   // no suspend request
662   assert(!is_suspended(), "cannot be suspended without a suspend request");
663   // Thread is safe, so it must execute the request, thus we can count it as suspended
664   // from this point.
665   set_suspended(true);








666   set_async_suspend_handshake(true);
667   log_trace(thread, suspend)("JavaThread:" INTPTR_FORMAT " suspended, arming ThreadSuspension", p2i(_handshakee));
668   ThreadSelfSuspensionHandshake* ts = new ThreadSelfSuspensionHandshake();
669   Handshake::execute(ts, _handshakee);
670   return true;
671 }
672 
673 // This is the closure that synchronously honors the suspend request.
674 class SuspendThreadHandshake : public HandshakeClosure {
675   bool _did_suspend;

676 public:
677   SuspendThreadHandshake() : HandshakeClosure("SuspendThread"), _did_suspend(false) {}
678   void do_thread(Thread* thr) {
679     JavaThread* target = JavaThread::cast(thr);
680     _did_suspend = target->handshake_state()->suspend_with_handshake();
681   }
682   bool did_suspend() { return _did_suspend; }
683 };
684 
685 bool HandshakeState::suspend() {

686   JavaThread* self = JavaThread::current();
687   if (_handshakee == self) {
688     // If target is the current thread we can bypass the handshake machinery
689     // and just suspend directly
690     ThreadBlockInVM tbivm(self);
691     MutexLocker ml(&_lock, Mutex::_no_safepoint_check_flag);
692     set_suspended(true);
693     do_self_suspend();
694     return true;
695   } else {
696     SuspendThreadHandshake st;
697     Handshake::execute(&st, _handshakee);
698     return st.did_suspend();
699   }
700 }
701 
702 bool HandshakeState::resume() {
703   if (!is_suspended()) {
704     return false;
705   }
706   MutexLocker ml(&_lock, Mutex::_no_safepoint_check_flag);
707   if (!is_suspended()) {
708     assert(!_handshakee->is_suspended(), "cannot be suspended without a suspend request");
709     return false;
710   }
711   // Resume the thread.
712   set_suspended(false);
713   _lock.notify();
714   return true;
715 }































296   }
297   if (current_target != executing_thread) {
298     // Only when the target is not executing the handshake itself.
299     StackWatermarkSet::start_processing(current_target, StackWatermarkKind::gc);
300   }
301   if (_requester != NULL && _requester != executing_thread && _requester->is_Java_thread()) {
302     // The handshake closure may contain oop Handles from the _requester.
303     // We must make sure we can use them.
304     StackWatermarkSet::start_processing(JavaThread::cast(_requester), StackWatermarkKind::gc);
305   }
306 }
307 
308 void HandshakeOperation::do_handshake(JavaThread* thread) {
309   jlong start_time_ns = 0;
310   if (log_is_enabled(Debug, handshake, task)) {
311     start_time_ns = os::javaTimeNanos();
312   }
313 
314   // Only actually execute the operation for non terminated threads.
315   if (!thread->is_terminated()) {
316     //NoSafepointVerifier nsv;
317     _handshake_cl->do_thread(thread);
318   }
319 
320   if (start_time_ns != 0) {
321     jlong completion_time = os::javaTimeNanos() - start_time_ns;
322     log_debug(handshake, task)("Operation: %s for thread " PTR_FORMAT ", is_vm_thread: %s, completed in " JLONG_FORMAT " ns",
323                                name(), p2i(thread), BOOL_TO_STR(Thread::current()->is_VM_thread()), completion_time);
324   }
325 
326   // Inform VMThread/Handshaker that we have completed the operation.
327   // When this is executed by the Handshakee we need a release store
328   // here to make sure memory operations executed in the handshake
329   // closure are visible to the VMThread/Handshaker after it reads
330   // that the operation has completed.
331   Atomic::dec(&_pending_threads);
332   // Trailing fence, used to make sure removal of the operation strictly
333   // happened after we completed the operation.
334 
335   // It is no longer safe to refer to 'this' as the VMThread/Handshaker may have destroyed this operation
336 }

393 }
394 
395 void Handshake::execute(AsyncHandshakeClosure* hs_cl, JavaThread* target) {
396   jlong start_time_ns = os::javaTimeNanos();
397   AsyncHandshakeOperation* op = new AsyncHandshakeOperation(hs_cl, target, start_time_ns);
398 
399   ThreadsListHandle tlh;
400   if (tlh.includes(target)) {
401     target->handshake_state()->add_operation(op);
402   } else {
403     log_handshake_info(start_time_ns, op->name(), 0, 0, "(thread dead)");
404     delete op;
405   }
406 }
407 
408 HandshakeState::HandshakeState(JavaThread* target) :
409   _handshakee(target),
410   _queue(),
411   _lock(Monitor::nosafepoint, "HandshakeState_lock"),
412   _active_handshaker(),
413   _caller(nullptr),
414   _suspended(false),
415   _async_suspend_handshake(false)
416 {
417 }
418 
419 void HandshakeState::add_operation(HandshakeOperation* op) {
420   // Adds are done lock free and so is arming.
421   _queue.push(op);
422   SafepointMechanism::arm_local_poll_release(_handshakee);
423 }
424 
425 bool HandshakeState::operation_pending(HandshakeOperation* op) {
426   MutexLocker ml(&_lock, Mutex::_no_safepoint_check_flag);
427   MatchOp mo(op);
428   return _queue.contains(mo);
429 }
430 
431 static bool no_suspend_filter(HandshakeOperation* op) {
432   return !op->is_suspend();
433 }
434 
435 HandshakeOperation* HandshakeState::get_op_for_self(bool allow_suspend) {
436   assert(_handshakee == Thread::current(), "Must be called by self");
437   assert(_lock.owned_by_self(), "Lock must be held");
438   if (allow_suspend) {
439     return _queue.peek();
440   } else {
441     return _queue.peek(no_suspend_filter);
442   }
443 }
444 
445 bool HandshakeState::non_self_queue_filter(HandshakeOperation* op) {
446   if (op->_handshake_cl->can_be_processed_by(Thread::current())) {
447     return !op->is_async();
448   }
449   return false;
450 }
451 
452 bool HandshakeState::have_non_self_executable_operation() {
453   assert(_handshakee != Thread::current(), "Must not be called by self");
454   assert(_lock.owned_by_self(), "Lock must be held");
455   return _queue.contains(non_self_queue_filter);
456 }
457 
458 bool HandshakeState::has_a_non_suspend_operation() {
459   MutexLocker ml(&_lock, Mutex::_no_safepoint_check_flag);
460   return _queue.contains(no_suspend_filter);
461 }
462 
463 HandshakeOperation* HandshakeState::get_op() {
464   assert(_handshakee != Thread::current(), "Must not be called by self");
465   assert(_lock.owned_by_self(), "Lock must be held");
466   return _queue.peek(non_self_queue_filter);
467 };
468 
469 void HandshakeState::remove_op(HandshakeOperation* op) {
470   assert(_lock.owned_by_self(), "Lock must be held");
471   MatchOp mo(op);
472   HandshakeOperation* ret = _queue.pop(mo);
473   assert(ret == op, "Popped op must match requested op");
474 };
475 
476 bool HandshakeState::process_by_self(bool allow_suspend) {
477   assert(Thread::current() == _handshakee, "should call from _handshakee");
478   assert(!_handshakee->is_terminated(), "should not be a terminated thread");
479   assert(_handshakee->thread_state() != _thread_blocked, "should not be in a blocked state");
480   assert(_handshakee->thread_state() != _thread_in_native, "should not be in native");
481 
482   ThreadInVMForHandshake tivm(_handshakee);
483   // Handshakes cannot safely safepoint.
484   // The exception to this rule is the asynchronous suspension handshake.
485   // It by-passes the NSV by manually doing the transition.
486   //NoSafepointVerifier nsv;
487 
488   while (has_operation()) {
489     MutexLocker ml(&_lock, Mutex::_no_safepoint_check_flag);
490 
491     HandshakeOperation* op = get_op_for_self(allow_suspend);
492     if (op != NULL) {
493       assert(op->_target == NULL || op->_target == Thread::current(), "Wrong thread");
494       bool async = op->is_async();
495       log_trace(handshake)("Proc handshake %s " INTPTR_FORMAT " on " INTPTR_FORMAT " by self",
496                            async ? "asynchronous" : "synchronous", p2i(op), p2i(_handshakee));
497       op->prepare(_handshakee, _handshakee);
498       if (!async) {
499         HandleMark hm(_handshakee);
500         PreserveExceptionMark pem(_handshakee);
501         op->do_handshake(_handshakee); // acquire, op removed after
502         remove_op(op);
503       } else {
504         // An asynchronous handshake may put the JavaThread in blocked state (safepoint safe).
505         // The destructor ~PreserveExceptionMark touches the exception oop so it must not be executed,
506         // since a safepoint may be in-progress when returning from the async handshake.

601   op->do_handshake(_handshakee); // acquire, op removed after
602   set_active_handshaker(NULL);
603   remove_op(op);
604 
605   _lock.unlock();
606 
607   log_trace(handshake)("%s(" INTPTR_FORMAT ") executed an op for JavaThread: " INTPTR_FORMAT " %s target op: " INTPTR_FORMAT,
608                        current_thread->is_VM_thread() ? "VM Thread" : "JavaThread",
609                        p2i(current_thread), p2i(_handshakee),
610                        op == match_op ? "including" : "excluding", p2i(match_op));
611 
612   return op == match_op ? HandshakeState::_succeeded : HandshakeState::_processed;
613 }
614 
615 void HandshakeState::do_self_suspend() {
616   assert(Thread::current() == _handshakee, "should call from _handshakee");
617   assert(_lock.owned_by_self(), "Lock must be held");
618   assert(!_handshakee->has_last_Java_frame() || _handshakee->frame_anchor()->walkable(), "should have walkable stack");
619   assert(_handshakee->thread_state() == _thread_blocked, "Caller should have transitioned to _thread_blocked");
620 
621   while (is_suspended_or_blocked()) {
622     JVMTI_ONLY(assert(!_handshakee->is_in_VTMT(), "no suspend allowed in VTMT transition");)
623     log_trace(thread, suspend)("JavaThread:" INTPTR_FORMAT " suspended", p2i(_handshakee));
624     _lock.wait_without_safepoint_check();
625   }
626   log_trace(thread, suspend)("JavaThread:" INTPTR_FORMAT " resumed", p2i(_handshakee));
627 }
628 
629 // This is the closure that prevents a suspended JavaThread from
630 // escaping the suspend request.
631 class ThreadSelfSuspensionHandshake : public AsyncHandshakeClosure {
632  public:
633   ThreadSelfSuspensionHandshake() : AsyncHandshakeClosure("ThreadSelfSuspensionHandshake") {}
634   void do_thread(Thread* thr) {
635     JavaThread* current = JavaThread::cast(thr);
636     assert(current == Thread::current(), "Must be self executed.");
637     JavaThreadState jts = current->thread_state();
638 
639     current->set_thread_state(_thread_blocked);
640     current->handshake_state()->do_self_suspend();
641     current->set_thread_state(jts);
642     current->handshake_state()->set_async_suspend_handshake(false);
643   }
644   virtual bool is_suspend() { return true; }
645 };
646 
647 bool HandshakeState::suspend_with_handshake(JavaThread* caller) {
648   // This tested for _handshakee->threadObj() != NULL as well, but the test doesn't work
649   // for that.  TODO: can you suspend a thread during initialization ?
650   if (_handshakee->is_exiting()) {
651     log_trace(thread, suspend)("JavaThread:" INTPTR_FORMAT " exiting", p2i(_handshakee));
652     return false;
653   }
654   bool should_block = caller != nullptr;
655   bool should_suspend = caller == nullptr;
656 
657   if (has_async_suspend_handshake()) {
658     if ((is_suspended() && should_suspend) || (is_blocked() && should_block)) {
659       log_trace(thread, suspend)("JavaThread:" INTPTR_FORMAT " already suspended or blocked", p2i(_handshakee));

660       return false;
661     } else if (should_suspend) {
662       // Target is going to wake up and leave suspension.
663       // Let's just stop the thread from doing that.
664       log_trace(thread, suspend)("JavaThread:" INTPTR_FORMAT " re-suspended", p2i(_handshakee));
665       set_suspended(true);
666       return true;
667     } else {
668       assert(should_block, "should block");
669       // Target is going to wake up and leave blocking.
670       // Let's just stop the thread from doing that.
671       log_trace(thread, suspend)("JavaThread:" INTPTR_FORMAT " re-blocked", p2i(_handshakee));
672       set_caller_thread(caller);
673       return true;
674     }
675   }
676 

677   // Thread is safe, so it must execute the request, thus we can count it as suspended
678   // or blocked from this point.
679   if (should_suspend) {
680     // no suspend request
681     assert(!is_suspended(), "cannot be suspended without a request");
682     set_suspended(true);
683   } else {
684     assert(!is_blocked(), "cannot be blocked without a request");
685     set_caller_thread(caller);
686   }
687 
688   set_async_suspend_handshake(true);
689   log_trace(thread, suspend)("JavaThread:" INTPTR_FORMAT " suspended, arming ThreadSuspension", p2i(_handshakee));
690   ThreadSelfSuspensionHandshake* ts = new ThreadSelfSuspensionHandshake();
691   Handshake::execute(ts, _handshakee);
692   return true;
693 }
694 
695 // This is the closure that synchronously honors the suspend request.
696 class SuspendThreadHandshake : public HandshakeClosure {
697   JavaThread* _caller;
698   bool        _did_suspend;
699 public:
700   SuspendThreadHandshake(JavaThread* caller) : HandshakeClosure("SuspendThread"), _caller(caller), _did_suspend(false) {}
701   void do_thread(Thread* thr) {
702     JavaThread* target = JavaThread::cast(thr);
703     _did_suspend = target->handshake_state()->suspend_with_handshake(_caller);
704   }
705   bool did_suspend() { return _did_suspend; }
706 };
707 
708 bool HandshakeState::suspend() {
709   JVMTI_ONLY(assert(!_handshakee->is_in_VTMT(), "no suspend allowed in VTMT transition");)
710   JavaThread* self = JavaThread::current();
711   if (_handshakee == self) {
712     // If target is the current thread we can bypass the handshake machinery
713     // and just suspend directly
714     ThreadBlockInVM tbivm(self);
715     MutexLocker ml(&_lock, Mutex::_no_safepoint_check_flag);
716     set_suspended(true);
717     do_self_suspend();
718     return true;
719   } else {
720     SuspendThreadHandshake st(nullptr);
721     Handshake::execute(&st, _handshakee);
722     return st.did_suspend();
723   }
724 }
725 
726 bool HandshakeState::resume() {
727   if (!is_suspended()) {
728     return false;
729   }
730   MutexLocker ml(&_lock, Mutex::_no_safepoint_check_flag);
731   if (!is_suspended()) {
732     assert(!_handshakee->is_suspended(), "cannot be suspended without a suspend request");
733     return false;
734   }
735   // Resume the thread.
736   set_suspended(false);
737   _lock.notify();
738   return true;
739 }
740 
741 // One thread blocks execution of another thread until it resumes it.  This is similar to
742 // suspend, and much of the code is shared but it's a separate state from being suspended.
743 // The commonality is that the thread is self-suspended and that thread waits for both
744 // conditions to clear.
745 bool HandshakeState::block_suspend(JavaThread* caller) {
746   assert(caller == JavaThread::current(), "caller must be current thread");
747 
748   SuspendThreadHandshake st(caller);
749   Handshake::execute(&st, _handshakee);
750   bool suspended = st.did_suspend();
751   return suspended;
752 }
753 
754 bool HandshakeState::continue_resume(JavaThread* caller) {
755   assert(caller == JavaThread::current(), "caller must be current thread");
756 
757   // If caller is non-null only resume blocked thread if it's the caller
758   if (!is_blocked() || caller_thread() != caller) {
759     return false;
760   }
761   MutexLocker ml(&_lock, Mutex::_no_safepoint_check_flag);
762   assert(is_blocked() && caller_thread() == caller,
763          "this is the only thread that can continue this thread");
764 
765   // Resume the thread.
766   set_caller_thread(nullptr); // !is_blocked()
767   _lock.notify();
768   return true;
769 }
< prev index next >