Bug 1361900: Fix one last merge botch, and fix a false rooting hazard warning.
☠☠ backed out by ffb1a39c9977 ☠ ☠
authorKris Maglione <maglione.k@gmail.com>
Fri, 12 May 2017 18:14:12 -0700
changeset 358154 23dc7b443bb0528ec880acb7fc0a32aec05f0255
parent 358153 17ff3fbf222c9f650fe0858d356914e56182828e
child 358155 d7711b69b0136381c4da5cd292619d514ffee1ee
push id90281
push usermaglione.k@gmail.com
push dateSat, 13 May 2017 01:15:31 +0000
treeherdermozilla-inbound@23dc7b443bb0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1361900
milestone55.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 1361900: Fix one last merge botch, and fix a false rooting hazard warning. MozReview-Commit-ID: JpKYYEBpbQj
js/xpconnect/loader/ScriptPreloader-inl.h
js/xpconnect/loader/ScriptPreloader.cpp
js/xpconnect/loader/ScriptPreloader.h
--- a/js/xpconnect/loader/ScriptPreloader-inl.h
+++ b/js/xpconnect/loader/ScriptPreloader-inl.h
@@ -253,17 +253,18 @@ public:
             : iter_(iter), done_(done)
         {}
 
         Iterator& iter() { return iter_.iter_.ref(); }
 
     public:
         Elem& operator*() { return *this; }
 
-        ElemType get() {
+        ElemType get()
+        {
           if (done_) {
             return nullptr;
           }
           return iter().Data();
         }
 
         ElemType operator->() { return get(); }
 
--- a/js/xpconnect/loader/ScriptPreloader.cpp
+++ b/js/xpconnect/loader/ScriptPreloader.cpp
@@ -428,16 +428,18 @@ ScriptPreloader::InitCacheInternal()
 
     headerSize = LittleEndian::readUint32(data.get());
     data += sizeof(headerSize);
 
     if (data + headerSize > end) {
         return Err(NS_ERROR_UNEXPECTED);
     }
 
+    AutoTArray<CachedScript*, 256> scripts;
+
     {
         auto cleanup = MakeScopeExit([&] () {
             mScripts.Clear();
         });
 
         Range<uint8_t> header(data, data + headerSize);
         data += headerSize;
 
@@ -457,16 +459,17 @@ ScriptPreloader::InitCacheInternal()
             // size, as a basic sanity check.
             if (script->mOffset != offset) {
                 return Err(NS_ERROR_UNEXPECTED);
             }
             offset += script->mSize;
 
             script->mXDRRange.emplace(scriptData, scriptData + script->mSize);
 
+            scripts.AppendElement(script.get());
             mScripts.Put(script->mCachePath, script.get());
             Unused << script.release();
         }
 
         if (buf.error()) {
             return Err(NS_ERROR_UNEXPECTED);
         }
 
@@ -477,17 +480,17 @@ ScriptPreloader::InitCacheInternal()
     MOZ_RELEASE_ASSERT(jsapi.Init(xpc::CompilationScope()));
     JSContext* cx = jsapi.cx();
 
     auto start = TimeStamp::Now();
     LOG(Info, "Off-thread decoding scripts...\n");
 
     JS::CompileOptions options(cx, JSVERSION_LATEST);
 
-    for (auto& script : IterHash(mScripts, Match<ScriptStatus::Restored>())) {
+    for (auto& script : scripts) {
         // Only async decode scripts which have been used in this process type.
         if (script->mProcessTypes.contains(CurrentProcessType()) &&
             script->AsyncDecodable() &&
             JS::CanCompileOffThread(cx, options, script->mSize)) {
             DecodeScriptOffThread(cx, script);
         } else {
             script->mReadyToExecute = true;
         }
--- a/js/xpconnect/loader/ScriptPreloader.h
+++ b/js/xpconnect/loader/ScriptPreloader.h
@@ -19,16 +19,17 @@
 #include "mozilla/loader/AutoMemMap.h"
 #include "nsClassHashtable.h"
 #include "nsIFile.h"
 #include "nsIMemoryReporter.h"
 #include "nsIObserver.h"
 #include "nsIThread.h"
 
 #include "jsapi.h"
+#include "js/GCAnnotations.h"
 
 #include <prio.h>
 
 namespace mozilla {
 namespace dom {
     class ContentParent;
 }
 namespace ipc {
@@ -202,17 +203,17 @@ private:
             if (!mXDRData.empty()) {
                 mXDRRange.reset();
                 mXDRData.destroy();
             }
         }
 
         void UpdateLoadTime(const TimeStamp& loadTime)
         {
-          if (!mLoadTime || loadTime < mLoadTime) {
+          if (mLoadTime.IsNull() || loadTime < mLoadTime) {
             mLoadTime = loadTime;
           }
         }
 
         bool AsyncDecodable() const { return mSize > MIN_OFFTHREAD_SIZE; }
 
         // Encodes this script into XDR data, and stores the result in mXDRData.
         // Returns true on success, false on failure.
@@ -313,17 +314,17 @@ private:
         // The read-only XDR data for this script, which was either read from an
         // existing cache file, or generated by encoding a script which was
         // compiled during this session.
         Maybe<JS::TranscodeRange> mXDRRange;
 
         // XDR data which was generated from a script compiled during this
         // session, and will be written to the cache file.
         MaybeOneOf<JS::TranscodeBuffer, nsTArray<uint8_t>> mXDRData;
-    };
+    } JS_HAZ_NON_GC_POINTER;
 
     template <ScriptStatus status>
     static Matcher<CachedScript*>* Match()
     {
         static CachedScript::StatusMatcher matcher{status};
         return &matcher;
     }