Bug 1277174 - Forbid nursery allocations within AutoAssertEmptyNursery, r=jonco

MozReview-Commit-ID: BY3ZQt9ax6a

--HG--
extra : rebase_source : 7001aaefe1590a903508fa6fe5186dff848319a8
This commit is contained in:
Steve Fink 2016-06-03 13:09:11 -07:00
parent 1eb9cc2888
commit 735d4c52b9
2 changed files with 7 additions and 3 deletions

View File

@ -7635,6 +7635,8 @@ AutoAssertHeapBusy::checkCondition(JSRuntime *rt)
void
AutoAssertEmptyNursery::checkCondition(JSRuntime *rt) {
if (!noAlloc)
noAlloc.emplace(rt);
this->rt = rt;
MOZ_ASSERT(rt->gc.nursery.isEmpty());
}

View File

@ -1385,6 +1385,8 @@ class MOZ_RAII AutoAssertEmptyNursery
protected:
JSRuntime* rt;
mozilla::Maybe<AutoAssertNoNurseryAlloc> noAlloc;
// Check that the nursery is empty.
void checkCondition(JSRuntime *rt);
@ -1393,12 +1395,12 @@ class MOZ_RAII AutoAssertEmptyNursery
}
public:
explicit AutoAssertEmptyNursery(JSRuntime* rt) {
explicit AutoAssertEmptyNursery(JSRuntime* rt) : rt(nullptr) {
checkCondition(rt);
}
~AutoAssertEmptyNursery() {
checkCondition(rt);
AutoAssertEmptyNursery(const AutoAssertEmptyNursery& other) : AutoAssertEmptyNursery(other.rt)
{
}
};