зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1673553 part 33 - Simplify some MIRGraph and MPhi code. r=iain
Differential Revision: https://phabricator.services.mozilla.com/D97578
This commit is contained in:
Родитель
c2b0d896d7
Коммит
33fc7fee2e
|
@ -2007,20 +2007,9 @@ bool MPhi::specializeType(TempAllocator& alloc) {
|
|||
|
||||
MOZ_ASSERT(!inputs_.empty());
|
||||
|
||||
size_t start;
|
||||
if (hasBackedgeType_) {
|
||||
// The type of this phi has already been populated with potential types
|
||||
// that could come in via loop backedges.
|
||||
// TODO(no-TI): clean up.
|
||||
start = 0;
|
||||
} else {
|
||||
setResultType(getOperand(0)->type());
|
||||
start = 1;
|
||||
}
|
||||
MIRType resultType = getOperand(0)->type();
|
||||
|
||||
MIRType resultType = this->type();
|
||||
|
||||
for (size_t i = start; i < inputs_.length(); i++) {
|
||||
for (size_t i = 1; i < inputs_.length(); i++) {
|
||||
MDefinition* def = getOperand(i);
|
||||
MergeTypes(&resultType, def->type());
|
||||
}
|
||||
|
@ -3300,23 +3289,6 @@ MResumePoint* MResumePoint::New(TempAllocator& alloc, MBasicBlock* block,
|
|||
return resume;
|
||||
}
|
||||
|
||||
MResumePoint* MResumePoint::Copy(TempAllocator& alloc, MResumePoint* src) {
|
||||
MResumePoint* resume =
|
||||
new (alloc) MResumePoint(src->block(), src->pc(), src->mode());
|
||||
// Copy the operands from the original resume point, and not from the
|
||||
// current block stack.
|
||||
if (!resume->operands_.init(alloc, src->numAllocatedOperands())) {
|
||||
src->block()->discardPreAllocatedResumePoint(resume);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Copy the operands.
|
||||
for (size_t i = 0; i < resume->numOperands(); i++) {
|
||||
resume->initOperand(i, src->getOperand(i));
|
||||
}
|
||||
return resume;
|
||||
}
|
||||
|
||||
MResumePoint::MResumePoint(MBasicBlock* block, jsbytecode* pc, Mode mode)
|
||||
: MNode(block, Kind::ResumePoint),
|
||||
pc_(pc),
|
||||
|
|
|
@ -6352,7 +6352,6 @@ class MPhi final : public MDefinition,
|
|||
InputVector inputs_;
|
||||
|
||||
TruncateKind truncateKind_;
|
||||
bool hasBackedgeType_;
|
||||
bool triedToSpecialize_;
|
||||
bool isIterator_;
|
||||
bool canProduceFloat32_;
|
||||
|
@ -6385,7 +6384,6 @@ class MPhi final : public MDefinition,
|
|||
: MDefinition(classOpcode),
|
||||
inputs_(alloc),
|
||||
truncateKind_(NoTruncate),
|
||||
hasBackedgeType_(false),
|
||||
triedToSpecialize_(false),
|
||||
isIterator_(false),
|
||||
canProduceFloat32_(false),
|
||||
|
@ -6422,7 +6420,6 @@ class MPhi final : public MDefinition,
|
|||
void replaceOperand(size_t index, MDefinition* operand) final {
|
||||
inputs_[index].replaceProducer(operand);
|
||||
}
|
||||
bool hasBackedgeType() const { return hasBackedgeType_; }
|
||||
bool triedToSpecialize() const { return triedToSpecialize_; }
|
||||
void specialize(MIRType type) {
|
||||
triedToSpecialize_ = true;
|
||||
|
@ -11635,7 +11632,6 @@ class MResumePoint final : public MNode
|
|||
public:
|
||||
static MResumePoint* New(TempAllocator& alloc, MBasicBlock* block,
|
||||
jsbytecode* pc, Mode mode);
|
||||
static MResumePoint* Copy(TempAllocator& alloc, MResumePoint* src);
|
||||
|
||||
MBasicBlock* block() const { return resumePointBlock(); }
|
||||
|
||||
|
|
|
@ -606,78 +606,6 @@ bool MBasicBlock::initEntrySlots(TempAllocator& alloc) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void MBasicBlock::shimmySlots(int discardDepth) {
|
||||
// Move all slots above the given depth down by one,
|
||||
// overwriting the MDefinition at discardDepth.
|
||||
|
||||
MOZ_ASSERT(discardDepth < 0);
|
||||
MOZ_ASSERT(stackPosition_ + discardDepth >= info_.firstStackSlot());
|
||||
|
||||
for (int i = discardDepth; i < -1; i++) {
|
||||
slots_[stackPosition_ + i] = slots_[stackPosition_ + i + 1];
|
||||
}
|
||||
|
||||
--stackPosition_;
|
||||
}
|
||||
|
||||
bool MBasicBlock::linkOsrValues(MStart* start) {
|
||||
MResumePoint* res = start->resumePoint();
|
||||
|
||||
for (uint32_t i = 0; i < stackDepth(); i++) {
|
||||
MDefinition* def = slots_[i];
|
||||
MInstruction* cloneRp = nullptr;
|
||||
if (i == info().environmentChainSlot()) {
|
||||
if (def->isOsrEnvironmentChain()) {
|
||||
cloneRp = def->toOsrEnvironmentChain();
|
||||
}
|
||||
} else if (i == info().returnValueSlot()) {
|
||||
if (def->isOsrReturnValue()) {
|
||||
cloneRp = def->toOsrReturnValue();
|
||||
}
|
||||
} else if (info().hasArguments() && i == info().argsObjSlot()) {
|
||||
MOZ_ASSERT(def->isConstant() || def->isOsrArgumentsObject());
|
||||
MOZ_ASSERT_IF(def->isConstant(),
|
||||
def->toConstant()->type() == MIRType::Undefined);
|
||||
if (def->isOsrArgumentsObject()) {
|
||||
cloneRp = def->toOsrArgumentsObject();
|
||||
}
|
||||
} else {
|
||||
MOZ_ASSERT(def->isOsrValue() || def->isGetArgumentsObjectArg() ||
|
||||
def->isConstant() || def->isParameter());
|
||||
|
||||
// A constant Undefined can show up here for an argument slot when
|
||||
// the function has an arguments object, but the argument in
|
||||
// question is stored on the scope chain.
|
||||
MOZ_ASSERT_IF(def->isConstant(),
|
||||
def->toConstant()->type() == MIRType::Undefined);
|
||||
|
||||
if (def->isOsrValue()) {
|
||||
cloneRp = def->toOsrValue();
|
||||
} else if (def->isGetArgumentsObjectArg()) {
|
||||
cloneRp = def->toGetArgumentsObjectArg();
|
||||
} else if (def->isParameter()) {
|
||||
cloneRp = def->toParameter();
|
||||
}
|
||||
}
|
||||
|
||||
if (cloneRp) {
|
||||
MResumePoint* clone = MResumePoint::Copy(graph().alloc(), res);
|
||||
if (!clone) {
|
||||
return false;
|
||||
}
|
||||
cloneRp->setResumePoint(clone);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MBasicBlock::rewriteAtDepth(int32_t depth, MDefinition* ins) {
|
||||
MOZ_ASSERT(depth < 0);
|
||||
MOZ_ASSERT(stackPosition_ + depth >= info_.firstStackSlot());
|
||||
rewriteSlot(stackPosition_ + depth, ins);
|
||||
}
|
||||
|
||||
MDefinition* MBasicBlock::environmentChain() {
|
||||
return getSlot(info().environmentChainSlot());
|
||||
}
|
||||
|
@ -1109,7 +1037,7 @@ void MBasicBlock::assertUsesAreNotWithin(MUseIterator use, MUseIterator end) {
|
|||
#endif
|
||||
}
|
||||
|
||||
AbortReason MBasicBlock::setBackedge(TempAllocator& alloc, MBasicBlock* pred) {
|
||||
bool MBasicBlock::setBackedge(MBasicBlock* pred) {
|
||||
// Predecessors must be finished, and at the correct stack depth.
|
||||
MOZ_ASSERT(hasLastIns());
|
||||
MOZ_ASSERT(pred->hasLastIns());
|
||||
|
@ -1118,25 +1046,15 @@ AbortReason MBasicBlock::setBackedge(TempAllocator& alloc, MBasicBlock* pred) {
|
|||
// We must be a pending loop header
|
||||
MOZ_ASSERT(kind_ == PENDING_LOOP_HEADER);
|
||||
|
||||
bool hadTypeChange = false;
|
||||
|
||||
// Add exit definitions to each corresponding phi at the entry.
|
||||
if (!inheritPhisFromBackedge(alloc, pred, &hadTypeChange)) {
|
||||
return AbortReason::Alloc;
|
||||
}
|
||||
|
||||
if (hadTypeChange) {
|
||||
return AbortReason::Disable;
|
||||
if (!inheritPhisFromBackedge(pred)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We are now a loop header proper
|
||||
kind_ = LOOP_HEADER;
|
||||
|
||||
if (!predecessors_.append(pred)) {
|
||||
return AbortReason::Alloc;
|
||||
}
|
||||
|
||||
return AbortReason::NoAbort;
|
||||
return predecessors_.append(pred);
|
||||
}
|
||||
|
||||
bool MBasicBlock::setBackedgeWasm(MBasicBlock* pred, size_t paramCount) {
|
||||
|
@ -1352,9 +1270,7 @@ void MBasicBlock::inheritPhis(MBasicBlock* header) {
|
|||
}
|
||||
}
|
||||
|
||||
bool MBasicBlock::inheritPhisFromBackedge(TempAllocator& alloc,
|
||||
MBasicBlock* backedge,
|
||||
bool* hadTypeChange) {
|
||||
bool MBasicBlock::inheritPhisFromBackedge(MBasicBlock* backedge) {
|
||||
// We must be a pending loop header
|
||||
MOZ_ASSERT(kind_ == PENDING_LOOP_HEADER);
|
||||
|
||||
|
@ -1390,13 +1306,9 @@ bool MBasicBlock::inheritPhisFromBackedge(TempAllocator& alloc,
|
|||
exitDef = entryDef->getOperand(0);
|
||||
}
|
||||
|
||||
bool typeChange = false;
|
||||
|
||||
if (!entryDef->addInputSlow(exitDef)) {
|
||||
return false;
|
||||
}
|
||||
// TODO(no-TI): remove hadTypeChange
|
||||
*hadTypeChange |= typeChange;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -175,13 +175,6 @@ class MBasicBlock : public TempObject, public InlineListNode<MBasicBlock> {
|
|||
}
|
||||
}
|
||||
|
||||
// Discard the slot at the given depth, lowering all slots above.
|
||||
void shimmySlots(int discardDepth);
|
||||
|
||||
// In an OSR block, set all MOsrValues to use the MResumePoint attached to
|
||||
// the MStart.
|
||||
MOZ_MUST_USE bool linkOsrValues(MStart* start);
|
||||
|
||||
// Sets the instruction associated with various slot types. The
|
||||
// instruction must lie at the top of the stack.
|
||||
void setLocal(uint32_t local) { setVariable(info_.localSlot(local)); }
|
||||
|
@ -192,9 +185,6 @@ class MBasicBlock : public TempObject, public InlineListNode<MBasicBlock> {
|
|||
// not be used under most circumstances.
|
||||
void rewriteSlot(uint32_t slot, MDefinition* ins) { setSlot(slot, ins); }
|
||||
|
||||
// Rewrites a slot based on its depth (same as argument to peek()).
|
||||
void rewriteAtDepth(int32_t depth, MDefinition* ins);
|
||||
|
||||
// Tracks an instruction as being pushed onto the operand stack.
|
||||
void push(MDefinition* ins) {
|
||||
MOZ_ASSERT(stackPosition_ < nslots());
|
||||
|
@ -283,10 +273,8 @@ class MBasicBlock : public TempObject, public InlineListNode<MBasicBlock> {
|
|||
void clearDominatorInfo();
|
||||
|
||||
// Sets a back edge. This places phi nodes and rewrites instructions within
|
||||
// the current loop as necessary. If the backedge introduces new types for
|
||||
// phis at the loop header, returns a disabling abort.
|
||||
MOZ_MUST_USE AbortReason setBackedge(TempAllocator& alloc,
|
||||
MBasicBlock* block);
|
||||
// the current loop as necessary.
|
||||
MOZ_MUST_USE bool setBackedge(MBasicBlock* block);
|
||||
MOZ_MUST_USE bool setBackedgeWasm(MBasicBlock* block, size_t paramCount);
|
||||
|
||||
// Resets a LOOP_HEADER block to a NORMAL block. This is needed when
|
||||
|
@ -302,9 +290,7 @@ class MBasicBlock : public TempObject, public InlineListNode<MBasicBlock> {
|
|||
void inheritPhis(MBasicBlock* header);
|
||||
|
||||
// Propagates backedge slots into phis operands of the loop header.
|
||||
MOZ_MUST_USE bool inheritPhisFromBackedge(TempAllocator& alloc,
|
||||
MBasicBlock* backedge,
|
||||
bool* hadTypeChange);
|
||||
MOZ_MUST_USE bool inheritPhisFromBackedge(MBasicBlock* backedge);
|
||||
|
||||
// Compute the types for phis in this block according to their inputs.
|
||||
MOZ_MUST_USE bool specializePhis(TempAllocator& alloc);
|
||||
|
|
|
@ -1451,14 +1451,12 @@ bool WarpBuilder::buildBackedge() {
|
|||
MBasicBlock* header = loopStack_.popCopy().header();
|
||||
current->end(MGoto::New(alloc(), header));
|
||||
|
||||
AbortReason r = header->setBackedge(alloc(), current);
|
||||
if (r == AbortReason::NoAbort) {
|
||||
setTerminatedBlock();
|
||||
return true;
|
||||
if (!header->setBackedge(current)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(r == AbortReason::Alloc);
|
||||
return false;
|
||||
setTerminatedBlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WarpBuilder::buildForwardGoto(BytecodeLocation target) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче