From 435bdeeaecdaf77ddbdaf4dda1a0a94822de9173 Mon Sep 17 00:00:00 2001 From: Jon Coppeard Date: Thu, 27 Oct 2016 11:03:53 +0100 Subject: [PATCH] Bug 1310147 - Remove AutoAssertNoAlloc and replace with AutoAssertNoGC r=sfink --- js/public/GCAPI.h | 1 + js/src/jit/IonCaches.cpp | 2 +- js/src/jsgc.cpp | 6 ++++++ js/src/jsgcinlines.h | 4 ++-- js/src/vm/HelperThreads.cpp | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/js/public/GCAPI.h b/js/public/GCAPI.h index bde91b44558a..f4c9fd7e8022 100644 --- a/js/public/GCAPI.h +++ b/js/public/GCAPI.h @@ -510,6 +510,7 @@ class JS_PUBLIC_API(AutoAssertNoGC) : public AutoRequireNoGC public: AutoAssertNoGC(); + explicit AutoAssertNoGC(JSRuntime* rt); explicit AutoAssertNoGC(JSContext* cx); ~AutoAssertNoGC(); }; diff --git a/js/src/jit/IonCaches.cpp b/js/src/jit/IonCaches.cpp index b42587e0c0c5..df82c83e3d71 100644 --- a/js/src/jit/IonCaches.cpp +++ b/js/src/jit/IonCaches.cpp @@ -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; diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index 1fb048cc8b8e..1858f7ae24e2 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -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()) { diff --git a/js/src/jsgcinlines.h b/js/src/jsgcinlines.h index 5ea37dc9a09c..8710e9884021 100644 --- a/js/src/jsgcinlines.h +++ b/js/src/jsgcinlines.h @@ -202,7 +202,7 @@ template <> class ZoneCellIter { ArenaIter arenaIter; ArenaCellIterImpl cellIter; - JS::AutoAssertNoAlloc noAlloc; + mozilla::Maybe nogc; protected: // For use when a subclass wants to insert some setup before init(). @@ -221,7 +221,7 @@ class ZoneCellIter { // 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 diff --git a/js/src/vm/HelperThreads.cpp b/js/src/vm/HelperThreads.cpp index 67266a209a3b..dd1f1ddde0d5 100644 --- a/js/src/vm/HelperThreads.cpp +++ b/js/src/vm/HelperThreads.cpp @@ -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);