本文整理汇总了C++中OffsetSet类的典型用法代码示例。如果您正苦于以下问题:C++ OffsetSet类的具体用法?C++ OffsetSet怎么用?C++ OffsetSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OffsetSet类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: instrSuccOffsets
OffsetSet instrSuccOffsets(Op* opc, const Unit* unit) {
OffsetSet succBcOffs;
Op* bcStart = (Op*)(unit->entry());
if (!instrIsControlFlow(*opc)) {
Offset succOff = opc + instrLen(opc) - bcStart;
succBcOffs.insert(succOff);
return succBcOffs;
}
if (instrAllowsFallThru(*opc)) {
Offset succOff = opc + instrLen(opc) - bcStart;
succBcOffs.insert(succOff);
}
if (isSwitch(*opc)) {
foreachSwitchTarget(opc, [&](Offset& offset) {
succBcOffs.insert(offset + opc - bcStart);
});
} else {
Offset target = instrJumpTarget(bcStart, opc - bcStart);
if (target != InvalidAbsoluteOffset) {
succBcOffs.insert(target);
}
}
return succBcOffs;
}
示例2: instrSuccOffsets
OffsetSet instrSuccOffsets(PC opc, const Unit* unit) {
OffsetSet succBcOffs;
auto const bcStart = unit->entry();
auto const op = peek_op(opc);
if (!instrIsControlFlow(op)) {
Offset succOff = opc + instrLen(opc) - bcStart;
succBcOffs.insert(succOff);
return succBcOffs;
}
if (instrAllowsFallThru(op)) {
Offset succOff = opc + instrLen(opc) - bcStart;
succBcOffs.insert(succOff);
}
if (isSwitch(op)) {
foreachSwitchTarget(opc, [&](Offset offset) {
succBcOffs.insert(offset + opc - bcStart);
});
} else {
Offset target = instrJumpTarget(bcStart, opc - bcStart);
if (target != InvalidAbsoluteOffset) {
succBcOffs.insert(target);
}
}
return succBcOffs;
}
示例3: check
/*
* Checks if the given region is well-formed, which entails the
* following properties:
*
* 1) The region has at least one block.
*
* 2) Each block in the region has a different id.
*
* 3) All arcs involve blocks within the region.
*
* 4) For each arc, the bytecode offset of the dst block must
* possibly follow the execution of the src block.
*
* 5) Each block contains at most one successor corresponding to a
* given SrcKey.
*
* 6) The region doesn't contain any loops, unless JitLoops is
* enabled.
*
* 7) All blocks are reachable from the entry block.
*
* 8) For each block, there must be a path from the entry to it that
* includes only earlier blocks in the region.
*
* 9) The region is topologically sorted unless loops are enabled.
*
* 10) The block-retranslation chains cannot have cycles.
*
*/
bool check(const RegionDesc& region, std::string& error) {
auto bad = [&](const std::string& errorMsg) {
error = errorMsg;
return false;
};
// 1) The region has at least one block.
if (region.empty()) return bad("empty region");
RegionDesc::BlockIdSet blockSet;
for (auto b : region.blocks()) {
auto bid = b->id();
// 2) Each block in the region has a different id.
if (blockSet.count(bid)) {
return bad(folly::sformat("many blocks with id {}", bid));
}
blockSet.insert(bid);
}
for (auto b : region.blocks()) {
auto bid = b->id();
SrcKey lastSk = region.block(bid)->last();
OffsetSet validSuccOffsets = lastSk.succOffsets();
OffsetSet succOffsets;
for (auto succ : region.succs(bid)) {
SrcKey succSk = region.block(succ)->start();
Offset succOffset = succSk.offset();
// 3) All arcs involve blocks within the region.
if (blockSet.count(succ) == 0) {
return bad(folly::sformat("arc with dst not in the region: {} -> {}",
bid, succ));
}
// Checks 4) and 5) below don't make sense for arcs corresponding
// to inlined calls and returns, so skip them in such cases.
// This won't be possible once task #4076399 is done.
if (lastSk.func() != succSk.func()) continue;
// 4) For each arc, the bytecode offset of the dst block must
// possibly follow the execution of the src block.
if (validSuccOffsets.count(succOffset) == 0) {
return bad(folly::sformat("arc with impossible control flow: {} -> {}",
bid, succ));
}
// 5) Each block contains at most one successor corresponding to a
// given SrcKey.
if (succOffsets.count(succOffset) > 0) {
return bad(folly::sformat("block {} has multiple successors with SK {}",
bid, show(succSk)));
}
succOffsets.insert(succOffset);
}
for (auto pred : region.preds(bid)) {
if (blockSet.count(pred) == 0) {
return bad(folly::sformat("arc with src not in the region: {} -> {}",
pred, bid));
}
}
}
// 6) is checked by dfsCheck.
DFSChecker dfsCheck(region);
if (!dfsCheck.check(region.entry()->id())) {
return bad("region is cyclic");
}
// 7) All blocks are reachable from the entry (first) block.
//.........这里部分代码省略.........
示例4: selectHotTrace
RegionDescPtr selectHotTrace(TransID triggerId,
const ProfData* profData,
TransCFG& cfg,
TransIDSet& selectedSet,
TransIDVec* selectedVec) {
auto region = std::make_shared<RegionDesc>();
TransID tid = triggerId;
TransID prevId = kInvalidTransID;
selectedSet.clear();
if (selectedVec) selectedVec->clear();
PostConditions accumPostConds;
// Maps BlockIds to the set of BC offsets for its successor blocks.
// Used to prevent multiple successors with the same SrcKey for now.
// This can go away once task #4157613 is done.
hphp_hash_map<RegionDesc::BlockId, SrcKeySet> succSKSet;
// Maps from BlockIds to accumulated post conditions for that block.
// Used to determine if we can add branch-over edges by checking the
// pre-conditions of the successor block.
hphp_hash_map<RegionDesc::BlockId, PostConditions> blockPostConds;
while (!selectedSet.count(tid)) {
RegionDescPtr blockRegion = profData->transRegion(tid);
if (blockRegion == nullptr) break;
// If the debugger is attached, only allow single-block regions.
if (prevId != kInvalidTransID && isDebuggerAttachedProcess()) {
FTRACE(2, "selectHotTrace: breaking region at Translation {} "
"because of debugger is attached\n", tid);
break;
}
// Break if block is not the first and requires reffiness checks.
// Task #2589970: fix translateRegion to support mid-region reffiness checks
if (prevId != kInvalidTransID) {
auto nRefDeps = blockRegion->blocks[0]->reffinessPreds().size();
if (nRefDeps > 0) {
FTRACE(2, "selectHotTrace: breaking region because of refDeps ({}) at "
"Translation {}\n", nRefDeps, tid);
break;
}
}
// Break if block is not the first and it corresponds to the main
// function body entry. This is to prevent creating multiple
// large regions containing the function body (starting at various
// DV funclets).
if (prevId != kInvalidTransID) {
const Func* func = profData->transFunc(tid);
Offset bcOffset = profData->transStartBcOff(tid);
if (func->base() == bcOffset) {
FTRACE(2, "selectHotTrace: breaking region because reached the main "
"function body entry at Translation {} (BC offset {})\n",
tid, bcOffset);
break;
}
}
if (prevId != kInvalidTransID) {
auto sk = profData->transSrcKey(tid);
if (profData->optimized(sk)) {
FTRACE(2, "selectHotTrace: breaking region because next sk already "
"optimized, for Translation {}\n", tid);
break;
}
}
// Break trace if translation tid cannot follow the execution of
// the entire translation prevId. This can only happen if the
// execution of prevId takes a side exit that leads to the
// execution of tid.
if (prevId != kInvalidTransID) {
Op* lastInstr = profData->transLastInstr(prevId);
const Unit* unit = profData->transFunc(prevId)->unit();
OffsetSet succOffs = findSuccOffsets(lastInstr, unit);
if (!succOffs.count(profData->transSrcKey(tid).offset())) {
if (HPHP::Trace::moduleEnabled(HPHP::Trace::pgo, 2)) {
FTRACE(2, "selectHotTrace: WARNING: Breaking region @: {}\n",
show(*region));
FTRACE(2, "selectHotTrace: next translation selected: tid = {}\n{}\n",
tid, show(*blockRegion));
FTRACE(2, "\nsuccOffs = {}\n", folly::join(", ", succOffs));
}
break;
}
}
if (region->blocks.size() > 0) {
auto& newBlock = blockRegion->blocks.front();
auto newBlockId = newBlock->id();
auto predBlockId = region->blocks.back().get()->id();
if (!RuntimeOption::EvalHHIRBytecodeControlFlow) {
region->addArc(predBlockId, newBlockId);
} else {
// With bytecode control-flow, we add all forward arcs in the TransCFG
// that are induced by the blocks in the region, as a simple way
// to expose control-flow for now.
// This can go away once Task #4075822 is done.
auto newBlockSrcKey = blockRegion->blocks.front().get()->start();
//.........这里部分代码省略.........
示例5: selectHotTrace
RegionDescPtr selectHotTrace(TransID triggerId,
const ProfData* profData,
TransCFG& cfg,
TransIDSet& selectedSet,
TransIDVec* selectedVec) {
auto region = std::make_shared<RegionDesc>();
TransID tid = triggerId;
TransID prevId = InvalidID;
selectedSet.clear();
if (selectedVec) selectedVec->clear();
PostConditions accumPostConds;
while (!selectedSet.count(tid)) {
RegionDescPtr blockRegion = profData->transRegion(tid);
if (blockRegion == nullptr) break;
// If the debugger is attached, only allow single-block regions.
if (prevId != InvalidID && isDebuggerAttachedProcess()) {
FTRACE(2, "selectHotTrace: breaking region at Translation {} "
"because of debugger is attached\n", tid);
break;
}
// Break if block is not the first and requires reffiness checks.
// Task #2589970: fix translateRegion to support mid-region reffiness checks
if (prevId != InvalidID) {
auto nRefDeps = blockRegion->blocks[0]->reffinessPreds().size();
if (nRefDeps > 0) {
FTRACE(2, "selectHotTrace: breaking region because of refDeps ({}) at "
"Translation {}\n", nRefDeps, tid);
break;
}
}
// Break if block is not the first and it corresponds to the main
// function body entry. This is to prevent creating multiple
// large regions containing the function body (starting at various
// DV funclets).
if (prevId != InvalidID) {
const Func* func = profData->transFunc(tid);
Offset bcOffset = profData->transStartBcOff(tid);
if (func->base() == bcOffset) {
FTRACE(2, "selectHotTrace: breaking region because reached the main "
"function body entry at Translation {} (BC offset {})\n",
tid, bcOffset);
break;
}
}
if (prevId != InvalidID) {
auto sk = profData->transSrcKey(tid);
if (profData->optimized(sk)) {
FTRACE(2, "selectHotTrace: breaking region because next sk already "
"optimized, for Translation {}\n", tid);
break;
}
}
// Break trace if translation tid cannot follow the execution of
// the entire translation prevId. This can only happen if the
// execution of prevId takes a side exit that leads to the
// execution of tid.
if (prevId != InvalidID) {
Op* lastInstr = profData->transLastInstr(prevId);
const Unit* unit = profData->transFunc(prevId)->unit();
OffsetSet succOffs = findSuccOffsets(lastInstr, unit);
if (!succOffs.count(profData->transSrcKey(tid).offset())) {
if (HPHP::Trace::moduleEnabled(HPHP::Trace::pgo, 2)) {
FTRACE(2, "selectHotTrace: WARNING: Breaking region @: {}\n",
JIT::show(*region));
FTRACE(2, "selectHotTrace: next translation selected: tid = {}\n{}\n",
tid, JIT::show(*blockRegion));
FTRACE(2, "\nsuccOffs = {}\n", folly::join(", ", succOffs));
}
break;
}
}
region->blocks.insert(region->blocks.end(), blockRegion->blocks.begin(),
blockRegion->blocks.end());
selectedSet.insert(tid);
if (selectedVec) selectedVec->push_back(tid);
Op lastOp = *(profData->transLastInstr(tid));
if (breaksRegion(lastOp)) {
FTRACE(2, "selectHotTrace: breaking region because of last instruction "
"in Translation {}: {}\n", tid, opcodeToName(lastOp));
break;
}
auto outArcs = cfg.outArcs(tid);
if (outArcs.size() == 0) {
FTRACE(2, "selectHotTrace: breaking region because there's no successor "
"for Translation {}\n", tid);
break;
}
auto lastNewBlock = blockRegion->blocks.back();
discardPoppedTypes(accumPostConds,
//.........这里部分代码省略.........