Bug 1356666, part 4 - Use handles as arguments in mozJSSubscriptLoader. r=mrbkap draft
authorAndrew McCreight <continuation@gmail.com>
Fri, 14 Apr 2017 14:38:51 -0700
changeset 563034 1a20b40ddafa76d528ecd353175cf0a02523ce7c
parent 563033 42b76c50c817cedc5dfce79c66f3cac9999c1858
child 624379 0dc153e00290ccd9103f54e4632bc30085458272
push id54194
push userbmo:continuation@gmail.com
push dateFri, 14 Apr 2017 21:57:45 +0000
reviewersmrbkap
bugs1356666
milestone55.0a1
Bug 1356666, part 4 - Use handles as arguments in mozJSSubscriptLoader. r=mrbkap MozReview-Commit-ID: 9fClU6BIWfT
js/xpconnect/loader/mozJSSubScriptLoader.cpp
--- a/js/xpconnect/loader/mozJSSubScriptLoader.cpp
+++ b/js/xpconnect/loader/mozJSSubScriptLoader.cpp
@@ -118,17 +118,17 @@ ReportError(JSContext* cx, const char* o
     msg.Append(": ");
     msg.Append(spec);
     ReportError(cx, msg);
 }
 
 static bool
 PrepareScript(nsIURI* uri,
               JSContext* cx,
-              RootedObject& targetObj,
+              HandleObject targetObj,
               const char* uriStr,
               const nsAString& charset,
               const char* buf,
               int64_t len,
               bool reuseGlobal,
               MutableHandleScript script,
               MutableHandleFunction function)
 {
@@ -180,25 +180,25 @@ PrepareScript(nsIURI* uri,
         return false;
     }
     return JS::CompileFunction(cx, envChain, options, nullptr, 0, nullptr,
                                buf, len, function);
 }
 
 static bool
 EvalScript(JSContext* cx,
-           RootedObject& targetObj,
+           HandleObject targetObj,
            MutableHandleValue retval,
            nsIURI* uri,
            bool cache,
-           RootedScript& script,
-           RootedFunction& function)
+           MutableHandleScript script,
+           HandleFunction function)
 {
     if (function) {
-        script = JS_GetFunctionScript(cx, function);
+        script.set(JS_GetFunctionScript(cx, function));
     }
 
     if (function) {
         if (!JS_CallFunction(cx, targetObj, function, JS::HandleValueArray::empty(), retval)) {
             return false;
         }
     } else {
         if (JS_IsGlobalObject(targetObj)) {
@@ -388,17 +388,17 @@ AsyncScriptLoader::OnStreamComplete(nsII
     if (!PrepareScript(uri, cx, targetObj, spec.get(), mCharset,
                        reinterpret_cast<const char*>(aBuf), aLength,
                        mReuseGlobal, &script, &function))
     {
         return NS_OK;
     }
 
     JS::Rooted<JS::Value> retval(cx);
-    if (EvalScript(cx, targetObj, &retval, uri, mCache, script, function)) {
+    if (EvalScript(cx, targetObj, &retval, uri, mCache, &script, function)) {
         autoPromise.ResolvePromise(retval);
     }
 
     return NS_OK;
 }
 
 nsresult
 mozJSSubScriptLoader::ReadScriptAsync(nsIURI* uri, JSObject* targetObjArg,
@@ -692,17 +692,17 @@ mozJSSubScriptLoader::DoLoadSubScriptWit
                         principal, reusingGlobal, &script, &function))
         {
             return NS_OK;
         }
     } else {
         cache = nullptr;
     }
 
-    Unused << EvalScript(cx, targetObj, retval, uri, !!cache, script, function);
+    Unused << EvalScript(cx, targetObj, retval, uri, !!cache, &script, function);
     return NS_OK;
 }
 
 /**
   * Let us compile scripts from a URI off the main thread.
   */
 
 class ScriptPrecompiler : public nsIIncrementalStreamLoaderObserver