Rename IRInstruction's iid property to id.
I called it iid because id was taken by the linear-scan specific 'id' field, which really was a linear number and could change. Now that we have LifetimeInfo.linear[inst], we can use the name id consistently between SSATmp, IRInstruction, and Block. This in turn allows StateVector to be one iota simpler. Renamed count to numIds while I was at it.
Esse commit está contido em:
@@ -111,7 +111,7 @@ private:
|
||||
};
|
||||
static_assert(sizeof(DceFlags) == 1, "sizeof(DceFlags) should be 1 byte");
|
||||
|
||||
// DCE state indexed by instr->getIId.
|
||||
// DCE state indexed by instr->getId().
|
||||
typedef StateVector<IRInstruction, DceFlags> DceState;
|
||||
typedef hphp_hash_set<const SSATmp*, pointer_hash<SSATmp>> SSASet;
|
||||
typedef StateVector<SSATmp, SSASet> SSACache;
|
||||
@@ -385,8 +385,8 @@ void optimizeActRecs(Trace* trace, DceState& state, IRFactory* factory,
|
||||
if (spInst->op() == SpillFrame &&
|
||||
spInst->getSrc(3)->type().subtypeOfAny(Type::Obj, Type::Null)) {
|
||||
FTRACE(5, "CreateCont ({}): weak use of frame {}\n",
|
||||
inst->getIId(),
|
||||
frameInst->getIId());
|
||||
inst->getId(),
|
||||
frameInst->getId());
|
||||
state[frameInst].incWeakUse();
|
||||
}
|
||||
}
|
||||
@@ -402,7 +402,7 @@ void optimizeActRecs(Trace* trace, DceState& state, IRFactory* factory,
|
||||
// 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->getIId());
|
||||
FTRACE(5, "killing frame {}\n", srcInst->getId());
|
||||
killedFrames = true;
|
||||
state[srcInst].setDead();
|
||||
}
|
||||
@@ -429,7 +429,7 @@ void optimizeActRecs(Trace* trace, DceState& state, IRFactory* factory,
|
||||
{
|
||||
auto const fp = inst->getSrc(1);
|
||||
if (state[fp->inst()].isDead()) {
|
||||
FTRACE(5, "CreateCont ({}) -> InlineCreateCont\n", inst->getIId());
|
||||
FTRACE(5, "CreateCont ({}) -> InlineCreateCont\n", inst->getId());
|
||||
|
||||
CreateContData data;
|
||||
data.origFunc = inst->getSrc(3)->getValFunc();
|
||||
@@ -451,7 +451,7 @@ void optimizeActRecs(Trace* trace, DceState& state, IRFactory* factory,
|
||||
{
|
||||
auto const fp = inst->getSrc(0);
|
||||
if (state[fp->inst()].isDead()) {
|
||||
FTRACE(5, "InlineReturn ({}) setDead\n", inst->getIId());
|
||||
FTRACE(5, "InlineReturn ({}) setDead\n", inst->getId());
|
||||
state[inst].setDead();
|
||||
}
|
||||
}
|
||||
@@ -459,7 +459,7 @@ void optimizeActRecs(Trace* trace, DceState& state, IRFactory* factory,
|
||||
|
||||
case DefInlineFP:
|
||||
FTRACE(5, "DefInlineFP ({}): weak/strong uses: {}/{}\n",
|
||||
inst->getIId(),
|
||||
inst->getId(),
|
||||
state[inst].weakUseCount(),
|
||||
uses[inst->getDst()]);
|
||||
break;
|
||||
@@ -546,8 +546,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.getIId() < live.size());
|
||||
return !live.test(inst.getIId());
|
||||
assert(inst.getId() < live.size());
|
||||
return !live.test(inst.getId());
|
||||
});
|
||||
if (block->empty()) blocks.erase(cur);
|
||||
}
|
||||
|
||||
@@ -289,12 +289,12 @@ std::string showExtra(Opcode opc, const IRExtraData* data) {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
IRInstruction::IRInstruction(Arena& arena, const IRInstruction* inst, IId iid)
|
||||
IRInstruction::IRInstruction(Arena& arena, const IRInstruction* inst, Id id)
|
||||
: m_op(inst->m_op)
|
||||
, m_typeParam(inst->m_typeParam)
|
||||
, m_numSrcs(inst->m_numSrcs)
|
||||
, m_numDsts(inst->m_numDsts)
|
||||
, m_iid(iid)
|
||||
, m_id(id)
|
||||
, m_srcs(m_numSrcs ? new (arena) SSATmp*[m_numSrcs] : nullptr)
|
||||
, m_dst(nullptr)
|
||||
, m_taken(nullptr)
|
||||
@@ -607,7 +607,7 @@ bool isRefCounted(SSATmp* tmp) {
|
||||
|
||||
void IRInstruction::convertToNop() {
|
||||
IRInstruction nop(Nop);
|
||||
// copy all but m_iid, m_block, m_taken, m_listNode
|
||||
// copy all but m_id, m_block, m_taken, m_listNode
|
||||
m_op = nop.m_op;
|
||||
m_typeParam = nop.m_typeParam;
|
||||
m_numSrcs = nop.m_numSrcs;
|
||||
@@ -644,7 +644,7 @@ void IRInstruction::become(IRFactory* factory, IRInstruction* other) {
|
||||
assert(!canCSE());
|
||||
auto& arena = factory->arena();
|
||||
|
||||
// Copy all but m_iid, m_block, m_listNode, and don't clone
|
||||
// Copy all but m_id, m_block, m_listNode, and don't clone
|
||||
// dests---the whole point of become() is things still point to us.
|
||||
m_op = other->m_op;
|
||||
m_typeParam = other->m_typeParam;
|
||||
@@ -863,7 +863,7 @@ TCA SSATmp::getValTCA() const {
|
||||
}
|
||||
|
||||
std::string ExitData::show() const {
|
||||
return folly::to<std::string>(toSmash->getIId());
|
||||
return folly::to<std::string>(toSmash->getId());
|
||||
}
|
||||
|
||||
std::string SSATmp::toString() const {
|
||||
|
||||
@@ -1632,7 +1632,7 @@ typedef Range<SSATmp*> DstRange;
|
||||
* (Destructors are not called when they come from IRFactory.)
|
||||
*/
|
||||
struct IRInstruction {
|
||||
enum IId { kTransient = 0xffffffff };
|
||||
enum Id { kTransient = 0xffffffff };
|
||||
|
||||
/*
|
||||
* Create an IRInstruction for the opcode `op'.
|
||||
@@ -1647,7 +1647,7 @@ struct IRInstruction {
|
||||
, m_typeParam(Type::None)
|
||||
, m_numSrcs(numSrcs)
|
||||
, m_numDsts(0)
|
||||
, m_iid(kTransient)
|
||||
, m_id(kTransient)
|
||||
, m_srcs(srcs)
|
||||
, m_dst(nullptr)
|
||||
, m_taken(nullptr)
|
||||
@@ -1663,7 +1663,7 @@ struct IRInstruction {
|
||||
* Construct an IRInstruction as a deep copy of `inst', using
|
||||
* arena to allocate memory for its srcs/dests.
|
||||
*/
|
||||
explicit IRInstruction(Arena& arena, const IRInstruction* inst, IId iid);
|
||||
explicit IRInstruction(Arena& arena, const IRInstruction* inst, Id id);
|
||||
|
||||
/*
|
||||
* Initialize the source list for this IRInstruction. We must not
|
||||
@@ -1760,7 +1760,7 @@ struct IRInstruction {
|
||||
|
||||
/*
|
||||
* Turns this instruction into the target instruction, without
|
||||
* changing stable fields (IId, current block, list fields). The
|
||||
* changing stable fields (id, current block, list fields). The
|
||||
* existing destination SSATmp(s) will continue to think they came
|
||||
* from this instruction.
|
||||
*
|
||||
@@ -1825,11 +1825,11 @@ struct IRInstruction {
|
||||
void setTCA(TCA newTCA) { m_tca = newTCA; }
|
||||
|
||||
/*
|
||||
* Instruction id (iid) is stable and useful as an array index.
|
||||
* Instruction id is stable and useful as an array index.
|
||||
*/
|
||||
uint32_t getIId() const {
|
||||
assert(m_iid != kTransient);
|
||||
return m_iid;
|
||||
uint32_t getId() const {
|
||||
assert(m_id != kTransient);
|
||||
return m_id;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1837,7 +1837,7 @@ struct IRInstruction {
|
||||
* is, it's allocated on the stack and we haven't yet committed to
|
||||
* inserting it in any blocks.
|
||||
*/
|
||||
bool isTransient() const { return m_iid == kTransient; }
|
||||
bool isTransient() const { return m_id == kTransient; }
|
||||
|
||||
Block* getBlock() const { return m_block; }
|
||||
void setBlock(Block* b) { m_block = b; }
|
||||
@@ -1898,7 +1898,7 @@ private:
|
||||
Type m_typeParam;
|
||||
uint16_t m_numSrcs;
|
||||
uint16_t m_numDsts;
|
||||
const IId m_iid;
|
||||
const Id m_id;
|
||||
SSATmp** m_srcs;
|
||||
SSATmp* m_dst; // if HasDest or NaryDest
|
||||
Block* m_taken; // for branches, guards, and jmp
|
||||
|
||||
@@ -183,7 +183,7 @@ public:
|
||||
* Replace an existing IRInstruction with a new one.
|
||||
*
|
||||
* This may involve making more allocations in the arena, but the
|
||||
* actual IRInstruction* itself, its IId, etc, will stay unchanged.
|
||||
* actual IRInstruction* itself, its Id, etc, will stay unchanged.
|
||||
*
|
||||
* This function takes arguments in the same format as gen().
|
||||
*/
|
||||
@@ -200,7 +200,7 @@ public:
|
||||
*/
|
||||
IRInstruction* cloneInstruction(const IRInstruction* inst) {
|
||||
auto newInst = new (m_arena) IRInstruction(
|
||||
m_arena, inst, IRInstruction::IId(m_nextInstId++));
|
||||
m_arena, inst, IRInstruction::Id(m_nextInstId++));
|
||||
if (newInst->modifiesStack()) {
|
||||
assert(newInst->naryDst());
|
||||
// The instruction is an opcode that modifies the stack, returning a new
|
||||
|
||||
@@ -268,13 +268,13 @@ private:
|
||||
}
|
||||
|
||||
bool isLive(IRInstruction* inst) const {
|
||||
assert(inst->getIId() < m_liveInsts.size());
|
||||
return m_liveInsts.test(inst->getIId());
|
||||
assert(inst->getId() < m_liveInsts.size());
|
||||
return m_liveInsts.test(inst->getId());
|
||||
}
|
||||
|
||||
void setLive(IRInstruction& inst, bool live) {
|
||||
assert(inst.getIId() < m_liveInsts.size());
|
||||
m_liveInsts.set(inst.getIId(), live);
|
||||
assert(inst.getId() < m_liveInsts.size());
|
||||
m_liveInsts.set(inst.getId(), live);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -138,9 +138,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->getIId());
|
||||
ostream << folly::format("({:02d}) ", inst->getId());
|
||||
} else {
|
||||
ostream << folly::format("({:02d}@{:02d}) ", inst->getIId(),
|
||||
ostream << folly::format("({:02d}@{:02d}) ", inst->getId(),
|
||||
lifetime->linear[inst]);
|
||||
}
|
||||
ostream << color(ANSI_COLOR_END);
|
||||
@@ -333,7 +333,7 @@ void print(std::ostream& os, const Trace* trace, const RegAllocInfo* regs,
|
||||
// print phi pseudo-instructions
|
||||
for (unsigned i = 0, n = inst.getNumDsts(); i < n; ++i) {
|
||||
os << std::string(kIndent +
|
||||
folly::format("({}) ", inst.getIId()).str().size(),
|
||||
folly::format("({}) ", inst.getId()).str().size(),
|
||||
' ');
|
||||
JIT::print(os, inst.getDst(i), regs, lifetime, false);
|
||||
os << punc(" = ") << color(ANSI_COLOR_CYAN) << "phi "
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace HPHP { namespace VM { namespace JIT {
|
||||
|
||||
/*
|
||||
* Utility to keep a vector of state about each key, indexed by
|
||||
* factoryId(key), where key can be an IRInstruction, Block, or SSATmp.
|
||||
* key->getId(), 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.
|
||||
@@ -42,7 +42,7 @@ struct StateVector {
|
||||
|
||||
StateVector(const IRFactory* factory, Info init)
|
||||
: m_factory(factory)
|
||||
, m_info(count(factory, (Key*)nullptr), init)
|
||||
, m_info(numIds(factory, (Key*)nullptr), init)
|
||||
, m_init(init) {
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ struct StateVector {
|
||||
|
||||
reference operator[](const Key& k) { return (*this)[&k]; }
|
||||
reference operator[](const Key* k) {
|
||||
auto id = factoryId(k);
|
||||
auto id = k->getId();
|
||||
if (id >= m_info.size()) grow();
|
||||
assert(id < m_info.size());
|
||||
return m_info[id];
|
||||
@@ -61,8 +61,8 @@ struct StateVector {
|
||||
|
||||
const_reference operator[](const Key& k) const { return (*this)[&k]; }
|
||||
const_reference operator[](const Key* k) const {
|
||||
assert(factoryId(k) < count(m_factory, (Key*)nullptr));
|
||||
auto id = factoryId(k);
|
||||
assert(k->getId() < numIds(m_factory, (Key*)nullptr));
|
||||
auto id = k->getId();
|
||||
return id < m_info.size() ? m_info[id] : m_init;
|
||||
}
|
||||
|
||||
@@ -74,25 +74,19 @@ struct StateVector {
|
||||
const_iterator cend() const { return m_info.cend(); }
|
||||
|
||||
private:
|
||||
static unsigned factoryId(const IRInstruction* inst) {
|
||||
return inst->getIId();
|
||||
}
|
||||
static unsigned factoryId(const Block* block) { return block->getId(); }
|
||||
static unsigned factoryId(const SSATmp* tmp) { return tmp->getId(); }
|
||||
|
||||
static unsigned count(const IRFactory* factory, IRInstruction*) {
|
||||
static unsigned numIds(const IRFactory* factory, IRInstruction*) {
|
||||
return factory->numInsts();
|
||||
}
|
||||
static unsigned count(const IRFactory* factory, SSATmp*) {
|
||||
static unsigned numIds(const IRFactory* factory, SSATmp*) {
|
||||
return factory->numTmps();
|
||||
}
|
||||
static unsigned count(const IRFactory* factory, Block*) {
|
||||
static unsigned numIds(const IRFactory* factory, Block*) {
|
||||
return factory->numBlocks();
|
||||
}
|
||||
|
||||
private:
|
||||
void grow() {
|
||||
m_info.resize(count(m_factory, static_cast<Key*>(nullptr)),
|
||||
m_info.resize(numIds(m_factory, static_cast<Key*>(nullptr)),
|
||||
m_init);
|
||||
}
|
||||
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário