Rename s/get// for id, src, dst, srcs, dsts, numSrcs, numDsts

Dropping the "get" prefix makes the code more readable.
Also srcReg(), dstReg().
Esse commit está contido em:
Edwin Smith
2013-05-29 09:10:33 -07:00
commit de sgolemon
commit 0fabe930f8
26 arquivos alterados com 765 adições e 766 exclusões
+4 -4
Ver Arquivo
@@ -56,7 +56,7 @@ struct Block : boost::noncopyable {
return front();
}
uint32_t getId() const { return m_id; }
uint32_t id() const { return m_id; }
Trace* getTrace() const { return m_trace; }
void setTrace(Trace* t) { m_trace = t; }
void setHint(Hint hint) { m_hint = hint; }
@@ -88,7 +88,7 @@ struct Block : boost::noncopyable {
* Returns whether this block is the initial entry block for the
* tracelet.
*/
bool isEntry() const { return getId() == 0; }
bool isEntry() const { return id() == 0; }
// return the last instruction in the block
IRInstruction* back() const {
@@ -164,7 +164,7 @@ struct Block : boost::noncopyable {
for (Edge& e : m_preds) {
IRInstruction* jmp = e.from()->back();
assert(jmp->op() == Jmp_ && jmp->getTaken() == this);
body(jmp, jmp->getSrc(i));
body(jmp, jmp->src(i));
}
}
@@ -173,7 +173,7 @@ struct Block : boost::noncopyable {
template<typename L>
SSATmp* findSrc(unsigned i, L body) {
for (Edge& e : m_preds) {
SSATmp* src = e.from()->back()->getSrc(i);
SSATmp* src = e.from()->back()->src(i);
if (body(src)) return src;
}
return nullptr;
+2 -2
Ver Arquivo
@@ -39,8 +39,8 @@ struct PostorderSort {
void walk(Block* block) {
assert(!block->empty());
if (m_visited.test(block->getId())) return;
m_visited.set(block->getId());
if (m_visited.test(block->id())) return;
m_visited.set(block->id());
Block* taken = block->getTaken();
if (taken && taken->getTrace()->isMain() != block->getTrace()->isMain()) {
walk(taken);
+15 -16
Ver Arquivo
@@ -75,11 +75,11 @@ bool checkBlock(Block* b) {
if (b->getTaken()) {
// only Jmp_ can branch to a join block expecting values.
assert(b->back()->op() == Jmp_ ||
b->getTaken()->front()->getNumDsts() == 0);
b->getTaken()->front()->numDsts() == 0);
}
if (b->getNext()) {
// cannot fall-through to join block expecting values
assert(b->getNext()->front()->getNumDsts() == 0);
assert(b->getNext()->front()->numDsts() == 0);
}
{
@@ -95,7 +95,7 @@ bool checkBlock(Block* b) {
}
}
for (int i = 0; i < b->front()->getNumDsts(); ++i) {
for (int i = 0; i < b->front()->numDsts(); ++i) {
auto const traceBlocks = b->getTrace()->getBlocks();
b->forEachSrc(i, [&](IRInstruction* inst, SSATmp*) {
assert(std::find(traceBlocks.begin(), traceBlocks.end(),
@@ -158,14 +158,14 @@ bool checkCfg(Trace* trace, const IRFactory& factory) {
// visit dom tree in preorder, checking all tmps
auto const children = findDomChildren(blocks);
boost::dynamic_bitset<> defined0(factory.numTmps());
StateVector<SSATmp, bool> defined0(&factory, false);
forPreorderDoms(blocks.front(), children, defined0,
[] (Block* block, boost::dynamic_bitset<>& defined) {
[] (Block* block, StateVector<SSATmp, bool>& defined) {
for (IRInstruction& inst : *block) {
for (DEBUG_ONLY SSATmp* src : inst.getSrcs()) {
for (DEBUG_ONLY SSATmp* src : inst.srcs()) {
assert(src->inst() != &inst);
assert_log(src->inst()->op() == DefConst ||
defined[src->getId()],
defined[src],
[&]{ return folly::format(
"src '{}' in '{}' came from '{}', which is not a "
"DefConst and is not defined at this use site",
@@ -173,11 +173,10 @@ bool checkCfg(Trace* trace, const IRFactory& factory) {
src->inst()->toString()).str();
});
}
for (SSATmp& dst : inst.getDsts()) {
assert(dst.inst() == &inst &&
inst.op() != DefConst);
assert(!defined[dst.getId()]);
defined[dst.getId()] = 1;
for (SSATmp& dst : inst.dsts()) {
assert(dst.inst() == &inst && inst.op() != DefConst);
assert(!defined[dst]);
defined[dst] = true;
}
}
});
@@ -201,7 +200,7 @@ bool checkTmpsSpanningCalls(Trace* trace, const IRFactory& irFactory) {
blocks.front(), children, State(&irFactory, false),
[&] (Block* b, State& state) {
for (auto& inst : *b) {
for (auto& src : inst.getSrcs()) {
for (auto& src : inst.srcs()) {
if (src->isA(Type::FramePtr)) continue;
if (src->isConst()) continue;
if (!state[src]) {
@@ -222,7 +221,7 @@ bool checkTmpsSpanningCalls(Trace* trace, const IRFactory& irFactory) {
*/
if (isCall(inst.op())) state.reset();
for (auto& d : inst.getDsts()) {
for (auto& d : inst.dsts()) {
state[d] = true;
}
}
@@ -241,7 +240,7 @@ bool checkRegisters(Trace* trace, const IRFactory& factory,
forPreorderDoms(blocks.front(), children, RegState(),
[&] (Block* block, RegState& state) {
for (IRInstruction& inst : *block) {
for (SSATmp* src : inst.getSrcs()) {
for (SSATmp* src : inst.srcs()) {
auto const &info = regs[src];
if (!info.spilled() &&
(info.getReg(0) == Transl::rVmSp ||
@@ -253,7 +252,7 @@ bool checkRegisters(Trace* trace, const IRFactory& factory,
assert(state.tmp(info, i) == src);
}
}
for (SSATmp& dst : inst.getDsts()) {
for (SSATmp& dst : inst.dsts()) {
auto const &info = regs[dst];
for (unsigned i = 0, n = info.numAllocatedRegs(); i < n; ++i) {
state.tmp(info, i) = &dst;
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
+3 -3
Ver Arquivo
@@ -391,8 +391,8 @@ public:
None, // Nothing: register will contain garbage
};
PhysReg getDstReg() const { return m_dstReg; }
PhysReg getSrcReg() const { return m_srcReg; }
PhysReg dstReg() const { return m_dstReg; }
PhysReg srcReg() const { return m_srcReg; }
Kind getKind() const { return m_kind; }
void setDstReg(PhysReg reg) { m_dstReg = reg; }
Immed getImm() const { return m_imm; }
@@ -484,7 +484,7 @@ struct ArgGroup {
}
ArgGroup& ssas(IRInstruction* inst, unsigned begin, unsigned count = 1) {
for (SSATmp* s : inst->getSrcs().subpiece(begin, count)) {
for (SSATmp* s : inst->srcs().subpiece(begin, count)) {
push_arg(ArgDesc(s, m_regs[s]));
}
return *this;
+44 -44
Ver Arquivo
@@ -109,7 +109,7 @@ private:
};
static_assert(sizeof(DceFlags) == 1, "sizeof(DceFlags) should be 1 byte");
// DCE state indexed by instr->getId().
// DCE state indexed by instr->id().
typedef StateVector<IRInstruction, DceFlags> DceState;
typedef hphp_hash_set<const SSATmp*, pointer_hash<SSATmp>> SSASet;
typedef StateVector<SSATmp, SSASet> SSACache;
@@ -130,15 +130,15 @@ void removeDeadInstructions(Trace* trace, const DceState& state) {
}
bool isUnguardedLoad(IRInstruction* inst) {
if (!inst->hasDst() || !inst->getDst()) return false;
if (!inst->hasDst() || !inst->dst()) return false;
Opcode opc = inst->op();
SSATmp* dst = inst->getDst();
SSATmp* dst = inst->dst();
Type type = dst->type();
return ((opc == LdStack && (type == Type::Gen || type == Type::Cell)) ||
(opc == LdLoc && type == Type::Gen) ||
(opc == LdRef && type == Type::Cell) ||
(opc == LdMem && type == Type::Cell &&
inst->getSrc(0)->type() == Type::PtrToCell) ||
inst->src(0)->type() == Type::PtrToCell) ||
(opc == Unbox && type == Type::Cell));
}
@@ -186,7 +186,7 @@ BlockList removeUnreachable(Trace* trace, IRFactory* factory) {
++bit;
continue;
}
FTRACE(5, "erasing block {}\n", (*bit)->getId());
FTRACE(5, "erasing block {}\n", (*bit)->id());
if ((*bit)->getTaken() && (*bit)->back()->op() == Jmp_) {
needsReflow = true;
}
@@ -219,7 +219,7 @@ initInstructions(const BlockList& blocks, DceState& state) {
wl.push_back(&inst);
}
if (inst.op() == DecRefNZ) {
auto* srcInst = inst.getSrc(0)->inst();
auto* srcInst = inst.src(0)->inst();
Opcode srcOpc = srcInst->op();
if (srcOpc != DefConst) {
assert(srcInst->op() == IncRef);
@@ -257,7 +257,7 @@ void optimizeRefCount(Trace* trace, DceState& state, UseCounts& uses) {
s.setDead();
}
if (inst->op() == DecRefNZ) {
SSATmp* src = inst->getSrc(0);
SSATmp* src = inst->src(0);
IRInstruction* srcInst = src->inst();
if (state[srcInst].countConsumedAny()) {
state[inst].setLive();
@@ -265,7 +265,7 @@ void optimizeRefCount(Trace* trace, DceState& state, UseCounts& uses) {
}
}
if (inst->op() == DecRef) {
SSATmp* src = inst->getSrc(0);
SSATmp* src = inst->src(0);
if (uses[src] == 1 && !src->type().canRunDtor()) {
IRInstruction* srcInst = src->inst();
if (srcInst->op() == IncRef) {
@@ -279,7 +279,7 @@ void optimizeRefCount(Trace* trace, DceState& state, UseCounts& uses) {
});
for (const IRInstruction* decref : decrefs) {
assert(decref->op() == DecRef);
SSATmp* src = decref->getSrc(0);
SSATmp* src = decref->src(0);
assert(src->inst()->op() == IncRef);
assert(!src->type().canRunDtor());
if (uses[src] == 1) {
@@ -325,19 +325,19 @@ void sinkIncRefs(Trace* trace, IRFactory* irFactory, DceState& state) {
for (auto* inst : boost::adaptors::reverse(toSink)) {
// prepend inserts an instruction to the beginning of a block, after
// the label. Therefore, we iterate through toSink in the reversed order.
IRInstruction* sunkInst = irFactory->gen(IncRef, inst->getSrc(0));
IRInstruction* sunkInst = irFactory->gen(IncRef, inst->src(0));
state[sunkInst].setLive();
exit->front()->prepend(sunkInst);
auto dstId = inst->getDst()->getId();
auto dstId = inst->dst()->id();
assert(!sunkTmps[dstId]);
sunkTmps[dstId] = sunkInst->getDst();
sunkTmps[dstId] = sunkInst->dst();
}
forEachInst(exit, [&](IRInstruction* inst) {
// Replace the original tmps with the sunk tmps.
for (uint32_t i = 0; i < inst->getNumSrcs(); ++i) {
SSATmp* src = inst->getSrc(i);
if (SSATmp* sunkTmp = sunkTmps[src->getId()]) {
for (uint32_t i = 0; i < inst->numSrcs(); ++i) {
SSATmp* src = inst->src(i);
if (SSATmp* sunkTmp = sunkTmps[src->id()]) {
inst->setSrc(i, sunkTmp);
}
}
@@ -366,7 +366,7 @@ void sinkIncRefs(Trace* trace, IRFactory* irFactory, DceState& state) {
}
}
if (inst->op() == DecRefNZ) {
IRInstruction* srcInst = inst->getSrc(0)->inst();
IRInstruction* srcInst = inst->src(0)->inst();
if (state[srcInst].isDead()) {
state[inst].setDead();
// This may take O(I) time where I is the number of IncRefs
@@ -375,8 +375,8 @@ void sinkIncRefs(Trace* trace, IRFactory* irFactory, DceState& state) {
}
}
if (Block* target = inst->getTaken()) {
if (!pushedTo[target->getId()]) {
pushedTo[target->getId()] = 1;
if (!pushedTo[target->id()]) {
pushedTo[target->id()] = 1;
Trace* exit = target->getTrace();
if (exit != trace) processExit(exit);
}
@@ -404,14 +404,14 @@ void optimizeActRecs(Trace* trace, DceState& state, IRFactory* factory,
switch (inst->op()) {
case CreateCont:
{
auto const frameInst = inst->getSrc(1)->inst();
auto const frameInst = inst->src(1)->inst();
if (frameInst->op() == DefInlineFP) {
auto const spInst = frameInst->getSrc(0)->inst();
auto const spInst = frameInst->src(0)->inst();
if (spInst->op() == SpillFrame &&
spInst->getSrc(3)->type().subtypeOfAny(Type::Obj, Type::Null)) {
spInst->src(3)->type().subtypeOfAny(Type::Obj, Type::Null)) {
FTRACE(5, "CreateCont ({}): weak use of frame {}\n",
inst->getId(),
frameInst->getId());
inst->id(),
frameInst->id());
state[frameInst].incWeakUse();
}
}
@@ -422,7 +422,7 @@ void optimizeActRecs(Trace* trace, DceState& state, IRFactory* factory,
// eliminated.
case StLoc:
{
auto const frameInst = inst->getSrc(0)->inst();
auto const frameInst = inst->src(0)->inst();
if (frameInst->op() == DefInlineFP) {
state[frameInst].incWeakUse();
}
@@ -431,14 +431,14 @@ void optimizeActRecs(Trace* trace, DceState& state, IRFactory* factory,
case InlineReturn:
{
auto frameUses = uses[inst->getSrc(0)];
auto srcInst = inst->getSrc(0)->inst();
auto frameUses = uses[inst->src(0)];
auto srcInst = inst->src(0)->inst();
if (srcInst->op() == DefInlineFP) {
auto weakUses = state[srcInst].weakUseCount();
// We haven't counted this InlineReturn as a weak use yet,
// which is where this '1' comes from.
if (frameUses - weakUses == 1) {
FTRACE(5, "killing frame {}\n", srcInst->getId());
FTRACE(5, "killing frame {}\n", srcInst->id());
killedFrames = true;
state[srcInst].setDead();
}
@@ -463,16 +463,16 @@ void optimizeActRecs(Trace* trace, DceState& state, IRFactory* factory,
switch (inst->op()) {
case CreateCont:
{
auto const fp = inst->getSrc(1);
auto const fp = inst->src(1);
if (state[fp->inst()].isDead()) {
FTRACE(5, "CreateCont ({}) -> InlineCreateCont\n", inst->getId());
FTRACE(5, "CreateCont ({}) -> InlineCreateCont\n", inst->id());
CreateContData data;
data.origFunc = inst->getSrc(3)->getValFunc();
data.genFunc = inst->getSrc(4)->getValFunc();
data.origFunc = inst->src(3)->getValFunc();
data.genFunc = inst->src(4)->getValFunc();
assert(fp->inst()->getSrc(0)->inst()->op() == SpillFrame);
auto const thisPtr = fp->inst()->getSrc(0)->inst()->getSrc(3);
assert(fp->inst()->src(0)->inst()->op() == SpillFrame);
auto const thisPtr = fp->inst()->src(0)->inst()->src(3);
factory->replace(
inst,
InlineCreateCont,
@@ -485,11 +485,11 @@ void optimizeActRecs(Trace* trace, DceState& state, IRFactory* factory,
case StLoc: case InlineReturn:
{
auto const fp = inst->getSrc(0);
auto const fp = inst->src(0);
if (state[fp->inst()].isDead()) {
FTRACE(5, "{} ({}) setDead\n",
opcodeName(inst->op()),
inst->getId());
inst->id());
state[inst].setDead();
}
}
@@ -497,9 +497,9 @@ void optimizeActRecs(Trace* trace, DceState& state, IRFactory* factory,
case DefInlineFP:
FTRACE(5, "DefInlineFP ({}): weak/strong uses: {}/{}\n",
inst->getId(),
inst->id(),
state[inst].weakUseCount(),
uses[inst->getDst()]);
uses[inst->dst()]);
break;
default:
@@ -530,13 +530,13 @@ void consumeIncRef(const IRInstruction* consumer, const SSATmp* src,
// srcInst is a CheckType that guards to a refcounted type. We need to
// trace through to its source. If the CheckType guards to a non-refcounted
// type then the reference is consumed by CheckType itself.
consumeIncRef(consumer, srcInst->getSrc(0), state, ssas, visitedSrcs);
consumeIncRef(consumer, srcInst->src(0), state, ssas, visitedSrcs);
} else if (srcInst->op() == DefLabel) {
// srcInst is a DefLabel that may be a join node. We need to find
// the dst index of src in srcInst and trace through to each jump
// providing a value for it.
for (unsigned i = 0, n = srcInst->getNumDsts(); i < n; ++i) {
if (srcInst->getDst(i) == src) {
for (unsigned i = 0, n = srcInst->numDsts(); i < n; ++i) {
if (srcInst->dst(i) == src) {
srcInst->getBlock()->forEachSrc(i,
[&](IRInstruction* jmp, SSATmp* val) {
consumeIncRef(consumer, val, state, ssas, visitedSrcs);
@@ -584,8 +584,8 @@ void removeDeadInstructions(Trace* trace, const boost::dynamic_bitset<>& live) {
auto cur = it; ++it;
Block* block = *cur;
block->remove_if([&] (const IRInstruction& inst) {
assert(inst.getId() < live.size());
return !live.test(inst.getId());
assert(inst.id() < live.size());
return !live.test(inst.id());
});
if (block->empty()) blocks.erase(cur);
}
@@ -614,8 +614,8 @@ void eliminateDeadCode(Trace* trace, IRFactory* irFactory) {
while (!wl.empty()) {
auto* inst = wl.front();
wl.pop_front();
for (uint32_t i = 0; i < inst->getNumSrcs(); i++) {
SSATmp* src = inst->getSrc(i);
for (uint32_t i = 0; i < inst->numSrcs(); i++) {
SSATmp* src = inst->src(i);
IRInstruction* srcInst = src->inst();
if (srcInst->op() == DefConst) {
continue;
@@ -95,7 +95,7 @@ void HhbcTranslator::refineType(SSATmp* tmp, Type type) {
// If tmp is incref or move, then chase down its src
Opcode opc = inst->op();
if (opc == Mov || opc == IncRef) {
refineType(inst->getSrc(0), type);
refineType(inst->src(0), type);
tmp->setType(outputType(inst));
} else if (tmp->type().isNull() && type.isNull()) {
// Refining Null to Uninit or InitNull is supported
@@ -2067,7 +2067,7 @@ SSATmp* HhbcTranslator::emitDecRefLocalsInline(SSATmp* retVal) {
* IncRef/DecRef pair in the main trace.
*/
if (retValSrcInstr->op() == IncRef) {
retValSrcLoc = retValSrcInstr->getSrc(0);
retValSrcLoc = retValSrcInstr->src(0);
retValSrcOpc = retValSrcLoc->inst()->op();
if (retValSrcOpc != LdLoc && retValSrcOpc != LdThis) {
retValSrcLoc = nullptr;
+24 -24
Ver Arquivo
@@ -378,7 +378,7 @@ bool IRInstruction::consumesReference(int srcNo) const {
// to a notCounted type.
if (m_op == CheckType) {
assert(srcNo == 0);
return getSrc(0)->type().maybeCounted() && getTypeParam().notCounted();
return src(0)->type().maybeCounted() && getTypeParam().notCounted();
}
// SpillStack consumes inputs 2 and onward
if (m_op == SpillStack) return srcNo >= 2;
@@ -407,7 +407,7 @@ bool IRInstruction::mayModifyRefs() const {
// DecRefNZ does not have side effects other than decrementing the ref
// count. Therefore, its MayModifyRefs should be false.
if (opc == DecRef) {
auto type = getSrc(0)->type();
auto type = src(0)->type();
if (isControlFlowInstruction()) {
// If the decref has a target label, then it exits if the destructor
// has to be called, so it does not have any side effects on the main
@@ -433,7 +433,7 @@ bool IRInstruction::isEssential() const {
// If the ref count optimization is turned off, mark all DecRefNZ as
// essential.
if (!RuntimeOption::EvalHHIREnableRefCountOpt ||
getSrc(0)->inst()->op() != IncRef) {
src(0)->inst()->op() != IncRef) {
return true;
}
}
@@ -517,13 +517,13 @@ bool IRInstruction::stores(uint32_t srcIdx) const {
return srcIdx == 4;
case SpillStack:
return srcIdx >= 2 && srcIdx < getNumSrcs();
return srcIdx >= 2 && srcIdx < numSrcs();
case Call:
return srcIdx >= 3 && srcIdx < getNumSrcs();
return srcIdx >= 3 && srcIdx < numSrcs();
case CallBuiltin:
return srcIdx >= 1 && srcIdx < getNumSrcs();
return srcIdx >= 1 && srcIdx < numSrcs();
default:
return false;
@@ -533,7 +533,7 @@ bool IRInstruction::stores(uint32_t srcIdx) const {
SSATmp* IRInstruction::getPassthroughValue() const {
assert(isPassthrough());
assert(m_op == IncRef || m_op == CheckType || m_op == Mov);
return getSrc(0);
return src(0);
}
bool IRInstruction::killsSources() const {
@@ -573,7 +573,7 @@ bool IRInstruction::modifiesStack() const {
SSATmp* IRInstruction::modifiedStkPtr() const {
assert(modifiesStack());
assert(VectorEffects::supported(this));
SSATmp* sp = getDst(hasMainDst() ? 1 : 0);
SSATmp* sp = dst(hasMainDst() ? 1 : 0);
assert(sp->isA(Type::StkPtr));
return sp;
}
@@ -585,26 +585,26 @@ bool IRInstruction::hasMainDst() const {
bool IRInstruction::mayReenterHelper() const {
if (isCmpOp(op())) {
return cmpOpTypesMayReenter(op(),
getSrc(0)->type(),
getSrc(1)->type());
src(0)->type(),
src(1)->type());
}
// Not necessarily actually false; this is just a helper for other
// bits.
return false;
}
SSATmp* IRInstruction::getDst(unsigned i) const {
SSATmp* IRInstruction::dst(unsigned i) const {
if (i == 0 && m_numDsts == 0) return nullptr;
assert(i < m_numDsts);
assert(naryDst() || i == 0);
return hasDst() ? getDst() : &m_dst[i];
return hasDst() ? dst() : &m_dst[i];
}
DstRange IRInstruction::getDsts() {
DstRange IRInstruction::dsts() {
return Range<SSATmp*>(m_dst, m_numDsts);
}
Range<const SSATmp*> IRInstruction::getDsts() const {
Range<const SSATmp*> IRInstruction::dsts() const {
return Range<const SSATmp*>(m_dst, m_numDsts);
}
@@ -617,7 +617,7 @@ const StringData* findClassName(SSATmp* cls) {
// Try to get the class name from a LdCls
IRInstruction* clsInst = cls->inst();
if (clsInst->op() == LdCls || clsInst->op() == LdClsCached) {
SSATmp* clsName = clsInst->getSrc(0);
SSATmp* clsName = clsInst->src(0);
assert(clsName->isA(Type::Str));
if (clsName->isConst()) {
return clsName->getValStr();
@@ -848,13 +848,13 @@ IRInstruction* IRInstruction::clone(IRFactory* factory) const {
return factory->cloneInstruction(this);
}
SSATmp* IRInstruction::getSrc(uint32_t i) const {
if (i >= getNumSrcs()) return nullptr;
SSATmp* IRInstruction::src(uint32_t i) const {
if (i >= numSrcs()) return nullptr;
return m_srcs[i];
}
void IRInstruction::setSrc(uint32_t i, SSATmp* newSrc) {
assert(i < getNumSrcs());
assert(i < numSrcs());
m_srcs[i] = newSrc;
}
@@ -878,8 +878,8 @@ bool IRInstruction::cseEquals(IRInstruction* inst) const {
m_numSrcs != inst->m_numSrcs) {
return false;
}
for (uint32_t i = 0; i < getNumSrcs(); i++) {
if (getSrc(i) != inst->getSrc(i)) {
for (uint32_t i = 0; i < numSrcs(); i++) {
if (src(i) != inst->src(i)) {
return false;
}
}
@@ -900,8 +900,8 @@ size_t IRInstruction::cseHash() const {
assert(canCSE());
size_t srcHash = 0;
for (unsigned i = 0; i < getNumSrcs(); ++i) {
srcHash = CSEHash::hashCombine(srcHash, getSrc(i));
for (unsigned i = 0; i < numSrcs(); ++i) {
srcHash = CSEHash::hashCombine(srcHash, src(i));
}
if (hasExtra()) {
srcHash = CSEHash::hashCombine(srcHash,
@@ -1050,7 +1050,7 @@ std::string Trace::toString() const {
int32_t spillValueCells(IRInstruction* spillStack) {
assert(spillStack->op() == SpillStack);
int32_t numSrcs = spillStack->getNumSrcs();
int32_t numSrcs = spillStack->numSrcs();
return numSrcs - 2;
}
@@ -1059,7 +1059,7 @@ bool isConvIntOrPtrToBool(IRInstruction* instr) {
case ConvIntToBool:
return true;
case ConvCellToBool:
return instr->getSrc(0)->type().subtypeOfAny(
return instr->src(0)->type().subtypeOfAny(
Type::Func, Type::Cls, Type::FuncCls, Type::VarEnv, Type::TCA);
default:
return false;
+1 -1
Ver Arquivo
@@ -56,7 +56,7 @@ SSATmp* IRFactory::findConst(ConstData& cdata, Type ctype) {
assert(tmp->type().equals(ctype));
return tmp;
}
return m_constTable.insert(cloneInstruction(&inst)->getDst());
return m_constTable.insert(cloneInstruction(&inst)->dst());
}
}}
+11 -11
Ver Arquivo
@@ -174,18 +174,18 @@ struct IRInstruction {
void setOpcode(Opcode newOpc) { m_op = newOpc; }
Type getTypeParam() const { return m_typeParam; }
void setTypeParam(Type t) { m_typeParam = t; }
uint32_t getNumSrcs() const { return m_numSrcs; }
uint32_t numSrcs() const { return m_numSrcs; }
void setNumSrcs(uint32_t i) {
assert(i <= m_numSrcs);
m_numSrcs = i;
}
SSATmp* getSrc(uint32_t i) const;
SSATmp* src(uint32_t i) const;
void setSrc(uint32_t i, SSATmp* newSrc);
SrcRange getSrcs() const {
SrcRange srcs() const {
return SrcRange(m_srcs, m_numSrcs);
}
unsigned getNumDsts() const { return m_numDsts; }
SSATmp* getDst() const {
unsigned numDsts() const { return m_numDsts; }
SSATmp* dst() const {
assert(!naryDst());
return m_dst;
}
@@ -197,12 +197,12 @@ struct IRInstruction {
/*
* Returns the ith dest of this instruction. i == 0 is treated specially: if
* the instruction has no dests, getDst(0) will return nullptr, and if the
* instruction is not naryDest, getDst(0) will return the single dest.
* the instruction has no dests, dst(0) will return nullptr, and if the
* instruction is not naryDest, dst(0) will return the single dest.
*/
SSATmp* getDst(unsigned i) const;
DstRange getDsts();
Range<const SSATmp*> getDsts() const;
SSATmp* dst(unsigned i) const;
DstRange dsts();
Range<const SSATmp*> dsts() const;
void setDsts(unsigned numDsts, SSATmp* newDsts) {
assert(naryDst());
m_numDsts = numDsts;
@@ -212,7 +212,7 @@ struct IRInstruction {
/*
* Instruction id is stable and useful as an array index.
*/
uint32_t getId() const {
uint32_t id() const {
assert(m_id != kTransient);
return m_id;
}
+8 -8
Ver Arquivo
@@ -38,12 +38,12 @@ void elimUnconditionalJump(Trace* trace, IRFactory* irFactory) {
boost::dynamic_bitset<> havePred(irFactory->numBlocks());
for (Block* block : trace->getBlocks()) {
if (block->getTaken()) {
auto id = block->getTaken()->getId();
auto id = block->getTaken()->id();
isJoin[id] = havePred[id];
havePred[id] = 1;
}
if (block->getNext()) {
auto id = block->getNext()->getId();
auto id = block->getNext()->id();
isJoin[id] = havePred[id];
havePred[id] = 1;
}
@@ -51,7 +51,7 @@ void elimUnconditionalJump(Trace* trace, IRFactory* irFactory) {
Block* lastBlock = trace->back();
auto lastInst = lastBlock->backIter(); // iterator to last instruction
IRInstruction& jmp = *lastInst;
if (jmp.op() == Jmp_ && !isJoin[jmp.getTaken()->getId()]) {
if (jmp.op() == Jmp_ && !isJoin[jmp.getTaken()->id()]) {
Block* target = jmp.getTaken();
lastBlock->splice(lastInst, target, target->skipLabel(), target->end());
lastBlock->erase(lastInst); // delete the jmp
@@ -161,12 +161,12 @@ void optimizeCondTraceExit(Trace* trace, IRFactory* irFactory) {
data.taken = jccExitTrace->back()->getExtra<ReqBindJmp>()->offset;
data.notTaken = mainExit->back()->getExtra<ReqBindJmp>()->offset;
FTRACE(5, "replacing {} with {}\n", jccInst->getId(), opcodeName(newOpcode));
FTRACE(5, "replacing {} with {}\n", jccInst->id(), opcodeName(newOpcode));
irFactory->replace(
mainExit->back(),
newOpcode,
data,
std::make_pair(jccInst->getNumSrcs(), jccInst->getSrcs().begin())
std::make_pair(jccInst->numSrcs(), jccInst->srcs().begin())
);
jccInst->convertToNop();
@@ -190,11 +190,11 @@ void optimizeSideExits(Trace* trace, IRFactory* irFactory) {
assert(syncABI->op() == SyncABIRegs);
FTRACE(5, "converting jump ({}) to side exit\n",
inst->getId());
inst->id());
auto const isStack = inst->op() == CheckStk;
auto const fp = syncABI->getSrc(0);
auto const sp = syncABI->getSrc(1);
auto const fp = syncABI->src(0);
auto const sp = syncABI->src(1);
SideExitGuardData data;
data.checkedSlot = isStack
+1 -1
Ver Arquivo
@@ -83,7 +83,7 @@ LayoutInfo layoutBlocks(Trace* trace, const IRFactory& irFactory) {
smart::vector<Block*>::iterator stop) {
folly::toAppend(what, &str);
for (; it != stop; ++it) {
folly::toAppend((*it)->getId(), &str);
folly::toAppend((*it)->id(), &str);
folly::toAppend(" ", &str);
}
};
+66 -66
Ver Arquivo
@@ -237,7 +237,7 @@ static SSATmp* canonicalize(SSATmp* tmp) {
if (opc != IncRef && opc != Mov && opc != StRef && opc != StRefNT) {
return tmp;
}
tmp = inst->getSrc(0);
tmp = inst->src(0);
}
}
@@ -323,7 +323,7 @@ PhysReg::Type LinearScan::getRegType(const SSATmp* tmp, int locIdx) const {
Type tmpType = tmp->type();
uint32_t tmpId = tmp->getId();
uint32_t tmpId = tmp->id();
if (tmp->inst()->op() == Reload) {
// We don't have an entry for reloaded SSATmps in
@@ -334,8 +334,8 @@ PhysReg::Type LinearScan::getRegType(const SSATmp* tmp, int locIdx) const {
// to a full XMM register, then so is the reloaded SSATmp. This
// might be a bit conservative, but avoids recomputing the analysis.
auto* reload = tmp->inst();
auto* spill = reload->getSrc(0)->inst();
tmpId = spill->getSrc(0)->getId();
auto* spill = reload->src(0)->inst();
tmpId = spill->src(0)->id();
}
if (tmpType.equals(Type::Uncounted) || tmpType.equals(Type::UncountedInit)) {
@@ -371,9 +371,9 @@ void LinearScan::allocRegToInstruction(InstructionList::iterator it) {
for (int regNo = 0; regNo < kNumRegs; ++regNo) {
m_regs[regNo].m_pinned = false;
}
smart::vector<bool> needsReloading(inst->getNumSrcs(), true);
for (uint32_t i = 0; i < inst->getNumSrcs(); ++i) {
SSATmp* tmp = inst->getSrc(i);
smart::vector<bool> needsReloading(inst->numSrcs(), true);
for (uint32_t i = 0; i < inst->numSrcs(); ++i) {
SSATmp* tmp = inst->src(i);
int32_t slotId = m_spillSlots[tmp];
if (slotId == -1) {
needsReloading[i] = false;
@@ -387,9 +387,9 @@ void LinearScan::allocRegToInstruction(InstructionList::iterator it) {
}
}
}
for (uint32_t i = 0; i < inst->getNumSrcs(); ++i) {
for (uint32_t i = 0; i < inst->numSrcs(); ++i) {
if (needsReloading[i]) {
SSATmp* tmp = inst->getSrc(i);
SSATmp* tmp = inst->src(i);
int32_t slotId = m_spillSlots[tmp];
// <tmp> is spilled, and not reloaded.
// Therefore, We need to reload the value into a new SSATmp.
@@ -402,7 +402,7 @@ void LinearScan::allocRegToInstruction(InstructionList::iterator it) {
// Create <reloadTmp> which inherits <tmp>'s slot ID and
// <spillTmp>'s last use ID.
// Replace <tmp> with <reloadTmp> in <inst>.
SSATmp* reloadTmp = reload->getDst();
SSATmp* reloadTmp = reload->dst();
m_uses[reloadTmp].lastUse = m_uses[spillTmp].lastUse;
m_spillSlots[reloadTmp] = slotId;
inst->setSrc(i, reloadTmp);
@@ -426,7 +426,7 @@ void LinearScan::allocRegToInstruction(InstructionList::iterator it) {
computePreColoringHint();
}
Range<SSATmp*> dsts = inst->getDsts();
Range<SSATmp*> dsts = inst->dsts();
if (dsts.empty()) return;
Opcode opc = inst->op();
@@ -442,7 +442,7 @@ void LinearScan::allocRegToInstruction(InstructionList::iterator it) {
// pointer to an AR that is not in rVmFp.
const bool abnormalFramePtr =
(opc == LdRaw &&
inst->getSrc(1)->getValInt() == RawMemSlot::ContARPtr);
inst->src(1)->getValInt() == RawMemSlot::ContARPtr);
// Note that the point of StashGeneratorSP is to save a StkPtr
// somewhere other than rVmSp. (TODO(#2288359): make rbx not
@@ -510,7 +510,7 @@ bool LinearScan::crossNativeCall(const SSATmp* tmp) const {
int LinearScan::allocRegToTmp(SSATmp* ssaTmp, uint32_t index) {
bool preferCallerSaved = true;
PhysReg::Type regType = getRegType(ssaTmp, index);
FTRACE(6, "getRegType(SSATmp {}, {}) = {}\n", ssaTmp->getId(),
FTRACE(6, "getRegType(SSATmp {}, {}) = {}\n", ssaTmp->id(),
index, int(regType));
assert(regType == PhysReg::GP || index == 0); // no type-only in XMM regs
@@ -666,8 +666,8 @@ uint32_t LinearScan::assignSpillLoc() {
m_natives.pop_front();
}
if (inst.op() == Spill) {
SSATmp* dst = inst.getDst();
SSATmp* src = inst.getSrc(0);
SSATmp* dst = inst.dst();
SSATmp* src = inst.src(0);
for (int locIndex = 0;
locIndex < src->numNeededRegs();
++locIndex) {
@@ -696,7 +696,7 @@ uint32_t LinearScan::assignSpillLoc() {
}
}
if (inst.op() == Reload) {
SSATmp* src = inst.getSrc(0);
SSATmp* src = inst.src(0);
for (int locIndex = 0;
locIndex < src->numNeededRegs();
++locIndex) {
@@ -729,7 +729,7 @@ void LinearScan::collectInfo(BlockList::iterator it, Trace* trace) {
if (!trace->isMain()) return;
int lastId = block->getTrace()->getData();
for (IRInstruction& inst : *block) {
for (auto* src : inst.getSrcs()) {
for (auto* src : inst.srcs()) {
if (lastId > m_uses[src].lastUse) {
m_uses[src].lastUse = lastId;
}
@@ -737,15 +737,15 @@ void LinearScan::collectInfo(BlockList::iterator it, Trace* trace) {
}
} else {
for (IRInstruction& inst : *block) {
for (auto* src : inst.getSrcs()) {
for (auto* src : inst.srcs()) {
m_uses[src].lastUse = m_linear[inst];
}
if (inst.isNative()) m_natives.push_back(&inst);
}
IRInstruction* jmp = block->back();
if (jmp->op() == Jmp_ && jmp->getNumSrcs() != 0) {
for (SSATmp* src : jmp->getSrcs()) {
if (jmp->op() == Jmp_ && jmp->numSrcs() != 0) {
for (SSATmp* src : jmp->srcs()) {
m_jmps[src].push_back(jmp);
}
}
@@ -767,13 +767,13 @@ void LinearScan::computePreColoringHint() {
for (auto const& arg : CallMap::getInfo(opc).args) {
switch (arg.type) {
case SSA:
m_preColoringHint.add(inst->getSrc(arg.srcIdx), 0, reg++);
m_preColoringHint.add(inst->src(arg.srcIdx), 0, reg++);
break;
case TV:
case VecKeyS:
case VecKeyIS:
m_preColoringHint.add(inst->getSrc(arg.srcIdx), 0, reg++);
m_preColoringHint.add(inst->getSrc(arg.srcIdx), 1, reg++);
m_preColoringHint.add(inst->src(arg.srcIdx), 0, reg++);
m_preColoringHint.add(inst->src(arg.srcIdx), 1, reg++);
break;
case Immed:
break;
@@ -787,29 +787,29 @@ void LinearScan::computePreColoringHint() {
// registers.
auto normalHint = [&](int count, int srcBase = 0, int argBase = 0) {
for (int i = 0; i < count; ++i) {
m_preColoringHint.add(inst->getSrc(i + srcBase), 0,
m_preColoringHint.add(inst->src(i + srcBase), 0,
i + argBase);
}
};
switch (opc) {
case LdFunc:
m_preColoringHint.add(inst->getSrc(0), 0, 1);
m_preColoringHint.add(inst->src(0), 0, 1);
break;
case NativeImpl:
m_preColoringHint.add(inst->getSrc(1), 0, 0);
m_preColoringHint.add(inst->src(1), 0, 0);
break;
case Concat:
{
Type lType = inst->getSrc(0)->type();
Type rType = inst->getSrc(1)->type();
Type lType = inst->src(0)->type();
Type rType = inst->src(1)->type();
if ((lType.isString() && rType.isString()) ||
(lType.isString() && rType == Type::Int) ||
(lType == Type::Int && rType.isString())) {
m_preColoringHint.add(inst->getSrc(0), 0, 0);
m_preColoringHint.add(inst->getSrc(1), 0, 1);
m_preColoringHint.add(inst->src(0), 0, 0);
m_preColoringHint.add(inst->src(1), 0, 1);
} else {
m_preColoringHint.add(inst->getSrc(0), 0, 1);
m_preColoringHint.add(inst->getSrc(1), 0, 3);
m_preColoringHint.add(inst->src(0), 0, 1);
m_preColoringHint.add(inst->src(1), 0, 3);
}
}
break;
@@ -821,8 +821,8 @@ void LinearScan::computePreColoringHint() {
case OpSame:
case OpNSame:
{
auto src1 = inst->getSrc(0);
auto src2 = inst->getSrc(1);
auto src1 = inst->src(0);
auto src2 = inst->src(1);
auto type1 = src1->type();
auto type2 = src2->type();
@@ -838,7 +838,7 @@ void LinearScan::computePreColoringHint() {
break;
case IterInit:
{
m_preColoringHint.add(inst->getSrc(0), 0, 1);
m_preColoringHint.add(inst->src(0), 0, 1);
}
break;
case InstanceOf:
@@ -858,7 +858,7 @@ void LinearScan::computePreColoringHint() {
normalHint(3);
break;
case LdCls:
m_preColoringHint.add(inst->getSrc(0), 0, 1);
m_preColoringHint.add(inst->src(0), 0, 1);
break;
case BoxPtr:
normalHint(1);
@@ -903,8 +903,8 @@ RegNumber LinearScan::getJmpPreColor(SSATmp* tmp, uint32_t regIndex,
if (srcInst->op() == DefLabel) {
// Figure out which dst of the label is tmp
for (unsigned i = 0, n = srcInst->getNumDsts(); i < n; ++i) {
if (srcInst->getDst(i) == tmp) {
for (unsigned i = 0, n = srcInst->numDsts(); i < n; ++i) {
if (srcInst->dst(i) == tmp) {
auto reg = findLabelSrcReg(m_allocInfo, srcInst, i, regIndex);
// Until we handle loops, it's a bug to try and allocate a
// register to a DefLabel's dest before all of its incoming
@@ -928,12 +928,12 @@ RegNumber LinearScan::getJmpPreColor(SSATmp* tmp, uint32_t regIndex,
IRInstruction* label = jmp->getTaken()->front();
// Figure out which src of the Jmp_ is tmp
for (unsigned si = 0, sn = jmp->getNumSrcs(); si < sn; ++si) {
SSATmp* src = jmp->getSrc(si);
for (unsigned si = 0, sn = jmp->numSrcs(); si < sn; ++si) {
SSATmp* src = jmp->src(si);
if (tmp == src) {
// For now, a DefLabel should never have a register assigned
// to it before any of its incoming Jmp_ instructions.
always_assert(m_allocInfo[label->getDst(si)].getReg(regIndex) ==
always_assert(m_allocInfo[label->dst(si)].getReg(regIndex) ==
reg::noreg);
auto reg = findLabelSrcReg(m_allocInfo, label, si, regIndex);
if (reg != reg::noreg) return reg;
@@ -958,8 +958,8 @@ void LinearScan::initFreeList() {
void LinearScan::coalesce(Trace* trace) {
forEachTraceInst(trace, [](IRInstruction* inst) {
for (uint32_t i = 0; i < inst->getNumSrcs(); ++i) {
SSATmp* src = inst->getSrc(i);
for (uint32_t i = 0; i < inst->numSrcs(); ++i) {
SSATmp* src = inst->src(i);
SSATmp* origSrc = canonicalize(src);
if (origSrc != src) {
// Replace every operand with its canonicalized version.
@@ -979,7 +979,7 @@ void LinearScan::numberInstructions(const BlockList& blocks) {
if (inst.op() == Marker) continue; // don't number markers
uint32_t id = nextId++;
m_linear[inst] = id;
for (SSATmp* tmp : inst.getSrcs()) {
for (SSATmp* tmp : inst.srcs()) {
m_uses[tmp].lastUse = id;
m_uses[tmp].count++;
}
@@ -1064,15 +1064,15 @@ void LinearScan::findFullXMMCandidates() {
m_fullXMMCandidates.reset();
for (auto* block : m_blocks) {
for (auto& inst : *block) {
for (SSATmp& tmp : inst.getDsts()) {
for (SSATmp& tmp : inst.dsts()) {
if (tmp.numNeededRegs() == 2 && inst.isLoad()) {
m_fullXMMCandidates[tmp.getId()] = true;
m_fullXMMCandidates[tmp.id()] = true;
}
}
int idx = 0;
for (SSATmp* tmp : inst.getSrcs()) {
for (SSATmp* tmp : inst.srcs()) {
if (tmp->numNeededRegs() == 2 && !inst.stores(idx)) {
notCandidates[tmp->getId()] = true;
notCandidates[tmp->id()] = true;
}
idx++;
}
@@ -1153,7 +1153,7 @@ void LinearScan::allocRegsOneTrace(BlockList::iterator& blockIt,
}
FTRACE(5, "Block{}: {} ({})\n",
trace->isMain() ? "" : " (exit trace)",
(*blockIt)->getId(), (*blockIt)->postId());
(*blockIt)->id(), (*blockIt)->postId());
// clear remembered reloads that don't dominate this block
for (SlotInfo& slot : m_slots) {
@@ -1191,7 +1191,7 @@ void LinearScan::allocRegsOneTrace(BlockList::iterator& blockIt,
while (begin < end) {
SlotInfo& slot = m_slots[begin++];
IRInstruction* spill = slot.spillTmp->inst();
IRInstruction* inst = spill->getSrc(0)->inst();
IRInstruction* inst = spill->src(0)->inst();
Block* block = inst->getBlock();
if (!isMain && block->getTrace()->isMain()) {
// We're on an exit trace, but the def is on the
@@ -1226,7 +1226,7 @@ void LinearScan::allocRegsToTrace() {
for (auto& b : m_blocks) {
s << folly::format("{}{} ",
b->isMain() ? "M" : "E",
b->getId());
b->id());
}
s << "\n";
HPHP::Trace::traceRelease("%s\n", s.str().c_str());
@@ -1270,7 +1270,7 @@ bool srcsAreLive(const RegAllocInfo& regs, IRInstruction* inst,
// in registers we trust to be live: rVmSp and rVmFp. Ignore DefConst
// sources because they're implicitly turned into immediates by every
// instruction that uses them.
for (SSATmp* src : inst->getSrcs()) {
for (SSATmp* src : inst->srcs()) {
if (!regs[src].hasReg(0) && src->inst()->op() != DefConst) return false;
auto reg = regs[src].getReg(0);
if (reg != rVmSp && reg != rVmFp) return false;
@@ -1289,8 +1289,8 @@ void LinearScan::rematerializeAux() {
SSATmp* curFp = nullptr;
smart::vector<SSATmp*> localValues;
auto killLocal = [&](IRInstruction& inst, unsigned src) {
if (src < inst.getNumSrcs()) {
unsigned loc = inst.getSrc(src)->getValInt();
if (src < inst.numSrcs()) {
unsigned loc = inst.src(src)->getValInt();
if (loc < localValues.size()) localValues[loc] = nullptr;
}
};
@@ -1338,18 +1338,18 @@ void LinearScan::rematerializeAux() {
IRInstruction& inst = *it;
Opcode opc = inst.op();
if (opc == DefFP || opc == FreeActRec) {
assert(m_allocInfo[inst.getDst()].getReg() == rVmFp);
curFp = inst.getDst();
assert(m_allocInfo[inst.dst()].getReg() == rVmFp);
curFp = inst.dst();
} else if (opc == Reload) {
// s = Spill t0
// t = Reload s
SSATmp* dst = inst.getDst();
SSATmp* dst = inst.dst();
SSATmp* spilledTmp = getSpilledTmp(dst);
IRInstruction* spilledInst = spilledTmp->inst();
IRInstruction* newInst = NULL;
if (spilledInst->isRematerializable() ||
(spilledInst->op() == LdStack &&
spilledInst->getSrc(0) == curSp)) {
spilledInst->src(0) == curSp)) {
// XXX: could change <newInst> to the non-check version.
// Rematerialize those rematerializable instructions (i.e.,
// isRematerializable returns true) and LdStack.
@@ -1386,14 +1386,14 @@ void LinearScan::rematerializeAux() {
}
// Updating curSp and localValues
if (inst.hasDst() && m_allocInfo[inst.getDst()].getReg() == rVmSp) {
if (inst.hasDst() && m_allocInfo[inst.dst()].getReg() == rVmSp) {
// inst modifies the stack pointer.
curSp = inst.getDst();
curSp = inst.dst();
}
if (opc == LdLoc || opc == StLoc || opc == StLocNT) {
setLocal(inst.getExtra<LocalId>()->locId,
opc == LdLoc ? inst.getDst() : inst.getSrc(1));
opc == LdLoc ? inst.dst() : inst.src(1));
}
// Other instructions that may have side effects on locals must
// kill the local variable values.
@@ -1417,10 +1417,10 @@ void LinearScan::rematerializeAux() {
void LinearScan::removeUnusedSpills() {
for (SlotInfo& slot : m_slots) {
IRInstruction* spill = slot.spillTmp->inst();
if (m_uses[spill->getDst()].count == 0) {
if (m_uses[spill->dst()].count == 0) {
Block* block = spill->getBlock();
block->erase(block->iteratorTo(spill));
SSATmp* src = spill->getSrc(0);
SSATmp* src = spill->src(0);
auto uses = m_uses[src].count - 1;
m_uses[src].count = uses;
if (uses == 0) {
@@ -1583,7 +1583,7 @@ uint32_t LinearScan::createSpillSlot(SSATmp* tmp) {
uint32_t slotId = m_slots.size();
m_spillSlots[tmp] = slotId;
IRInstruction* spillInst = m_irFactory->gen(Spill, tmp);
SSATmp* spillTmp = spillInst->getDst();
SSATmp* spillTmp = spillInst->dst();
SlotInfo si;
si.spillTmp = spillTmp;
si.latestReload = tmp;
@@ -1604,9 +1604,9 @@ uint32_t LinearScan::getNextNativeId() const {
SSATmp* LinearScan::getSpilledTmp(SSATmp* tmp) {
assert(tmp->inst()->op() == Reload);
SSATmp* slot = tmp->inst()->getSrc(0);
SSATmp* slot = tmp->inst()->src(0);
assert(slot->inst()->op() == Spill);
return slot->inst()->getSrc(0);
return slot->inst()->src(0);
}
// If <tmp> is a reloaded value, follow the spill-reload chain to find
+38 -38
Ver Arquivo
@@ -123,13 +123,13 @@ private:
void update(IRInstruction* inst) {
assert(inst != nullptr);
int offset = inst->getSrc(1)->getValInt();
int offset = inst->src(1)->getValInt();
PropList::iterator it, end;
for (it = accesses.begin(), end = accesses.end(); it != end; ++it) {
if (it->offset == offset) {
it->access = inst;
it->value = inst->getSrc(2);
it->value = inst->src(2);
}
}
@@ -216,13 +216,13 @@ private:
Opcode op = inst->op();
if (isLoad(op)) {
return inst->getDst();
return inst->dst();
}
if (isStore(op)) {
if (op == StProp || op == StPropNT) {
return inst->getSrc(2);
return inst->src(2);
}
return inst->getSrc(1);
return inst->src(1);
}
if (isVectorOp(op)) {
// Vector instructions may change boxes such that the new value
@@ -230,7 +230,7 @@ private:
return nullptr;
}
if (op == Box) {
return inst->getSrc(0);
return inst->src(0);
}
// no support for extracting the value from this instruction, so return NULL
@@ -241,12 +241,12 @@ private:
assert(inst != nullptr);
switch (inst->op()) {
case LdRef:
return inst->getDst();
return inst->dst();
case StRef:
case StRefNT:
return inst->getSrc(1);
return inst->src(1);
case Box:
return inst->getSrc(0);
return inst->src(0);
default:
// no support for extracting the value from this instruction
return nullptr;
@@ -267,13 +267,13 @@ private:
}
bool isLive(IRInstruction* inst) const {
assert(inst->getId() < m_liveInsts.size());
return m_liveInsts.test(inst->getId());
assert(inst->id() < m_liveInsts.size());
return m_liveInsts.test(inst->id());
}
void setLive(IRInstruction& inst, bool live) {
assert(inst.getId() < m_liveInsts.size());
m_liveInsts.set(inst.getId(), live);
assert(inst.id() < m_liveInsts.size());
m_liveInsts.set(inst.id(), live);
}
private:
@@ -293,7 +293,7 @@ void MemMap::killRefInfo(IRInstruction* save) {
// if 'save' is a load, then don't kill access info of refs that have a
// different type than 'save'
if ((isLoad(save->op()) || save->op() == LdMem)) {
auto saveType = save->getDst()->type();
auto saveType = save->dst()->type();
if (it->second->value != nullptr &&
it->second->value->type() != saveType &&
it->second->value->type().isKnownDataType() &&
@@ -320,7 +320,7 @@ void MemMap::killPropInfo(IRInstruction* save) {
assert(save != nullptr);
PropInfoList* propInfoList = nullptr;
PropMap::iterator find = m_props.find(save->getSrc(0));
PropMap::iterator find = m_props.find(save->src(0));
if (find != m_props.end()) {
propInfoList = find->second;
}
@@ -329,7 +329,7 @@ void MemMap::killPropInfo(IRInstruction* save) {
// of a LdMem or StMem), otherwise -1
Opcode op = save->op();
int offset = (op == LdProp || op == StProp || op == StPropNT) ?
save->getSrc(1)->getValInt() : -1;
save->src(1)->getValInt() : -1;
for (PropMap::iterator it = m_props.begin(), end = m_props.end();
it != end; ++it) {
@@ -350,9 +350,9 @@ void MemMap::killPropInfo(IRInstruction* save) {
// have a different type than 'save'
if ((isLoad(save->op()) || save->op() == LdMem) &&
copy->value != nullptr &&
copy->value->type() != save->getDst()->type() &&
copy->value->type() != save->dst()->type() &&
copy->value->type().isKnownDataType() &&
save->getDst()->type().isKnownDataType()) {
save->dst()->type().isKnownDataType()) {
continue;
}
// TODO consider doing the same with the type of the base ref pointer
@@ -411,7 +411,7 @@ void MemMap::processInstruction(IRInstruction* inst, bool isPseudoMain) {
switch (op) {
case Box: {
m_unescaped[inst->getDst()] = new RefInfo(inst);
m_unescaped[inst->dst()] = new RefInfo(inst);
break;
}
@@ -431,7 +431,7 @@ void MemMap::processInstruction(IRInstruction* inst, bool isPseudoMain) {
}
case Unbox:
case LdRef: {
SSATmp* ref = inst->getSrc(0);
SSATmp* ref = inst->src(0);
// only need to kill access info of possibly escaped refs
if (m_unescaped.count(ref) > 0) {
@@ -453,8 +453,8 @@ void MemMap::processInstruction(IRInstruction* inst, bool isPseudoMain) {
case Mov:
case IncRef: {
SSATmp* dest = inst->getDst();
SSATmp* source = inst->getSrc(0);
SSATmp* dest = inst->dst();
SSATmp* source = inst->src(0);
// figure out which map the new alias is supposed to be inserted into
if (source->type().isBoxed()) {
@@ -497,13 +497,13 @@ void MemMap::processInstruction(IRInstruction* inst, bool isPseudoMain) {
case StLoc:
case StLocNT: {
storeLocal(inst->getExtra<LocalId>()->locId, inst->getSrc(1));
storeLocal(inst->getExtra<LocalId>()->locId, inst->src(1));
break;
}
case StRef:
case StRefNT: {
SSATmp* ref = inst->getSrc(0);
SSATmp* alias = inst->getDst();
SSATmp* ref = inst->src(0);
SSATmp* alias = inst->dst();
// StRef* instructions create a new alias that doesn't affect our tracked
// ref count. after a StRef, the source temp is no longer used, so it just
@@ -543,18 +543,18 @@ void MemMap::processInstruction(IRInstruction* inst, bool isPseudoMain) {
case LdProp:
case StProp:
case StPropNT: {
SSATmp* obj = inst->getSrc(0);
SSATmp* obj = inst->src(0);
// if we're storing out an unescaped ref, then it has now escaped
if (op != LdProp && m_unescaped.count(inst->getSrc(2)) > 0) {
escapeRef(inst->getSrc(2));
if (op != LdProp && m_unescaped.count(inst->src(2)) > 0) {
escapeRef(inst->src(2));
}
if (m_props.count(obj) > 0) {
m_props[obj]->update(inst);
} else {
PropInfoList* list = new PropInfoList;
int offset = inst->getSrc(1)->getValInt();
int offset = inst->src(1)->getValInt();
list->accesses.push_back(PropInfo(inst, offset));
m_props[obj] = list;
}
@@ -564,8 +564,8 @@ void MemMap::processInstruction(IRInstruction* inst, bool isPseudoMain) {
}
case DecRef:
case DecRefNZ: {
SSATmp* ref = inst->getSrc(0);
Type ty = inst->getSrc(0)->type();
SSATmp* ref = inst->src(0);
Type ty = inst->src(0)->type();
if (ref->isConst()) {
// cannot be ref-counted
@@ -613,7 +613,7 @@ void MemMap::processInstruction(IRInstruction* inst, bool isPseudoMain) {
// escape any boxes that are on the right hand side of the current
// instruction
RefMap::iterator end = m_unescaped.end();
for (SSATmp* src : inst->getSrcs()) {
for (SSATmp* src : inst->srcs()) {
RefMap::iterator find = m_unescaped.find(src);
if (find != end) {
escapeRef(find->first);
@@ -688,7 +688,7 @@ void MemMap::optimizeMemoryAccesses(Trace* trace) {
if (isLoad(op)) {
if (op == LdProp) {
offset = inst.getSrc(1)->getValInt();
offset = inst.src(1)->getValInt();
}
// initialize each instruction as live
setLive(inst, true);
@@ -696,14 +696,14 @@ void MemMap::optimizeMemoryAccesses(Trace* trace) {
optimizeLoad(&inst, offset);
} else if (isStore(op)) {
if (op == StProp || op == StPropNT) {
offset = inst.getSrc(1)->getValInt();
offset = inst.src(1)->getValInt();
}
// if we see a store, first check if its last available access is a store
// if it is, then the last access is a dead store
auto access = inst.op() == StLoc || inst.op() == StLocNT
? lastLocalAccess(inst.getExtra<LocalId>()->locId)
: getLastAccess(inst.getSrc(0), offset);
: getLastAccess(inst.src(0), offset);
if (access && isStore(access->op())) {
// if a dead St* is followed by a St*NT, then the second store needs to
// now write in the type because the first store will be removed
@@ -760,12 +760,12 @@ void MemMap::optimizeLoad(IRInstruction* inst, int offset) {
// then replace the load with a Mov
auto value = inst->op() == LdLoc
? getLocalValue(inst->getExtra<LocalId>()->locId)
: getValue(inst->getSrc(0), offset);
: getValue(inst->src(0), offset);
if (value == nullptr) {
return;
}
Type instTy = inst->getDst()->type();
Type instTy = inst->dst()->type();
Type valTy = value->type();
// check for loads that have a guard that will definitely fail
@@ -781,7 +781,7 @@ void MemMap::optimizeLoad(IRInstruction* inst, int offset) {
inst->setSrc(1, nullptr);
inst->setNumSrcs(1);
} else {
assert(inst->getNumSrcs() == 1);
assert(inst->numSrcs() == 1);
}
inst->setTaken(nullptr);
+14 -14
Ver Arquivo
@@ -32,10 +32,10 @@ void cloneToBlock(const BlockList& rpoBlocks,
StateVector<SSATmp,SSATmp*> rewriteMap(irFactory, nullptr);
auto rewriteSources = [&] (IRInstruction* inst) {
for (int i = 0; i < inst->getNumSrcs(); ++i) {
if (auto newTmp = rewriteMap[inst->getSrc(i)]) {
for (int i = 0; i < inst->numSrcs(); ++i) {
if (auto newTmp = rewriteMap[inst->src(i)]) {
FTRACE(5, " rewrite: {} -> {}\n",
inst->getSrc(i)->toString(),
inst->src(i)->toString(),
newTmp->toString());
inst->setSrc(i, newTmp);
}
@@ -46,15 +46,15 @@ void cloneToBlock(const BlockList& rpoBlocks,
for (auto it = first; it != last; ++it) {
assert(!it->isControlFlowInstruction());
FTRACE(5, "cloneToBlock({}): {}\n", target->getId(), it->toString());
FTRACE(5, "cloneToBlock({}): {}\n", target->id(), it->toString());
auto const newInst = irFactory->cloneInstruction(&*it);
if (auto const numDests = newInst->getNumDsts()) {
if (auto const numDests = newInst->numDsts()) {
for (int i = 0; i < numDests; ++i) {
FTRACE(5, " add rewrite: {} -> {}\n",
it->getDst(i)->toString(),
newInst->getDst(i)->toString());
rewriteMap[it->getDst(i)] = newInst->getDst(i);
it->dst(i)->toString(),
newInst->dst(i)->toString());
rewriteMap[it->dst(i)] = newInst->dst(i);
}
}
@@ -64,7 +64,7 @@ void cloneToBlock(const BlockList& rpoBlocks,
auto it = rpoIteratorTo(rpoBlocks, target);
for (; it != rpoBlocks.end(); ++it) {
FTRACE(5, "cloneToBlock: rewriting block {}\n", (*it)->getId());
FTRACE(5, "cloneToBlock: rewriting block {}\n", (*it)->id());
for (auto& inst : **it) {
FTRACE(5, " rewriting {}\n", inst.toString());
rewriteSources(&inst);
@@ -85,7 +85,7 @@ void moveToBlock(Block::iterator const first,
assert(!inst->isControlFlowInstruction());
FTRACE(5, "moveToBlock({}): {}\n",
target->getId(),
target->id(),
inst->toString());
it = srcBlock->erase(it);
@@ -98,7 +98,7 @@ void reflowTypes(Block* const changed, const BlockList& blocks) {
assert(isRPOSorted(blocks));
auto retypeDst = [&] (IRInstruction* inst, int num) {
auto ssa = inst->getDst(num);
auto ssa = inst->dst(num);
/*
* The type of a tmp defined by DefLabel is the union of the
@@ -117,8 +117,8 @@ void reflowTypes(Block* const changed, const BlockList& blocks) {
};
auto visit = [&] (IRInstruction* inst) {
for (int i = 0; i < inst->getNumDsts(); ++i) {
auto const ssa = inst->getDst(i);
for (int i = 0; i < inst->numDsts(); ++i) {
auto const ssa = inst->dst(i);
auto const oldType = ssa->type();
retypeDst(inst, i);
if (ssa->type() != oldType) {
@@ -131,7 +131,7 @@ void reflowTypes(Block* const changed, const BlockList& blocks) {
auto it = rpoIteratorTo(blocks, changed);
assert(it != blocks.end());
for (; it != blocks.end(); ++it) {
FTRACE(5, "reflowTypes: visiting block {}\n", (*it)->getId());
FTRACE(5, "reflowTypes: visiting block {}\n", (*it)->id());
for (auto& inst : **it) visit(&inst);
}
}
+3 -3
Ver Arquivo
@@ -45,7 +45,7 @@ static const DestType DNone = DestType::None;
* Func
* A value describing the function to call:
* (TCA)<function pointer> - Raw function pointer
* {FSSA, idx} - Use a const TCA from inst->getSrc(idx)
* {FSSA, idx} - Use a const TCA from inst->src(idx)
*
* Dest
* DSSA - The helper returns a single-register value
@@ -59,8 +59,8 @@ static const DestType DNone = DestType::None;
*
* Args
* A list of tuples describing the arguments to pass to the helper
* {SSA, idx} - Pass the value in inst->getSrc(idx)
* {TV, idx} - Pass the value in inst->getSrc(idx) as a
* {SSA, idx} - Pass the value in inst->src(idx)
* {TV, idx} - Pass the value in inst->src(idx) as a
* TypedValue, in two registers
* {VecKeyS, idx} - Like TV, but Str values are passed as a raw
* StringData*, in a single register
+6 -6
Ver Arquivo
@@ -42,7 +42,7 @@ static void insertAfter(IRInstruction* definer, IRInstruction* inst) {
* to check the _count field.
*/
static void insertRefCountAsserts(IRInstruction& inst, IRFactory* factory) {
for (SSATmp& dst : inst.getDsts()) {
for (SSATmp& dst : inst.dsts()) {
Type t = dst.type();
if (t.subtypeOf(Type::Counted | Type::StaticStr | Type::StaticArr)) {
insertAfter(&inst, factory->gen(DbgAssertRefCount, &dst));
@@ -55,8 +55,8 @@ static void insertRefCountAsserts(IRInstruction& inst, IRFactory* factory) {
* a SpillStack instruction.
*/
static void insertSpillStackAsserts(IRInstruction& inst, IRFactory* factory) {
SSATmp* sp = inst.getDst();
auto const vals = inst.getSrcs().subpiece(2);
SSATmp* sp = inst.dst();
auto const vals = inst.srcs().subpiece(2);
auto* block = inst.getBlock();
auto pos = block->iteratorTo(&inst); ++pos;
for (unsigned i = 0, n = vals.size(); i < n; ++i) {
@@ -67,7 +67,7 @@ static void insertSpillStackAsserts(IRInstruction& inst, IRFactory* factory) {
StackOffset(i),
sp);
block->insert(pos, addr);
IRInstruction* check = factory->gen(DbgAssertPtr, addr->getDst());
IRInstruction* check = factory->gen(DbgAssertPtr, addr->dst());
block->insert(pos, check);
}
}
@@ -87,13 +87,13 @@ static void insertAsserts(Trace* trace, IRFactory* factory) {
continue;
}
if (inst.op() == Call) {
SSATmp* sp = inst.getDst();
SSATmp* sp = inst.dst();
IRInstruction* addr = factory->gen(LdStackAddr,
Type::PtrToGen,
StackOffset(0),
sp);
insertAfter(&inst, addr);
insertAfter(addr, factory->gen(DbgAssertPtr, addr->getDst()));
insertAfter(addr, factory->gen(DbgAssertPtr, addr->dst()));
continue;
}
if (!inst.isBlockEnd()) insertRefCountAsserts(inst, factory);
@@ -82,11 +82,11 @@ void optimizePredictions(Trace* const trace, IRFactory* const irFactory) {
* type-specialized versions.
*/
auto optLdMem = [&] (IRInstruction* checkType, IRInstruction* lastMarker) {
auto const incRef = checkType->getSrc(0)->inst();
auto const incRef = checkType->src(0)->inst();
if (incRef->op() != IncRef) return;
auto const ldMem = incRef->getSrc(0)->inst();
auto const ldMem = incRef->src(0)->inst();
if (ldMem->op() != LdMem) return;
if (ldMem->getSrc(1)->getValInt() != 0) return;
if (ldMem->src(1)->getValInt() != 0) return;
if (!ldMem->getTypeParam().equals(Type::Cell)) return;
FTRACE(5, "candidate: {}\n", ldMem->toString());
@@ -117,7 +117,7 @@ void optimizePredictions(Trace* const trace, IRFactory* const irFactory) {
CheckTypeMem,
checkType->getTypeParam(),
checkType->getTaken(),
ldMem->getSrc(0)
ldMem->src(0)
);
mainBlock->insert(mainBlock->iteratorTo(ldMem), newCheckType);
@@ -140,7 +140,7 @@ void optimizePredictions(Trace* const trace, IRFactory* const irFactory) {
irFactory->replace(
checkType,
Mov,
incRef->getDst()
incRef->dst()
);
// Move the fallthrough case to specialized.
@@ -169,7 +169,7 @@ void optimizePredictions(Trace* const trace, IRFactory* const irFactory) {
}
if (inst.op() == CheckType &&
inst.getSrc(0)->type().equals(Type::Cell)) {
inst.src(0)->type().equals(Type::Cell)) {
assert(lastMarker);
optLdMem(&inst, lastMarker);
break;
+13 -13
Ver Arquivo
@@ -67,10 +67,10 @@ void printOpcode(std::ostream& os, const IRInstruction* inst) {
void printDst(std::ostream& os, const IRInstruction* inst,
const RegAllocInfo* regs, const LifetimeInfo* lifetime) {
if (inst->getNumDsts() == 0) return;
if (inst->numDsts() == 0) return;
const char* sep = "";
for (const SSATmp& dst : inst->getDsts()) {
for (const SSATmp& dst : inst->dsts()) {
os << punc(sep);
print(os, &dst, regs, lifetime, true);
sep = ", ";
@@ -80,7 +80,7 @@ void printDst(std::ostream& os, const IRInstruction* inst,
void printSrc(std::ostream& ostream, const IRInstruction* inst, uint32_t i,
const RegAllocInfo* regs, const LifetimeInfo* lifetime) {
SSATmp* src = inst->getSrc(i);
SSATmp* src = inst->src(i);
if (src != nullptr) {
if (lifetime && lifetime->linear[inst] != 0 && !src->isConst() &&
lifetime->uses[src].lastUse == lifetime->linear[inst]) {
@@ -100,11 +100,11 @@ void printSrcs(std::ostream& os, const IRInstruction* inst,
const LifetimeInfo* lifetime) {
bool first = true;
if (inst->op() == IncStat) {
os << " " << Stats::g_counterNames[inst->getSrc(0)->getValInt()]
<< ", " << inst->getSrc(1)->getValInt();
os << " " << Stats::g_counterNames[inst->src(0)->getValInt()]
<< ", " << inst->src(1)->getValInt();
return;
}
for (uint32_t i = 0, n = inst->getNumSrcs(); i < n; i++) {
for (uint32_t i = 0, n = inst->numSrcs(); i < n; i++) {
if (!first) {
os << punc(", ");
} else {
@@ -117,7 +117,7 @@ void printSrcs(std::ostream& os, const IRInstruction* inst,
void printLabel(std::ostream& os, const Block* block) {
os << color(ANSI_COLOR_MAGENTA);
os << "L" << block->getId();
os << "L" << block->id();
switch (block->getHint()) {
case Block::Unlikely: os << "<Unlikely>"; break;
case Block::Likely: os << "<Likely>"; break;
@@ -143,9 +143,9 @@ void print(std::ostream& ostream, const IRInstruction* inst,
if (!inst->isTransient()) {
ostream << color(ANSI_COLOR_YELLOW);
if (!lifetime || !lifetime->linear[inst]) {
ostream << folly::format("({:02d}) ", inst->getId());
ostream << folly::format("({:02d}) ", inst->id());
} else {
ostream << folly::format("({:02d}@{:02d}) ", inst->getId(),
ostream << folly::format("({:02d}@{:02d}) ", inst->id(),
lifetime->linear[inst]);
}
ostream << color(ANSI_COLOR_END);
@@ -224,7 +224,7 @@ void print(std::ostream& os, const SSATmp* tmp, const RegAllocInfo* regs,
return;
}
os << color(ANSI_COLOR_WHITE);
os << "t" << tmp->getId();
os << "t" << tmp->id();
os << color(ANSI_COLOR_END);
if (printLastUse && lifetime && lifetime->uses[tmp].lastUse != 0) {
os << color(ANSI_COLOR_GRAY)
@@ -359,11 +359,11 @@ void print(std::ostream& os, const Trace* trace, const RegAllocInfo* regs,
printLabel(os, inst.getBlock());
os << punc(":") << "\n";
// print phi pseudo-instructions
for (unsigned i = 0, n = inst.getNumDsts(); i < n; ++i) {
for (unsigned i = 0, n = inst.numDsts(); i < n; ++i) {
os << std::string(kIndent +
folly::format("({}) ", inst.getId()).str().size(),
folly::format("({}) ", inst.id()).str().size(),
' ');
JIT::print(os, inst.getDst(i), regs, lifetime, false);
JIT::print(os, inst.dst(i), regs, lifetime, false);
os << punc(" = ") << color(ANSI_COLOR_CYAN) << "phi "
<< color(ANSI_COLOR_END);
bool first = true;
+116 -116
Ver Arquivo
@@ -40,13 +40,13 @@ StackValueInfo getStackValue(SSATmp* sp, uint32_t index) {
case ReDefGeneratorSP:
case StashGeneratorSP:
return getStackValue(inst->getSrc(0), index);
return getStackValue(inst->src(0), index);
case ReDefSP:
return getStackValue(inst->getSrc(1), index);
return getStackValue(inst->src(1), index);
case ExceptionBarrier:
return getStackValue(inst->getSrc(0), index);
return getStackValue(inst->src(0), index);
case SideExitGuardStk:
always_assert(0 && "simplifier is not tested for running after jumpopts");
@@ -63,7 +63,7 @@ StackValueInfo getStackValue(SSATmp* sp, uint32_t index) {
if (inst->getExtra<StackOffset>()->offset == index) {
return StackValueInfo { inst->getTypeParam() };
}
return getStackValue(inst->getSrc(0), index);
return getStackValue(inst->src(0), index);
case CallArray: {
if (index == 0) {
@@ -71,7 +71,7 @@ StackValueInfo getStackValue(SSATmp* sp, uint32_t index) {
return StackValueInfo { nullptr };
}
auto info =
getStackValue(inst->getSrc(0),
getStackValue(inst->src(0),
// Pushes a return value, pops an ActRec and args Array
index -
(1 /* pushed */ - kNumActRecCells + 1 /* popped */));
@@ -85,7 +85,7 @@ StackValueInfo getStackValue(SSATmp* sp, uint32_t index) {
return StackValueInfo { nullptr };
}
auto info =
getStackValue(inst->getSrc(0),
getStackValue(inst->src(0),
index -
(1 /* pushed */ - kNumActRecCells /* popped */));
info.spansCall = true;
@@ -94,13 +94,13 @@ StackValueInfo getStackValue(SSATmp* sp, uint32_t index) {
case SpillStack: {
int64_t numPushed = 0;
int32_t numSpillSrcs = inst->getNumSrcs() - 2;
int32_t numSpillSrcs = inst->numSrcs() - 2;
for (int i = 0; i < numSpillSrcs; ++i) {
SSATmp* tmp = inst->getSrc(i + 2);
SSATmp* tmp = inst->src(i + 2);
if (index == numPushed) {
if (tmp->inst()->op() == IncRef) {
tmp = tmp->inst()->getSrc(0);
tmp = tmp->inst()->src(0);
}
if (!tmp->type().equals(Type::None)) {
return StackValueInfo { tmp };
@@ -111,16 +111,16 @@ StackValueInfo getStackValue(SSATmp* sp, uint32_t index) {
// This is not one of the values pushed onto the stack by this
// spillstack instruction, so continue searching.
SSATmp* prevSp = inst->getSrc(0);
int64_t numPopped = inst->getSrc(1)->getValInt();
SSATmp* prevSp = inst->src(0);
int64_t numPopped = inst->src(1)->getValInt();
return getStackValue(prevSp,
// pop values pushed by spillstack
index - (numPushed - numPopped));
}
case InterpOne: {
SSATmp* prevSp = inst->getSrc(1);
int64_t spAdjustment = inst->getSrc(3)->getValInt(); // # popped - # pushed
SSATmp* prevSp = inst->src(1);
int64_t spAdjustment = inst->src(3)->getValInt(); // # popped - # pushed
Type resultType = inst->getTypeParam();
if (index == 0 && !resultType.equals(Type::None)) {
return StackValueInfo { resultType };
@@ -129,7 +129,7 @@ StackValueInfo getStackValue(SSATmp* sp, uint32_t index) {
}
case SpillFrame:
return getStackValue(inst->getSrc(0),
return getStackValue(inst->src(0),
// pushes an ActRec
index - kNumActRecCells);
@@ -137,14 +137,14 @@ StackValueInfo getStackValue(SSATmp* sp, uint32_t index) {
{
// Assume it's a vector instruction. This will assert in
// vectorBaseIdx if not.
auto const base = inst->getSrc(vectorBaseIdx(inst));
auto const base = inst->src(vectorBaseIdx(inst));
assert(base->inst()->op() == LdStackAddr);
if (base->inst()->getExtra<LdStackAddr>()->offset == index) {
VectorEffects ve(inst);
assert(ve.baseTypeChanged || ve.baseValChanged);
return StackValueInfo { ve.baseType.derefIfPtr() };
}
return getStackValue(base->inst()->getSrc(0), index);
return getStackValue(base->inst()->src(0), index);
}
}
@@ -167,18 +167,18 @@ smart::vector<SSATmp*> collectStackValues(SSATmp* sp, uint32_t stackDepth) {
//////////////////////////////////////////////////////////////////////
static void copyPropSrc(IRInstruction* inst, int index) {
auto tmp = inst->getSrc(index);
auto tmp = inst->src(index);
auto srcInst = tmp->inst();
switch (srcInst->op()) {
case Mov:
inst->setSrc(index, srcInst->getSrc(0));
inst->setSrc(index, srcInst->src(0));
break;
case IncRef:
if (!isRefCounted(srcInst->getSrc(0))) {
if (!isRefCounted(srcInst->src(0))) {
srcInst->setOpcode(Mov);
inst->setSrc(index, srcInst->getSrc(0));
inst->setSrc(index, srcInst->src(0));
}
break;
@@ -188,7 +188,7 @@ static void copyPropSrc(IRInstruction* inst, int index) {
}
void copyProp(IRInstruction* inst) {
for (uint32_t i = 0; i < inst->getNumSrcs(); i++) {
for (uint32_t i = 0; i < inst->numSrcs(); i++) {
copyPropSrc(inst, i);
}
}
@@ -242,8 +242,8 @@ template<class... Args> SSATmp* Simplifier::gen(Args&&... args) {
//////////////////////////////////////////////////////////////////////
SSATmp* Simplifier::simplify(IRInstruction* inst) {
SSATmp* src1 = inst->getSrc(0);
SSATmp* src2 = inst->getSrc(1);
SSATmp* src1 = inst->src(0);
SSATmp* src2 = inst->src(1);
Opcode opc = inst->op();
switch (opc) {
@@ -348,9 +348,9 @@ SSATmp* Simplifier::simplify(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifySpillStack(IRInstruction* inst) {
auto const sp = inst->getSrc(0);
auto const spDeficit = inst->getSrc(1)->getValInt();
auto spillVals = inst->getSrcs().subpiece(2);
auto const sp = inst->src(0);
auto const spDeficit = inst->src(1)->getValInt();
auto spillVals = inst->srcs().subpiece(2);
auto const numSpillSrcs = spillVals.size();
auto const spillCells = spillValueCells(inst);
int64_t adjustment = spDeficit - spillCells;
@@ -364,7 +364,7 @@ SSATmp* Simplifier::simplifySpillStack(IRInstruction* inst) {
for (uint32_t i = 0, cellOff = 0; i < numSpillSrcs; i++) {
const int64_t offset = cellOff + adjustment;
auto* srcInst = spillVals[i]->inst();
if (srcInst->op() == LdStack && srcInst->getSrc(0) == sp &&
if (srcInst->op() == LdStack && srcInst->src(0) == sp &&
srcInst->getExtra<LdStack>()->offset == offset) {
spillVals[i] = m_tb->genDefNone();
}
@@ -377,14 +377,14 @@ SSATmp* Simplifier::simplifySpillStack(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyCall(IRInstruction* inst) {
auto spillVals = inst->getSrcs().subpiece(3);
auto const spillStack = inst->getSrc(0)->inst();
auto spillVals = inst->srcs().subpiece(3);
auto const spillStack = inst->src(0)->inst();
if (spillStack->op() != SpillStack) {
return nullptr;
}
SSATmp* sp = spillStack->getSrc(0);
int baseOffset = spillStack->getSrc(1)->getValInt() -
SSATmp* sp = spillStack->src(0);
int baseOffset = spillStack->src(1)->getValInt() -
spillValueCells(spillStack);
auto const numSpillSrcs = spillVals.size();
for (int32_t i = 0; i < numSpillSrcs; i++) {
@@ -393,7 +393,7 @@ SSATmp* Simplifier::simplifyCall(IRInstruction* inst) {
IRInstruction* srcInst = spillVals[i]->inst();
// If our value came from a LdStack on the same sp and offset,
// we don't need to spill it.
if (srcInst->op() == LdStack && srcInst->getSrc(0) == sp &&
if (srcInst->op() == LdStack && srcInst->src(0) == sp &&
srcInst->getExtra<LdStack>()->offset == offset) {
spillVals[i] = m_tb->genDefNone();
}
@@ -407,7 +407,7 @@ SSATmp* Simplifier::simplifyCall(IRInstruction* inst) {
// We never inline functions that could have a VarEnv, so an
// ExitOnVarEnv that has a frame based on DefInlineFP can be removed.
SSATmp* Simplifier::simplifyExitOnVarEnv(IRInstruction* inst) {
auto const frameInst = inst->getSrc(0)->inst();
auto const frameInst = inst->src(0)->inst();
if (frameInst->op() == DefInlineFP) {
inst->convertToNop();
}
@@ -415,17 +415,17 @@ SSATmp* Simplifier::simplifyExitOnVarEnv(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyLdCtx(IRInstruction* inst) {
const Func* func = inst->getSrc(1)->getValFunc();
const Func* func = inst->src(1)->getValFunc();
if (func->isStatic()) {
// ActRec->m_cls of a static function is always a valid class pointer with
// the bottom bit set
return gen(LdCctx, inst->getSrc(0));
return gen(LdCctx, inst->src(0));
}
return nullptr;
}
SSATmp* Simplifier::simplifyLdClsCtx(IRInstruction* inst) {
SSATmp* ctx = inst->getSrc(0);
SSATmp* ctx = inst->src(0);
Type ctxType = ctx->type();
if (ctxType.equals(Type::Obj)) {
// this pointer... load its class ptr
@@ -438,7 +438,7 @@ SSATmp* Simplifier::simplifyLdClsCtx(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyGetCtxFwdCall(IRInstruction* inst) {
SSATmp* srcCtx = inst->getSrc(0);
SSATmp* srcCtx = inst->src(0);
if (srcCtx->isA(Type::Cctx)) {
return srcCtx;
}
@@ -446,7 +446,7 @@ SSATmp* Simplifier::simplifyGetCtxFwdCall(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyLdCls(IRInstruction* inst) {
SSATmp* clsName = inst->getSrc(0);
SSATmp* clsName = inst->src(0);
if (clsName->isConst()) {
const Class* cls = Unit::lookupClass(clsName->getValStr());
if (cls) {
@@ -454,7 +454,7 @@ SSATmp* Simplifier::simplifyLdCls(IRInstruction* inst) {
// the class is always defined
return cns(cls);
}
const Class* ctx = inst->getSrc(1)->getValClass();
const Class* ctx = inst->src(1)->getValClass();
if (ctx && ctx->classof(cls)) {
// the class of the current function being compiled is the
// same as or derived from cls, so cls must be defined and
@@ -469,7 +469,7 @@ SSATmp* Simplifier::simplifyLdCls(IRInstruction* inst) {
SSATmp* Simplifier::simplifyCheckType(IRInstruction* inst) {
Type type = inst->getTypeParam();
SSATmp* src = inst->getSrc(0);
SSATmp* src = inst->src(0);
Type srcType = src->type();
if (srcType.subtypeOf(type)) {
@@ -507,8 +507,8 @@ SSATmp* Simplifier::simplifyCheckType(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyQueryJmp(IRInstruction* inst) {
SSATmp* src1 = inst->getSrc(0);
SSATmp* src2 = inst->getSrc(1);
SSATmp* src1 = inst->src(0);
SSATmp* src2 = inst->src(1);
Opcode opc = inst->op();
// reuse the logic in simplifyCmp.
SSATmp* newCmp = simplifyCmp(queryJmpToQueryOp(opc), src1, src2);
@@ -547,7 +547,7 @@ SSATmp* Simplifier::simplifyNot(SSATmp* src) {
switch (op) {
// !!X --> X
case OpNot:
return inst->getSrc(0);
return inst->src(0);
// !(X cmp Y) --> X opposite_cmp Y
case OpLt:
@@ -559,9 +559,9 @@ SSATmp* Simplifier::simplifyNot(SSATmp* src) {
case OpSame:
case OpNSame:
// Not for Dbl: (x < NaN) != !(x >= NaN)
if (!inst->getSrc(0)->isA(Type::Dbl) &&
!inst->getSrc(1)->isA(Type::Dbl)) {
return gen(negateQueryOp(op), inst->getSrc(0), inst->getSrc(1));
if (!inst->src(0)->isA(Type::Dbl) &&
!inst->src(1)->isA(Type::Dbl)) {
return gen(negateQueryOp(op), inst->src(0), inst->src(1));
}
break;
@@ -571,7 +571,7 @@ SSATmp* Simplifier::simplifyNot(SSATmp* src) {
// add an isNegatable.
return gen(
negateQueryOp(op),
std::make_pair(inst->getNumSrcs(), inst->getSrcs().begin())
std::make_pair(inst->numSrcs(), inst->srcs().begin())
);
return nullptr;
// TODO !(X | non_zero) --> 0
@@ -691,18 +691,18 @@ SSATmp* Simplifier::simplifyNot(SSATmp* src) {
if (src1->isA(Type::Int) && src2->isA(Type::Int)) { \
IRInstruction* inst1 = src1->inst(); \
IRInstruction* inst2 = src2->inst(); \
if (inst1->op() == Op##NAME && inst1->getSrc(1)->isConst()) { \
if (inst1->op() == Op##NAME && inst1->src(1)->isConst()) { \
/* (X + C1) + C2 --> X + C3 */ \
if (src2->isConst()) { \
int64_t right = inst1->getSrc(1)->getValInt(); \
int64_t right = inst1->src(1)->getValInt(); \
right OP##= src2->getValInt(); \
return gen(Op##NAME, inst1->getSrc(0), cns(right)); \
return gen(Op##NAME, inst1->src(0), cns(right)); \
} \
/* (X + C1) + (Y + C2) --> X + Y + C3 */ \
if (inst2->op() == Op##NAME && inst2->getSrc(1)->isConst()) { \
int64_t right = inst1->getSrc(1)->getValInt(); \
right OP##= inst2->getSrc(1)->getValInt(); \
SSATmp* left = gen(Op##NAME, inst1->getSrc(0), inst2->getSrc(0)); \
if (inst2->op() == Op##NAME && inst2->src(1)->isConst()) { \
int64_t right = inst1->src(1)->getValInt(); \
right OP##= inst2->src(1)->getValInt(); \
SSATmp* left = gen(Op##NAME, inst1->src(0), inst2->src(0)); \
return gen(Op##NAME, left, cns(right)); \
} \
} \
@@ -718,21 +718,21 @@ SSATmp* Simplifier::simplifyNot(SSATmp* src) {
Opcode op2 = inst2->op(); \
/* all combinations of X * Y + X * Z --> X * (Y + Z) */ \
if (op1 == Op##INNAME && op2 == Op##INNAME) { \
if (inst1->getSrc(0) == inst2->getSrc(0)) { \
SSATmp* fold = gen(Op##OUTNAME, inst1->getSrc(1), inst2->getSrc(1)); \
return gen(Op##INNAME, inst1->getSrc(0), fold); \
if (inst1->src(0) == inst2->src(0)) { \
SSATmp* fold = gen(Op##OUTNAME, inst1->src(1), inst2->src(1)); \
return gen(Op##INNAME, inst1->src(0), fold); \
} \
if (inst1->getSrc(0) == inst2->getSrc(1)) { \
SSATmp* fold = gen(Op##OUTNAME, inst1->getSrc(1), inst2->getSrc(0)); \
return gen(Op##INNAME, inst1->getSrc(0), fold); \
if (inst1->src(0) == inst2->src(1)) { \
SSATmp* fold = gen(Op##OUTNAME, inst1->src(1), inst2->src(0)); \
return gen(Op##INNAME, inst1->src(0), fold); \
} \
if (inst1->getSrc(1) == inst2->getSrc(0)) { \
SSATmp* fold = gen(Op##OUTNAME, inst1->getSrc(0), inst2->getSrc(1)); \
return gen(Op##INNAME, inst1->getSrc(1), fold); \
if (inst1->src(1) == inst2->src(0)) { \
SSATmp* fold = gen(Op##OUTNAME, inst1->src(0), inst2->src(1)); \
return gen(Op##INNAME, inst1->src(1), fold); \
} \
if (inst1->getSrc(1) == inst2->getSrc(1)) { \
SSATmp* fold = gen(Op##OUTNAME, inst1->getSrc(0), inst2->getSrc(0)); \
return gen(Op##INNAME, inst1->getSrc(1), fold); \
if (inst1->src(1) == inst2->src(1)) { \
SSATmp* fold = gen(Op##OUTNAME, inst1->src(0), inst2->src(0)); \
return gen(Op##INNAME, inst1->src(1), fold); \
} \
} \
} while (0)
@@ -757,10 +757,10 @@ SSATmp* Simplifier::simplifyAdd(SSATmp* src1, SSATmp* src2) {
IRInstruction* inst2 = src2->inst();
Opcode op2 = inst2->op();
if (op2 == OpSub) {
SSATmp* src = inst2->getSrc(0);
SSATmp* src = inst2->src(0);
if (src->isConst() && src->type() == Type::Int) {
if (src->getValInt() == 0) {
return gen(OpSub, src1, inst2->getSrc(1));
return gen(OpSub, src1, inst2->src(1));
}
}
}
@@ -791,10 +791,10 @@ SSATmp* Simplifier::simplifySub(SSATmp* src1, SSATmp* src2) {
IRInstruction* inst2 = src2->inst();
Opcode op2 = inst2->op();
if (op2 == OpSub) {
SSATmp* src = inst2->getSrc(0);
SSATmp* src = inst2->src(0);
if (src->isConst() && src->type() == Type::Int) {
if (src->getValInt() == 0) {
return gen(OpAdd, src1, inst2->getSrc(1));
return gen(OpAdd, src1, inst2->src(1));
}
}
}
@@ -910,7 +910,7 @@ SSATmp* Simplifier::simplifyLogicXor(SSATmp* src1, SSATmp* src2) {
static SSATmp* chaseIncRefs(SSATmp* tmp) {
while (tmp->inst()->op() == IncRef) {
tmp = tmp->inst()->getSrc(0);
tmp = tmp->inst()->src(0);
}
return tmp;
}
@@ -1190,7 +1190,7 @@ SSATmp* Simplifier::simplifyIsType(IRInstruction* inst) {
bool trueSense =
inst->op() == IsType || inst->op() == JmpIsType;
auto type = inst->getTypeParam();
auto src = inst->getSrc(0);
auto src = inst->src(0);
auto srcType = src->type();
// The comparisons below won't work for these cases covered by this
@@ -1231,7 +1231,7 @@ SSATmp* Simplifier::simplifyConcat(SSATmp* src1, SSATmp* src2) {
}
SSATmp* Simplifier::simplifyConvToArr(IRInstruction* inst) {
SSATmp* src = inst->getSrc(0);
SSATmp* src = inst->src(0);
if (src->isConst()) {
Array arr = Array::Create(src->getValVariant());
return cns(ArrayData::GetScalarArray(arr.get()));
@@ -1240,7 +1240,7 @@ SSATmp* Simplifier::simplifyConvToArr(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyConvArrToBool(IRInstruction* inst) {
SSATmp* src = inst->getSrc(0);
SSATmp* src = inst->src(0);
if (src->isConst()) {
if (src->getValArr()->empty()) {
return cns(false);
@@ -1251,7 +1251,7 @@ SSATmp* Simplifier::simplifyConvArrToBool(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyConvDblToBool(IRInstruction* inst) {
SSATmp* src = inst->getSrc(0);
SSATmp* src = inst->src(0);
if (src->isConst()) {
return cns(bool(src->getValDbl()));
}
@@ -1259,7 +1259,7 @@ SSATmp* Simplifier::simplifyConvDblToBool(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyConvIntToBool(IRInstruction* inst) {
SSATmp* src = inst->getSrc(0);
SSATmp* src = inst->src(0);
if (src->isConst()) {
return cns(bool(src->getValInt()));
}
@@ -1267,7 +1267,7 @@ SSATmp* Simplifier::simplifyConvIntToBool(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyConvStrToBool(IRInstruction* inst) {
SSATmp* src = inst->getSrc(0);
SSATmp* src = inst->src(0);
if (src->isConst()) {
// only the strings "", and "0" convert to false, all other strings
// are converted to true
@@ -1278,7 +1278,7 @@ SSATmp* Simplifier::simplifyConvStrToBool(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyConvArrToDbl(IRInstruction* inst) {
SSATmp* src = inst->getSrc(0);
SSATmp* src = inst->src(0);
if (src->isConst()) {
if (src->getValArr()->empty()) {
return cns(0.0);
@@ -1288,7 +1288,7 @@ SSATmp* Simplifier::simplifyConvArrToDbl(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyConvBoolToDbl(IRInstruction* inst) {
SSATmp* src = inst->getSrc(0);
SSATmp* src = inst->src(0);
if (src->isConst()) {
return cns(double(src->getValBool()));
}
@@ -1296,7 +1296,7 @@ SSATmp* Simplifier::simplifyConvBoolToDbl(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyConvIntToDbl(IRInstruction* inst) {
SSATmp* src = inst->getSrc(0);
SSATmp* src = inst->src(0);
if (src->isConst()) {
return cns(double(src->getValInt()));
}
@@ -1304,7 +1304,7 @@ SSATmp* Simplifier::simplifyConvIntToDbl(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyConvStrToDbl(IRInstruction* inst) {
SSATmp* src = inst->getSrc(0);
SSATmp* src = inst->src(0);
if (src->isConst()) {
const StringData *str = src->getValStr();
int64_t lval;
@@ -1321,7 +1321,7 @@ SSATmp* Simplifier::simplifyConvStrToDbl(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyConvArrToInt(IRInstruction* inst) {
SSATmp* src = inst->getSrc(0);
SSATmp* src = inst->src(0);
if (src->isConst()) {
if (src->getValArr()->empty()) {
return cns(0);
@@ -1332,7 +1332,7 @@ SSATmp* Simplifier::simplifyConvArrToInt(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyConvBoolToInt(IRInstruction* inst) {
SSATmp* src = inst->getSrc(0);
SSATmp* src = inst->src(0);
if (src->isConst()) {
return cns(int(src->getValBool()));
}
@@ -1340,7 +1340,7 @@ SSATmp* Simplifier::simplifyConvBoolToInt(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyConvDblToInt(IRInstruction* inst) {
SSATmp* src = inst->getSrc(0);
SSATmp* src = inst->src(0);
if (src->isConst()) {
return cns(toInt64(src->getValDbl()));
}
@@ -1348,7 +1348,7 @@ SSATmp* Simplifier::simplifyConvDblToInt(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyConvStrToInt(IRInstruction* inst) {
SSATmp* src = inst->getSrc(0);
SSATmp* src = inst->src(0);
if (src->isConst()) {
const StringData *str = src->getValStr();
int64_t lval;
@@ -1365,7 +1365,7 @@ SSATmp* Simplifier::simplifyConvStrToInt(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyConvBoolToStr(IRInstruction* inst) {
SSATmp* src = inst->getSrc(0);
SSATmp* src = inst->src(0);
if (src->isConst()) {
if (src->getValBool()) {
return cns(StringData::GetStaticString("1"));
@@ -1376,7 +1376,7 @@ SSATmp* Simplifier::simplifyConvBoolToStr(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyConvDblToStr(IRInstruction* inst) {
SSATmp* src = inst->getSrc(0);
SSATmp* src = inst->src(0);
if (src->isConst()) {
return cns(
StringData::convert_double_helper(src->getValDbl()));
@@ -1385,7 +1385,7 @@ SSATmp* Simplifier::simplifyConvDblToStr(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyConvIntToStr(IRInstruction* inst) {
SSATmp* src = inst->getSrc(0);
SSATmp* src = inst->src(0);
if (src->isConst()) {
return cns(
StringData::convert_integer_helper(src->getValInt()));
@@ -1394,7 +1394,7 @@ SSATmp* Simplifier::simplifyConvIntToStr(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyConvCellToBool(IRInstruction* inst) {
auto const src = inst->getSrc(0);
auto const src = inst->src(0);
auto const srcType = src->type();
if (srcType.isBool()) return src;
@@ -1409,11 +1409,11 @@ SSATmp* Simplifier::simplifyConvCellToBool(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyLdClsPropAddr(IRInstruction* inst) {
SSATmp* propName = inst->getSrc(1);
SSATmp* propName = inst->src(1);
if (!propName->isConst()) return nullptr;
SSATmp* cls = inst->getSrc(0);
auto ctxCls = inst->getSrc(2)->getValClass();
SSATmp* cls = inst->src(0);
auto ctxCls = inst->src(2)->getValClass();
if (canUseSPropCache(cls, propName->getValStr(), ctxCls)) {
@@ -1424,7 +1424,7 @@ SSATmp* Simplifier::simplifyLdClsPropAddr(IRInstruction* inst) {
cls,
propName,
cns(clsNameStr),
inst->getSrc(2));
inst->src(2));
}
return nullptr;
@@ -1437,12 +1437,12 @@ SSATmp* Simplifier::simplifyLdClsPropAddr(IRInstruction* inst) {
* calls that will have that.)
*/
SSATmp* Simplifier::simplifyLdThis(IRInstruction* inst) {
auto fpInst = inst->getSrc(0)->inst();
auto fpInst = inst->src(0)->inst();
if (fpInst->op() == DefInlineFP) {
auto spInst = fpInst->getSrc(0)->inst();
auto spInst = fpInst->src(0)->inst();
if (spInst->op() == SpillFrame &&
spInst->getSrc(3)->isA(Type::Obj)) {
return spInst->getSrc(3);
spInst->src(3)->isA(Type::Obj)) {
return spInst->src(3);
}
return nullptr;
}
@@ -1451,7 +1451,7 @@ SSATmp* Simplifier::simplifyLdThis(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyUnbox(IRInstruction* inst) {
auto* src = inst->getSrc(0);
auto* src = inst->src(0);
auto type = outputType(inst);
Type srcType = src->type();
@@ -1468,15 +1468,15 @@ SSATmp* Simplifier::simplifyUnbox(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyUnboxPtr(IRInstruction* inst) {
if (inst->getSrc(0)->isA(Type::PtrToCell)) {
if (inst->src(0)->isA(Type::PtrToCell)) {
// Nothing to unbox
return inst->getSrc(0);
return inst->src(0);
}
return nullptr;
}
SSATmp* Simplifier::simplifyCheckInit(IRInstruction* inst) {
Type srcType = inst->getSrc(0)->type();
Type srcType = inst->src(0)->type();
srcType = inst->op() == CheckInitMem ? srcType.deref() : srcType;
assert(srcType.notPtr());
assert(inst->getTaken());
@@ -1487,21 +1487,21 @@ SSATmp* Simplifier::simplifyCheckInit(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyPrint(IRInstruction* inst) {
if (inst->getSrc(0)->type().isNull()) {
if (inst->src(0)->type().isNull()) {
inst->convertToNop();
}
return nullptr;
}
SSATmp* Simplifier::simplifyDecRef(IRInstruction* inst) {
if (!isRefCounted(inst->getSrc(0))) {
if (!isRefCounted(inst->src(0))) {
inst->convertToNop();
}
return nullptr;
}
SSATmp* Simplifier::simplifyIncRef(IRInstruction* inst) {
SSATmp* src = inst->getSrc(0);
SSATmp* src = inst->src(0);
if (!isRefCounted(src)) {
return src;
}
@@ -1509,7 +1509,7 @@ SSATmp* Simplifier::simplifyIncRef(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyCondJmp(IRInstruction* inst) {
SSATmp* const src = inst->getSrc(0);
SSATmp* const src = inst->src(0);
IRInstruction* const srcInst = src->inst();
const Opcode srcOpcode = srcInst->op();
@@ -1536,7 +1536,7 @@ SSATmp* Simplifier::simplifyCondJmp(IRInstruction* inst) {
if (src->inst()->op() == OpNot) {
return gen(inst->op() == JmpZero ? JmpNZero : JmpZero,
inst->getTaken(),
srcInst->getSrc(0));
srcInst->src(0));
}
/*
@@ -1545,19 +1545,19 @@ SSATmp* Simplifier::simplifyCondJmp(IRInstruction* inst) {
* are refcounted, since we may have dec refs between the src
* instruction and the jump.
*/
for (auto& src : srcInst->getSrcs()) {
for (auto& src : srcInst->srcs()) {
if (isRefCounted(src)) return nullptr;
}
// If the source is conversion of an int or pointer to boolean, we
// can test the int/ptr value directly.
if (isConvIntOrPtrToBool(srcInst)) {
return gen(inst->op(), inst->getTaken(), srcInst->getSrc(0));
return gen(inst->op(), inst->getTaken(), srcInst->src(0));
}
// Fuse jumps with query operators.
if (isQueryOp(srcOpcode)) {
SrcRange ssas = srcInst->getSrcs();
SrcRange ssas = srcInst->srcs();
return gen(
queryToJmpOp(
inst->op() == JmpZero
@@ -1573,7 +1573,7 @@ SSATmp* Simplifier::simplifyCondJmp(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyCastStk(IRInstruction* inst) {
auto const info = getStackValue(inst->getSrc(0),
auto const info = getStackValue(inst->src(0),
inst->getExtra<CastStk>()->offset);
if (info.knownType.subtypeOf(inst->getTypeParam())) {
// No need to cast---the type was as good or better.
@@ -1583,7 +1583,7 @@ SSATmp* Simplifier::simplifyCastStk(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyAssertStk(IRInstruction* inst) {
auto const info = getStackValue(inst->getSrc(0),
auto const info = getStackValue(inst->src(0),
inst->getExtra<AssertStk>()->offset);
// AssertStk indicated that we knew the type from static analysis,
@@ -1597,7 +1597,7 @@ SSATmp* Simplifier::simplifyAssertStk(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyLdStack(IRInstruction* inst) {
auto const info = getStackValue(inst->getSrc(0),
auto const info = getStackValue(inst->src(0),
inst->getExtra<LdStack>()->offset);
// We don't want to extend live ranges of tmps across calls, so we
@@ -1632,8 +1632,8 @@ SSATmp* Simplifier::simplifyLdLoc(IRInstruction* inst) {
// Replace StRef with StRefNT when we know we aren't going to change
// its m_type field.
SSATmp* Simplifier::simplifyStRef(IRInstruction* inst) {
auto const oldUnbox = inst->getSrc(0)->type().unbox();
auto const newType = inst->getSrc(1)->type();
auto const oldUnbox = inst->src(0)->type().unbox();
auto const newType = inst->src(1)->type();
if (oldUnbox.isKnownDataType() &&
oldUnbox.equals(newType) && !oldUnbox.isString()) {
inst->setOpcode(StRefNT);
@@ -1642,7 +1642,7 @@ SSATmp* Simplifier::simplifyStRef(IRInstruction* inst) {
}
SSATmp* Simplifier::simplifyLdStackAddr(IRInstruction* inst) {
auto const info = getStackValue(inst->getSrc(0),
auto const info = getStackValue(inst->src(0),
inst->getExtra<StackOffset>()->offset);
if (!info.knownType.equals(Type::None)) {
inst->setTypeParam(
@@ -1657,7 +1657,7 @@ SSATmp* Simplifier::simplifyDecRefStack(IRInstruction* inst) {
inst->convertToNop();
return nullptr;
}
auto const info = getStackValue(inst->getSrc(0),
auto const info = getStackValue(inst->src(0),
inst->getExtra<StackOffset>()->offset);
if (info.value && !info.spansCall) {
inst->convertToNop();
+1 -1
Ver Arquivo
@@ -23,7 +23,7 @@ namespace HPHP { namespace JIT {
class SSATmp {
public:
uint32_t getId() const { return m_id; }
uint32_t id() const { return m_id; }
IRInstruction* inst() const { return m_inst; }
void setInstruction(IRInstruction* i) { m_inst = i; }
Type type() const { return m_type; }
+4 -4
Ver Arquivo
@@ -28,7 +28,7 @@ namespace HPHP { namespace JIT {
/*
* Utility to keep a vector of state about each key, indexed by
* key->getId(), where key can be an IRInstruction, Block, or SSATmp.
* key->id(), where key can be an IRInstruction, Block, or SSATmp.
*
* Takes an `init' element, which everything is defaulted to. Calls
* to reset() restore all entries to this state.
@@ -61,7 +61,7 @@ struct StateVector {
reference operator[](const Key& k) { return (*this)[&k]; }
reference operator[](const Key* k) {
auto id = k->getId();
auto id = k->id();
if (id >= m_info.size()) grow();
assert(id < m_info.size());
return m_info[id];
@@ -69,8 +69,8 @@ struct StateVector {
const_reference operator[](const Key& k) const { return (*this)[&k]; }
const_reference operator[](const Key* k) const {
assert(k->getId() < numIds(m_factory, (Key*)nullptr));
auto id = k->getId();
assert(k->id() < numIds(m_factory, (Key*)nullptr));
auto id = k->id();
return id < m_info.size() ? m_info[id] : m_init;
}
+38 -38
Ver Arquivo
@@ -106,9 +106,9 @@ SSATmp* TraceBuilder::genDefNone() {
void TraceBuilder::trackDefInlineFP(IRInstruction* inst) {
auto const target = inst->getExtra<DefInlineFP>()->target;
auto const savedSPOff = inst->getExtra<DefInlineFP>()->retSPOff;
auto const calleeFP = inst->getDst();
auto const calleeSP = inst->getSrc(0);
auto const savedSP = inst->getSrc(1);
auto const calleeFP = inst->dst();
auto const calleeSP = inst->src(0);
auto const savedSP = inst->src(1);
// Saved tracebuilder state will include the "return" fp/sp.
// Whatever the current fpValue is is good enough, but we have to be
@@ -176,7 +176,7 @@ void TraceBuilder::updateTrackedState(IRInstruction* inst) {
break;
case Call:
m_spValue = inst->getDst();
m_spValue = inst->dst();
// A call pops the ActRec and pushes a return value.
m_spOffset -= kNumActRecCells;
m_spOffset += 1;
@@ -186,7 +186,7 @@ void TraceBuilder::updateTrackedState(IRInstruction* inst) {
break;
case CallArray:
m_spValue = inst->getDst();
m_spValue = inst->dst();
// A CallArray pops the ActRec an array arg and pushes a return value.
m_spOffset -= kNumActRecCells;
assert(m_spOffset >= 0);
@@ -201,13 +201,13 @@ void TraceBuilder::updateTrackedState(IRInstruction* inst) {
case DefFP:
case FreeActRec:
m_fpValue = inst->getDst();
m_fpValue = inst->dst();
break;
case ReDefGeneratorSP:
case DefSP:
case ReDefSP:
m_spValue = inst->getDst();
m_spValue = inst->dst();
m_spOffset = inst->getExtra<StackOffset>()->offset;
break;
@@ -216,26 +216,26 @@ void TraceBuilder::updateTrackedState(IRInstruction* inst) {
case CheckStk:
case GuardStk:
case ExceptionBarrier:
m_spValue = inst->getDst();
m_spValue = inst->dst();
break;
case SpillStack: {
m_spValue = inst->getDst();
m_spValue = inst->dst();
// Push the spilled values but adjust for the popped values
int64_t stackAdjustment = inst->getSrc(1)->getValInt();
int64_t stackAdjustment = inst->src(1)->getValInt();
m_spOffset -= stackAdjustment;
m_spOffset += spillValueCells(inst);
break;
}
case SpillFrame:
m_spValue = inst->getDst();
m_spValue = inst->dst();
m_spOffset += kNumActRecCells;
break;
case InterpOne: {
m_spValue = inst->getDst();
int64_t stackAdjustment = inst->getSrc(3)->getValInt();
m_spValue = inst->dst();
int64_t stackAdjustment = inst->src(3)->getValInt();
// push the return value if any and adjust for the popped values
m_spOffset -= stackAdjustment;
break;
@@ -246,20 +246,20 @@ void TraceBuilder::updateTrackedState(IRInstruction* inst) {
// fall through to StMem; stored value is the same arg number (2)
case StMem:
case StMemNT:
m_refCountedMemValue = inst->getSrc(2);
m_refCountedMemValue = inst->src(2);
break;
case LdMem:
case LdProp:
case LdRef:
m_refCountedMemValue = inst->getDst();
m_refCountedMemValue = inst->dst();
break;
case StRefNT:
case StRef: {
m_refCountedMemValue = inst->getSrc(2);
SSATmp* newRef = inst->getDst();
SSATmp* prevRef = inst->getSrc(0);
m_refCountedMemValue = inst->src(2);
SSATmp* newRef = inst->dst();
SSATmp* prevRef = inst->src(0);
// update other tracked locals that also contain prevRef
updateLocalRefValues(prevRef, newRef);
break;
@@ -268,11 +268,11 @@ void TraceBuilder::updateTrackedState(IRInstruction* inst) {
case StLocNT:
case StLoc:
setLocalValue(inst->getExtra<LocalId>()->locId,
inst->getSrc(1));
inst->src(1));
break;
case LdLoc:
setLocalValue(inst->getExtra<LdLoc>()->locId, inst->getDst());
setLocalValue(inst->getExtra<LdLoc>()->locId, inst->dst());
break;
case OverrideLoc:
@@ -290,24 +290,24 @@ void TraceBuilder::updateTrackedState(IRInstruction* inst) {
case IterInitK:
// kill the locals to which this instruction stores iter's key and value
killLocalValue(inst->getSrc(3)->getValInt());
killLocalValue(inst->getSrc(4)->getValInt());
killLocalValue(inst->src(3)->getValInt());
killLocalValue(inst->src(4)->getValInt());
break;
case IterInit:
// kill the local to which this instruction stores iter's value
killLocalValue(inst->getSrc(3)->getValInt());
killLocalValue(inst->src(3)->getValInt());
break;
case IterNextK:
// kill the locals to which this instruction stores iter's key and value
killLocalValue(inst->getSrc(2)->getValInt());
killLocalValue(inst->getSrc(3)->getValInt());
killLocalValue(inst->src(2)->getValInt());
killLocalValue(inst->src(3)->getValInt());
break;
case IterNext:
// kill the local to which this instruction stores iter's value
killLocalValue(inst->getSrc(2)->getValInt());
killLocalValue(inst->src(2)->getValInt());
break;
case LdThis:
@@ -340,9 +340,9 @@ void TraceBuilder::updateTrackedState(IRInstruction* inst) {
// if the instruction kills any of its sources, remove them from the
// CSE table
if (inst->killsSources()) {
for (int i = 0; i < inst->getNumSrcs(); ++i) {
for (int i = 0; i < inst->numSrcs(); ++i) {
if (inst->killsSource(i)) {
cseKill(inst->getSrc(i));
cseKill(inst->src(i));
}
}
}
@@ -520,7 +520,7 @@ CSEHash* TraceBuilder::getCSEHashTable(IRInstruction* inst) {
}
void TraceBuilder::cseInsert(IRInstruction* inst) {
getCSEHashTable(inst)->insert(inst->getDst());
getCSEHashTable(inst)->insert(inst->dst());
}
void TraceBuilder::cseKill(SSATmp* src) {
@@ -592,9 +592,9 @@ SSATmp* TraceBuilder::preOptimizeDecRef(IRInstruction* inst) {
* available. I.e. by the time they get to the DecRef we won't see
* it in isValueAvailable anymore and won't convert to DecRefNZ.
*/
auto const srcInst = inst->getSrc(0)->inst();
auto const srcInst = inst->src(0)->inst();
if (srcInst->op() == IncRef) {
if (isValueAvailable(srcInst->getSrc(0))) {
if (isValueAvailable(srcInst->src(0))) {
inst->setOpcode(DecRefNZ);
}
}
@@ -621,13 +621,13 @@ SSATmp* TraceBuilder::preOptimizeDecRefThis(IRInstruction* inst) {
* frame, so debug_backtrace() can't see a non-live pointer value.
*/
if (thisInst->op() == IncRef &&
callerHasValueAvailable(thisInst->getSrc(0))) {
callerHasValueAvailable(thisInst->src(0))) {
gen(DecRefNZ, thiss);
inst->convertToNop();
return nullptr;
}
assert(inst->getSrc(0) == m_fpValue);
assert(inst->src(0) == m_fpValue);
gen(DecRef, thiss);
inst->convertToNop();
return nullptr;
@@ -693,7 +693,7 @@ SSATmp* TraceBuilder::preOptimizeLdLocAddr(IRInstruction* inst) {
SSATmp* TraceBuilder::preOptimizeStLoc(IRInstruction* inst) {
auto const curType = getLocalType(inst->getExtra<StLoc>()->locId);
auto const newType = inst->getSrc(1)->type();
auto const newType = inst->src(1)->type();
assert(inst->getTypeParam().equals(Type::None));
@@ -789,7 +789,7 @@ SSATmp* TraceBuilder::optimizeInst(IRInstruction* inst) {
appendInstruction(inst);
// returns nullptr if instruction has no dest, returns the first
// (possibly only) dest otherwise
return inst->getDst(0);
return inst->dst(0);
}
return nullptr;
}
@@ -850,7 +850,7 @@ void TraceBuilder::reoptimize() {
Block* block = blocks.front();
blocks.pop_front();
assert(block->getTrace() == m_trace.get());
FTRACE(5, "Block: {}\n", block->getId());
FTRACE(5, "Block: {}\n", block->id());
m_trace->push_back(block);
if (m_snapshots[block]) {
@@ -871,7 +871,7 @@ void TraceBuilder::reoptimize() {
updateTrackedState(inst);
continue;
}
SSATmp* dst = inst->getDst();
SSATmp* dst = inst->dst();
if (dst->type() != Type::None && dst != tmp) {
// The result of optimization has a different destination than the inst.
// Generate a mov(tmp->dst) to get result into dst. If we get here then
@@ -990,7 +990,7 @@ void TraceBuilder::killLocals() {
// make the new DefConst instruction
IRInstruction* clone = t->inst()->clone(&m_irFactory);
clone->setOpcode(DefConst);
m_localValues[i] = clone->getDst();
m_localValues[i] = clone->dst();
continue;
}
assert(!t->isConst());
+2 -2
Ver Arquivo
@@ -142,7 +142,7 @@ struct TraceBuilder {
SSATmp* genFor(Trace* t, Args... args) {
auto instr = m_irFactory.gen(args...);
t->back()->push_back(instr);
return instr->getDst();
return instr->dst();
}
//////////////////////////////////////////////////////////////////////
@@ -200,7 +200,7 @@ struct TraceBuilder {
SSATmp* v2 = taken();
gen(Jmp_, done_block, v2);
appendBlock(done_block);
SSATmp* result = done_block->getLabel()->getDst(0);
SSATmp* result = done_block->getLabel()->dst(0);
result->setType(Type::unionOf(v1->type(), v2->type()));
return result;
}
+19 -19
Ver Arquivo
@@ -62,7 +62,7 @@ Type builtinReturn(const IRInstruction* inst) {
}
Type boxReturn(const IRInstruction* inst, int srcId) {
auto t = inst->getSrc(srcId)->type();
auto t = inst->src(srcId)->type();
// If t contains Uninit, replace it with InitNull.
t = t.maybe(Type::Uninit) ? (t - Type::Uninit) | Type::InitNull : t;
// We don't try to track when a BoxedStaticStr might be converted to
@@ -109,8 +109,8 @@ Type binArithResultType(Opcode op, Type t1, Type t2) {
Type outputType(const IRInstruction* inst, int dstId) {
#define D(type) return Type::type;
#define DofS(n) return inst->getSrc(n)->type();
#define DUnbox(n) return inst->getSrc(n)->type().unbox();
#define DofS(n) return inst->src(n)->type();
#define DUnbox(n) return inst->src(n)->type().unbox();
#define DBox(n) return boxReturn(inst, n);
#define DParam return inst->getTypeParam();
#define DMulti return Type::None;
@@ -120,8 +120,8 @@ Type outputType(const IRInstruction* inst, int dstId) {
#define ND assert(0 && "outputType requires HasDest or NaryDest");
#define DBuiltin return builtinReturn(inst);
#define DArith return binArithResultType(inst->op(), \
inst->getSrc(0)->type(), \
inst->getSrc(1)->type());
inst->src(0)->type(), \
inst->src(1)->type());
#define O(name, dstinfo, srcinfo, flags) case name: dstinfo not_reached();
@@ -186,9 +186,9 @@ void assertOperandTypes(const IRInstruction* inst) {
always_assert(false && "instruction operand type check failure");
};
auto getSrc = [&]() -> SSATmp* {
if (curSrc < inst->getNumSrcs()) {
return inst->getSrc(curSrc);
auto src = [&]() -> SSATmp* {
if (curSrc < inst->numSrcs()) {
return inst->src(curSrc);
}
bail(folly::format(
@@ -211,13 +211,13 @@ void assertOperandTypes(const IRInstruction* inst) {
curSrc,
inst->toString(),
expected,
inst->getSrc(curSrc)->type().toString()
inst->src(curSrc)->type().toString()
).str()
);
};
auto checkNoArgs = [&]{
if (inst->getNumSrcs() == 0) return;
if (inst->numSrcs() == 0) return;
bail(folly::format(
"Error: instruction expected no operands\n"
" instruction: {}\n",
@@ -227,7 +227,7 @@ void assertOperandTypes(const IRInstruction* inst) {
};
auto countCheck = [&]{
if (inst->getNumSrcs() == curSrc) return;
if (inst->numSrcs() == curSrc) return;
bail(folly::format(
"Error: instruction had too many operands\n"
" instruction: {}\n"
@@ -249,10 +249,10 @@ void assertOperandTypes(const IRInstruction* inst) {
};
auto checkSpills = [&] {
for (; curSrc < inst->getNumSrcs(); ++curSrc) {
for (; curSrc < inst->numSrcs(); ++curSrc) {
// SpillStack slots may be stack types or None, if the
// simplifier removed some.
auto const valid = inst->getSrc(curSrc)->type()
auto const valid = inst->src(curSrc)->type()
.subtypeOfAny(Type::Gen, Type::Cls, Type::None);
check(valid, "Gen|Cls|None");
}
@@ -265,11 +265,11 @@ void assertOperandTypes(const IRInstruction* inst) {
#define NA return checkNoArgs();
#define S(...) { \
Type t = buildUnion(__VA_ARGS__); \
check(getSrc()->isA(t), t.toString()); \
check(src()->isA(t), t.toString()); \
++curSrc; \
}
#define C(type) check(getSrc()->isConst() && \
getSrc()->isA(type), \
#define C(type) check(src()->isConst() && \
src()->isA(type), \
"constant " #type); \
++curSrc;
#define CStr C(StaticStr)
@@ -283,11 +283,11 @@ void assertOperandTypes(const IRInstruction* inst) {
#define DVector
#define D(...)
#define DBuiltin
#define DUnbox(src) checkDst(src < inst->getNumSrcs(), \
#define DUnbox(src) checkDst(src < inst->numSrcs(), \
"invalid src num");
#define DBox(src) checkDst(src < inst->getNumSrcs(), \
#define DBox(src) checkDst(src < inst->numSrcs(), \
"invalid src num");
#define DofS(src) checkDst(src < inst->getNumSrcs(), \
#define DofS(src) checkDst(src < inst->numSrcs(), \
"invalid src num");
#define DParam checkDst(inst->getTypeParam() != Type::None || \
inst->op() == DefConst /* for DefNone */, \
@@ -48,10 +48,10 @@ void VectorEffects::get(const IRInstruction* inst,
SetLocTypeFunc setLocalType) {
// If the base for this instruction is a local address, the
// helper call might have side effects on the local's value
SSATmp* base = inst->getSrc(vectorBaseIdx(inst));
SSATmp* base = inst->src(vectorBaseIdx(inst));
IRInstruction* locInstr = base->inst();
if (locInstr->op() == LdLocAddr) {
UNUSED Type baseType = locInstr->getDst()->type();
UNUSED Type baseType = locInstr->dst()->type();
assert(baseType.equals(base->type()));
assert(baseType.isPtr() || baseType.isKnownDataType());
int loc = locInstr->getExtra<LdLocAddr>()->locId;
@@ -94,9 +94,9 @@ VectorEffects::VectorEffects(const IRInstruction* inst) {
int keyIdx = vectorKeyIdx(inst);
int valIdx = vectorValIdx(inst);
init(inst->op(),
inst->getSrc(vectorBaseIdx(inst))->type(),
keyIdx == -1 ? Type::None : inst->getSrc(keyIdx)->type(),
valIdx == -1 ? Type::None : inst->getSrc(valIdx)->type());
inst->src(vectorBaseIdx(inst))->type(),
keyIdx == -1 ? Type::None : inst->src(keyIdx)->type(),
valIdx == -1 ? Type::None : inst->src(valIdx)->type());
}
VectorEffects::VectorEffects(Opcode op, Type base, Type key, Type val) {
@@ -2068,8 +2068,8 @@ bool HhbcTranslator::VectorTranslator::usePredictedResult() {
// where the result of a SetM might have the same type as its input without
// being the same value.
IRInstruction* inst = m_result->inst();
SSATmp* base = inst->getSrc(vectorBaseIdx(inst));
SSATmp* value = inst->getSrc(vectorValIdx(inst));
SSATmp* base = inst->src(vectorBaseIdx(inst));
SSATmp* value = inst->src(vectorValIdx(inst));
return base->type().strip().not(Type::Str) ||
value->type().strip().not(Type::Str);
}