mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1231224 part 10 - Make various Vector calls check for OOM. r=terrence
--HG-- extra : rebase_source : fae86eb928fc510c3d5c7a895675cf218fc15b3a
This commit is contained in:
parent
5b0fc89a9e
commit
36e21ef4d9
@ -539,7 +539,7 @@ js::Nursery::collect(JSRuntime* rt, JS::gcreason::Reason reason, ObjectGroupList
|
||||
for (size_t i = 0; i < ArrayLength(tenureCounts.entries); i++) {
|
||||
const TenureCount& entry = tenureCounts.entries[i];
|
||||
if (entry.count >= 3000)
|
||||
pretenureGroups->append(entry.group); // ignore alloc failure
|
||||
(void)pretenureGroups->append(entry.group); // ignore alloc failure
|
||||
}
|
||||
}
|
||||
TIME_END(pretenure);
|
||||
|
@ -446,7 +446,10 @@ AllocationIntegrityState::dump()
|
||||
// were discovered.
|
||||
|
||||
Vector<IntegrityItem, 20, SystemAllocPolicy> seenOrdered;
|
||||
seenOrdered.appendN(IntegrityItem(), seen.count());
|
||||
if (!seenOrdered.appendN(IntegrityItem(), seen.count())) {
|
||||
fprintf(stderr, "OOM while dumping allocations\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (IntegrityItemSet::Enum iter(seen); !iter.empty(); iter.popFront()) {
|
||||
IntegrityItem item = iter.front();
|
||||
|
@ -3740,7 +3740,7 @@ Zone::sweepCompartments(FreeOp* fop, bool keepAtleastOne, bool destroyingRuntime
|
||||
foundOne = true;
|
||||
}
|
||||
}
|
||||
compartments.resize(write - compartments.begin());
|
||||
compartments.shrinkTo(write - compartments.begin());
|
||||
MOZ_ASSERT_IF(keepAtleastOne, !compartments.empty());
|
||||
}
|
||||
|
||||
@ -3784,7 +3784,7 @@ GCRuntime::sweepZones(FreeOp* fop, bool destroyingRuntime)
|
||||
}
|
||||
*write++ = zone;
|
||||
}
|
||||
zones.resize(write - zones.begin());
|
||||
zones.shrinkTo(write - zones.begin());
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -3537,8 +3537,12 @@ JSObject::dump()
|
||||
if (obj->isNative()) {
|
||||
fprintf(stderr, "properties:\n");
|
||||
Vector<Shape*, 8, SystemAllocPolicy> props;
|
||||
for (Shape::Range<NoGC> r(obj->as<NativeObject>().lastProperty()); !r.empty(); r.popFront())
|
||||
props.append(&r.front());
|
||||
for (Shape::Range<NoGC> r(obj->as<NativeObject>().lastProperty()); !r.empty(); r.popFront()) {
|
||||
if (!props.append(&r.front())) {
|
||||
fprintf(stderr, "(OOM while appending properties)\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (size_t i = props.length(); i-- != 0;)
|
||||
DumpProperty(&obj->as<NativeObject>(), *props[i]);
|
||||
}
|
||||
|
@ -540,6 +540,12 @@ public:
|
||||
*/
|
||||
void shrinkBy(size_t aIncr);
|
||||
|
||||
/**
|
||||
* Destroy elements in the range [aNewLength, end()). Does not deallocate
|
||||
* or unreserve storage for those elements.
|
||||
*/
|
||||
void shrinkTo(size_t aNewLength);
|
||||
|
||||
/** Grow the vector by aIncr elements. */
|
||||
bool growBy(size_t aIncr);
|
||||
|
||||
@ -948,6 +954,14 @@ Vector<T, N, AP>::shrinkBy(size_t aIncr)
|
||||
mLength -= aIncr;
|
||||
}
|
||||
|
||||
template<typename T, size_t N, class AP>
|
||||
MOZ_ALWAYS_INLINE void
|
||||
Vector<T, N, AP>::shrinkTo(size_t aNewLength)
|
||||
{
|
||||
MOZ_ASSERT(aNewLength <= mLength);
|
||||
shrinkBy(mLength - aNewLength);
|
||||
}
|
||||
|
||||
template<typename T, size_t N, class AP>
|
||||
MOZ_ALWAYS_INLINE bool
|
||||
Vector<T, N, AP>::growBy(size_t aIncr)
|
||||
|
@ -45,10 +45,10 @@ TestBinarySearch()
|
||||
size_t m;
|
||||
|
||||
Vector<int> v1;
|
||||
v1.append(2);
|
||||
v1.append(4);
|
||||
v1.append(6);
|
||||
v1.append(8);
|
||||
MOZ_RELEASE_ASSERT(v1.append(2));
|
||||
MOZ_RELEASE_ASSERT(v1.append(4));
|
||||
MOZ_RELEASE_ASSERT(v1.append(6));
|
||||
MOZ_RELEASE_ASSERT(v1.append(8));
|
||||
|
||||
MOZ_RELEASE_ASSERT(!BinarySearch(v1, 0, v1.length(), 1, &m) && m == 0);
|
||||
MOZ_RELEASE_ASSERT( BinarySearch(v1, 0, v1.length(), 2, &m) && m == 0);
|
||||
@ -78,9 +78,9 @@ TestBinarySearch()
|
||||
MOZ_RELEASE_ASSERT(!BinarySearch(v2, 0, 0, 9, &m) && m == 0);
|
||||
|
||||
Vector<Person> v3;
|
||||
v3.append(Person(2, 42));
|
||||
v3.append(Person(4, 13));
|
||||
v3.append(Person(6, 360));
|
||||
MOZ_RELEASE_ASSERT(v3.append(Person(2, 42)));
|
||||
MOZ_RELEASE_ASSERT(v3.append(Person(4, 13)));
|
||||
MOZ_RELEASE_ASSERT(v3.append(Person(6, 360)));
|
||||
|
||||
A(!BinarySearch(GetAge(v3), 0, v3.length(), 1, &m) && m == 0);
|
||||
A( BinarySearch(GetAge(v3), 0, v3.length(), 2, &m) && m == 0);
|
||||
|
Loading…
Reference in New Issue
Block a user