Bug 1359001 - Make AutoAssertGCCallback a no-op in opt builds r=sfink
authorJon Coppeard <jcoppeard@mozilla.com>
Tue, 25 Apr 2017 10:56:34 +0100
changeset 567825 5633dacc482dc373aa7ba40f4bddce4315296465
parent 567824 4c552f9aa3dd87bbd3937f6c0e31a1507da67b3f
child 567826 89815b99de27831dc069a09b2085c6a3a1a23365
push id55716
push userbmo:rbarker@mozilla.com
push dateTue, 25 Apr 2017 16:19:16 +0000
reviewerssfink
bugs1359001
milestone55.0a1
Bug 1359001 - Make AutoAssertGCCallback a no-op in opt builds r=sfink
dom/bindings/BindingUtils.h
js/public/GCAPI.h
js/src/jsgc.cpp
js/xpconnect/src/XPCWrappedNative.cpp
--- a/dom/bindings/BindingUtils.h
+++ b/dom/bindings/BindingUtils.h
@@ -1331,25 +1331,25 @@ ClearWrapper(T* p, void*)
   CallQueryInterface(p, &cache);
   ClearWrapper(p, cache);
 }
 
 template<class T>
 inline void
 UpdateWrapper(T* p, nsWrapperCache* cache, JSObject* obj, const JSObject* old)
 {
-  JS::AutoAssertGCCallback inCallback(obj);
+  JS::AutoAssertGCCallback inCallback;
   cache->UpdateWrapper(obj, old);
 }
 
 template<class T>
 inline void
 UpdateWrapper(T* p, void*, JSObject* obj, const JSObject* old)
 {
-  JS::AutoAssertGCCallback inCallback(obj);
+  JS::AutoAssertGCCallback inCallback;
   nsWrapperCache* cache;
   CallQueryInterface(p, &cache);
   UpdateWrapper(p, cache, obj, old);
 }
 
 // Attempt to preserve the wrapper, if any, for a Paris DOM bindings object.
 // Return true if we successfully preserved the wrapper, or there is no wrapper
 // to preserve. In the latter case we don't need to preserve the wrapper, because
--- a/js/public/GCAPI.h
+++ b/js/public/GCAPI.h
@@ -578,17 +578,21 @@ class JS_PUBLIC_API(AutoSuppressGCAnalys
  * trigger a GC occurs while this guard object is live.
  *
  * This is useful to make the static analysis ignore code that runs in GC
  * callbacks.
  */
 class JS_PUBLIC_API(AutoAssertGCCallback) : public AutoSuppressGCAnalysis
 {
   public:
-    explicit AutoAssertGCCallback(JSObject* obj);
+#ifdef DEBUG
+    AutoAssertGCCallback();
+#else
+    AutoAssertGCCallback() {}
+#endif
 };
 
 /**
  * Place AutoCheckCannotGC in scopes that you believe can never GC. These
  * annotations will be verified both dynamically via AutoAssertNoGC, and
  * statically with the rooting hazard analysis (implemented by making the
  * analysis consider AutoCheckCannotGC to be a GC pointer, and therefore
  * complain if it is live across a GC call.) It is useful when dealing with
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -7424,23 +7424,23 @@ JS::AutoEnterCycleCollection::AutoEnterC
     TlsContext.get()->heapState = HeapState::CycleCollecting;
 }
 
 JS::AutoEnterCycleCollection::~AutoEnterCycleCollection()
 {
     MOZ_ASSERT(JS::CurrentThreadIsHeapCycleCollecting());
     TlsContext.get()->heapState = HeapState::Idle;
 }
-#endif
-
-JS::AutoAssertGCCallback::AutoAssertGCCallback(JSObject* obj)
+
+JS::AutoAssertGCCallback::AutoAssertGCCallback()
   : AutoSuppressGCAnalysis()
 {
     MOZ_ASSERT(JS::CurrentThreadIsHeapCollecting());
 }
+#endif
 
 JS_FRIEND_API(const char*)
 JS::GCTraceKindToAscii(JS::TraceKind kind)
 {
     switch(kind) {
 #define MAP_NAME(name, _0, _1) case JS::TraceKind::name: return #name;
 JS_FOR_EACH_TRACEKIND(MAP_NAME);
 #undef MAP_NAME
--- a/js/xpconnect/src/XPCWrappedNative.cpp
+++ b/js/xpconnect/src/XPCWrappedNative.cpp
@@ -882,17 +882,17 @@ XPCWrappedNative::FlatJSObjectFinalized(
     // likely that it has already been finalized.
 
     Release();
 }
 
 void
 XPCWrappedNative::FlatJSObjectMoved(JSObject* obj, const JSObject* old)
 {
-    JS::AutoAssertGCCallback inCallback(obj);
+    JS::AutoAssertGCCallback inCallback;
     MOZ_ASSERT(mFlatJSObject == old);
 
     nsWrapperCache* cache = nullptr;
     CallQueryInterface(mIdentity, &cache);
     if (cache)
         cache->UpdateWrapper(obj, old);
 
     mFlatJSObject = obj;