当前位置: 首页>>代码示例>>C++>>正文


C++ SrcKey::setOffset方法代码示例

本文整理汇总了C++中SrcKey::setOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ SrcKey::setOffset方法的具体用法?C++ SrcKey::setOffset怎么用?C++ SrcKey::setOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SrcKey的用法示例。


在下文中一共展示了SrcKey::setOffset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: selectTraceletLegacy

RegionDescPtr selectTraceletLegacy(Offset initSpOffset,
                                   const Tracelet& tlet) {
  typedef RegionDesc::Block Block;

  auto const region = std::make_shared<RegionDesc>();
  SrcKey sk(tlet.m_sk);
  auto const unit = tlet.func()->unit();

  const Func* topFunc = nullptr;
  Block* curBlock = nullptr;
  auto newBlock = [&](SrcKey start, Offset spOff) {
    assert(curBlock == nullptr || curBlock->length() > 0);
    region->blocks.push_back(
      std::make_shared<Block>(
        start.func(), start.resumed(), start.offset(), 0, spOff));
    Block* newCurBlock = region->blocks.back().get();
    if (curBlock) {
      region->addArc(curBlock->id(), newCurBlock->id());
    }
    curBlock = newCurBlock;
  };
  newBlock(sk, initSpOffset);

  for (auto ni = tlet.m_instrStream.first; ni; ni = ni->next) {
    assert(sk == ni->source);
    assert(ni->unit() == unit);

    Offset curSpOffset = initSpOffset + ni->stackOffset;

    curBlock->addInstruction();
    if ((curBlock->length() == 1 && ni->funcd != nullptr) ||
        ni->funcd != topFunc) {
      topFunc = ni->funcd;
      curBlock->setKnownFunc(sk, topFunc);
    }

    if (ni->calleeTrace && !ni->calleeTrace->m_inliningFailed) {
      assert(ni->op() == Op::FCall || ni->op() == Op::FCallD);
      assert(ni->funcd == ni->calleeTrace->func());
      // This should be translated as an inlined call. Insert the blocks of the
      // callee in the region.
      auto const& callee = *ni->calleeTrace;
      curBlock->setInlinedCallee(ni->funcd);
      SrcKey cSk = callee.m_sk;
      auto const cUnit = callee.func()->unit();

      // Note: the offsets of the inlined blocks aren't currently read
      // for anything, so it's unclear whether they should be relative
      // to the main function entry or the inlined function.  We're
      // just doing this for now.
      auto const initInliningSpOffset = curSpOffset;
      newBlock(cSk,
               initInliningSpOffset + callee.m_instrStream.first->stackOffset);

      for (auto cni = callee.m_instrStream.first; cni; cni = cni->next) {
        // Sometimes inlined callees trace through jumps that have a
        // known taken/non-taken state based on the calling context:
        if (cni->nextOffset != kInvalidOffset) {
          curBlock->addInstruction();
          cSk.setOffset(cni->nextOffset);
          newBlock(cSk, initInliningSpOffset + ni->stackOffset);
          continue;
        }

        assert(cSk == cni->source);
        assert(cni->op() == OpRetC ||
               cni->op() == OpRetV ||
               cni->op() == OpCreateCont ||
               cni->op() == OpAwait ||
               cni->op() == OpNativeImpl ||
               !instrIsNonCallControlFlow(cni->op()));

        curBlock->addInstruction();
        cSk.advance(cUnit);
      }

      if (ni->next) {
        sk.advance(unit);
        newBlock(sk, curSpOffset);
      }
      continue;
    }

    if (!ni->noOp && isFPassStar(ni->op())) {
      curBlock->setParamByRef(sk, ni->preppedByRef);
    }

    if (ni->next && isUnconditionalJmp(ni->op())) {
      // A Jmp that isn't the final instruction in a Tracelet means we traced
      // through a forward jump in analyze. Update sk to point to the next NI
      // in the stream.
      auto dest = ni->offset() + ni->imm[0].u_BA;
      assert(dest > sk.offset()); // We only trace for forward Jmps for now.
      sk.setOffset(dest);

      // The Jmp terminates this block.
      newBlock(sk, curSpOffset);
    } else {
      sk.advance(unit);
    }
//.........这里部分代码省略.........
开发者ID:guns2410,项目名称:hhvm,代码行数:101,代码来源:region-selection.cpp


注:本文中的SrcKey::setOffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。