Bug 1466118 part 5 - Replace assertSameCompartmentImpl with JSContext::checkImpl. r=luke
--- 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)
{