Bug 1310147 - Remove AutoAssertNoAlloc and replace with AutoAssertNoGC r=sfink
authorJon Coppeard <jcoppeard@mozilla.com>
Thu, 27 Oct 2016 11:03:53 +0100
changeset 319706 cc3d6c32ed8016883293256289b614b1c677ccc3
parent 319705 df256c6bf29f3bd7f75b3b955291c25ca527ee6a
child 319707 9888f1a23001fde6435e1a9ed7e6d3af8dd988d8
child 319817 e47ad07f2d527ca78a01f022c177df8437b03b6a
push id20746
push usercbook@mozilla.com
push dateThu, 27 Oct 2016 14:49:14 +0000
treeherderfx-team@9888f1a23001 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1310147
milestone52.0a1
Bug 1310147 - Remove AutoAssertNoAlloc and replace with AutoAssertNoGC r=sfink
js/public/GCAPI.h
js/src/jit/IonCaches.cpp
js/src/jsgc.cpp
js/src/jsgcinlines.h
js/src/vm/HelperThreads.cpp
--- a/js/public/GCAPI.h
+++ b/js/public/GCAPI.h
@@ -505,16 +505,17 @@ class JS_PUBLIC_API(AutoRequireNoGC)
  */
 class JS_PUBLIC_API(AutoAssertNoGC) : public AutoRequireNoGC
 {
     js::gc::GCRuntime* gc;
     size_t gcNumber;
 
   public:
     AutoAssertNoGC();
+    explicit AutoAssertNoGC(JSRuntime* rt);
     explicit AutoAssertNoGC(JSContext* cx);
     ~AutoAssertNoGC();
 };
 
 /**
  * Assert if an allocation of a GC thing occurs while this class is live. This
  * class does not disable the static rooting hazard analysis.
  */
--- a/js/src/jit/IonCaches.cpp
+++ b/js/src/jit/IonCaches.cpp
@@ -3652,17 +3652,17 @@ SetPropertyIC::tryAttachAddSlot(JSContex
 
     // Fail cache emission if the object is frozen
     if (obj->is<NativeObject>() && obj->as<NativeObject>().getElementsHeader()->isFrozen())
         return true;
 
     // 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;
 
     // The property did not exist before, now we can try to inline the property add.
     bool checkTypeset = false;
     if (tryNativeAddSlot &&
         IsPropertyAddInlineable(cx, &obj->as<NativeObject>(), id, value(), oldShape,
                                 needsTypeBarrier(), &checkTypeset))
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -7010,16 +7010,22 @@ JS::AutoAssertNoGC::AutoAssertNoGC()
         if (runtime) {
             gc = &runtime->gc;
             gcNumber = gc->gcNumber();
             gc->enterUnsafeRegion();
         }
     }
 }
 
+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())
 {
     gc->enterUnsafeRegion();
 }
 
 JS::AutoAssertNoGC::~AutoAssertNoGC()
 {
--- a/js/src/jsgcinlines.h
+++ b/js/src/jsgcinlines.h
@@ -197,17 +197,17 @@ class ArenaCellIterUnderFinalize : publi
 
 template <typename T>
 class ZoneCellIter;
 
 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().
     ZoneCellIter() {}
 
     void init(JS::Zone* zone, AllocKind kind) {
         MOZ_ASSERT_IF(IsNurseryAllocable(kind),
                       zone->runtimeFromAnyThread()->gc.nursery.isEmpty());
@@ -216,17 +216,17 @@ class ZoneCellIter<TenuredCell> {
 
     void initForTenuredIteration(JS::Zone* zone, AllocKind kind) {
         JSRuntime* rt = zone->runtimeFromAnyThread();
 
         // If called from outside a GC, ensure that the heap is in a state
         // 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
         // against other threads iterating or allocating. However, we do have
         // background finalization; we may have to wait for this to finish if
         // it's currently active.
         if (IsBackgroundFinalized(kind) && zone->arenas.needBackgroundFinalizeWait(kind))
             rt->gc.waitBackgroundSweepEnd();
--- a/js/src/vm/HelperThreads.cpp
+++ b/js/src/vm/HelperThreads.cpp
@@ -1316,17 +1316,17 @@ GlobalHelperThreadState::mergeParseTaskC
                                                    Handle<GlobalObject*> global,
                                                    JSCompartment* dest)
 {
     // After we call LeaveParseTaskZone() it's not safe to GC until we have
     // finished merging the contents of the parse task's compartment into the
     // 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);
 
     {
         // Generator functions don't have Function.prototype as prototype but a
         // different function object, so the IdentifyStandardPrototype trick
         // below won't work.  Just special-case it.
         GlobalObject* parseGlobal = &parseTask->exclusiveContextGlobal->as<GlobalObject>();