Bug 1548798 - Switch SequenceRooter, RecordRooter and RootedUnion to use RootedContext. r=smaug
authorZibi Braniecki <zbraniecki@mozilla.com>
Fri, 03 May 2019 16:07:21 +0000
changeset 531333 67590bfca46ffa5d84426b453cd4e88ac36d6b0b
parent 531332 42a61320b49b43123e2c71770d9b32cdb15fc6a0
child 531334 c7b00a72c46d60c4d04674dd95fa9645bb69c542
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1548798
milestone68.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 1548798 - Switch SequenceRooter, RecordRooter and RootedUnion to use RootedContext. r=smaug Differential Revision: https://phabricator.services.mozilla.com/D29810
dom/bindings/BindingUtils.h
--- a/dom/bindings/BindingUtils.h
+++ b/dom/bindings/BindingUtils.h
@@ -2074,31 +2074,34 @@ void DoTraceSequence(JSTracer* trc, Infa
   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_RAII SequenceRooter final : private JS::CustomAutoRooter {
  public:
-  SequenceRooter(JSContext* aCx,
+  template <typename CX>
+  SequenceRooter(const CX& cx,
                  FallibleTArray<T>* aSequence MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
-      : JS::CustomAutoRooter(aCx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT),
+      : JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT),
         mFallibleArray(aSequence),
         mSequenceType(eFallibleArray) {}
 
-  SequenceRooter(JSContext* aCx,
+  template <typename CX>
+  SequenceRooter(const CX& cx,
                  InfallibleTArray<T>* aSequence MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
-      : JS::CustomAutoRooter(aCx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT),
+      : JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT),
         mInfallibleArray(aSequence),
         mSequenceType(eInfallibleArray) {}
 
-  SequenceRooter(JSContext* aCx, Nullable<nsTArray<T>>* aSequence
-                                     MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
-      : JS::CustomAutoRooter(aCx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT),
+  template <typename CX>
+  SequenceRooter(const CX& cx, Nullable<nsTArray<T>>* aSequence
+                                   MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
+      : JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT),
         mNullableArray(aSequence),
         mSequenceType(eNullableArray) {}
 
  private:
   enum SequenceType { eInfallibleArray, eFallibleArray, eNullableArray };
 
   virtual void trace(JSTracer* trc) override {
     if (mSequenceType == eFallibleArray) {
@@ -2121,25 +2124,27 @@ class MOZ_RAII SequenceRooter final : pr
 
   SequenceType mSequenceType;
 };
 
 // Rooter class for Record; this is what we mostly use in the codegen.
 template <typename K, typename V>
 class MOZ_RAII RecordRooter final : private JS::CustomAutoRooter {
  public:
-  RecordRooter(JSContext* aCx,
+  template <typename CX>
+  RecordRooter(const CX& cx,
                Record<K, V>* aRecord MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
-      : JS::CustomAutoRooter(aCx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT),
+      : JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT),
         mRecord(aRecord),
         mRecordType(eRecord) {}
 
-  RecordRooter(JSContext* aCx,
+  template <typename CX>
+  RecordRooter(const CX& cx,
                Nullable<Record<K, V>>* aRecord MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
-      : JS::CustomAutoRooter(aCx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT),
+      : JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT),
         mNullableRecord(aRecord),
         mRecordType(eNullableRecord) {}
 
  private:
   enum RecordType { eRecord, eNullableRecord };
 
   virtual void trace(JSTracer* trc) override {
     if (mRecordType == eRecord) {
@@ -2158,28 +2163,30 @@ class MOZ_RAII RecordRooter final : priv
   };
 
   RecordType mRecordType;
 };
 
 template <typename T>
 class MOZ_RAII RootedUnion : public T, private JS::CustomAutoRooter {
  public:
-  explicit RootedUnion(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
+  template <typename CX>
+  explicit RootedUnion(const CX& cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : T(),
         JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT) {}
 
   virtual void trace(JSTracer* trc) override { this->TraceUnion(trc); }
 };
 
 template <typename T>
 class MOZ_STACK_CLASS NullableRootedUnion : public Nullable<T>,
                                             private JS::CustomAutoRooter {
  public:
-  explicit NullableRootedUnion(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
+  template <typename CX>
+  explicit NullableRootedUnion(const CX& cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : Nullable<T>(),
         JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT) {}
 
   virtual void trace(JSTracer* trc) override {
     if (!this->IsNull()) {
       this->Value().TraceUnion(trc);
     }
   }