Exemple #1
0
void BlockScope::addUse(BlockScopeRawPtr user, int useKinds) {
  if (is(ClassScope) ? static_cast<HPHP::ClassScope*>(this)->isUserClass() :
      is(FunctionScope) &&
      static_cast<HPHP::FunctionScope*>(this)->isUserFunction()) {

    if (user.get() == this) {
      m_selfUser |= useKinds;
      return;
    }

    Lock lock(s_depsMutex);
    Lock l2(s_jobStateMutex);
    std::pair<BlockScopeRawPtrFlagsHashMap::iterator,bool> val =
      m_userMap.insert(BlockScopeRawPtrFlagsHashMap::value_type(user,
                                                                useKinds));
    if (val.second) {
      m_orderedUsers.push_back(&*val.first);
      user->m_orderedDeps.push_back(
          std::make_pair(BlockScopeRawPtr(this), &(val.first->second)));
      ASSERT(user->getMark() != BlockScope::MarkReady &&
             user->getMark() != BlockScope::MarkWaiting);
    } else {
      val.first->second |= useKinds;
    }
  }
}
Exemple #2
0
bool BlockScope::hasUser(BlockScopeRawPtr user, int useKinds) const {
  if (is(ClassScope) ?
        static_cast<const HPHP::ClassScope*>(this)->isUserClass() :
        is(FunctionScope) &&
        static_cast<const HPHP::FunctionScope*>(this)->isUserFunction()) {

    if (user.get() == this) {
      return m_selfUser & useKinds;
    }

    Lock lock(s_depsMutex);
    const auto it = m_userMap.find(user);
    return it != m_userMap.end() && it->second & useKinds;
  }
  return true; // builtins/systems always have a user of anybody
}
Exemple #3
0
void ClassScope::setVolatile() {
  if (!m_volatile) {
    m_volatile = true;
    Lock lock(s_depsMutex);
    const BlockScopeRawPtrFlagsVec &orderedUsers = getOrderedUsers();
    for (BlockScopeRawPtrFlagsVec::const_iterator it = orderedUsers.begin(),
           end = orderedUsers.end(); it != end; ++it) {
      BlockScopeRawPtrFlagsVec::value_type pf = *it;
      if (pf->second & UseKindParentRef) {
        BlockScopeRawPtr scope = pf->first;
        if (scope->is(BlockScope::ClassScope)) {
          ((HPHP::ClassScope*)scope.get())->setVolatile();
        }
      }
    }
  }
}
Exemple #4
0
void BlockScope::addUse(BlockScopeRawPtr user, int useKinds) {
  if ((is(ClassScope) || is(FunctionScope)) && !isBuiltin()) {

    if (user.get() == this) {
      m_selfUser |= useKinds;
      return;
    }

    Lock lock(s_depsMutex);
    Lock l2(s_jobStateMutex);
    auto val = m_userMap.emplace(user, useKinds);
    if (val.second) {
      m_orderedUsers.push_back(&*val.first);
      user->m_orderedDeps.emplace_back(BlockScopeRawPtr{this},
                                       &(val.first->second));
      assert(user->getMark() != BlockScope::MarkReady &&
             user->getMark() != BlockScope::MarkWaiting);
    } else {
      val.first->second |= useKinds;
    }
  }
}