Bug 1310147 - Remove AutoAssertNoAlloc and replace with AutoAssertNoGC r=sfink

This commit is contained in:
Jon Coppeard 2016-10-27 11:03:53 +01:00
parent 4f90a79a0c
commit 435bdeeaec
5 changed files with 11 additions and 4 deletions

View File

@ -510,6 +510,7 @@ class JS_PUBLIC_API(AutoAssertNoGC) : public AutoRequireNoGC
public:
AutoAssertNoGC();
explicit AutoAssertNoGC(JSRuntime* rt);
explicit AutoAssertNoGC(JSContext* cx);
~AutoAssertNoGC();
};

View File

@ -3657,7 +3657,7 @@ SetPropertyIC::tryAttachAddSlot(JSContext* cx, HandleScript outerScript, IonScri
// A GC may have caused cache.value() to become stale as it is not traced.
// In this case the IonScript will have been invalidated, so check for that.
// Assert no further GC is possible past this point.
JS::AutoAssertNoAlloc nogc;
JS::AutoAssertNoGC nogc;
if (ion->invalidated())
return true;

View File

@ -7015,6 +7015,12 @@ JS::AutoAssertNoGC::AutoAssertNoGC()
}
}
JS::AutoAssertNoGC::AutoAssertNoGC(JSRuntime* rt)
: gc(&rt->gc), gcNumber(rt->gc.gcNumber())
{
gc->enterUnsafeRegion();
}
JS::AutoAssertNoGC::AutoAssertNoGC(JSContext* cx)
: gc(&cx->gc), gcNumber(cx->gc.gcNumber())
{

View File

@ -202,7 +202,7 @@ template <>
class ZoneCellIter<TenuredCell> {
ArenaIter arenaIter;
ArenaCellIterImpl cellIter;
JS::AutoAssertNoAlloc noAlloc;
mozilla::Maybe<JS::AutoAssertNoGC> nogc;
protected:
// For use when a subclass wants to insert some setup before init().
@ -221,7 +221,7 @@ class ZoneCellIter<TenuredCell> {
// that allows us to iterate.
if (!rt->isHeapBusy()) {
// Assert that no GCs can occur while a ZoneCellIter is live.
noAlloc.disallowAlloc(rt);
nogc.emplace(rt);
}
// We have a single-threaded runtime, so there's no need to protect

View File

@ -1321,7 +1321,7 @@ GlobalHelperThreadState::mergeParseTaskCompartment(JSContext* cx, ParseTask* par
// destination compartment. Finish any ongoing incremental GC first and
// assert that no allocation can occur.
gc::FinishGC(cx);
JS::AutoAssertNoAlloc noAlloc(cx);
JS::AutoAssertNoGC nogc(cx);
LeaveParseTaskZone(cx, parseTask);