本文整理汇总了C++中SrcKey类的典型用法代码示例。如果您正苦于以下问题:C++ SrcKey类的具体用法?C++ SrcKey怎么用?C++ SrcKey使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SrcKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findPredTrans
static TransIDSet findPredTrans(TransID dstID,
const ProfData* profData,
const SrcDB& srcDB,
const TcaTransIDMap& jmpToTransID) {
SrcKey dstSK = profData->transSrcKey(dstID);
const SrcRec* dstSR = srcDB.find(dstSK);
assertx(dstSR);
TransIDSet predSet;
for (auto& inBr : dstSR->incomingBranches()) {
TransID srcID = folly::get_default(jmpToTransID, inBr.toSmash(),
kInvalidTransID);
FTRACE(5, "findPredTrans: toSmash = {} srcID = {}\n",
inBr.toSmash(), srcID);
if (srcID != kInvalidTransID && profData->isKindProfile(srcID)) {
auto srcSuccOffsets = profData->transLastSrcKey(srcID).succOffsets();
if (srcSuccOffsets.count(dstSK.offset())) {
predSet.insert(srcID);
} else {
FTRACE(5, "findPredTrans: WARNING: incoming branch with impossible "
"control flow between translations: {} -> {}"
"(probably due to side exit)\n", srcID, dstID);
}
}
}
return predSet;
}
示例2: assertx
TransCFG::TransCFG(FuncId funcId,
const ProfData* profData,
const SrcDB& srcDB,
const TcaTransIDMap& jmpToTransID) {
assertx(profData);
// add nodes
for (auto tid : profData->funcProfTransIDs(funcId)) {
assertx(profData->transRegion(tid) != nullptr);
// This will skip DV Funclets if they were already
// retranslated w/ the prologues:
if (!profData->optimized(profData->transSrcKey(tid))) {
int64_t weight = profData->absTransCounter(tid);
addNode(tid, weight);
}
}
// add arcs
for (TransID dstId : nodes()) {
SrcKey dstSK = profData->transSrcKey(dstId);
RegionDesc::BlockPtr dstBlock = profData->transRegion(dstId)->entry();
FTRACE(5, "TransCFG: adding incoming arcs in dstId = {}\n", dstId);
TransIDSet predIDs = findPredTrans(dstId, profData, srcDB, jmpToTransID);
for (auto predId : predIDs) {
if (hasNode(predId)) {
auto predPostConds =
profData->transRegion(predId)->blocks().back()->postConds();
SrcKey predSK = profData->transSrcKey(predId);
if (preCondsAreSatisfied(dstBlock, predPostConds) &&
predSK.resumed() == dstSK.resumed()) {
FTRACE(5, "TransCFG: adding arc {} -> {} ({} -> {})\n",
predId, dstId, showShort(predSK), showShort(dstSK));
addArc(predId, dstId, TransCFG::Arc::kUnknownWeight);
}
}
}
}
// infer arc weights
bool changed;
do {
changed = false;
for (TransID tid : nodes()) {
int64_t nodeWeight = weight(tid);
if (inferredArcWeight(inArcs(tid), nodeWeight)) changed = true;
if (inferredArcWeight(outArcs(tid), nodeWeight)) changed = true;
}
} while (changed);
// guess weight for non-inferred arcs
for (TransID tid : nodes()) {
for (auto arc : outArcs(tid)) {
if (arc->weight() == Arc::kUnknownWeight) {
arc->setGuessed();
int64_t arcWgt = std::min(weight(arc->src()), weight(arc->dst())) / 2;
arc->setWeight(arcWgt);
}
}
}
}
示例3: breaksRegion
bool breaksRegion(SrcKey sk) {
switch (sk.op()) {
case Op::SSwitch:
case Op::CreateCont:
case Op::Yield:
case Op::YieldK:
case Op::RetC:
case Op::RetV:
case Op::Exit:
case Op::Fatal:
case Op::Throw:
case Op::Unwind:
case Op::Eval:
case Op::NativeImpl:
return true;
case Op::Await:
// We break regions at resumed Await instructions, to avoid
// duplicating the translation of the resumed SrcKey after the
// Await.
return sk.resumed();
default:
return false;
}
}
示例4: canInlineAt
bool InliningDecider::canInlineAt(SrcKey callSK, const Func* callee) const {
if (m_disabled ||
!callee ||
!RuntimeOption::EvalHHIREnableGenTimeInlining ||
RuntimeOption::EvalJitEnableRenameFunction ||
callee->attrs() & AttrInterceptable) {
return false;
}
// We can only inline at normal FCalls.
if (callSK.op() != Op::FCall &&
callSK.op() != Op::FCallD) {
return false;
}
// Don't inline from resumed functions. The inlining mechanism doesn't have
// support for these---it has no way to redefine stack pointers relative to
// the frame pointer, because in a resumed function the frame pointer points
// into the heap instead of into the eval stack.
if (callSK.resumed()) return false;
// TODO(#4238160): Inlining into pseudomain callsites is still buggy.
if (callSK.func()->isPseudoMain()) return false;
if (!isCalleeInlinable(callSK, callee) || !checkNumArgs(callSK, callee)) {
return false;
}
return true;
}
示例5: prepareForNextHHBC
void prepareForNextHHBC(IRGS& env,
const NormalizedInstruction* ni,
SrcKey newSk,
bool lastBcInst) {
FTRACE(1, "------------------- prepareForNextHHBC ------------------\n");
env.currentNormalizedInstruction = ni;
always_assert_flog(
IMPLIES(isInlining(env), !env.lastBcInst),
"Tried to end trace while inlining."
);
always_assert_flog(
IMPLIES(isInlining(env), !env.firstBcInst),
"Inlining while still at the first region instruction."
);
always_assert(env.bcStateStack.size() >= env.inlineLevel + 1);
auto pops = env.bcStateStack.size() - 1 - env.inlineLevel;
while (pops--) env.bcStateStack.pop_back();
always_assert_flog(env.bcStateStack.back().func() == newSk.func(),
"Tried to update current SrcKey with a different func");
env.bcStateStack.back().setOffset(newSk.offset());
updateMarker(env);
env.lastBcInst = lastBcInst;
env.catchCreator = nullptr;
env.irb->prepareForNextHHBC();
}
示例6: recordActRecPush
static void recordActRecPush(const SrcKey sk,
const StringData* name,
const StringData* clsName,
bool staticCall) {
auto unit = sk.unit();
FTRACE(2, "annotation: recordActRecPush: {}@{} {}{}{} ({}static)\n",
unit->filepath()->data(),
sk.offset(),
clsName ? clsName->data() : "",
clsName ? "::" : "",
name,
!staticCall ? "non" : "");
SrcKey next(sk);
next.advance(unit);
const FPIEnt *fpi = sk.func()->findFPI(next.offset());
assert(fpi);
assert(name->isStatic());
assert(sk.offset() == fpi->m_fpushOff);
auto const fcall = SrcKey { sk.func(), fpi->m_fcallOff };
assert(isFCallStar(*reinterpret_cast<const Op*>(unit->at(fcall.offset()))));
auto const func = lookupDirectFunc(sk, name, clsName, staticCall);
if (func) {
recordFunc(fcall, func);
}
}
示例7:
void
IRTranslator::translateFCallArray(const NormalizedInstruction& i) {
const Offset pcOffset = i.offset();
SrcKey next = i.nextSk();
const Offset after = next.offset();
HHIR_EMIT(FCallArray, pcOffset, after,
jit::callDestroysLocals(i, m_hhbcTrans.curFunc()));
}
示例8: recordFunc
static void recordFunc(const SrcKey sk,
const Func* func) {
FTRACE(2, "annotation: recordFunc: {}@{} {}\n",
sk.unit()->filepath()->data(),
sk.offset(),
func->fullName()->data());
s_callDB.insert(std::make_pair(sk, func));
}
示例9: canInlineAt
bool InliningDecider::canInlineAt(SrcKey callSK, const Func* callee) const {
if (!callee ||
!RuntimeOption::EvalHHIREnableGenTimeInlining ||
RuntimeOption::EvalJitEnableRenameFunction ||
callee->attrs() & AttrInterceptable) {
return false;
}
if (callee->cls()) {
if (!classHasPersistentRDS(callee->cls())) {
// if the callee's class is not persistent, its still ok
// to use it if we're jitting into a method of a subclass
auto ctx = callSK.func()->cls();
if (!ctx || !ctx->classof(callee->cls())) {
return false;
}
}
} else {
auto const handle = callee->funcHandle();
if (handle == rds::kInvalidHandle || !rds::isPersistentHandle(handle)) {
// if the callee isn't persistent, its still ok to
// use it if its defined at the top level in the same
// unit as the caller
if (callee->unit() != callSK.unit() || !callee->top()) {
return false;
}
}
}
// If inlining was disabled... don't inline.
if (m_disabled) return false;
// TODO(#3331014): We have this hack until more ARM codegen is working.
if (arch() == Arch::ARM) return false;
// We can only inline at normal FCalls.
if (callSK.op() != Op::FCall &&
callSK.op() != Op::FCallD) {
return false;
}
// Don't inline from resumed functions. The inlining mechanism doesn't have
// support for these---it has no way to redefine stack pointers relative to
// the frame pointer, because in a resumed function the frame pointer points
// into the heap instead of into the eval stack.
if (callSK.resumed()) return false;
// TODO(#4238160): Inlining into pseudomain callsites is still buggy.
if (callSK.func()->isPseudoMain()) return false;
if (!isCalleeInlinable(callSK, callee) || !checkNumArgs(callSK, callee)) {
return false;
}
return true;
}
示例10: showShort
std::string showShort(SrcKey sk) {
if (!sk.valid()) return "<invalid SrcKey>";
return folly::format(
"{}(id {:#x})@{}{}",
sk.func()->fullName(),
sk.funcID(),
sk.offset(),
sk.resumed() ? "r" : ""
).str();
}
示例11: emit_retranslate_opt_stub
TCA emit_retranslate_opt_stub(CodeBlock& cb, FPInvOffset spOff,
SrcKey target, TransID transID) {
return emit_persistent(
cb,
target.resumed() ? folly::none : folly::make_optional(spOff),
REQ_RETRANSLATE_OPT,
target.toAtomicInt(),
transID
);
}
示例12: emit_retranslate_stub
TCA emit_retranslate_stub(CodeBlock& cb, FPInvOffset spOff,
SrcKey target, TransFlags trflags) {
return emit_persistent(
cb,
target.resumed() ? folly::none : folly::make_optional(spOff),
REQ_RETRANSLATE,
target.offset(),
trflags.packed
);
}
示例13: sktrace
void sktrace(SrcKey sk, const char *fmt, ...) {
if (!Trace::enabled) return;
auto inst = instrToString((Op*)sk.unit()->at(sk.offset()));
Trace::trace("%s: %20s ", show(sk).c_str(), inst.c_str());
va_list a;
va_start(a, fmt);
Trace::vtrace(fmt, a);
va_end(a);
}
示例14: assertx
SrcKey RegionDesc::lastSrcKey() const {
assertx(!empty());
FuncId startFuncId = start().funcID();
for (int i = m_blocks.size() - 1; i >= 0; i--) {
SrcKey sk = m_blocks[i]->last();
if (sk.funcID() == startFuncId) {
return sk;
}
}
always_assert(0);
}
示例15: emit_bindaddr_stub
TCA emit_bindaddr_stub(CodeBlock& cb, FPInvOffset spOff, TCA* addr,
SrcKey target, TransFlags trflags) {
return emit_ephemeral(
cb,
mcg->getFreeStub(cb, &mcg->cgFixups()),
target.resumed() ? folly::none : folly::make_optional(spOff),
REQ_BIND_ADDR,
addr,
target.toAtomicInt(),
trflags.packed
);
}