From 8d9a00892f0c1c323876e8de8b0b23f7ed6c91c7 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Fri, 12 May 2017 18:14:12 -0700 Subject: [PATCH] Bug 1361900: Fix one last merge botch, and fix a false rooting hazard warning. MozReview-Commit-ID: JpKYYEBpbQj --HG-- extra : rebase_source : 5bbb462ed3255c631cc1c280359af8c9c2224239 extra : histedit_source : 444c4c02eb1a3ced85cef09f7b7a6e7f5b9235b5%2Cb16ca4316a1aabf5e5c1b8641a0e1818d815da76 --- js/xpconnect/loader/ScriptPreloader-inl.h | 3 ++- js/xpconnect/loader/ScriptPreloader.cpp | 5 ++++- js/xpconnect/loader/ScriptPreloader.h | 5 +++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/js/xpconnect/loader/ScriptPreloader-inl.h b/js/xpconnect/loader/ScriptPreloader-inl.h index 3f89d5ab7843..e0d16f7365c9 100644 --- a/js/xpconnect/loader/ScriptPreloader-inl.h +++ b/js/xpconnect/loader/ScriptPreloader-inl.h @@ -258,7 +258,8 @@ public: public: Elem& operator*() { return *this; } - ElemType get() { + ElemType get() + { if (done_) { return nullptr; } diff --git a/js/xpconnect/loader/ScriptPreloader.cpp b/js/xpconnect/loader/ScriptPreloader.cpp index 17f3508f8e98..918c3ac89c70 100644 --- a/js/xpconnect/loader/ScriptPreloader.cpp +++ b/js/xpconnect/loader/ScriptPreloader.cpp @@ -433,6 +433,8 @@ ScriptPreloader::InitCacheInternal() return Err(NS_ERROR_UNEXPECTED); } + AutoTArray scripts; + { auto cleanup = MakeScopeExit([&] () { mScripts.Clear(); @@ -462,6 +464,7 @@ ScriptPreloader::InitCacheInternal() script->mXDRRange.emplace(scriptData, scriptData + script->mSize); + scripts.AppendElement(script.get()); mScripts.Put(script->mCachePath, script.get()); Unused << script.release(); } @@ -482,7 +485,7 @@ ScriptPreloader::InitCacheInternal() JS::CompileOptions options(cx, JSVERSION_LATEST); - for (auto& script : IterHash(mScripts, Match())) { + for (auto& script : scripts) { // Only async decode scripts which have been used in this process type. if (script->mProcessTypes.contains(CurrentProcessType()) && script->AsyncDecodable() && diff --git a/js/xpconnect/loader/ScriptPreloader.h b/js/xpconnect/loader/ScriptPreloader.h index 08071777f6fb..80fc5bec729c 100644 --- a/js/xpconnect/loader/ScriptPreloader.h +++ b/js/xpconnect/loader/ScriptPreloader.h @@ -24,6 +24,7 @@ #include "nsIThread.h" #include "jsapi.h" +#include "js/GCAnnotations.h" #include @@ -207,7 +208,7 @@ private: void UpdateLoadTime(const TimeStamp& loadTime) { - if (!mLoadTime || loadTime < mLoadTime) { + if (mLoadTime.IsNull() || loadTime < mLoadTime) { mLoadTime = loadTime; } } @@ -318,7 +319,7 @@ private: // XDR data which was generated from a script compiled during this // session, and will be written to the cache file. MaybeOneOf> mXDRData; - }; + } JS_HAZ_NON_GC_POINTER; template static Matcher* Match()