Bug 1466118 part 5 - Replace assertSameCompartmentImpl with JSContext::checkImpl. r=luke
authorJan de Mooij <jdemooij@mozilla.com>
Tue, 21 Aug 2018 12:34:18 +0200
changeset 481321 af49f7a464d573a7008a301b315bd4303996e320
parent 481320 239b363ac50deb1431607b87ede33c918a45a969
child 481322 ff5cb8442b5d452de5677dbacf9bec9df0bf5a83
push id232
push userfmarier@mozilla.com
push dateWed, 05 Sep 2018 20:45:54 +0000
reviewersluke
bugs1466118
milestone63.0a1
Bug 1466118 part 5 - Replace assertSameCompartmentImpl with JSContext::checkImpl. r=luke
js/src/vm/JSContext-inl.h
js/src/vm/JSContext.h
--- a/js/src/vm/JSContext-inl.h
+++ b/js/src/vm/JSContext-inl.h
@@ -168,55 +168,55 @@ class CompartmentChecker
         check(desc.value(), argIndex);
     }
 
     void check(TypeSet::Type type, int argIndex) {
         check(type.maybeCompartment(), argIndex);
     }
 };
 
+} // namespace js
+
 template <class T1> inline void
-assertSameCompartmentImpl(JSContext* cx, int argIndex, const T1& t1)
+JSContext::checkImpl(int argIndex, const T1& t1)
 {
     // Don't perform these checks when called from a finalizer. The checking
     // depends on other objects not having been swept yet.
     if (JS::RuntimeHeapIsCollecting())
         return;
-    CompartmentChecker c(cx);
+    js::CompartmentChecker c(this);
     c.check(t1, argIndex);
 }
 
 template <class Head, class... Tail> inline void
-assertSameCompartmentImpl(JSContext* cx, int argIndex, const Head& head, const Tail&... tail)
+JSContext::checkImpl(int argIndex, const Head& head, const Tail&... tail)
 {
-    assertSameCompartmentImpl(cx, argIndex, head);
-    assertSameCompartmentImpl(cx, argIndex + 1, tail...);
+    checkImpl(argIndex, head);
+    checkImpl(argIndex + 1, tail...);
 }
 
-} // namespace js
-
 template <class... Args> inline void
 JSContext::check(const Args&... args)
 {
 #ifdef JS_CRASH_DIAGNOSTICS
-    assertSameCompartmentImpl(this, 0, args...);
+    checkImpl(0, args...);
 #endif
 }
 
 template <class... Args> inline void
 JSContext::releaseCheck(const Args&... args)
 {
-    assertSameCompartmentImpl(this, 0, args...);
+    checkImpl(0, args...);
 }
 
 template <class... Args> MOZ_ALWAYS_INLINE void
 JSContext::debugOnlyCheck(const Args&... args)
 {
 #if defined(DEBUG) && defined(JS_CRASH_DIAGNOSTICS)
-    assertSameCompartmentImpl(this, 0, args...);
+    checkImpl(0, args...);
 #endif
 }
 
 namespace js {
 
 STATIC_PRECONDITION_ASSUME(ubound(args.argv_) >= argc)
 MOZ_ALWAYS_INLINE bool
 CallNativeImpl(JSContext* cx, NativeImpl impl, const CallArgs& args)
--- a/js/src/vm/JSContext.h
+++ b/js/src/vm/JSContext.h
@@ -950,16 +950,24 @@ struct JSContext : public JS::RootingCon
     js::ThreadData<void*> promiseRejectionTrackerCallbackData;
 
     JSObject* getIncumbentGlobal(JSContext* cx);
     bool enqueuePromiseJob(JSContext* cx, js::HandleFunction job, js::HandleObject promise,
                            js::HandleObject incumbentGlobal);
     void addUnhandledRejectedPromise(JSContext* cx, js::HandleObject promise);
     void removeUnhandledRejectedPromise(JSContext* cx, js::HandleObject promise);
 
+  private:
+    template <class T1>
+    inline void checkImpl(int argIndex, const T1& t1);
+
+    template <class Head, class... Tail>
+    inline void checkImpl(int argIndex, const Head& head, const Tail&... tail);
+
+  public:
     template <class... Args> inline void check(const Args&... args);
     template <class... Args> inline void releaseCheck(const Args&... args);
     template <class... Args> MOZ_ALWAYS_INLINE void debugOnlyCheck(const Args&... args);
 }; /* struct JSContext */
 
 inline JS::Result<>
 JSContext::boolToResult(bool ok)
 {