本文整理汇总了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);
}
//.........这里部分代码省略.........