Bug 1466118 part 2 - Replace releaseAssertSameCompartment with JSContext::releaseCheck. r=luke
--- a/js/src/vm/HelperThreads.cpp
+++ b/js/src/vm/HelperThreads.cpp
@@ -1660,17 +1660,17 @@ GlobalHelperThreadState::finishParseTask
return false;
}
mergeParseTaskRealm(cx, parseTask.get().get(), cx->realm());
bool ok = finishCallback(parseTask.get().get());
for (auto& script : parseTask->scripts)
- releaseAssertSameCompartment(cx, script);
+ cx->releaseCheck(script);
if (!parseTask->finish(cx) || !ok)
return false;
// Report out of memory errors eagerly, or errors could be malformed.
if (parseTask->outOfMemory) {
ReportOutOfMemory(cx);
return false;
--- a/js/src/vm/JSContext-inl.h
+++ b/js/src/vm/JSContext-inl.h
@@ -194,22 +194,26 @@ assertSameCompartmentImpl(JSContext* cx,
template <class... Args> inline void
assertSameCompartment(JSContext* cx, const Args&... args)
{
#ifdef JS_CRASH_DIAGNOSTICS
assertSameCompartmentImpl(cx, 1, args...);
#endif
}
+} // namespace js
+
template <class... Args> inline void
-releaseAssertSameCompartment(JSContext* cx, const Args&... args)
+JSContext::releaseCheck(const Args&... args)
{
- assertSameCompartmentImpl(cx, 1, args...);
+ assertSameCompartmentImpl(this, 0, args...);
}
+namespace js {
+
template <class... Args> inline void
assertSameCompartmentDebugOnly(JSContext* cx, const Args&... args)
{
#if defined(DEBUG) && defined(JS_CRASH_DIAGNOSTICS)
assertSameCompartmentImpl(cx, 1, args...);
#endif
}
--- a/js/src/vm/JSContext.h
+++ b/js/src/vm/JSContext.h
@@ -949,16 +949,18 @@ struct JSContext : public JS::RootingCon
js::ThreadData<JSPromiseRejectionTrackerCallback> promiseRejectionTrackerCallback;
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);
+
+ template <class... Args> inline void releaseCheck(const Args&... args);
}; /* struct JSContext */
inline JS::Result<>
JSContext::boolToResult(bool ok)
{
if (MOZ_LIKELY(ok)) {
MOZ_ASSERT(!isExceptionPending());
MOZ_ASSERT(!isPropagatingForcedReturn());
--- a/js/src/vm/JSScript.cpp
+++ b/js/src/vm/JSScript.cpp
@@ -1381,17 +1381,17 @@ ScriptSourceObject::create(JSContext* cx
return sourceObject;
}
/* static */ bool
ScriptSourceObject::initFromOptions(JSContext* cx, HandleScriptSourceObject source,
const ReadOnlyCompileOptions& options)
{
- releaseAssertSameCompartment(cx, source);
+ cx->releaseCheck(source);
MOZ_ASSERT(source->getReservedSlot(ELEMENT_SLOT).isMagic(JS_GENERIC_MAGIC));
MOZ_ASSERT(source->getReservedSlot(ELEMENT_PROPERTY_SLOT).isMagic(JS_GENERIC_MAGIC));
MOZ_ASSERT(source->getReservedSlot(INTRODUCTION_SCRIPT_SLOT).isMagic(JS_GENERIC_MAGIC));
RootedObject element(cx, options.element());
RootedString elementAttributeName(cx, options.elementAttributeName());
if (!initElementProperties(cx, source, element, elementAttributeName))
return false;