mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1261361 - Make Vector::infallibleGrowByUninitialized check mReserved instead of mCapacity. r=Waldo
--HG-- extra : rebase_source : 2b6cdfae61946505b83748c016ef0b112ecf4780
This commit is contained in:
parent
b0e24f4d55
commit
67e655e4bf
@ -5892,7 +5892,8 @@ IonBuilder::inlineCalls(CallInfo& callInfo, const ObjectVector& targets, BoolVec
|
||||
if (choiceSet[i])
|
||||
count++;
|
||||
}
|
||||
retPhi->reserveLength(count);
|
||||
if (!retPhi->reserveLength(count))
|
||||
return false;
|
||||
|
||||
// Inline each of the inlineable targets.
|
||||
for (uint32_t i = 0; i < targets.length(); i++) {
|
||||
|
@ -7248,7 +7248,8 @@ class MPhi final
|
||||
public InlineListNode<MPhi>,
|
||||
public NoTypePolicy::Data
|
||||
{
|
||||
js::Vector<MUse, 2, JitAllocPolicy> inputs_;
|
||||
using InputVector = js::Vector<MUse, 2, JitAllocPolicy>;
|
||||
InputVector inputs_;
|
||||
|
||||
TruncateKind truncateKind_;
|
||||
bool hasBackedgeType_;
|
||||
@ -7354,31 +7355,32 @@ class MPhi final
|
||||
|
||||
// Add types for this phi which speculate about new inputs that may come in
|
||||
// via a loop backedge.
|
||||
bool addBackedgeType(MIRType type, TemporaryTypeSet* typeSet);
|
||||
MOZ_WARN_UNUSED_RESULT bool addBackedgeType(MIRType type, TemporaryTypeSet* typeSet);
|
||||
|
||||
// Initializes the operands vector to the given capacity,
|
||||
// permitting use of addInput() instead of addInputSlow().
|
||||
bool reserveLength(size_t length) {
|
||||
MOZ_WARN_UNUSED_RESULT bool reserveLength(size_t length) {
|
||||
return inputs_.reserve(length);
|
||||
}
|
||||
|
||||
// Use only if capacity has been reserved by reserveLength
|
||||
void addInput(MDefinition* ins) {
|
||||
// Use infallibleGrowByUninitialized and placement-new instead of just
|
||||
// infallibleAppend to avoid creating a temporary MUse which will get
|
||||
// linked into |ins|'s use list and then unlinked in favor of the
|
||||
// MUse in the Vector. We'd ideally like to use an emplace method here,
|
||||
// once Vector supports that.
|
||||
inputs_.infallibleGrowByUninitialized(1);
|
||||
new (&inputs_.back()) MUse(ins, this);
|
||||
inputs_.infallibleEmplaceBack(ins, this);
|
||||
}
|
||||
|
||||
// Appends a new input to the input vector. May perform reallocation.
|
||||
// Prefer reserveLength() and addInput() instead, where possible.
|
||||
bool addInputSlow(MDefinition* ins) {
|
||||
MOZ_WARN_UNUSED_RESULT bool addInputSlow(MDefinition* ins) {
|
||||
return inputs_.emplaceBack(ins, this);
|
||||
}
|
||||
|
||||
// Appends a new input to the input vector. Infallible because
|
||||
// we know the inputs fits in the vector's inline storage.
|
||||
void addInlineInput(MDefinition* ins) {
|
||||
MOZ_ASSERT(inputs_.length() < InputVector::InlineLength);
|
||||
MOZ_ALWAYS_TRUE(addInputSlow(ins));
|
||||
}
|
||||
|
||||
// Update the type of this phi after adding |ins| as an input. Set
|
||||
// |*ptypeChange| to true if the type changed.
|
||||
bool checkForTypeChange(MDefinition* ins, bool* ptypeChange);
|
||||
|
@ -443,7 +443,7 @@ MBasicBlock::NewAsmJS(MIRGraph& graph, const CompileInfo& info, MBasicBlock* pre
|
||||
phi = phis + (i - nfree);
|
||||
new(phi) MPhi(alloc, predSlot->type());
|
||||
|
||||
phi->addInput(predSlot);
|
||||
phi->addInlineInput(predSlot);
|
||||
|
||||
// Add append Phis in the block.
|
||||
block->addPhi(phi);
|
||||
@ -559,7 +559,7 @@ MBasicBlock::inherit(TempAllocator& alloc, BytecodeAnalysis* analysis, MBasicBlo
|
||||
size_t i = 0;
|
||||
for (i = 0; i < info().firstStackSlot(); i++) {
|
||||
MPhi* phi = MPhi::New(alloc);
|
||||
phi->addInput(pred->getSlot(i));
|
||||
phi->addInlineInput(pred->getSlot(i));
|
||||
addPhi(phi);
|
||||
setSlot(i, phi);
|
||||
entryResumePoint()->initOperand(i, phi);
|
||||
@ -579,7 +579,7 @@ MBasicBlock::inherit(TempAllocator& alloc, BytecodeAnalysis* analysis, MBasicBlo
|
||||
|
||||
for (; i < stackDepth(); i++) {
|
||||
MPhi* phi = MPhi::New(alloc);
|
||||
phi->addInput(pred->getSlot(i));
|
||||
phi->addInlineInput(pred->getSlot(i));
|
||||
addPhi(phi);
|
||||
setSlot(i, phi);
|
||||
entryResumePoint()->initOperand(i, phi);
|
||||
@ -1351,8 +1351,9 @@ MBasicBlock::setBackedgeAsmJS(MBasicBlock* pred)
|
||||
exitDef = entryDef->getOperand(0);
|
||||
}
|
||||
|
||||
// Phis always have room for 2 operands, so we can use addInput.
|
||||
entryDef->addInput(exitDef);
|
||||
// Phis always have room for 2 operands, so this can't fail.
|
||||
MOZ_ASSERT(phi->numOperands() == 1);
|
||||
entryDef->addInlineInput(exitDef);
|
||||
|
||||
MOZ_ASSERT(slot < pred->stackDepth());
|
||||
setSlot(slot, entryDef);
|
||||
|
@ -86,10 +86,10 @@ BEGIN_TEST(testJitDCEinGVN_phi)
|
||||
|
||||
// x = 1.0
|
||||
// y = 3.0;
|
||||
x->addInputSlow(c1);
|
||||
MOZ_RELEASE_ASSERT(x->addInputSlow(c1));
|
||||
MConstant* c3 = MConstant::New(func.alloc, DoubleValue(3.0));
|
||||
thenBlock1->add(c3);
|
||||
y->addInputSlow(c3);
|
||||
MOZ_RELEASE_ASSERT(y->addInputSlow(c3));
|
||||
thenBlock1->end(MGoto::New(func.alloc, joinBlock));
|
||||
MOZ_ALWAYS_TRUE(joinBlock->addPredecessor(func.alloc, thenBlock1));
|
||||
|
||||
@ -102,10 +102,10 @@ BEGIN_TEST(testJitDCEinGVN_phi)
|
||||
// y = 4.0;
|
||||
MConstant* c2 = MConstant::New(func.alloc, DoubleValue(2.0));
|
||||
thenBlock2->add(c2);
|
||||
x->addInputSlow(c2);
|
||||
MOZ_RELEASE_ASSERT(x->addInputSlow(c2));
|
||||
MConstant* c4 = MConstant::New(func.alloc, DoubleValue(4.0));
|
||||
thenBlock2->add(c4);
|
||||
y->addInputSlow(c4);
|
||||
MOZ_RELEASE_ASSERT(y->addInputSlow(c4));
|
||||
thenBlock2->end(MGoto::New(func.alloc, joinBlock));
|
||||
MOZ_ALWAYS_TRUE(joinBlock->addPredecessor(func.alloc, thenBlock2));
|
||||
|
||||
@ -113,10 +113,10 @@ BEGIN_TEST(testJitDCEinGVN_phi)
|
||||
// x = 1.0
|
||||
// y = 5.0;
|
||||
// }
|
||||
x->addInputSlow(c1);
|
||||
MOZ_RELEASE_ASSERT(x->addInputSlow(c1));
|
||||
MConstant* c5 = MConstant::New(func.alloc, DoubleValue(5.0));
|
||||
elseBlock->add(c5);
|
||||
y->addInputSlow(c5);
|
||||
MOZ_RELEASE_ASSERT(y->addInputSlow(c5));
|
||||
elseBlock->end(MGoto::New(func.alloc, joinBlock));
|
||||
MOZ_ALWAYS_TRUE(joinBlock->addPredecessor(func.alloc, elseBlock));
|
||||
|
||||
|
@ -231,10 +231,10 @@ BEGIN_TEST(testJitGVN_PinnedPhis)
|
||||
MConstant* z1 = MConstant::New(func.alloc, Int32Value(1));
|
||||
MConstant* z2 = MConstant::New(func.alloc, Int32Value(2));
|
||||
MConstant* z3 = MConstant::New(func.alloc, Int32Value(2));
|
||||
phi0->addInputSlow(z0);
|
||||
phi1->addInputSlow(z1);
|
||||
phi2->addInputSlow(z2);
|
||||
phi3->addInputSlow(z3);
|
||||
MOZ_RELEASE_ASSERT(phi0->addInputSlow(z0));
|
||||
MOZ_RELEASE_ASSERT(phi1->addInputSlow(z1));
|
||||
MOZ_RELEASE_ASSERT(phi2->addInputSlow(z2));
|
||||
MOZ_RELEASE_ASSERT(phi3->addInputSlow(z3));
|
||||
entry->add(z0);
|
||||
entry->add(z1);
|
||||
entry->add(z2);
|
||||
@ -259,10 +259,10 @@ BEGIN_TEST(testJitGVN_PinnedPhis)
|
||||
MConstant* z5 = MConstant::New(func.alloc, Int32Value(4));
|
||||
MInstruction* z6 = MAdd::New(func.alloc, phi2, phi3);
|
||||
MConstant* z7 = MConstant::New(func.alloc, Int32Value(6));
|
||||
phi0->addInputSlow(z4);
|
||||
phi1->addInputSlow(z5);
|
||||
phi2->addInputSlow(z6);
|
||||
phi3->addInputSlow(z7);
|
||||
MOZ_RELEASE_ASSERT(phi0->addInputSlow(z4));
|
||||
MOZ_RELEASE_ASSERT(phi1->addInputSlow(z5));
|
||||
MOZ_RELEASE_ASSERT(phi2->addInputSlow(z6));
|
||||
MOZ_RELEASE_ASSERT(phi3->addInputSlow(z7));
|
||||
exit->add(z4);
|
||||
exit->add(z5);
|
||||
exit->add(z6);
|
||||
|
@ -1031,6 +1031,11 @@ Vector<T, N, AP>::growByUninitialized(size_t aIncr)
|
||||
} else if (!maybeCheckSimulatedOOM(mLength + aIncr)) {
|
||||
return false;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (mLength + aIncr > mReserved) {
|
||||
mReserved = mLength + aIncr;
|
||||
}
|
||||
#endif
|
||||
infallibleGrowByUninitialized(aIncr);
|
||||
return true;
|
||||
}
|
||||
@ -1039,13 +1044,8 @@ template<typename T, size_t N, class AP>
|
||||
MOZ_ALWAYS_INLINE void
|
||||
Vector<T, N, AP>::infallibleGrowByUninitialized(size_t aIncr)
|
||||
{
|
||||
MOZ_ASSERT(mLength + aIncr <= mCapacity);
|
||||
MOZ_ASSERT(mLength + aIncr <= reserved());
|
||||
mLength += aIncr;
|
||||
#ifdef DEBUG
|
||||
if (mLength > mReserved) {
|
||||
mReserved = mLength;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T, size_t N, class AP>
|
||||
|
Loading…
Reference in New Issue
Block a user