Bug 1466118 part 2 - Replace releaseAssertSameCompartment with JSContext::releaseCheck. r=luke
authorJan de Mooij <jdemooij@mozilla.com>
Tue, 21 Aug 2018 12:07:57 +0200
changeset 433040 5cb4cd7c449ecef9226496dc736d7c7325d37473
parent 433039 3bf5eb6fe16d1fa91924edc63da909f1b96d1307
child 433041 224b09c2e661110abc9d29c7cca417cb5de5d3b4
push id34499
push usercsabou@mozilla.com
push dateThu, 23 Aug 2018 21:40:51 +0000
treeherdermozilla-central@49b70f7e6817 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1466118
milestone63.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 1466118 part 2 - Replace releaseAssertSameCompartment with JSContext::releaseCheck. r=luke
js/src/vm/HelperThreads.cpp
js/src/vm/JSContext-inl.h
js/src/vm/JSContext.h
js/src/vm/JSScript.cpp
--- 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;