Rename curFunc() to liveFunc()

Esse commit está contido em:
bsimmers
2013-07-25 13:18:03 -07:00
commit de Sara Golemon
commit 48dc5639f1
9 arquivos alterados com 71 adições e 61 exclusões
+4 -3
Ver Arquivo
@@ -834,10 +834,11 @@ string Stack::toString(const ActRec* fp, int offset,
std::ostringstream os;
auto unit = fp->unit();
auto func = fp->func();
os << prefix << "=== Stack at "
<< unit->filepath()->data() << ":"
<< unit->getLineNumber(unit->offsetOf(vmpc())) << " func "
<< curFunc()->fullName()->data() << " ===\n";
<< func->fullName()->data() << " ===\n";
toStringFrame(os, fp, offset, m_top, prefix);
@@ -1527,7 +1528,7 @@ void VMExecutionContext::enterVMWork(ActRec* enterFnAr) {
assert(start);
tx()->enterTCAfterProlog(start);
} else {
SrcKey sk(curFunc(), m_pc);
SrcKey sk(m_fp->func(), m_pc);
tx()->enterTCAtSrcKey(sk);
}
} else {
@@ -6984,7 +6985,7 @@ OPCODES
static inline void
profileReturnValue(const DataType dt) {
const Func* f = curFunc();
const Func* f = liveFunc();
if (f->isPseudoMain() || f->isClosureBody() || f->isMagic() ||
Func::isSpecial(f->name()))
return;
+6 -2
Ver Arquivo
@@ -320,8 +320,12 @@ struct ActRec {
}
const Unit* unit() const {
m_func->validate();
return m_func->unit();
func()->validate();
return func()->unit();
}
const Func* func() const {
return m_func;
}
/**
+2 -2
Ver Arquivo
@@ -102,11 +102,11 @@ static void recordActRecPush(NormalizedInstruction& i,
SrcKey next(sk);
next.advance(unit);
const FPIEnt *fpi = curFunc()->findFPI(next.offset());
const FPIEnt *fpi = sk.func()->findFPI(next.offset());
assert(fpi);
assert(name->isStatic());
assert(sk.offset() == fpi->m_fpushOff);
auto const fcall = SrcKey { curFunc(), fpi->m_fcallOff };
auto const fcall = SrcKey { sk.func(), fpi->m_fcallOff };
assert(isFCallStar(toOp(*unit->at(fcall.offset()))));
if (clsName) {
const Class* cls = Unit::lookupUniqueClass(clsName);
+4 -4
Ver Arquivo
@@ -630,7 +630,7 @@ void IRTranslator::translateContEnter(const NormalizedInstruction& i) {
// ContEnter can't exist in an inlined function right now. (If it
// ever can, this curFunc() needs to change.)
assert(!m_hhbcTrans.isInlining());
const Func* srcFunc = curFunc();
const Func* srcFunc = i.func();
int32_t callOffsetInUnit = after - srcFunc->base();
HHIR_EMIT(ContEnter, callOffsetInUnit);
@@ -1068,7 +1068,7 @@ findCuf(const NormalizedInstruction& ni,
return nullptr;
}
Class* ctx = curFunc()->cls();
Class* ctx = ni.func()->cls();
if (sclass->isame(s_self.get())) {
if (!ctx) return nullptr;
@@ -1328,7 +1328,7 @@ IRTranslator::translateFCall(const NormalizedInstruction& i) {
always_assert(!m_hhbcTrans.isInlining() && "curUnit and curFunc calls");
const PC after = i.m_unit->at(i.nextSk().offset());
const Func* srcFunc = curFunc();
const Func* srcFunc = i.func();
Offset returnBcOffset =
srcFunc->unit()->offsetOf(after - srcFunc->base());
@@ -1338,7 +1338,7 @@ IRTranslator::translateFCall(const NormalizedInstruction& i) {
*/
if (i.calleeTrace) {
if (!i.calleeTrace->m_inliningFailed && !m_hhbcTrans.isInlining()) {
assert(shouldIRInline(curFunc(), i.funcd, *i.calleeTrace));
assert(shouldIRInline(i.func(), i.funcd, *i.calleeTrace));
m_hhbcTrans.beginInlining(numArgs, i.funcd, returnBcOffset);
static const bool shapeStats = Stats::enabledAny() &&
+1 -1
Ver Arquivo
@@ -197,7 +197,7 @@ RegionDescPtr selectTraceletLegacy(const Transl::Tracelet& tlet) {
Block* curBlock;
auto newBlock = [&] {
region->blocks.push_back(
std::make_shared<Block>(tlet.m_func, sk.offset(), 0));
std::make_shared<Block>(tlet.func(), sk.offset(), 0));
curBlock = region->blocks.back().get();
};
newBlock();
+4 -4
Ver Arquivo
@@ -43,10 +43,10 @@ inline const uchar*& vmpc() { return g_vmContext->m_pc; }
inline ActRec*& vmFirstAR() { return g_vmContext->m_firstAR; }
inline ActRec* curFrame() { return (ActRec*)vmfp(); }
inline const Func* curFunc() { return curFrame()->m_func; }
inline const Unit* liveUnit() { return curFunc()->unit(); }
inline const Func* liveFunc() { return curFrame()->m_func; }
inline const Unit* liveUnit() { return liveFunc()->unit(); }
inline Class* curClass() {
const auto* func = curFunc();
const auto* func = liveFunc();
auto* cls = func->cls();
if (func->isPseudoMain() || func->isTraitMethod() || cls == nullptr) {
return nullptr;
@@ -55,7 +55,7 @@ inline Class* curClass() {
}
inline Offset curSpOff() {
Cell* fp = vmfp();
if (curFunc()->isGenerator()) {
if (liveFunc()->isGenerator()) {
fp = (Cell*)Stack::generatorStackBase((ActRec*)fp);
}
return fp - vmsp();
+25 -26
Ver Arquivo
@@ -591,7 +591,7 @@ bool TranslatorX64::profileSrcKey(const SrcKey& sk) const {
// tables. So, to support retranslating them, we need to reset the
// prologue tables and the prologue cache appropriately.
// (test/quick/floatcmp.php exposes this problem)
if (curFunc()->isClosureBody()) return false;
if (sk.func()->isClosureBody()) return false;
return true;
}
@@ -654,7 +654,7 @@ TCA TranslatorX64::retranslateOpt(TransID transId, bool align) {
// we don't have a Func* (since it's grabbed from the Block).
// Anyway, in this case, the region translator resorts generates a
// TransLive translation, corresponding to the current live VM context.
func = const_cast<Func*>(curFunc());
func = const_cast<Func*>(liveFunc());
} else {
func = m_profData->transFunc(transId);
}
@@ -749,14 +749,13 @@ reqName(int req) {
TCA
TranslatorX64::getTranslation(const TranslArgs& args) {
auto sk = args.m_sk;
curFunc()->validate();
sk.func()->validate();
SKTRACE(2, sk,
"getTranslation: curUnit %s funcId %x offset %d\n",
sk.unit()->filepath()->data(),
sk.getFuncId(),
sk.offset());
SKTRACE(2, sk, " funcId: %x \n",
curFunc()->getFuncId());
SKTRACE(2, sk, " funcId: %x \n", sk.func()->getFuncId());
if (curFrame()->hasVarEnv() && curFrame()->getVarEnv()->isGlobalScope()) {
SKTRACE(2, sk, "punting on pseudoMain\n");
@@ -861,7 +860,7 @@ TranslatorX64::createTranslation(const TranslArgs& args) {
SKTRACE(1, sk, "inserting anchor translation for (%p,%d) at %p\n",
sk.unit(), sk.offset(), req);
SrcRec* sr = m_srcDB.insert(sk);
sr->setFuncInfo(curFunc());
sr->setFuncInfo(sk.func());
sr->setAnchorTranslation(req);
size_t asize = a.frontier() - astart;
@@ -2007,7 +2006,7 @@ TranslatorX64::bindJmpccFirst(TCA toSmash,
bool taken,
ConditionCode cc,
bool& smashed) {
const Func* f = curFunc();
const Func* f = liveFunc();
LeaseHolder writer(s_writeLease);
if (!writer) return nullptr;
Offset offWillExplore = taken ? offTaken : offNotTaken;
@@ -2062,7 +2061,7 @@ TranslatorX64::bindJmpccFirst(TCA toSmash,
TCA
TranslatorX64::bindJmpccSecond(TCA toSmash, const Offset off,
ConditionCode cc, bool& smashed) {
const Func* f = curFunc();
const Func* f = liveFunc();
SrcKey dest(f, off);
TCA branch = getTranslation(TranslArgs(dest, true).src(toSmash));
LeaseHolder writer(s_writeLease, LeaseAcquire::NO_ACQUIRE);
@@ -2367,7 +2366,7 @@ TranslatorX64::enterTC(TCA start, void* data) {
g_vmContext->dispatchBB();
PC newPc = g_vmContext->getPC();
if (!newPc) { g_vmContext->m_fp = 0; return; }
sk = SrcKey(curFunc(), newPc);
sk = SrcKey(liveFunc(), newPc);
start = getTranslation(TranslArgs(sk, true));
}
assert(start == (TCA)HPHP::Transl::funcBodyHelperThunk ||
@@ -2495,7 +2494,7 @@ bool TranslatorX64::handleServiceRequest(TReqInfo& info,
{
TCA toSmash = (TCA)args[0];
Offset off = args[1];
sk = SrcKey(curFunc(), off);
sk = SrcKey(liveFunc(), off);
if (requestNum == REQ_BIND_SIDE_EXIT) {
SKTRACE(3, sk, "side exit taken!\n");
}
@@ -2511,7 +2510,7 @@ bool TranslatorX64::handleServiceRequest(TReqInfo& info,
start = bindJmpccFirst(toSmash, offTaken, offNotTaken,
taken, cc, smashed);
// SrcKey: we basically need to emulate the fail
sk = SrcKey(curFunc(), taken ? offTaken : offNotTaken);
sk = SrcKey(liveFunc(), taken ? offTaken : offNotTaken);
} break;
case REQ_BIND_JMPCC_SECOND: {
@@ -2519,12 +2518,12 @@ bool TranslatorX64::handleServiceRequest(TReqInfo& info,
Offset off = (Offset)args[1];
ConditionCode cc = ConditionCode(args[2]);
start = bindJmpccSecond(toSmash, off, cc, smashed);
sk = SrcKey(curFunc(), off);
sk = SrcKey(liveFunc(), off);
} break;
case REQ_RETRANSLATE_NO_IR: {
TCA toSmash = (TCA)args[0];
sk = SrcKey(curFunc(), (Offset)args[1]);
sk = SrcKey(liveFunc(), (Offset)args[1]);
start = retranslateAndPatchNoIR(sk, true, toSmash);
SKTRACE(1, sk, "retranslated (without IR) @%p\n", start);
} break;
@@ -2542,7 +2541,7 @@ bool TranslatorX64::handleServiceRequest(TReqInfo& info,
case REQ_RETRANSLATE: {
INC_TPC(retranslate);
sk = SrcKey(curFunc(), (Offset)args[0]);
sk = SrcKey(liveFunc(), (Offset)args[0]);
start = retranslate(TranslArgs(sk, true));
SKTRACE(2, sk, "retranslated @%p\n", start);
} break;
@@ -2557,7 +2556,7 @@ bool TranslatorX64::handleServiceRequest(TReqInfo& info,
* axiom.
*/
assert(numInstrs >= 0);
SKTRACE(5, SrcKey(curFunc(), off), "interp: enter\n");
SKTRACE(5, SrcKey(liveFunc(), off), "interp: enter\n");
if (numInstrs) {
s_perfCounters[tpc_interp_instr] += numInstrs;
g_vmContext->dispatchN(numInstrs);
@@ -2568,7 +2567,7 @@ bool TranslatorX64::handleServiceRequest(TReqInfo& info,
}
PC newPc = g_vmContext->getPC();
if (!newPc) { g_vmContext->m_fp = 0; return false; }
SrcKey newSk(curFunc(), newPc);
SrcKey newSk(liveFunc(), newPc);
SKTRACE(5, newSk, "interp: exit\n");
sk = newSk;
start = getTranslation(TranslArgs(newSk, true));
@@ -2596,7 +2595,7 @@ bool TranslatorX64::handleServiceRequest(TReqInfo& info,
g_vmContext->m_fp = 0;
return false;
}
SrcKey dest(curFunc(), vmpc());
SrcKey dest(liveFunc(), vmpc());
sk = dest;
start = getTranslation(TranslArgs(dest, true));
} break;
@@ -2609,7 +2608,7 @@ bool TranslatorX64::handleServiceRequest(TReqInfo& info,
* delete instructions from the instruction stream, we
* need to use fpi regions to find the fcall.
*/
const FPIEnt* fe = curFunc()->findPrecedingFPI(
const FPIEnt* fe = liveFunc()->findPrecedingFPI(
liveUnit()->offsetOf(vmpc()));
vmpc() = liveUnit()->at(fe->m_fcallOff);
assert(isFCallStar(toOp(*vmpc())));
@@ -2853,7 +2852,7 @@ TranslatorX64::getInputsIntoXMMRegs(const NormalizedInstruction& ni,
VMExecutionContext* \
interpOne##opcode(ActRec* ar, Cell* sp, Offset pcOff) { \
interp_set_regs(ar, sp, pcOff); \
SKTRACE(5, SrcKey(curFunc(), vmpc()), "%40s %p %p\n", \
SKTRACE(5, SrcKey(liveFunc(), vmpc()), "%40s %p %p\n", \
"interpOne" #opcode " before (fp,sp)", \
vmfp(), vmsp()); \
assert(toOp(*vmpc()) == Op::opcode); \
@@ -3235,7 +3234,7 @@ void dumpTranslationInfo(const Tracelet& t, TCA postGuards) {
TRACE(3, " Translating from file %s:%d %s at %p:\n",
unit->filepath()->data(),
unit->getLineNumber(sk.offset()),
curFunc()->name()->data(),
sk.func()->name()->data(),
postGuards);
TRACE(3, " preconds:\n");
TRACE(3, " types:\n");
@@ -3322,7 +3321,7 @@ TranslatorX64::translateWork(const TranslArgs& args) {
// We always go through the tracelet translator in this case
}
} else {
JIT::RegionContext rContext { curFunc(), sk.offset(), curSpOff() };
JIT::RegionContext rContext { sk.func(), sk.offset(), curSpOff() };
FTRACE(2, "populating live context for region\n");
populateLiveContext(rContext);
region = JIT::selectRegion(rContext, &t);
@@ -3404,9 +3403,9 @@ TranslatorX64::translateWork(const TranslArgs& args) {
m_bcMap));
m_bcMap.clear();
recordGdbTranslation(sk, curFunc(), a, start,
recordGdbTranslation(sk, sk.func(), a, start,
false, false);
recordGdbTranslation(sk, curFunc(), astubs, stubStart,
recordGdbTranslation(sk, sk.func(), astubs, stubStart,
false, false);
if (RuntimeOption::EvalJitPGO) {
m_profData->addTrans(t, transKind);
@@ -3450,7 +3449,7 @@ TranslatorX64::translateTracelet(Tracelet& t) {
Stats::emitInc(a, Stats::Instr_TC, t.m_numOpcodes);
// Profiling on function entry.
if (t.m_sk.offset() == curFunc()->base()) {
if (t.m_sk.offset() == t.func()->base()) {
ht.profileFunctionEntry("Normal");
}
@@ -3463,7 +3462,7 @@ TranslatorX64::translateTracelet(Tracelet& t) {
static const bool enabled = Stats::enabledAny() &&
getenv("HHVM_STATS_FUNCSHAPE");
if (!enabled) return;
if (t.m_sk.offset() != curFunc()->base()) return;
if (t.m_sk.offset() != t.func()->base()) return;
if (auto last = t.m_instrStream.last) {
if (last->op() != OpRetC && last->op() != OpRetV) {
return;
@@ -3487,7 +3486,7 @@ TranslatorX64::translateTracelet(Tracelet& t) {
ni->interp = true;
return Retry;
}
assert(ni->source.offset() >= curFunc()->base());
assert(ni->source.offset() >= t.func()->base());
// We sometimes leave the tail of a truncated tracelet in place to aid
// analysis, but breaksTracelet is authoritative.
if (ni->breaksTracelet) break;
+22 -14
Ver Arquivo
@@ -185,6 +185,10 @@ SrcKey Tracelet::nextSk() const {
return m_instrStream.last->nextSk();
}
const Func* Tracelet::func() const {
return m_sk.func();
}
/*
* locPhysicalOffset --
*
@@ -194,7 +198,7 @@ SrcKey Tracelet::nextSk() const {
* you're looking for, be sure to pass in a non-default f.
*/
int locPhysicalOffset(Location l, const Func* f) {
f = f ? f : curFunc();
f = f ? f : liveFunc();
assert_not_implemented(l.space == Location::Stack ||
l.space == Location::Local ||
l.space == Location::Iter);
@@ -294,7 +298,7 @@ RuntimeType Translator::outThisObjectType() {
* correct object type because arGetContextClass() looks at
* ar->m_func's class for methods.
*/
const Class *ctx = curFunc()->isMethod() ?
const Class *ctx = liveFunc()->isMethod() ?
arGetContextClass(curFrame()) : nullptr;
if (ctx) {
assert(!curFrame()->hasThis() ||
@@ -518,7 +522,7 @@ PropInfo getFinalPropertyOffset(const NormalizedInstruction& ni,
static std::pair<DataType,double>
predictMVec(const NormalizedInstruction* ni) {
auto info = getFinalPropertyOffset(*ni,
curFunc()->cls(),
ni->func()->cls(),
getMInstrInfo(ni->mInstrOp()));
if (info.offset != -1 && info.hphpcType != KindOfInvalid) {
FTRACE(1, "prediction for CGetM prop: {}, hphpc\n",
@@ -1439,7 +1443,7 @@ void preInputApplyMetaData(Unit::MetaHandle metaHand,
while (metaHand.nextArg(info)) {
switch (info.m_kind) {
case Unit::MetaInfo::Kind::NonRefCounted:
ni->nonRefCountedLocals.resize(curFunc()->numLocals());
ni->nonRefCountedLocals.resize(ni->func()->numLocals());
ni->nonRefCountedLocals[info.m_data] = 1;
break;
case Unit::MetaInfo::Kind::GuardedThis:
@@ -1884,7 +1888,7 @@ void getInputsImpl(SrcKey startSk,
}
const bool wantInlineReturn = [&] {
const int localCount = curFunc()->numLocals();
const int localCount = ni->func()->numLocals();
// Inline return causes us to guard this tracelet more precisely. If
// we're already chaining to get here, just do a generic return in the
// hopes of avoiding further specialization. The localCount constraint
@@ -1908,7 +1912,7 @@ void getInputsImpl(SrcKey startSk,
if ((input & AllLocals) && wantInlineReturn) {
ni->inlineReturn = true;
ni->ignoreInnerType = true;
int n = curFunc()->numLocals();
int n = ni->func()->numLocals();
for (int i = 0; i < n; ++i) {
if (!ni->nonRefCountedLocals[i]) {
inputs.emplace_back(Location(Location::Local, i));
@@ -2480,6 +2484,10 @@ const Unit* NormalizedInstruction::unit() const {
return m_unit;
}
const Func* NormalizedInstruction::func() const {
return source.func();
}
Offset NormalizedInstruction::offset() const {
return source.offset();
}
@@ -3047,7 +3055,7 @@ static bool shouldAnalyzeCallee(const NormalizedInstruction* fcall,
void Translator::analyzeCallee(TraceletContext& tas,
Tracelet& parent,
NormalizedInstruction* fcall) {
auto const callerFunc = curFunc();
auto const callerFunc = fcall->func();
auto const fpi = callerFunc->findFPI(fcall->source.offset());
auto const pushOp = fcall->m_unit->getOpcode(fpi->m_fpushOff);
@@ -3268,14 +3276,14 @@ static bool instrBreaksProfileBB(const NormalizedInstruction* instr) {
std::unique_ptr<Tracelet> Translator::analyze(SrcKey sk,
const TypeMap& initialTypes) {
std::unique_ptr<Tracelet> retval(new Tracelet());
auto func = sk.func();
auto unit = sk.unit();
auto& t = *retval;
t.m_sk = sk;
t.m_func = curFunc();
DEBUG_ONLY const char* file = unit->filepath()->data();
DEBUG_ONLY const int lineNum = unit->getLineNumber(t.m_sk.offset());
DEBUG_ONLY const char* funcName = curFunc()->fullName()->data();
DEBUG_ONLY const char* funcName = func->fullName()->data();
TRACE(1, "Translator::analyze %s:%d %s\n", file, lineNum, funcName);
TraceletContext tas(&t, initialTypes);
@@ -3401,7 +3409,7 @@ std::unique_ptr<Tracelet> Translator::analyze(SrcKey sk,
}
if (isFCallStar(ni->op())) t.m_arState.pop();
if (doVarEnvTaint || callDestroysLocals(*ni, curFunc())) tas.varEnvTaint();
if (doVarEnvTaint || callDestroysLocals(*ni, func)) tas.varEnvTaint();
DynLocation* outputs[] = { ni->outStack,
ni->outLocal, ni->outLocal2,
@@ -3418,7 +3426,7 @@ std::unique_ptr<Tracelet> Translator::analyze(SrcKey sk,
if (ni->op() == OpCreateCont) {
// CreateCont stores Uninit to all locals but NormalizedInstruction
// doesn't have enough output fields, so we special case it here.
auto const numLocals = curFunc()->numLocals();
auto const numLocals = ni->func()->numLocals();
for (unsigned i = 0; i < numLocals; ++i) {
tas.recordWrite(t.newDynLocation(Location(Location::Local, i),
KindOfUninit));
@@ -3490,7 +3498,7 @@ std::unique_ptr<Tracelet> Translator::analyze(SrcKey sk,
SKTRACE(1, sk, "greedily continuing through %dth jmp + %d\n",
tas.m_numJmps, ni->imm[0].u_IA);
tas.recordJmp();
sk = SrcKey(curFunc(), sk.offset() + ni->imm[0].u_IA);
sk = SrcKey(func, sk.offset() + ni->imm[0].u_IA);
goto head; // don't advance sk
} else if (opcodeBreaksBB(ni->op()) ||
(dontGuardAnyInputs(ni->op()) && opcodeChangesPC(ni->op()))) {
@@ -3797,7 +3805,7 @@ void Translator::traceStart(Offset bcStartOffset) {
color(ANSI_COLOR_END));
m_irTrans.reset(new JIT::IRTranslator(
bcStartOffset, curSpOff(), curFunc()));
bcStartOffset, curSpOff(), liveFunc()));
}
void Translator::traceEnd() {
@@ -4219,7 +4227,7 @@ const Func* lookupImmutableMethod(const Class* cls, const StringData* name,
bool privateOnly = false;
if (!RuntimeOption::RepoAuthoritative ||
!(cls->preClass()->attrs() & AttrUnique)) {
Class* ctx = curFunc()->cls();
Class* ctx = liveFunc()->cls();
if (!ctx || !ctx->classof(cls)) {
return nullptr;
}
+3 -5
Ver Arquivo
@@ -293,7 +293,9 @@ class NormalizedInstruction {
Op mInstrOp() const;
PC pc() const;
const Unit* unit() const;
const Func* func() const;
Offset offset() const;
SrcKey nextSk() const;
NormalizedInstruction()
: next(nullptr)
@@ -348,8 +350,6 @@ class NormalizedInstruction {
return m_dynLocs.back().get();
}
SrcKey nextSk() const;
private:
smart::vector<smart::unique_ptr<DynLocation>::type> m_dynLocs;
};
@@ -545,9 +545,6 @@ struct Tracelet : private boost::noncopyable {
ActRecState m_arState;
RefDeps m_refDeps;
// The function this Tracelet was generated from.
const Func* m_func;
/*
* If we were unable to make sense of the instruction stream (e.g., it
* used instructions that the translator does not understand), then this
@@ -587,6 +584,7 @@ struct Tracelet : private boost::noncopyable {
std::string toString() const;
SrcKey nextSk() const;
const Func* func() const;
};
const char* getTransKindName(TransKind kind);