< prev index next >

src/hotspot/share/runtime/handshake.cpp

Print this page
*** 435,11 ***
  
    target->handshake_state()->add_operation(op);
  }
  
  // Filters
! static bool non_self_executable_filter(HandshakeOperation* op) {
    return !op->is_async();
  }
  static bool no_async_exception_filter(HandshakeOperation* op) {
    return !op->is_async_exception();
  }
--- 435,11 ---
  
    target->handshake_state()->add_operation(op);
  }
  
  // Filters
! static bool handshaker_filter(HandshakeOperation* op) {
    return !op->is_async();
  }
  static bool no_async_exception_filter(HandshakeOperation* op) {
    return !op->is_async_exception();
  }

*** 476,11 ***
    _queue.push(op);
    SafepointMechanism::arm_local_poll_release(_handshakee);
  }
  
  bool HandshakeState::operation_pending(HandshakeOperation* op) {
!   MutexLocker ml(&_lock, Mutex::_no_safepoint_check_flag);
    MatchOp mo(op);
    return _queue.contains(mo);
  }
  
  HandshakeOperation* HandshakeState::get_op_for_self(bool allow_suspend, bool check_async_exception) {
--- 476,11 ---
    _queue.push(op);
    SafepointMechanism::arm_local_poll_release(_handshakee);
  }
  
  bool HandshakeState::operation_pending(HandshakeOperation* op) {
!   ConditionalMutexLocker ml(&_lock, !_lock.owned_by_self(), Mutex::_no_safepoint_check_flag);
    MatchOp mo(op);
    return _queue.contains(mo);
  }
  
  HandshakeOperation* HandshakeState::get_op_for_self(bool allow_suspend, bool check_async_exception) {

*** 530,28 ***
      remove_op(op);
      delete op;
    }
  }
  
! bool HandshakeState::have_non_self_executable_operation() {
    assert(_handshakee != Thread::current(), "Must not be called by self");
    assert(_lock.owned_by_self(), "Lock must be held");
!   return _queue.contains(non_self_executable_filter);
  }
  
! HandshakeOperation* HandshakeState::get_op() {
    assert(_handshakee != Thread::current(), "Must not be called by self");
    assert(_lock.owned_by_self(), "Lock must be held");
!   return _queue.peek(non_self_executable_filter);
! };
  
  void HandshakeState::remove_op(HandshakeOperation* op) {
    assert(_lock.owned_by_self(), "Lock must be held");
    MatchOp mo(op);
    HandshakeOperation* ret = _queue.pop(mo);
    assert(ret == op, "Popped op must match requested op");
! };
  
  bool HandshakeState::process_by_self(bool allow_suspend, bool check_async_exception) {
    assert(Thread::current() == _handshakee, "should call from _handshakee");
    assert(!_handshakee->is_terminated(), "should not be a terminated thread");
  
--- 530,28 ---
      remove_op(op);
      delete op;
    }
  }
  
! bool HandshakeState::has_handshaker_operation() {
    assert(_handshakee != Thread::current(), "Must not be called by self");
    assert(_lock.owned_by_self(), "Lock must be held");
!   return _queue.contains(handshaker_filter);
  }
  
! HandshakeOperation* HandshakeState::get_op_for_handshaker() {
    assert(_handshakee != Thread::current(), "Must not be called by self");
    assert(_lock.owned_by_self(), "Lock must be held");
!   return _queue.peek(handshaker_filter);
! }
  
  void HandshakeState::remove_op(HandshakeOperation* op) {
    assert(_lock.owned_by_self(), "Lock must be held");
    MatchOp mo(op);
    HandshakeOperation* ret = _queue.pop(mo);
    assert(ret == op, "Popped op must match requested op");
! }
  
  bool HandshakeState::process_by_self(bool allow_suspend, bool check_async_exception) {
    assert(Thread::current() == _handshakee, "should call from _handshakee");
    assert(!_handshakee->is_terminated(), "should not be a terminated thread");
  

*** 623,11 ***
    }
    // Operations are added lock free and then the poll is armed.
    // If all handshake operations for the handshakee are finished and someone
    // just adds an operation we may see it here. But if the handshakee is not
    // armed yet it is not safe to proceed.
!   if (have_non_self_executable_operation()) {
      OrderAccess::loadload(); // Matches the implicit storestore in add_operation()
      if (SafepointMechanism::local_poll_armed(_handshakee)) {
        return true;
      }
    }
--- 623,11 ---
    }
    // Operations are added lock free and then the poll is armed.
    // If all handshake operations for the handshakee are finished and someone
    // just adds an operation we may see it here. But if the handshakee is not
    // armed yet it is not safe to proceed.
!   if (has_handshaker_operation()) {
      OrderAccess::loadload(); // Matches the implicit storestore in add_operation()
      if (SafepointMechanism::local_poll_armed(_handshakee)) {
        return true;
      }
    }

*** 659,11 ***
      return HandshakeState::_not_safe;
    }
  
    Thread* current_thread = Thread::current();
  
!   HandshakeOperation* op = get_op();
  
    assert(op != nullptr, "Must have an op");
    assert(SafepointMechanism::local_poll_armed(_handshakee), "Must be");
    assert(op->_target == nullptr || _handshakee == op->_target, "Wrong thread");
  
--- 659,11 ---
      return HandshakeState::_not_safe;
    }
  
    Thread* current_thread = Thread::current();
  
!   HandshakeOperation* op = get_op_for_handshaker();
  
    assert(op != nullptr, "Must have an op");
    assert(SafepointMechanism::local_poll_armed(_handshakee), "Must be");
    assert(op->_target == nullptr || _handshakee == op->_target, "Wrong thread");
  
< prev index next >