Bug 1201190 - Part 3: Mark every consumer of GUARD_OBJECT as MOZ_RAII, r=ehsan
authorMichael Layzell <michael@thelayzells.com>
Thu, 03 Sep 2015 12:15:23 -0400
changeset 294812 31a26ed444843f086c468a98236e8c98b7115b44
parent 294811 296fe95e64cb2143570f3b3bc8300f06590713e3
child 294813 cd8b8017370cf14c472c107d256bb98ce7a19270
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1201190
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1201190 - Part 3: Mark every consumer of GUARD_OBJECT as MOZ_RAII, r=ehsan
docshell/base/timeline/AutoGlobalTimelineMarker.h
docshell/base/timeline/AutoTimelineMarker.h
dom/base/ScriptSettings.h
dom/base/nsContentUtils.h
dom/base/nsFrameLoader.cpp
dom/bindings/BindingUtils.h
dom/bindings/RootedDictionary.h
dom/bindings/TypedArray.h
dom/media/MediaResource.h
dom/plugins/ipc/PluginModuleParent.cpp
dom/svg/DOMSVGLength.cpp
dom/svg/DOMSVGLengthList.cpp
dom/svg/DOMSVGNumber.cpp
dom/svg/DOMSVGNumberList.cpp
dom/svg/DOMSVGPathSeg.cpp
dom/svg/DOMSVGPathSegList.cpp
dom/svg/DOMSVGPoint.cpp
dom/svg/DOMSVGPointList.cpp
dom/svg/DOMSVGStringList.cpp
dom/svg/DOMSVGTransformList.cpp
dom/svg/SVGSVGElement.h
dom/svg/SVGTransform.cpp
dom/workers/XMLHttpRequest.cpp
editor/libeditor/nsEditorUtils.h
ipc/glue/MessageChannel.cpp
ipc/glue/Neutering.h
js/ipc/CPOWTimer.h
js/public/RootingAPI.h
js/src/ds/LifoAlloc.h
js/src/gc/GCInternals.h
js/src/gc/Statistics.h
js/src/jit/Ion.cpp
js/src/jit/JitSpewer.cpp
js/src/jsapi.h
js/src/jscntxt.h
js/src/jscompartment.h
js/src/jsfriendapi.h
js/src/jsgc.h
js/src/jsutil.h
js/src/shell/js.cpp
js/src/vm/Debugger.cpp
js/src/vm/HelperThreads.h
js/src/vm/Interpreter.cpp
js/src/vm/RegExpStatics.h
js/src/vm/Runtime.h
js/src/vm/SPSProfiler.h
js/src/vm/SavedStacks.h
js/src/vm/ScopeObject.h
js/src/vm/Shape.h
js/src/vm/TraceLogging.h
js/src/vm/TraceLoggingGraph.cpp
js/xpconnect/src/xpcprivate.h
layout/generic/Selection.h
layout/generic/nsFlexContainerFrame.cpp
layout/generic/nsSelection.cpp
layout/style/nsCSSParser.cpp
layout/style/nsRuleProcessorData.h
layout/svg/nsSVGClipPathFrame.h
layout/svg/nsSVGFilterFrame.cpp
layout/svg/nsSVGGradientFrame.cpp
layout/svg/nsSVGMarkerFrame.h
layout/svg/nsSVGMaskFrame.h
layout/svg/nsSVGPatternFrame.cpp
layout/svg/nsSVGUtils.h
mfbt/ReentrancyGuard.h
mfbt/ScopeExit.h
mfbt/Scoped.h
mozglue/build/WindowsDllBlocklist.h
toolkit/components/osfile/NativeOSFileInternals.cpp
toolkit/components/telemetry/Telemetry.h
toolkit/devtools/heapsnapshot/AutoMemMap.h
tools/profiler/public/GeckoProfilerImpl.h
xpcom/glue/AutoRestore.h
xpcom/glue/Mutex.h
--- a/docshell/base/timeline/AutoGlobalTimelineMarker.h
+++ b/docshell/base/timeline/AutoGlobalTimelineMarker.h
@@ -24,17 +24,17 @@ namespace mozilla {
 // Example usage:
 //
 //     {
 //       AutoGlobalTimelineMarker marker("Cycle Collection");
 //       nsCycleCollector* cc = GetCycleCollector();
 //       cc->Collect();
 //       ...
 //     }
-class MOZ_STACK_CLASS AutoGlobalTimelineMarker
+class MOZ_RAII AutoGlobalTimelineMarker
 {
   MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER;
 
   // The name of the marker we are adding.
   const char* mName;
 
 public:
   explicit AutoGlobalTimelineMarker(const char* aName
--- a/docshell/base/timeline/AutoTimelineMarker.h
+++ b/docshell/base/timeline/AutoTimelineMarker.h
@@ -23,17 +23,17 @@ namespace mozilla {
 //
 // Example usage:
 //
 //     {
 //       AutoTimelineMarker marker(mDocShell, "Parse CSS");
 //       nsresult rv = ParseTheCSSFile(mFile);
 //       ...
 //     }
-class MOZ_STACK_CLASS AutoTimelineMarker
+class MOZ_RAII AutoTimelineMarker
 {
   MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER;
 
   // The name of the marker we are adding.
   const char* mName;
 
   // The docshell that is associated with this marker.
   nsRefPtr<nsDocShell> mDocShell;
--- a/dom/base/ScriptSettings.h
+++ b/dom/base/ScriptSettings.h
@@ -407,17 +407,17 @@ private:
 
 } // namespace dom
 
 /**
  * Use AutoJSContext when you need a JS context on the stack but don't have one
  * passed as a parameter. AutoJSContext will take care of finding the most
  * appropriate JS context and release it when leaving the stack.
  */
-class MOZ_STACK_CLASS AutoJSContext {
+class MOZ_RAII AutoJSContext {
 public:
   explicit AutoJSContext(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM);
   operator JSContext*() const;
 
 protected:
   explicit AutoJSContext(bool aSafe MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
 
   // We need this Init() method because we can't use delegating constructor for
@@ -429,17 +429,17 @@ protected:
   dom::AutoJSAPI mJSAPI;
   MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
 /**
  * Use ThreadsafeAutoJSContext when you want an AutoJSContext but might be
  * running on a worker thread.
  */
-class MOZ_STACK_CLASS ThreadsafeAutoJSContext {
+class MOZ_RAII ThreadsafeAutoJSContext {
 public:
   explicit ThreadsafeAutoJSContext(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM);
   operator JSContext*() const;
 
 private:
   JSContext* mCx; // Used on workers.  Null means mainthread.
   Maybe<JSAutoRequest> mRequest; // Used on workers.
   Maybe<AutoJSContext> mAutoJSContext; // Used on main thread.
@@ -447,27 +447,27 @@ private:
 };
 
 /**
  * AutoSafeJSContext is similar to AutoJSContext but will only return the safe
  * JS context. That means it will never call nsContentUtils::GetCurrentJSContext().
  *
  * Note - This is deprecated. Please use AutoJSAPI instead.
  */
-class MOZ_STACK_CLASS AutoSafeJSContext : public AutoJSContext {
+class MOZ_RAII AutoSafeJSContext : public AutoJSContext {
 public:
   explicit AutoSafeJSContext(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM);
 private:
   JSAutoCompartment mAc;
 };
 
 /**
  * Like AutoSafeJSContext but can be used safely on worker threads.
  */
-class MOZ_STACK_CLASS ThreadsafeAutoSafeJSContext {
+class MOZ_RAII ThreadsafeAutoSafeJSContext {
 public:
   explicit ThreadsafeAutoSafeJSContext(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM);
   operator JSContext*() const;
 
 private:
   JSContext* mCx; // Used on workers.  Null means mainthread.
   Maybe<JSAutoRequest> mRequest; // Used on workers.
   Maybe<AutoSafeJSContext> mAutoSafeJSContext; // Used on main thread.
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -2646,17 +2646,17 @@ private:
   static nsString* sAltText;
   static nsString* sModifierSeparator;
 
 #if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
   static bool sDOMWindowDumpEnabled;
 #endif
 };
 
-class MOZ_STACK_CLASS nsAutoScriptBlocker {
+class MOZ_RAII nsAutoScriptBlocker {
 public:
   explicit nsAutoScriptBlocker(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM) {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     nsContentUtils::AddScriptBlocker();
   }
   ~nsAutoScriptBlocker() {
     nsContentUtils::RemoveScriptBlocker();
   }
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -629,17 +629,17 @@ AllDescendantsOfType(nsIDocShellTreeItem
 
   return true;
 }
 
 /**
  * A class that automatically sets mInShow to false when it goes
  * out of scope.
  */
-class MOZ_STACK_CLASS AutoResetInShow {
+class MOZ_RAII AutoResetInShow {
   private:
     nsFrameLoader* mFrameLoader;
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
   public:
     explicit AutoResetInShow(nsFrameLoader* aFrameLoader MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : mFrameLoader(aFrameLoader)
     {
       MOZ_GUARD_OBJECT_NOTIFIER_INIT;
@@ -984,17 +984,17 @@ nsFrameLoader::SwapWithOtherRemoteLoader
 
   mInSwap = aOther->mInSwap = false;
 
   unused << mRemoteBrowser->SendSwappedWithOtherRemoteLoader();
   unused << aOther->mRemoteBrowser->SendSwappedWithOtherRemoteLoader();
   return NS_OK;
 }
 
-class MOZ_STACK_CLASS AutoResetInFrameSwap final
+class MOZ_RAII AutoResetInFrameSwap final
 {
 public:
   AutoResetInFrameSwap(nsFrameLoader* aThisFrameLoader,
                        nsFrameLoader* aOtherFrameLoader,
                        nsDocShell* aThisDocShell,
                        nsDocShell* aOtherDocShell,
                        EventTarget* aThisEventTarget,
                        EventTarget* aOtherEventTarget
--- a/dom/bindings/BindingUtils.h
+++ b/dom/bindings/BindingUtils.h
@@ -2261,17 +2261,17 @@ template<typename T>
 void DoTraceSequence(JSTracer* trc, InfallibleTArray<T>& seq)
 {
   SequenceTracer<T>::TraceSequence(trc, seq.Elements(),
                                    seq.Elements() + seq.Length());
 }
 
 // Rooter class for sequences; this is what we mostly use in the codegen
 template<typename T>
-class MOZ_STACK_CLASS SequenceRooter : private JS::CustomAutoRooter
+class MOZ_RAII SequenceRooter : private JS::CustomAutoRooter
 {
 public:
   SequenceRooter(JSContext *aCx, FallibleTArray<T>* aSequence
                  MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : JS::CustomAutoRooter(aCx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT),
       mFallibleArray(aSequence),
       mSequenceType(eFallibleArray)
   {
@@ -2320,17 +2320,17 @@ public:
     Nullable<nsTArray<T> >* mNullableArray;
   };
 
   SequenceType mSequenceType;
 };
 
 // Rooter class for MozMap; this is what we mostly use in the codegen.
 template<typename T>
-class MOZ_STACK_CLASS MozMapRooter : private JS::CustomAutoRooter
+class MOZ_RAII MozMapRooter : private JS::CustomAutoRooter
 {
 public:
   MozMapRooter(JSContext *aCx, MozMap<T>* aMozMap
                MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : JS::CustomAutoRooter(aCx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT),
       mMozMap(aMozMap),
       mMozMapType(eMozMap)
   {
@@ -2366,18 +2366,18 @@ private:
     MozMap<T>* mMozMap;
     Nullable<MozMap<T>>* mNullableMozMap;
   };
 
   MozMapType mMozMapType;
 };
 
 template<typename T>
-class MOZ_STACK_CLASS RootedUnion : public T,
-                                    private JS::CustomAutoRooter
+class MOZ_RAII RootedUnion : public T,
+                             private JS::CustomAutoRooter
 {
 public:
   explicit RootedUnion(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
     T(),
     JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)
   {
   }
 
--- a/dom/bindings/RootedDictionary.h
+++ b/dom/bindings/RootedDictionary.h
@@ -10,34 +10,34 @@
 #include "mozilla/GuardObjects.h"
 #include "mozilla/dom/Nullable.h"
 #include "jsapi.h"
 
 namespace mozilla {
 namespace dom {
 
 template<typename T>
-class MOZ_STACK_CLASS RootedDictionary : public T,
+class MOZ_RAII RootedDictionary : public T,
                                          private JS::CustomAutoRooter
 {
 public:
   explicit RootedDictionary(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
     T(),
     JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)
   {
   }
 
   virtual void trace(JSTracer *trc) override
   {
     this->TraceDictionary(trc);
   }
 };
 
 template<typename T>
-class MOZ_STACK_CLASS NullableRootedDictionary : public Nullable<T>,
+class MOZ_RAII NullableRootedDictionary : public Nullable<T>,
                                                  private JS::CustomAutoRooter
 {
 public:
   explicit NullableRootedDictionary(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
     Nullable<T>(),
     JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)
   {
   }
--- a/dom/bindings/TypedArray.h
+++ b/dom/bindings/TypedArray.h
@@ -322,17 +322,17 @@ class TypedArrayCreator
     }
 
   private:
     const ArrayType& mArray;
 };
 
 // A class for rooting an existing TypedArray struct
 template<typename ArrayType>
-class MOZ_STACK_CLASS TypedArrayRooter : private JS::CustomAutoRooter
+class MOZ_RAII TypedArrayRooter : private JS::CustomAutoRooter
 {
 public:
   TypedArrayRooter(JSContext* cx,
                    ArrayType* aArray MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
     JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT),
     mArray(aArray)
   {
   }
@@ -344,17 +344,17 @@ public:
 
 private:
   TypedArrayObjectStorage* const mArray;
 };
 
 // And a specialization for dealing with nullable typed arrays
 template<typename Inner> struct Nullable;
 template<typename ArrayType>
-class MOZ_STACK_CLASS TypedArrayRooter<Nullable<ArrayType> > :
+class MOZ_RAII TypedArrayRooter<Nullable<ArrayType> > :
     private JS::CustomAutoRooter
 {
 public:
   TypedArrayRooter(JSContext* cx,
                    Nullable<ArrayType>* aArray MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
     JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT),
     mArray(aArray)
   {
@@ -368,18 +368,18 @@ public:
   }
 
 private:
   Nullable<ArrayType>* const mArray;
 };
 
 // Class for easily setting up a rooted typed array object on the stack
 template<typename ArrayType>
-class MOZ_STACK_CLASS RootedTypedArray : public ArrayType,
-                                         private TypedArrayRooter<ArrayType>
+class MOZ_RAII RootedTypedArray : public ArrayType,
+                                  private TypedArrayRooter<ArrayType>
 {
 public:
   explicit RootedTypedArray(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
     ArrayType(),
     TypedArrayRooter<ArrayType>(cx, this
                                 MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)
   {
   }
--- a/dom/media/MediaResource.h
+++ b/dom/media/MediaResource.h
@@ -789,17 +789,17 @@ protected:
 
 /**
  * RAII class that handles pinning and unpinning for MediaResource and derived.
  * This should be used when making calculations that involve potentially-cached
  * MediaResource data, so that the state of the world can't change out from under
  * us.
  */
 template<class T>
-class MOZ_STACK_CLASS AutoPinned {
+class MOZ_RAII AutoPinned {
  public:
   explicit AutoPinned(T* aResource MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : mResource(aResource) {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     MOZ_ASSERT(mResource);
     mResource->Pin();
   }
 
   ~AutoPinned() {
--- a/dom/plugins/ipc/PluginModuleParent.cpp
+++ b/dom/plugins/ipc/PluginModuleParent.cpp
@@ -301,17 +301,17 @@ public:
     }
 
     static bool
     IsLoadModuleOnStack()
     {
         return sIsLoadModuleOnStack;
     }
 
-    class MOZ_STACK_CLASS NotifyLoadingModule
+    class MOZ_RAII NotifyLoadingModule
     {
     public:
         explicit NotifyLoadingModule(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM)
         {
             MOZ_GUARD_OBJECT_NOTIFIER_INIT;
             PluginModuleMapping::sIsLoadModuleOnStack = true;
         }
 
--- a/dom/svg/DOMSVGLength.cpp
+++ b/dom/svg/DOMSVGLength.cpp
@@ -61,17 +61,17 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   NS_INTERFACE_MAP_ENTRY(nsIDOMSVGLength)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 //----------------------------------------------------------------------
 // Helper class: AutoChangeLengthNotifier
 // Stack-based helper class to pair calls to WillChangeLengthList and
 // DidChangeLengthList.
-class MOZ_STACK_CLASS AutoChangeLengthNotifier
+class MOZ_RAII AutoChangeLengthNotifier
 {
 public:
   explicit AutoChangeLengthNotifier(DOMSVGLength* aLength MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : mLength(aLength)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     MOZ_ASSERT(mLength, "Expecting non-null length");
     MOZ_ASSERT(mLength->HasOwner(),
--- a/dom/svg/DOMSVGLengthList.cpp
+++ b/dom/svg/DOMSVGLengthList.cpp
@@ -74,17 +74,17 @@ DOMSVGLengthList::WrapObject(JSContext *
 {
   return mozilla::dom::SVGLengthListBinding::Wrap(cx, this, aGivenProto);
 }
 
 //----------------------------------------------------------------------
 // Helper class: AutoChangeLengthListNotifier
 // Stack-based helper class to pair calls to WillChangeLengthList and
 // DidChangeLengthList.
-class MOZ_STACK_CLASS AutoChangeLengthListNotifier
+class MOZ_RAII AutoChangeLengthListNotifier
 {
 public:
   explicit AutoChangeLengthListNotifier(DOMSVGLengthList* aLengthList MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : mLengthList(aLengthList)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     MOZ_ASSERT(mLengthList, "Expecting non-null lengthList");
     mEmptyOrOldValue =
--- a/dom/svg/DOMSVGNumber.cpp
+++ b/dom/svg/DOMSVGNumber.cpp
@@ -48,17 +48,17 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 //----------------------------------------------------------------------
 // Helper class: AutoChangeNumberNotifier
 // Stack-based helper class to pair calls to WillChangeNumberList and
 // DidChangeNumberList.
-class MOZ_STACK_CLASS AutoChangeNumberNotifier
+class MOZ_RAII AutoChangeNumberNotifier
 {
 public:
   explicit AutoChangeNumberNotifier(DOMSVGNumber* aNumber MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : mNumber(aNumber)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     MOZ_ASSERT(mNumber, "Expecting non-null number");
     MOZ_ASSERT(mNumber->HasOwner(),
--- a/dom/svg/DOMSVGNumberList.cpp
+++ b/dom/svg/DOMSVGNumberList.cpp
@@ -75,17 +75,17 @@ DOMSVGNumberList::WrapObject(JSContext *
 {
   return mozilla::dom::SVGNumberListBinding::Wrap(cx, this, aGivenProto);
 }
 
 //----------------------------------------------------------------------
 // Helper class: AutoChangeNumberListNotifier
 // Stack-based helper class to pair calls to WillChangeNumberList and
 // DidChangeNumberList.
-class MOZ_STACK_CLASS AutoChangeNumberListNotifier
+class MOZ_RAII AutoChangeNumberListNotifier
 {
 public:
   explicit AutoChangeNumberListNotifier(DOMSVGNumberList* aNumberList MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : mNumberList(aNumberList)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     MOZ_ASSERT(mNumberList, "Expecting non-null numberList");
     mEmptyOrOldValue =
--- a/dom/svg/DOMSVGPathSeg.cpp
+++ b/dom/svg/DOMSVGPathSeg.cpp
@@ -40,17 +40,17 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DOMSVGPathSeg, AddRef)
 NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DOMSVGPathSeg, Release)
 
 //----------------------------------------------------------------------
 // Helper class: AutoChangePathSegNotifier
 // Stack-based helper class to pair calls to WillChangePathSegList
 // and DidChangePathSegList.
-class MOZ_STACK_CLASS AutoChangePathSegNotifier
+class MOZ_RAII AutoChangePathSegNotifier
 {
 public:
   explicit AutoChangePathSegNotifier(DOMSVGPathSeg* aPathSeg MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : mPathSeg(aPathSeg)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     MOZ_ASSERT(mPathSeg, "Expecting non-null pathSeg");
     MOZ_ASSERT(mPathSeg->HasOwner(),
--- a/dom/svg/DOMSVGPathSegList.cpp
+++ b/dom/svg/DOMSVGPathSegList.cpp
@@ -50,17 +50,17 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 
 //----------------------------------------------------------------------
 // Helper class: AutoChangePathSegListNotifier
 // Stack-based helper class to pair calls to WillChangePathSegList and
 // DidChangePathSegList.
-class MOZ_STACK_CLASS AutoChangePathSegListNotifier
+class MOZ_RAII AutoChangePathSegListNotifier
 {
 public:
   explicit AutoChangePathSegListNotifier(DOMSVGPathSegList* aPathSegList MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : mPathSegList(aPathSegList)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     MOZ_ASSERT(mPathSegList, "Expecting non-null pathSegList");
     mEmptyOrOldValue =
--- a/dom/svg/DOMSVGPoint.cpp
+++ b/dom/svg/DOMSVGPoint.cpp
@@ -18,17 +18,17 @@ using namespace mozilla;
 using namespace mozilla::gfx;
 
 namespace mozilla {
 
 //----------------------------------------------------------------------
 // Helper class: AutoChangePointNotifier
 // Stack-based helper class to pair calls to WillChangePointList and
 // DidChangePointList.
-class MOZ_STACK_CLASS AutoChangePointNotifier
+class MOZ_RAII AutoChangePointNotifier
 {
 public:
   explicit AutoChangePointNotifier(DOMSVGPoint* aPoint MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : mPoint(aPoint)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     MOZ_ASSERT(mPoint, "Expecting non-null point");
     MOZ_ASSERT(mPoint->HasOwner(),
--- a/dom/svg/DOMSVGPointList.cpp
+++ b/dom/svg/DOMSVGPointList.cpp
@@ -68,17 +68,17 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 //----------------------------------------------------------------------
 // Helper class: AutoChangePointListNotifier
 // Stack-based helper class to pair calls to WillChangePointList and
 // DidChangePointList.
-class MOZ_STACK_CLASS AutoChangePointListNotifier
+class MOZ_RAII AutoChangePointListNotifier
 {
 public:
   explicit AutoChangePointListNotifier(DOMSVGPointList* aPointList MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : mPointList(aPointList)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     MOZ_ASSERT(mPointList, "Expecting non-null pointList");
     mEmptyOrOldValue =
--- a/dom/svg/DOMSVGStringList.cpp
+++ b/dom/svg/DOMSVGStringList.cpp
@@ -38,17 +38,17 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 //----------------------------------------------------------------------
 // Helper class: AutoChangeStringListNotifier
 // Stack-based helper class to pair calls to WillChangeStringListList and
 // DidChangeStringListList.
-class MOZ_STACK_CLASS AutoChangeStringListNotifier
+class MOZ_RAII AutoChangeStringListNotifier
 {
 public:
   explicit AutoChangeStringListNotifier(DOMSVGStringList* aStringList MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : mStringList(aStringList)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     MOZ_ASSERT(mStringList, "Expecting non-null stringList");
     mEmptyOrOldValue =
--- a/dom/svg/DOMSVGTransformList.cpp
+++ b/dom/svg/DOMSVGTransformList.cpp
@@ -76,17 +76,17 @@ DOMSVGTransformList::WrapObject(JSContex
 {
   return mozilla::dom::SVGTransformListBinding::Wrap(cx, this, aGivenProto);
 }
 
 //----------------------------------------------------------------------
 // Helper class: AutoChangeTransformListNotifier
 // Stack-based helper class to pair calls to WillChangeTransformList and
 // DidChangeTransformList.
-class MOZ_STACK_CLASS AutoChangeTransformListNotifier
+class MOZ_RAII AutoChangeTransformListNotifier
 {
 public:
   explicit AutoChangeTransformListNotifier(DOMSVGTransformList* aTransformList MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : mTransformList(aTransformList)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     MOZ_ASSERT(mTransformList, "Expecting non-null transformList");
     mEmptyOrOldValue =
--- a/dom/svg/SVGSVGElement.h
+++ b/dom/svg/SVGSVGElement.h
@@ -402,17 +402,17 @@ private:
   bool     mHasChildrenOnlyTransform;
   bool     mUseCurrentView;
 };
 
 } // namespace dom
 
 // Helper class to automatically manage temporary changes to an SVG document's
 // state for rendering purposes.
-class MOZ_STACK_CLASS AutoSVGRenderingState
+class MOZ_RAII AutoSVGRenderingState
 {
 public:
   AutoSVGRenderingState(const Maybe<SVGImageContext>& aSVGContext,
                         float aFrameTime,
                         dom::SVGSVGElement* aRootElem
                         MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : mHaveOverrides(aSVGContext.isSome() &&
                      aSVGContext->GetPreserveAspectRatio().isSome())
--- a/dom/svg/SVGTransform.cpp
+++ b/dom/svg/SVGTransform.cpp
@@ -66,17 +66,17 @@ SVGTransform::WrapObject(JSContext* aCx,
 {
   return SVGTransformBinding::Wrap(aCx, this, aGivenProto);
 }
 
 //----------------------------------------------------------------------
 // Helper class: AutoChangeTransformNotifier
 // Stack-based helper class to pair calls to WillChangeTransformList
 // and DidChangeTransformList.
-class MOZ_STACK_CLASS AutoChangeTransformNotifier
+class MOZ_RAII AutoChangeTransformNotifier
 {
 public:
   explicit AutoChangeTransformNotifier(SVGTransform* aTransform MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : mTransform(aTransform)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     MOZ_ASSERT(mTransform, "Expecting non-null transform");
     if (mTransform->HasOwner()) {
--- a/dom/workers/XMLHttpRequest.cpp
+++ b/dom/workers/XMLHttpRequest.cpp
@@ -538,17 +538,17 @@ class EventRunnable final : public MainT
   bool mProgressEvent;
   bool mLengthComputable;
   bool mUseCachedArrayBufferResponse;
   nsresult mResponseTextResult;
   nsresult mStatusResult;
   nsresult mResponseResult;
 
 public:
-  class StateDataAutoRooter : private JS::CustomAutoRooter
+  class MOZ_RAII StateDataAutoRooter : private JS::CustomAutoRooter
   {
     XMLHttpRequest::StateData* mStateData;
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 
   public:
     explicit StateDataAutoRooter(JSContext* aCx, XMLHttpRequest::StateData* aData
                                  MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : CustomAutoRooter(aCx), mStateData(aData)
--- a/editor/libeditor/nsEditorUtils.h
+++ b/editor/libeditor/nsEditorUtils.h
@@ -26,17 +26,17 @@ namespace dom {
 class Selection;
 } // namespace dom
 } // namespace mozilla
 
 /***************************************************************************
  * stack based helper class for batching a collection of txns inside a
  * placeholder txn.
  */
-class MOZ_STACK_CLASS nsAutoPlaceHolderBatch
+class MOZ_RAII nsAutoPlaceHolderBatch
 {
   private:
     nsCOMPtr<nsIEditor> mEd;
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
   public:
     nsAutoPlaceHolderBatch(nsIEditor *aEd, nsIAtom *atom MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : mEd(do_QueryInterface(aEd))
     {
@@ -53,33 +53,33 @@ class MOZ_STACK_CLASS nsAutoPlaceHolderB
     }
 };
 
 /***************************************************************************
  * stack based helper class for batching a collection of txns.
  * Note: I changed this to use placeholder batching so that we get
  * proper selection save/restore across undo/redo.
  */
-class MOZ_STACK_CLASS nsAutoEditBatch : public nsAutoPlaceHolderBatch
+class MOZ_RAII nsAutoEditBatch : public nsAutoPlaceHolderBatch
 {
   MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
   public:
     explicit nsAutoEditBatch(nsIEditor *aEd MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : nsAutoPlaceHolderBatch(aEd, nullptr)
     {
       MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     }
     ~nsAutoEditBatch() {}
 };
 
 /***************************************************************************
  * stack based helper class for saving/restoring selection.  Note that this
  * assumes that the nodes involved are still around afterwards!
  */
-class MOZ_STACK_CLASS nsAutoSelectionReset
+class MOZ_RAII nsAutoSelectionReset
 {
   private:
     /** ref-counted reference to the selection that we are supposed to restore */
     nsRefPtr<mozilla::dom::Selection> mSel;
     nsEditor *mEd;  // non-owning ref to nsEditor
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 
   public:
@@ -91,17 +91,17 @@ class MOZ_STACK_CLASS nsAutoSelectionRes
 
     /** Abort: cancel selection saver */
     void Abort();
 };
 
 /***************************************************************************
  * stack based helper class for StartOperation()/EndOperation() sandwich
  */
-class MOZ_STACK_CLASS nsAutoRules
+class MOZ_RAII nsAutoRules
 {
   public:
 
   nsAutoRules(nsEditor *ed, EditAction action,
               nsIEditor::EDirection aDirection
               MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : mEd(ed), mDoNothing(false)
   {
@@ -126,17 +126,17 @@ class MOZ_STACK_CLASS nsAutoRules
   MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
 
 /***************************************************************************
  * stack based helper class for turning off active selection adjustment
  * by low level transactions
  */
-class MOZ_STACK_CLASS nsAutoTxnsConserveSelection
+class MOZ_RAII nsAutoTxnsConserveSelection
 {
   public:
 
   explicit nsAutoTxnsConserveSelection(nsEditor *ed MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : mEd(ed), mOldState(true)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     if (mEd)
@@ -158,17 +158,17 @@ class MOZ_STACK_CLASS nsAutoTxnsConserve
   nsEditor *mEd;
   bool mOldState;
   MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
 /***************************************************************************
  * stack based helper class for batching reflow and paint requests.
  */
-class MOZ_STACK_CLASS nsAutoUpdateViewBatch
+class MOZ_RAII nsAutoUpdateViewBatch
 {
   public:
 
   explicit nsAutoUpdateViewBatch(nsEditor *ed MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : mEd(ed)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     NS_ASSERTION(mEd, "null mEd pointer!");
 
@@ -192,34 +192,34 @@ class MOZ_STACK_CLASS nsAutoUpdateViewBa
  *****************************************************************************/
 
 class nsBoolDomIterFunctor
 {
   public:
     virtual bool operator()(nsINode* aNode) const = 0;
 };
 
-class MOZ_STACK_CLASS nsDOMIterator
+class MOZ_RAII nsDOMIterator
 {
   public:
     explicit nsDOMIterator(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM);
 
     explicit nsDOMIterator(nsINode& aNode MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
     virtual ~nsDOMIterator();
 
     nsresult Init(nsRange& aRange);
 
     void AppendList(const nsBoolDomIterFunctor& functor,
                     nsTArray<mozilla::OwningNonNull<nsINode>>& arrayOfNodes) const;
   protected:
     nsCOMPtr<nsIContentIterator> mIter;
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
-class MOZ_STACK_CLASS nsDOMSubtreeIterator : public nsDOMIterator
+class MOZ_RAII nsDOMSubtreeIterator : public nsDOMIterator
 {
   public:
     explicit nsDOMSubtreeIterator(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM);
     virtual ~nsDOMSubtreeIterator();
 
     nsresult Init(nsRange& aRange);
 };
 
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -272,17 +272,17 @@ private:
     // Disable harmful methods.
     CxxStackFrame() = delete;
     CxxStackFrame(const CxxStackFrame&) = delete;
     CxxStackFrame& operator=(const CxxStackFrame&) = delete;
 };
 
 namespace {
 
-class MOZ_STACK_CLASS MaybeScriptBlocker {
+class MOZ_RAII MaybeScriptBlocker {
 public:
     explicit MaybeScriptBlocker(MessageChannel *aChannel, bool aBlock
                                 MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
         : mBlocked(aChannel->ShouldBlockScripts() && aBlock)
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
         if (mBlocked) {
             nsContentUtils::AddScriptBlocker();
--- a/ipc/glue/Neutering.h
+++ b/ipc/glue/Neutering.h
@@ -18,17 +18,17 @@ namespace mozilla {
 namespace ipc {
 
 /**
  * This class is a RAII wrapper around Window neutering. As long as a
  * NeuteredWindowRegion object is instantiated, Win32 windows belonging to the
  * current thread will be neutered. It is safe to nest multiple instances of
  * this class.
  */
-class MOZ_STACK_CLASS NeuteredWindowRegion
+class MOZ_RAII NeuteredWindowRegion
 {
 public:
   explicit NeuteredWindowRegion(bool aDoNeuter MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
   ~NeuteredWindowRegion();
 
   /**
    * This function clears any backlog of nonqueued messages that are pending for
    * the current thread.
@@ -41,17 +41,17 @@ private:
 };
 
 /**
  * This class is analagous to MutexAutoUnlock for Mutex; it is an RAII class
  * that is to be instantiated within a NeuteredWindowRegion, thus temporarily
  * disabling neutering for the remainder of its enclosing block.
  * @see NeuteredWindowRegion
  */
-class MOZ_STACK_CLASS DeneuteredWindowRegion
+class MOZ_RAII DeneuteredWindowRegion
 {
 public:
   DeneuteredWindowRegion(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM);
   ~DeneuteredWindowRegion();
 
 private:
   MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
   bool mReneuter;
--- a/js/ipc/CPOWTimer.h
+++ b/js/ipc/CPOWTimer.h
@@ -15,17 +15,17 @@
  * A stopwatch measuring the duration of a CPOW call.
  *
  * As the process is consuming neither user time nor system time
  * during a CPOW call, we measure such durations using wallclock time.
  *
  * This stopwatch is active iff JSRuntime::stopwatch.isActive is set.
  * Upon destruction, update JSRuntime::stopwatch.data.totalCPOWTime.
  */
-class MOZ_STACK_CLASS CPOWTimer final {
+class MOZ_RAII CPOWTimer final {
   public:
     explicit inline CPOWTimer(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
     ~CPOWTimer();
 
   private:
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 
     /**
--- a/js/public/RootingAPI.h
+++ b/js/public/RootingAPI.h
@@ -649,17 +649,17 @@ namespace JS {
  * Local variable of type T whose value is always rooted. This is typically
  * used for local variables, or for non-rooted values being passed to a
  * function that requires a handle, e.g. Foo(Root<T>(cx, x)).
  *
  * If you want to add additional methods to Rooted for a specific
  * specialization, define a RootedBase<T> specialization containing them.
  */
 template <typename T>
-class MOZ_STACK_CLASS Rooted : public js::RootedBase<T>
+class MOZ_RAII Rooted : public js::RootedBase<T>
 {
     static_assert(!mozilla::IsConvertible<T, Traceable*>::value,
                   "Rooted takes pointer or Traceable types but not Traceable* type");
 
     /* Note: CX is a subclass of either ContextFriendFields or PerThreadDataFriendFields. */
     void registerWithRootLists(js::RootLists& roots) {
         js::ThingRootKind kind = js::RootKind<T>::rootKind();
         this->stack = &roots.stackRoots_[kind];
@@ -772,17 +772,17 @@ class HandleBase<JSObject*>
 {
   public:
     template <class U>
     JS::Handle<U*> as() const;
 };
 
 /* Interface substitute for Rooted<T> which does not root the variable's memory. */
 template <typename T>
-class FakeRooted : public RootedBase<T>
+class MOZ_RAII FakeRooted : public RootedBase<T>
 {
   public:
     template <typename CX>
     explicit FakeRooted(CX* cx
                         MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : ptr(GCMethods<T>::initial())
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
--- a/js/src/ds/LifoAlloc.h
+++ b/js/src/ds/LifoAlloc.h
@@ -477,17 +477,17 @@ class LifoAlloc
         // Return a Mark at the current position of the Enum.
         Mark mark() {
             alloc_->markCount++;
             return Mark(chunk_, position_);
         }
     };
 };
 
-class LifoAllocScope
+class MOZ_NON_TEMPORARY_CLASS LifoAllocScope
 {
     LifoAlloc*      lifoAlloc;
     LifoAlloc::Mark mark;
     bool            shouldRelease;
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 
   public:
     explicit LifoAllocScope(LifoAlloc* lifoAlloc
--- a/js/src/gc/GCInternals.h
+++ b/js/src/gc/GCInternals.h
@@ -87,17 +87,17 @@ class IncrementalSafety
     }
 };
 
 IncrementalSafety
 IsIncrementalGCSafe(JSRuntime* rt);
 
 #ifdef JS_GC_ZEAL
 
-class AutoStopVerifyingBarriers
+class MOZ_RAII AutoStopVerifyingBarriers
 {
     GCRuntime* gc;
     bool restartPreVerifier;
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 
   public:
     AutoStopVerifyingBarriers(JSRuntime* rt, bool isShutdown
                               MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
@@ -147,17 +147,17 @@ struct MovingTracer : JS::CallbackTracer
         MOZ_ASSERT(!RelocationOverlay::isCellForwarded(thing.asCell()));
     }
 
 #ifdef DEBUG
     TracerKind getTracerKind() const override { return TracerKind::Moving; }
 #endif
 };
 
-class AutoMaybeStartBackgroundAllocation
+class MOZ_RAII AutoMaybeStartBackgroundAllocation
 {
   private:
     JSRuntime* runtime;
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 
   public:
     explicit AutoMaybeStartBackgroundAllocation(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM)
       : runtime(nullptr)
@@ -171,17 +171,17 @@ class AutoMaybeStartBackgroundAllocation
 
     ~AutoMaybeStartBackgroundAllocation() {
         if (runtime)
             runtime->gc.startBackgroundAllocTaskIfIdle();
     }
 };
 
 // In debug builds, set/unset the GC sweeping flag for the current thread.
-struct AutoSetThreadIsSweeping
+struct MOZ_RAII AutoSetThreadIsSweeping
 {
 #ifdef DEBUG
     explicit AutoSetThreadIsSweeping(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM)
       : threadData_(js::TlsPerThreadData.get())
     {
         MOZ_ASSERT(!threadData_->gcSweeping);
         threadData_->gcSweeping = true;
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
--- a/js/src/gc/Statistics.h
+++ b/js/src/gc/Statistics.h
@@ -326,33 +326,33 @@ struct Statistics
 
     UniqueChars formatJsonDescription(uint64_t timestamp);
     UniqueChars formatJsonSliceDescription(unsigned i, const SliceData& slice);
     UniqueChars formatJsonPhaseTimes(const PhaseTimeTable phaseTimes);
 
     double computeMMU(int64_t resolution) const;
 };
 
-struct AutoGCSlice
+struct MOZ_RAII AutoGCSlice
 {
     AutoGCSlice(Statistics& stats, const ZoneGCStats& zoneStats, JSGCInvocationKind gckind,
                 SliceBudget budget, JS::gcreason::Reason reason
                 MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : stats(stats)
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
         stats.beginSlice(zoneStats, gckind, budget, reason);
     }
     ~AutoGCSlice() { stats.endSlice(); }
 
     Statistics& stats;
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
-struct AutoPhase
+struct MOZ_RAII AutoPhase
 {
     AutoPhase(Statistics& stats, Phase phase
               MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : stats(stats), task(nullptr), phase(phase), enabled(true)
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
         stats.beginPhase(phase);
     }
@@ -386,17 +386,17 @@ struct AutoPhase
 
     Statistics& stats;
     const GCParallelTask* task;
     Phase phase;
     bool enabled;
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
-struct AutoSCC
+struct MOZ_RAII AutoSCC
 {
     AutoSCC(Statistics& stats, unsigned scc
             MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : stats(stats), scc(scc)
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
         start = stats.beginSCC();
     }
--- a/js/src/jit/Ion.cpp
+++ b/js/src/jit/Ion.cpp
@@ -513,17 +513,17 @@ FinishAllOffThreadCompilations(JSCompart
         IonBuilder* builder = finished[i];
         if (builder->compartment == CompileCompartment::get(comp)) {
             FinishOffThreadBuilder(nullptr, builder);
             HelperThreadState().remove(finished, &i);
         }
     }
 }
 
-class AutoLazyLinkExitFrame
+class MOZ_RAII AutoLazyLinkExitFrame
 {
     JitActivation* jitActivation_;
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 
   public:
     explicit AutoLazyLinkExitFrame(JitActivation* jitActivation
                                    MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : jitActivation_(jitActivation)
--- a/js/src/jit/JitSpewer.cpp
+++ b/js/src/jit/JitSpewer.cpp
@@ -70,17 +70,17 @@ class IonSpewer
     void lockOutput() {
         PR_Lock(outputLock_);
     }
     void unlockOutput() {
         PR_Unlock(outputLock_);
     }
 };
 
-class AutoLockIonSpewerOutput
+class MOZ_RAII AutoLockIonSpewerOutput
 {
   private:
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
   public:
     explicit AutoLockIonSpewerOutput(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM);
     ~AutoLockIonSpewerOutput();
 };
 
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -62,17 +62,17 @@ class JS_PUBLIC_API(AutoCheckRequestDept
 
 # define CHECK_REQUEST(cx) \
     ((void) 0)
 
 #endif /* JS_DEBUG */
 
 /* AutoValueArray roots an internal fixed-size array of Values. */
 template <size_t N>
-class AutoValueArray : public AutoGCRooter
+class MOZ_RAII AutoValueArray : public AutoGCRooter
 {
     const size_t length_;
     Value elements_[N];
 
   public:
     explicit AutoValueArray(JSContext* cx
                             MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : AutoGCRooter(cx, VALARRAY), length_(N)
@@ -94,17 +94,17 @@ class AutoValueArray : public AutoGCRoot
         MOZ_ASSERT(i < N);
         return MutableHandleValue::fromMarkedLocation(&elements_[i]);
     }
 
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
 template<class T>
-class AutoVectorRooterBase : protected AutoGCRooter
+class MOZ_RAII AutoVectorRooterBase : protected AutoGCRooter
 {
     typedef js::Vector<T, 8> VectorImpl;
     VectorImpl vector;
 
   public:
     explicit AutoVectorRooterBase(JSContext* cx, ptrdiff_t tag
                               MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : AutoGCRooter(cx, tag), vector(cx)
@@ -191,17 +191,17 @@ class AutoVectorRooterBase : protected A
         for (size_t i = oldLength; i < vector.length(); ++i, ++t)
             memset(t, 0, sizeof(T));
     }
 
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
 template <typename T>
-class MOZ_STACK_CLASS AutoVectorRooter : public AutoVectorRooterBase<T>
+class MOZ_RAII AutoVectorRooter : public AutoVectorRooterBase<T>
 {
   public:
     explicit AutoVectorRooter(JSContext* cx
                              MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
         : AutoVectorRooterBase<T>(cx, this->GetTag(T()))
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     }
@@ -220,17 +220,17 @@ typedef AutoVectorRooter<Value> AutoValu
 typedef AutoVectorRooter<jsid> AutoIdVector;
 typedef AutoVectorRooter<JSObject*> AutoObjectVector;
 
 using ValueVector = js::TraceableVector<JS::Value>;
 using IdVector = js::TraceableVector<jsid>;
 using ScriptVector = js::TraceableVector<JSScript*>;
 
 template<class Key, class Value>
-class AutoHashMapRooter : protected AutoGCRooter
+class MOZ_RAII AutoHashMapRooter : protected AutoGCRooter
 {
   private:
     typedef js::HashMap<Key, Value> HashMapImpl;
 
   public:
     explicit AutoHashMapRooter(JSContext* cx, ptrdiff_t tag
                                MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : AutoGCRooter(cx, tag), map(cx)
@@ -344,17 +344,17 @@ class AutoHashMapRooter : protected Auto
     AutoHashMapRooter& operator=(const AutoHashMapRooter& hmr) = delete;
 
     HashMapImpl map;
 
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
 template<class T>
-class AutoHashSetRooter : protected AutoGCRooter
+class MOZ_RAII AutoHashSetRooter : protected AutoGCRooter
 {
   private:
     typedef js::HashSet<T> HashSetImpl;
 
   public:
     explicit AutoHashSetRooter(JSContext* cx, ptrdiff_t tag
                                MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : AutoGCRooter(cx, tag), set(cx)
@@ -455,17 +455,17 @@ class AutoHashSetRooter : protected Auto
     HashSetImpl set;
 
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
 /*
  * Custom rooting behavior for internal and external clients.
  */
-class JS_PUBLIC_API(CustomAutoRooter) : private AutoGCRooter
+class MOZ_RAII JS_PUBLIC_API(CustomAutoRooter) : private AutoGCRooter
 {
   public:
     template <typename CX>
     explicit CustomAutoRooter(CX* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : AutoGCRooter(cx, CUSTOM)
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     }
@@ -1065,17 +1065,17 @@ namespace js {
 void
 AssertHeapIsIdle(JSRuntime* rt);
 
 void
 AssertHeapIsIdle(JSContext* cx);
 
 } /* namespace js */
 
-class JSAutoRequest
+class MOZ_RAII JSAutoRequest
 {
   public:
     explicit JSAutoRequest(JSContext* cx
                            MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : mContext(cx)
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
         JS_BeginRequest(mContext);
@@ -1404,31 +1404,31 @@ JS_RefreshCrossCompartmentWrappers(JSCon
  *   }
  *
  * Note: these calls must still execute in a LIFO manner w.r.t all other
  * enter/leave calls on the context. Furthermore, only the return value of a
  * JS_EnterCompartment call may be passed as the 'oldCompartment' argument of
  * the corresponding JS_LeaveCompartment call.
  */
 
-class JS_PUBLIC_API(JSAutoCompartment)
+class MOZ_RAII JS_PUBLIC_API(JSAutoCompartment)
 {
     JSContext* cx_;
     JSCompartment* oldCompartment_;
   public:
     JSAutoCompartment(JSContext* cx, JSObject* target
                       MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
     JSAutoCompartment(JSContext* cx, JSScript* target
                       MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
     ~JSAutoCompartment();
 
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
-class JS_PUBLIC_API(JSAutoNullableCompartment)
+class MOZ_RAII JS_PUBLIC_API(JSAutoNullableCompartment)
 {
     JSContext* cx_;
     JSCompartment* oldCompartment_;
   public:
     explicit JSAutoNullableCompartment(JSContext* cx, JSObject* targetOrNull
                                        MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
     ~JSAutoNullableCompartment();
 
@@ -4222,17 +4222,17 @@ JS_GetStringEncodingLength(JSContext* cx
  * encoded into bytes with no error reported. Otherwise it returns the number
  * of bytes that are necessary to encode the string. If that exceeds the
  * length parameter, the string will be cut and only length bytes will be
  * written into the buffer.
  */
 JS_PUBLIC_API(size_t)
 JS_EncodeStringToBuffer(JSContext* cx, JSString* str, char* buffer, size_t length);
 
-class JSAutoByteString
+class MOZ_RAII JSAutoByteString
 {
   public:
     JSAutoByteString(JSContext* cx, JSString* str
                      MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : mBytes(JS_EncodeString(cx, str))
     {
         MOZ_ASSERT(cx);
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
@@ -5034,17 +5034,17 @@ GetScriptedCallerGlobal(JSContext* cx);
  * popped from the stack.
  */
 extern JS_PUBLIC_API(void)
 HideScriptedCaller(JSContext* cx);
 
 extern JS_PUBLIC_API(void)
 UnhideScriptedCaller(JSContext* cx);
 
-class AutoHideScriptedCaller
+class MOZ_RAII AutoHideScriptedCaller
 {
   public:
     explicit AutoHideScriptedCaller(JSContext* cx
                                     MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : mContext(cx)
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
         HideScriptedCaller(mContext);
--- a/js/src/jscntxt.h
+++ b/js/src/jscntxt.h
@@ -28,17 +28,17 @@ namespace jit {
 class JitContext;
 class DebugModeOSRVolatileJitFrameIterator;
 } // namespace jit
 
 typedef HashSet<JSObject*> ObjectSet;
 typedef HashSet<Shape*> ShapeSet;
 
 /* Detects cycles when traversing an object graph. */
-class AutoCycleDetector
+class MOZ_RAII AutoCycleDetector
 {
     JSContext* cx;
     RootedObject obj;
     bool cyclic;
     uint32_t hashsetGenerationAtInit;
     ObjectSet::AddPtr hashsetAddPointer;
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 
@@ -461,17 +461,17 @@ struct JSContext : public js::ExclusiveC
      * threshold when p is not null. The function takes the pointer and not
      * a boolean flag to minimize the amount of code in its inlined callers.
      */
     JS_FRIEND_API(void) checkMallocGCPressure(void* p);
 }; /* struct JSContext */
 
 namespace js {
 
-struct AutoResolving {
+struct MOZ_RAII AutoResolving {
   public:
     enum Kind {
         LOOKUP,
         WATCH
     };
 
     AutoResolving(JSContext* cx, HandleObject obj, HandleId id, Kind kind = LOOKUP
                   MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
@@ -665,17 +665,17 @@ CheckForInterrupt(JSContext* cx)
 /************************************************************************/
 
 typedef JS::AutoVectorRooter<PropertyName*> AutoPropertyNameVector;
 
 using ShapeVector = js::TraceableVector<Shape*>;
 using StringVector = js::TraceableVector<JSString*>;
 
 /* AutoArrayRooter roots an external array of Values. */
-class AutoArrayRooter : private JS::AutoGCRooter
+class MOZ_RAII AutoArrayRooter : private JS::AutoGCRooter
 {
   public:
     AutoArrayRooter(JSContext* cx, size_t len, Value* vec
                     MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : JS::AutoGCRooter(cx, len), array(vec)
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
         MOZ_ASSERT(tag_ >= 0);
@@ -744,17 +744,17 @@ class AutoAssertNoException
     {
         MOZ_ASSERT_IF(!hadException, !cx->isExceptionPending());
     }
 };
 
 /* Exposed intrinsics for the JITs. */
 bool intrinsic_IsSuspendedStarGenerator(JSContext* cx, unsigned argc, Value* vp);
 
-class AutoLockForExclusiveAccess
+class MOZ_RAII AutoLockForExclusiveAccess
 {
     JSRuntime* runtime;
 
     void init(JSRuntime* rt) {
         runtime = rt;
         if (runtime->numExclusiveThreads) {
             runtime->assertCanLock(ExclusiveAccessLock);
             PR_Lock(runtime->exclusiveAccessLock);
--- a/js/src/jscompartment.h
+++ b/js/src/jscompartment.h
@@ -180,17 +180,17 @@ typedef HashMap<CrossCompartmentKey, Rea
 struct ImmediateMetadata { };
 struct DelayMetadata { };
 using PendingMetadata = ReadBarrieredObject;
 
 using NewObjectMetadataState = mozilla::Variant<ImmediateMetadata,
                                                 DelayMetadata,
                                                 PendingMetadata>;
 
-class MOZ_STACK_CLASS AutoSetNewObjectMetadata : private JS::CustomAutoRooter
+class MOZ_RAII AutoSetNewObjectMetadata : private JS::CustomAutoRooter
 {
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER;
 
     JSContext* cx_;
     NewObjectMetadataState prevState_;
 
     AutoSetNewObjectMetadata(const AutoSetNewObjectMetadata& aOther) = delete;
     void operator=(const AutoSetNewObjectMetadata& aOther) = delete;
@@ -759,17 +759,17 @@ ExclusiveContext::global() const
      * on-stack will be marked automatically, so there's no need for a read
      * barrier on it. Once the compartment is popped, the handle is no longer
      * safe to use.
      */
     MOZ_ASSERT(compartment_, "Caller needs to enter a compartment first");
     return Handle<GlobalObject*>::fromMarkedLocation(compartment_->global_.unsafeGet());
 }
 
-class AssertCompartmentUnchanged
+class MOZ_RAII AssertCompartmentUnchanged
 {
   public:
     explicit AssertCompartmentUnchanged(JSContext* cx
                                         MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : cx(cx), oldCompartment(cx->compartment())
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     }
@@ -857,30 +857,30 @@ struct WrapperValue
     Value get() const { return value; }
     operator const Value&() const { return value; }
     JSObject& toObject() const { return value.toObject(); }
 
   private:
     Value value;
 };
 
-class AutoWrapperVector : public JS::AutoVectorRooterBase<WrapperValue>
+class MOZ_RAII AutoWrapperVector : public JS::AutoVectorRooterBase<WrapperValue>
 {
   public:
     explicit AutoWrapperVector(JSContext* cx
                                MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
         : AutoVectorRooterBase<WrapperValue>(cx, WRAPVECTOR)
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     }
 
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
-class AutoWrapperRooter : private JS::AutoGCRooter {
+class MOZ_RAII AutoWrapperRooter : private JS::AutoGCRooter {
   public:
     AutoWrapperRooter(JSContext* cx, WrapperValue v
                       MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : JS::AutoGCRooter(cx, WRAPPER), value(v)
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     }
 
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -2689,17 +2689,17 @@ typedef void
 
 /*
  * Sets a callback that is run whenever js-ctypes is about to be used when
  * calling into C.
  */
 JS_FRIEND_API(void)
 SetCTypesActivityCallback(JSRuntime* rt, CTypesActivityCallback cb);
 
-class JS_FRIEND_API(AutoCTypesActivityCallback) {
+class MOZ_RAII JS_FRIEND_API(AutoCTypesActivityCallback) {
   private:
     JSContext* cx;
     CTypesActivityCallback callback;
     CTypesActivityType endType;
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 
   public:
     AutoCTypesActivityCallback(JSContext* cx, CTypesActivityType beginType,
--- a/js/src/jsgc.h
+++ b/js/src/jsgc.h
@@ -1369,17 +1369,17 @@ class ZoneList
 
 JSObject*
 NewMemoryStatisticsObject(JSContext* cx);
 
 } /* namespace gc */
 
 #ifdef DEBUG
 /* Use this to avoid assertions when manipulating the wrapper map. */
-class AutoDisableProxyCheck
+class MOZ_RAII AutoDisableProxyCheck
 {
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER;
     gc::GCRuntime& gc;
 
   public:
     explicit AutoDisableProxyCheck(JSRuntime* rt
                                    MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
     ~AutoDisableProxyCheck();
--- a/js/src/jsutil.h
+++ b/js/src/jsutil.h
@@ -163,17 +163,17 @@ template <class T, class U>
 MOZ_ALWAYS_INLINE T&
 ImplicitCast(U& u)
 {
     T& t = u;
     return t;
 }
 
 template<typename T>
-class AutoScopedAssign
+class MOZ_RAII AutoScopedAssign
 {
   public:
     AutoScopedAssign(T* addr, const T& value
                      MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
         : addr_(addr), old(*addr_)
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
         *addr_ = value;
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -3395,17 +3395,17 @@ runOffThreadScript(JSContext* cx, unsign
 
     RootedScript script(cx, JS::FinishOffThreadScript(cx, rt, token));
     if (!script)
         return false;
 
     return JS_ExecuteScript(cx, script, args.rval());
 }
 
-struct FreeOnReturn
+struct MOZ_RAII FreeOnReturn
 {
     JSContext* cx;
     const char* ptr;
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 
     explicit FreeOnReturn(JSContext* cx, const char* ptr = nullptr
                  MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : cx(cx), ptr(ptr)
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -1819,17 +1819,17 @@ Debugger::slowPathPromiseHook(JSContext*
     // Promise hooks are infallible and we ignore errors from uncaught
     // exceptions by design.
     MOZ_ASSERT(status == JSTRAP_CONTINUE);
 }
 
 
 /*** Debugger code invalidation for observing execution ******************************************/
 
-class MOZ_STACK_CLASS ExecutionObservableCompartments : public Debugger::ExecutionObservableSet
+class MOZ_RAII ExecutionObservableCompartments : public Debugger::ExecutionObservableSet
 {
     HashSet<JSCompartment*> compartments_;
     HashSet<Zone*> zones_;
 
   public:
     explicit ExecutionObservableCompartments(JSContext* cx
                                              MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : compartments_(cx),
@@ -1853,17 +1853,17 @@ class MOZ_STACK_CLASS ExecutionObservabl
 
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
 // Given a particular AbstractFramePtr F that has become observable, this
 // represents the stack frames that need to be bailed out or marked as
 // debuggees, and the scripts that need to be recompiled, taking inlining into
 // account.
-class MOZ_STACK_CLASS ExecutionObservableFrame : public Debugger::ExecutionObservableSet
+class MOZ_RAII ExecutionObservableFrame : public Debugger::ExecutionObservableSet
 {
     AbstractFramePtr frame_;
 
   public:
     explicit ExecutionObservableFrame(AbstractFramePtr frame
                                       MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : frame_(frame)
     {
@@ -1914,17 +1914,17 @@ class MOZ_STACK_CLASS ExecutionObservabl
         // frame debuggee marking; so this overload doesn't need a parallel to
         // the just-so inlining logic above.
         return iter.hasUsableAbstractFramePtr() && iter.abstractFramePtr() == frame_;
     }
 
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
-class MOZ_STACK_CLASS ExecutionObservableScript : public Debugger::ExecutionObservableSet
+class MOZ_RAII ExecutionObservableScript : public Debugger::ExecutionObservableSet
 {
     RootedScript script_;
 
   public:
     ExecutionObservableScript(JSContext* cx, JSScript* script
                               MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : script_(cx, script)
     {
--- a/js/src/vm/HelperThreads.h
+++ b/js/src/vm/HelperThreads.h
@@ -407,33 +407,33 @@ struct AutoEnqueuePendingParseTasksAfter
     explicit AutoEnqueuePendingParseTasksAfterGC(const gc::GCRuntime& gc) : gc_(gc) {}
     ~AutoEnqueuePendingParseTasksAfterGC();
 };
 
 /* Start a compression job for the specified token. */
 bool
 StartOffThreadCompression(ExclusiveContext* cx, SourceCompressionTask* task);
 
-class AutoLockHelperThreadState
+class MOZ_RAII AutoLockHelperThreadState
 {
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 
   public:
     explicit AutoLockHelperThreadState(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM)
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
         HelperThreadState().lock();
     }
 
     ~AutoLockHelperThreadState() {
         HelperThreadState().unlock();
     }
 };
 
-class AutoUnlockHelperThreadState
+class MOZ_RAII AutoUnlockHelperThreadState
 {
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 
   public:
 
     explicit AutoUnlockHelperThreadState(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM)
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -370,17 +370,17 @@ ExecuteState::pushInterpreterFrame(JSCon
 }
 namespace js {
 // Implementation of per-performance group performance measurement.
 //
 //
 // All mutable state is stored in `Runtime::stopwatch` (per-process
 // performance stats and logistics) and in `PerformanceGroup` (per
 // group performance stats).
-class AutoStopwatch final
+class MOZ_RAII AutoStopwatch final
 {
     // The context with which this object was initialized.
     // Non-null.
     JSContext* const cx_;
 
     // An indication of the number of times we have entered the event
     // loop.  Used only for comparison.
     uint64_t iteration_;
--- a/js/src/vm/RegExpStatics.h
+++ b/js/src/vm/RegExpStatics.h
@@ -181,17 +181,17 @@ class RegExpStatics
         return offsetof(RegExpStatics, lazyIndex);
     }
 
     static size_t offsetOfPendingLazyEvaluation() {
         return offsetof(RegExpStatics, pendingLazyEvaluation);
     }
 };
 
-class AutoRegExpStaticsBuffer : private JS::CustomAutoRooter
+class MOZ_RAII AutoRegExpStaticsBuffer : private JS::CustomAutoRooter
 {
   public:
     explicit AutoRegExpStaticsBuffer(JSContext* cx
                                      MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : CustomAutoRooter(cx), statics(RegExpStatics::InitBuffer())
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     }
--- a/js/src/vm/Runtime.h
+++ b/js/src/vm/Runtime.h
@@ -1859,17 +1859,17 @@ FreeOp::freeLater(void* p)
 }
 
 /*
  * RAII class that takes the GC lock while it is live.
  *
  * Note that the lock may be temporarily released by use of AutoUnlockGC when
  * passed a non-const reference to this class.
  */
-class MOZ_STACK_CLASS AutoLockGC
+class MOZ_RAII AutoLockGC
 {
   public:
     explicit AutoLockGC(JSRuntime* rt
                         MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : runtime_(rt), wasUnlocked_(false)
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
         lock();
@@ -1898,17 +1898,17 @@ class MOZ_STACK_CLASS AutoLockGC
     JSRuntime* runtime_;
     mozilla::DebugOnly<bool> wasUnlocked_;
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 
     AutoLockGC(const AutoLockGC&) = delete;
     AutoLockGC& operator=(const AutoLockGC&) = delete;
 };
 
-class MOZ_STACK_CLASS AutoUnlockGC
+class MOZ_RAII AutoUnlockGC
 {
   public:
     explicit AutoUnlockGC(AutoLockGC& lock
                           MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : lock(lock)
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
         lock.unlock();
@@ -1921,17 +1921,17 @@ class MOZ_STACK_CLASS AutoUnlockGC
   private:
     AutoLockGC& lock;
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 
     AutoUnlockGC(const AutoUnlockGC&) = delete;
     AutoUnlockGC& operator=(const AutoUnlockGC&) = delete;
 };
 
-class MOZ_STACK_CLASS AutoKeepAtoms
+class MOZ_RAII AutoKeepAtoms
 {
     PerThreadData* pt;
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 
   public:
     explicit AutoKeepAtoms(PerThreadData* pt
                            MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : pt(pt)
@@ -2090,17 +2090,17 @@ class RuntimeAllocPolicy
     void free_(void* p) { js_free(p); }
     void reportAllocOverflow() const {}
 };
 
 extern const JSSecurityCallbacks NullSecurityCallbacks;
 
 // Debugging RAII class which marks the current thread as performing an Ion
 // compilation, for use by CurrentThreadCan{Read,Write}CompilationData
-class AutoEnterIonCompilation
+class MOZ_RAII AutoEnterIonCompilation
 {
   public:
     explicit AutoEnterIonCompilation(bool safeForMinorGC
                                      MOZ_GUARD_OBJECT_NOTIFIER_PARAM) {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
 
 #ifdef DEBUG
         PerThreadData* pt = js::TlsPerThreadData.get();
--- a/js/src/vm/SPSProfiler.h
+++ b/js/src/vm/SPSProfiler.h
@@ -222,17 +222,17 @@ class AutoSPSLock
   private:
     PRLock* lock_;
 };
 
 /*
  * This class is used to suppress profiler sampling during
  * critical sections where stack state is not valid.
  */
-class AutoSuppressProfilerSampling
+class MOZ_RAII AutoSuppressProfilerSampling
 {
   public:
     explicit AutoSuppressProfilerSampling(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
     explicit AutoSuppressProfilerSampling(JSRuntime* rt MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
 
     ~AutoSuppressProfilerSampling();
 
   private:
@@ -255,17 +255,17 @@ SPSProfiler::stringsReset()
     strings.clear();
 }
 
 /*
  * This class is used in RunScript() to push the marker onto the sampling stack
  * that we're about to enter JS function calls. This is the only time in which a
  * valid stack pointer is pushed to the sampling stack.
  */
-class SPSEntryMarker
+class MOZ_RAII SPSEntryMarker
 {
   public:
     explicit SPSEntryMarker(JSRuntime* rt,
                             JSScript* script
                             MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
     ~SPSEntryMarker();
 
   private:
@@ -274,17 +274,17 @@ class SPSEntryMarker
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
 /*
  * This class is used in the interpreter to bound regions where the baseline JIT
  * being entered via OSR.  It marks the current top pseudostack entry as
  * OSR-ed
  */
-class SPSBaselineOSRMarker
+class MOZ_RAII SPSBaselineOSRMarker
 {
   public:
     explicit SPSBaselineOSRMarker(JSRuntime* rt, bool hasSPSFrame
                                   MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
     ~SPSBaselineOSRMarker();
 
   private:
     SPSProfiler* profiler;
--- a/js/src/vm/SavedStacks.h
+++ b/js/src/vm/SavedStacks.h
@@ -176,17 +176,17 @@ class SavedStacks {
     double          allocationSamplingProbability;
     uint32_t        allocationSkipCount;
     uint64_t        rngState;
     bool            creatingSavedFrame;
 
     // Similar to mozilla::ReentrancyGuard, but instead of asserting against
     // reentrancy, just change the behavior of SavedStacks::saveCurrentStack to
     // return a nullptr SavedFrame.
-    struct MOZ_STACK_CLASS AutoReentrancyGuard {
+    struct MOZ_RAII AutoReentrancyGuard {
         MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER;
         SavedStacks& stacks;
 
         explicit AutoReentrancyGuard(SavedStacks& stacks MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
             : stacks(stacks)
         {
             MOZ_GUARD_OBJECT_NOTIFIER_INIT;
             stacks.creatingSavedFrame = true;
--- a/js/src/vm/ScopeObject.h
+++ b/js/src/vm/ScopeObject.h
@@ -820,17 +820,17 @@ CloneNestedScopeObject(JSContext* cx, Ha
 /*****************************************************************************/
 
 // A scope iterator describes the active scopes starting from a dynamic scope,
 // static scope pair. This pair may be derived from the current point of
 // execution in a frame. If derived in such a fashion, the ScopeIter tracks
 // whether the current scope is within the extent of this initial frame.
 // Here, "frame" means a single activation of: a function, eval, or global
 // code.
-class ScopeIter
+class MOZ_RAII ScopeIter
 {
     StaticScopeIter<CanGC> ssi_;
     RootedObject scope_;
     AbstractFramePtr frame_;
 
     void incrementStaticScopeIter();
     void settle();
 
--- a/js/src/vm/Shape.h
+++ b/js/src/vm/Shape.h
@@ -977,17 +977,17 @@ class AccessorShape : public Shape
 
 inline
 StackBaseShape::StackBaseShape(Shape* shape)
   : flags(shape->getObjectFlags()),
     clasp(shape->getObjectClass()),
     compartment(shape->compartment())
 {}
 
-class AutoRooterGetterSetter
+class MOZ_RAII AutoRooterGetterSetter
 {
     class Inner : private JS::CustomAutoRooter
     {
       public:
         inline Inner(ExclusiveContext* cx, uint8_t attrs, GetterOp* pgetter_, SetterOp* psetter_);
 
       private:
         virtual void trace(JSTracer* trc);
--- a/js/src/vm/TraceLogging.h
+++ b/js/src/vm/TraceLogging.h
@@ -434,17 +434,17 @@ inline void TraceLogStartEventPrivate(Tr
 inline void TraceLogStopEventPrivate(TraceLoggerThread* logger, uint32_t id) {
 #ifdef JS_TRACE_LOGGING
     if (logger)
         logger->stopEvent(id);
 #endif
 }
 
 // Automatic logging at the start and end of function call.
-class AutoTraceLog
+class MOZ_RAII AutoTraceLog
 {
 #ifdef JS_TRACE_LOGGING
     TraceLoggerThread* logger;
     union {
         const TraceLoggerEvent* event;
         TraceLoggerTextId id;
     } payload;
     bool isEvent;
--- a/js/src/vm/TraceLoggingGraph.cpp
+++ b/js/src/vm/TraceLoggingGraph.cpp
@@ -19,17 +19,17 @@
 #  define TRACE_LOG_DIR "/tmp/"
 # endif
 #endif
 
 using mozilla::NativeEndian;
 
 TraceLoggerGraphState* traceLoggerGraphState = nullptr;
 
-class AutoTraceLoggerGraphStateLock
+class MOZ_RAII AutoTraceLoggerGraphStateLock
 {
   TraceLoggerGraphState* graph;
 
   public:
     explicit AutoTraceLoggerGraphStateLock(TraceLoggerGraphState* graph MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : graph(graph)
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -3035,17 +3035,17 @@ private:
     // Complete stackframe where the error happened.
     // Must be SavedFrame object.
     JS::Heap<JSObject*>  mStack;
 };
 
 /******************************************************************************
  * Handles pre/post script processing.
  */
-class MOZ_STACK_CLASS AutoScriptEvaluate
+class MOZ_RAII AutoScriptEvaluate
 {
 public:
     /**
      * Saves the JSContext as well as initializing our state
      * @param cx The JSContext, this can be null, we don't do anything then
      */
     explicit AutoScriptEvaluate(JSContext * cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
          : mJSContext(cx), mEvaluated(false) {
@@ -3072,17 +3072,17 @@ private:
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 
     // No copying or assignment allowed
     AutoScriptEvaluate(const AutoScriptEvaluate&) = delete;
     AutoScriptEvaluate & operator =(const AutoScriptEvaluate&) = delete;
 };
 
 /***************************************************************************/
-class MOZ_STACK_CLASS AutoResolveName
+class MOZ_RAII AutoResolveName
 {
 public:
     AutoResolveName(XPCCallContext& ccx, JS::HandleId name
                     MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
           mOld(ccx, XPCJSRuntime::Get()->SetResolveName(name))
 #ifdef DEBUG
           ,mCheck(ccx, name)
 #endif
--- a/layout/generic/Selection.h
+++ b/layout/generic/Selection.h
@@ -212,17 +212,17 @@ private:
 
 public:
   SelectionType GetType(){return mType;}
   void          SetType(SelectionType aType){mType = aType;}
 
   nsresult     NotifySelectionListeners();
 
   friend struct AutoApplyUserSelectStyle;
-  struct MOZ_STACK_CLASS AutoApplyUserSelectStyle
+  struct MOZ_RAII AutoApplyUserSelectStyle
   {
     explicit AutoApplyUserSelectStyle(Selection* aSelection
                              MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : mSavedValue(aSelection->mApplyUserSelectStyle)
     {
       MOZ_GUARD_OBJECT_NOTIFIER_INIT;
       aSelection->mApplyUserSelectStyle = true;
     }
--- a/layout/generic/nsFlexContainerFrame.cpp
+++ b/layout/generic/nsFlexContainerFrame.cpp
@@ -3618,17 +3618,17 @@ nsFlexContainerFrame::Reflow(nsPresConte
                  contentBoxMainSize, availableBSizeForContent,
                  struts, axisTracker);
   }
 }
 
 // RAII class to clean up a list of FlexLines.
 // Specifically, this removes each line from the list, deletes all the
 // FlexItems in its list, and deletes the FlexLine.
-class MOZ_STACK_CLASS AutoFlexLineListClearer
+class MOZ_RAII AutoFlexLineListClearer
 {
 public:
   explicit AutoFlexLineListClearer(LinkedList<FlexLine>& aLines
                                    MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
   : mLines(aLines)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
   }
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -327,17 +327,17 @@ IsValidSelectionPoint(nsFrameSelection *
     return false; //not in the right content. tLimiter said so
   }
 
   limiter = aFrameSel->GetAncestorLimiter();
   return !limiter || nsContentUtils::ContentIsDescendantOf(aNode, limiter);
 }
 
 namespace mozilla {
-struct MOZ_STACK_CLASS AutoPrepareFocusRange
+struct MOZ_RAII AutoPrepareFocusRange
 {
   AutoPrepareFocusRange(Selection* aSelection,
                         bool aContinueSelection,
                         bool aMultipleSelection
                         MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
 
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -423,17 +423,17 @@ protected:
   void ReleaseScanner(void);
 
   /**
    * This is a RAII class which behaves like an "AutoRestore<>" for our parser
    * input state. When instantiated, this class saves the current parser input
    * state (in a CSSParserInputState object), and it restores the parser to
    * that state when destructed, unless "DoNotRestore()" has been called.
   */
-  class MOZ_STACK_CLASS nsAutoCSSParserInputStateRestorer {
+  class MOZ_RAII nsAutoCSSParserInputStateRestorer {
     public:
       explicit nsAutoCSSParserInputStateRestorer(CSSParserImpl* aParser
                                                  MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
         : mParser(aParser),
           mShouldRestore(true)
       {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
         mParser->SaveInputState(mSavedState);
@@ -471,17 +471,17 @@ protected:
    * so it doesn't really matter which reporter we use. We suppress reporting
    * because this class is only used with CSS that is synthesized & didn't
    * come directly from an author, and it would be confusing if we reported
    * syntax errors for CSS that an author didn't provide.
    *
    * XXXdholbert we could also change this & report errors, if needed. Might
    * want to customize the error reporting somehow though.
    */
-  class MOZ_STACK_CLASS nsAutoScannerChanger {
+  class MOZ_RAII nsAutoScannerChanger {
     public:
       nsAutoScannerChanger(CSSParserImpl* aParser,
                            const nsAString& aStringToScan
                            MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
         : mParser(aParser),
           mOriginalScanner(aParser->mScanner),
           mStringScanner(aStringToScan, 0),
           mParserStateRestorer(aParser),
--- a/layout/style/nsRuleProcessorData.h
+++ b/layout/style/nsRuleProcessorData.h
@@ -220,17 +220,17 @@ struct MOZ_STACK_CLASS TreeMatchContext 
   bool IsWithinStyleScopeForSelectorMatching() const
   {
     NS_ASSERTION(mForScopedStyle, "only call IsWithinScopeForSelectorMatching "
                                   "when mForScopedStyle is true");
     return mCurrentStyleScope;
   }
 
   /* Helper class for maintaining the ancestor state */
-  class MOZ_STACK_CLASS AutoAncestorPusher {
+  class MOZ_RAII AutoAncestorPusher {
   public:
     explicit AutoAncestorPusher(TreeMatchContext& aTreeMatchContext
                                 MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : mPushedAncestor(false)
       , mPushedStyleScope(false)
       , mTreeMatchContext(aTreeMatchContext)
       , mElement(nullptr)
     {
@@ -290,17 +290,17 @@ struct MOZ_STACK_CLASS TreeMatchContext 
    * code for special cases where child element style is modified based on
    * parent display value.
    *
    * The optional second parameter aSkipParentDisplayBasedStyleFixup allows
    * this class to be instantiated but only conditionally activated (e.g.
    * in cases where we may or may not want to be skipping flex/grid-item
    * style fixup for a particular chunk of code).
    */
-  class MOZ_STACK_CLASS AutoParentDisplayBasedStyleFixupSkipper {
+  class MOZ_RAII AutoParentDisplayBasedStyleFixupSkipper {
   public:
     explicit AutoParentDisplayBasedStyleFixupSkipper(TreeMatchContext& aTreeMatchContext,
                                                      bool aSkipParentDisplayBasedStyleFixup = true
                                                      MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : mAutoRestorer(aTreeMatchContext.mSkippingParentDisplayBasedStyleFixup)
     {
       MOZ_GUARD_OBJECT_NOTIFIER_INIT;
       if (aSkipParentDisplayBasedStyleFixup) {
--- a/layout/svg/nsSVGClipPathFrame.h
+++ b/layout/svg/nsSVGClipPathFrame.h
@@ -99,17 +99,17 @@ public:
    */
   gfxMatrix GetClipPathTransform(nsIFrame* aClippedFrame);
 
  private:
   // A helper class to allow us to paint clip paths safely. The helper
   // automatically sets and clears the mInUse flag on the clip path frame
   // (to prevent nasty reference loops). It's easy to mess this up
   // and break things, so this helper makes the code far more robust.
-  class MOZ_STACK_CLASS AutoClipPathReferencer
+  class MOZ_RAII AutoClipPathReferencer
   {
   public:
     explicit AutoClipPathReferencer(nsSVGClipPathFrame *aFrame
                                     MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
        : mFrame(aFrame) {
       MOZ_GUARD_OBJECT_NOTIFIER_INIT;
       NS_ASSERTION(!mFrame->mInUse, "reference loop!");
       mFrame->mInUse = true;
--- a/layout/svg/nsSVGFilterFrame.cpp
+++ b/layout/svg/nsSVGFilterFrame.cpp
@@ -22,17 +22,17 @@ using namespace mozilla::dom;
 nsIFrame*
 NS_NewSVGFilterFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
 {
   return new (aPresShell) nsSVGFilterFrame(aContext);
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGFilterFrame)
 
-class MOZ_STACK_CLASS nsSVGFilterFrame::AutoFilterReferencer
+class MOZ_RAII nsSVGFilterFrame::AutoFilterReferencer
 {
 public:
   explicit AutoFilterReferencer(nsSVGFilterFrame *aFrame MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : mFrame(aFrame)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     // Reference loops should normally be detected in advance and handled, so
     // we're not expecting to encounter them here
--- a/layout/svg/nsSVGGradientFrame.cpp
+++ b/layout/svg/nsSVGGradientFrame.cpp
@@ -19,17 +19,17 @@
 // XXX Tight coupling with content classes ahead!
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 //----------------------------------------------------------------------
 // Helper classes
 
-class MOZ_STACK_CLASS nsSVGGradientFrame::AutoGradientReferencer
+class MOZ_RAII nsSVGGradientFrame::AutoGradientReferencer
 {
 public:
   explicit AutoGradientReferencer(nsSVGGradientFrame *aFrame
                                   MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : mFrame(aFrame)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     // Reference loops should normally be detected in advance and handled, so
--- a/layout/svg/nsSVGMarkerFrame.h
+++ b/layout/svg/nsSVGMarkerFrame.h
@@ -105,17 +105,17 @@ private:
   // nsSVGContainerFrame methods:
   virtual gfxMatrix GetCanvasTM() override;
 
   // A helper class to allow us to paint markers safely. The helper
   // automatically sets and clears the mInUse flag on the marker frame (to
   // prevent nasty reference loops) as well as the reference to the marked
   // frame and its coordinate context. It's easy to mess this up
   // and break things, so this helper makes the code far more robust.
-  class MOZ_STACK_CLASS AutoMarkerReferencer
+  class MOZ_RAII AutoMarkerReferencer
   {
   public:
     AutoMarkerReferencer(nsSVGMarkerFrame *aFrame,
                          nsSVGPathGeometryFrame *aMarkedFrame
                          MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
     ~AutoMarkerReferencer();
   private:
     nsSVGMarkerFrame *mFrame;
--- a/layout/svg/nsSVGMaskFrame.h
+++ b/layout/svg/nsSVGMaskFrame.h
@@ -95,17 +95,17 @@ private:
    * returns the resulting transform.
    */
   gfxMatrix GetMaskTransform(nsIFrame* aMaskedFrame);
 
   // A helper class to allow us to paint masks safely. The helper
   // automatically sets and clears the mInUse flag on the mask frame
   // (to prevent nasty reference loops). It's easy to mess this up
   // and break things, so this helper makes the code far more robust.
-  class MOZ_STACK_CLASS AutoMaskReferencer
+  class MOZ_RAII AutoMaskReferencer
   {
   public:
     explicit AutoMaskReferencer(nsSVGMaskFrame *aFrame
                                 MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
        : mFrame(aFrame) {
       MOZ_GUARD_OBJECT_NOTIFIER_INIT;
       NS_ASSERTION(!mFrame->mInUse, "reference loop!");
       mFrame->mInUse = true;
--- a/layout/svg/nsSVGPatternFrame.cpp
+++ b/layout/svg/nsSVGPatternFrame.cpp
@@ -27,17 +27,17 @@
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::gfx;
 
 //----------------------------------------------------------------------
 // Helper classes
 
-class MOZ_STACK_CLASS nsSVGPatternFrame::AutoPatternReferencer
+class MOZ_RAII nsSVGPatternFrame::AutoPatternReferencer
 {
 public:
   explicit AutoPatternReferencer(nsSVGPatternFrame *aFrame
                                  MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : mFrame(aFrame)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     // Reference loops should normally be detected in advance and handled, so
--- a/layout/svg/nsSVGUtils.h
+++ b/layout/svg/nsSVGUtils.h
@@ -132,17 +132,17 @@ public:
 private:
   Rect mBBox;
   bool mIsEmpty;
 };
 
 // GRRR WINDOWS HATE HATE HATE
 #undef CLIP_MASK
 
-class MOZ_STACK_CLASS SVGAutoRenderState
+class MOZ_RAII SVGAutoRenderState
 {
   typedef mozilla::gfx::DrawTarget DrawTarget;
 
 public:
   explicit SVGAutoRenderState(DrawTarget* aDrawTarget
                               MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
   ~SVGAutoRenderState();
 
--- a/mfbt/ReentrancyGuard.h
+++ b/mfbt/ReentrancyGuard.h
@@ -11,17 +11,17 @@
 
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/GuardObjects.h"
 
 namespace mozilla {
 
 /* Useful for implementing containers that assert non-reentrancy */
-class ReentrancyGuard
+class MOZ_RAII ReentrancyGuard
 {
   MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 #ifdef DEBUG
   bool& mEntered;
 #endif
 
 public:
   template<class T>
--- a/mfbt/ScopeExit.h
+++ b/mfbt/ScopeExit.h
@@ -81,17 +81,17 @@
  */
 
 #include "mozilla/GuardObjects.h"
 #include "mozilla/Move.h"
 
 namespace mozilla {
 
 template <typename ExitFunction>
-class ScopeExit {
+class MOZ_STACK_CLASS ScopeExit {
   ExitFunction mExitFunction;
   bool mExecuteOnDestruction;
   MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 
 public:
   explicit ScopeExit(ExitFunction&& cleanup
                      MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
    : mExitFunction(cleanup)
--- a/mfbt/Scoped.h
+++ b/mfbt/Scoped.h
@@ -72,17 +72,17 @@ namespace mozilla {
  *     // Returns the value corresponding to the uninitialized or freed state
  *     const static type empty();
  *     // Release resources corresponding to the wrapped value
  *     // This function is responsible for not releasing an |empty| value
  *     const static void release(type);
  *   }
  */
 template<typename Traits>
-class Scoped
+class MOZ_NON_TEMPORARY_CLASS Scoped
 {
 public:
   typedef typename Traits::type Resource;
 
   explicit Scoped(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM)
     : mValue(Traits::empty())
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
@@ -182,17 +182,17 @@ private:
  * This allows to implement templates such as ScopedFreePtr.
  *
  * @param name The name of the class to define.
  * @param Traits A struct implementing clean-up. See the implementations
  * for more details.
  */
 #define SCOPED_TEMPLATE(name, Traits)                                         \
 template<typename Type>                                                       \
-struct name : public mozilla::Scoped<Traits<Type> >                           \
+struct MOZ_NON_TEMPORARY_CLASS name : public mozilla::Scoped<Traits<Type> >   \
 {                                                                             \
   typedef mozilla::Scoped<Traits<Type> > Super;                               \
   typedef typename Super::Resource Resource;                                  \
   name& operator=(Resource aRhs)                                              \
   {                                                                           \
     Super::operator=(aRhs);                                                   \
     return *this;                                                             \
   }                                                                           \
--- a/mozglue/build/WindowsDllBlocklist.h
+++ b/mozglue/build/WindowsDllBlocklist.h
@@ -13,17 +13,17 @@
 #include "nscore.h"
 
 #define HAS_DLL_BLOCKLIST
 
 NS_IMPORT void DllBlocklist_Initialize();
 NS_IMPORT void DllBlocklist_SetInXPCOMLoadOnMainThread(bool inXPCOMLoadOnMainThread);
 NS_IMPORT void DllBlocklist_WriteNotes(HANDLE file);
 
-class AutoSetXPCOMLoadOnMainThread
+class MOZ_RAII AutoSetXPCOMLoadOnMainThread
 {
   public:
     AutoSetXPCOMLoadOnMainThread(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM) {
       MOZ_GUARD_OBJECT_NOTIFIER_INIT;
       DllBlocklist_SetInXPCOMLoadOnMainThread(true);
     }
 
     ~AutoSetXPCOMLoadOnMainThread() {
--- a/toolkit/components/osfile/NativeOSFileInternals.cpp
+++ b/toolkit/components/osfile/NativeOSFileInternals.cpp
@@ -86,17 +86,17 @@ struct ScopedArrayBufferContentsTraits {
   }
   const static void release(type ptr) {
     js_free(ptr.data);
     ptr.data = nullptr;
     ptr.nbytes = 0;
   }
 };
 
-struct ScopedArrayBufferContents: public Scoped<ScopedArrayBufferContentsTraits> {
+struct MOZ_NON_TEMPORARY_CLASS ScopedArrayBufferContents: public Scoped<ScopedArrayBufferContentsTraits> {
   explicit ScopedArrayBufferContents(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM):
     Scoped<ScopedArrayBufferContentsTraits>(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_TO_PARENT)
   { }
   explicit ScopedArrayBufferContents(const ArrayBufferContents& v
                             MOZ_GUARD_OBJECT_NOTIFIER_PARAM):
     Scoped<ScopedArrayBufferContentsTraits>(v MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)
   { }
   ScopedArrayBufferContents& operator=(ArrayBufferContents ptr) {
--- a/toolkit/components/telemetry/Telemetry.h
+++ b/toolkit/components/telemetry/Telemetry.h
@@ -113,17 +113,17 @@ struct AccumulateDelta_impl<Microsecond>
   }
   static void compute(ID id, const nsCString& key, TimeStamp start, TimeStamp end = TimeStamp::Now()) {
     Accumulate(id, key, static_cast<uint32_t>((end - start).ToMicroseconds()));
   }
 };
 
 
 template<ID id, TimerResolution res = Millisecond>
-class AutoTimer {
+class MOZ_RAII AutoTimer {
 public:
   explicit AutoTimer(TimeStamp aStart = TimeStamp::Now() MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
      : start(aStart)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
   }
 
   explicit AutoTimer(const nsCString& aKey, TimeStamp aStart = TimeStamp::Now() MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
@@ -143,17 +143,17 @@ public:
 
 private:
   const TimeStamp start;
   const nsCString key;
   MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
 template<ID id>
-class AutoCounter {
+class MOZ_RAII AutoCounter {
 public:
   explicit AutoCounter(uint32_t counterStart = 0 MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : counter(counterStart)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
   }
 
   ~AutoCounter() {
--- a/toolkit/devtools/heapsnapshot/AutoMemMap.h
+++ b/toolkit/devtools/heapsnapshot/AutoMemMap.h
@@ -23,17 +23,17 @@ namespace devtools {
 //       if (NS_FAILED(mm.init("/path/to/desired/file"))) {
 //          // Handle the error however you see fit.
 //         return false;
 //       }
 //
 //       doStuffWithMappedMemory(mm.address());
 //     }
 //     // The memory is automatically unmapped when the AutoMemMap leaves scope.
-class MOZ_STACK_CLASS AutoMemMap
+class MOZ_RAII AutoMemMap
 {
   MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER;
 
   PRFileInfo64 fileInfo;
   PRFileDesc*  fd;
   PRFileMap*   fileMap;
   void*        addr;
 
--- a/tools/profiler/public/GeckoProfilerImpl.h
+++ b/tools/profiler/public/GeckoProfilerImpl.h
@@ -372,17 +372,17 @@ static inline void profiler_tracing(cons
 #else
 #define PROFILE_DEFAULT_INTERVAL 1
 #endif
 #define PROFILE_DEFAULT_FEATURES NULL
 #define PROFILE_DEFAULT_FEATURE_COUNT 0
 
 namespace mozilla {
 
-class MOZ_STACK_CLASS GeckoProfilerTracingRAII {
+class MOZ_RAII GeckoProfilerTracingRAII {
 public:
   GeckoProfilerTracingRAII(const char* aCategory, const char* aInfo,
                            mozilla::UniquePtr<ProfilerBacktrace> aBacktrace
                            MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : mCategory(aCategory)
     , mInfo(aInfo)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
--- a/xpcom/glue/AutoRestore.h
+++ b/xpcom/glue/AutoRestore.h
@@ -22,17 +22,17 @@ namespace mozilla {
  *     mIsPainting = true;
  *
  *     // ... your code here ...
  *
  *     // mIsPainting is reset to its old value at the end of this block
  *   }
  */
 template<class T>
-class MOZ_STACK_CLASS AutoRestore
+class MOZ_RAII AutoRestore
 {
 private:
   T& mLocation;
   T mValue;
   MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 public:
   explicit AutoRestore(T& aValue MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : mLocation(aValue)
--- a/xpcom/glue/Mutex.h
+++ b/xpcom/glue/Mutex.h
@@ -140,17 +140,17 @@ private:
 /**
  * MutexAutoLock
  * Acquires the Mutex when it enters scope, and releases it when it leaves
  * scope.
  *
  * MUCH PREFERRED to bare calls to Mutex.Lock and Unlock.
  */
 template<typename T>
-class MOZ_STACK_CLASS BaseAutoLock
+class MOZ_RAII BaseAutoLock
 {
 public:
   /**
    * Constructor
    * The constructor aquires the given lock.  The destructor
    * releases the lock.
    *
    * @param aLock A valid mozilla::Mutex* returned by
@@ -185,17 +185,17 @@ typedef BaseAutoLock<OffTheBooksMutex> O
 /**
  * MutexAutoUnlock
  * Releases the Mutex when it enters scope, and re-acquires it when it leaves
  * scope.
  *
  * MUCH PREFERRED to bare calls to Mutex.Unlock and Lock.
  */
 template<typename T>
-class MOZ_STACK_CLASS BaseAutoUnlock
+class MOZ_RAII BaseAutoUnlock
 {
 public:
   explicit BaseAutoUnlock(T& aLock MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : mLock(&aLock)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     NS_ASSERTION(mLock, "null lock");
     mLock->Unlock();