Bug 824864 - Pass EvaluateString out-param as a pointer, not a reference. r=bz
authorBobby Holley <bobbyholley@gmail.com>
Wed, 16 Jan 2013 18:50:27 -0800
changeset 128987 de4229773698ed9e71ae3b25b30d52458be9becd
parent 128986 53469a0e1ddd32803e2dde659fe1cb93af11714d
child 128988 3b3c304723cc9d66b5e54f2423e677476dcf5f75
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs824864
milestone21.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 824864 - Pass EvaluateString out-param as a pointer, not a reference. r=bz
content/base/src/nsScriptLoader.cpp
content/xbl/src/nsXBLProtoImplField.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsIScriptContext.h
dom/base/nsJSEnvironment.cpp
dom/base/nsJSEnvironment.h
dom/plugins/base/nsNPAPIPlugin.cpp
dom/src/jsurl/nsJSProtocolHandler.cpp
--- a/content/base/src/nsScriptLoader.cpp
+++ b/content/base/src/nsScriptLoader.cpp
@@ -860,17 +860,17 @@ nsScriptLoader::EvaluateScript(nsScriptL
   if (version != JSVERSION_UNKNOWN) {
     JS::CompileOptions options(context->GetNativeContext());
     options.setFileAndLine(url.get(), aRequest->mLineNo)
            .setVersion(JSVersion(aRequest->mJSVersion));
     if (aRequest->mOriginPrincipal)
       options.setOriginPrincipals(nsJSPrincipals::get(aRequest->mOriginPrincipal));
     JS::Value ignored;
     rv = context->EvaluateString(aScript, *globalObject->GetGlobalJSObject(),
-                                 options, /* aCoerceToString = */ false, ignored);
+                                 options, /* aCoerceToString = */ false, &ignored);
   }
 
   // Put the old script back in case it wants to do anything else.
   mCurrentScript = oldCurrent;
 
   JSContext *cx = nullptr; // Initialize this to keep GCC happy.
   cx = context->GetNativeContext();
   JSAutoRequest ar(cx);
--- a/content/xbl/src/nsXBLProtoImplField.cpp
+++ b/content/xbl/src/nsXBLProtoImplField.cpp
@@ -110,17 +110,17 @@ nsXBLProtoImplField::InstallField(nsIScr
   JS::CompileOptions options(cx);
   options.setFileAndLine(uriSpec.get(), mLineNumber)
          .setVersion(JSVERSION_LATEST)
          .setUserBit(true); // Flag us as XBL
   rv = context->EvaluateString(nsDependentString(mFieldText,
                                                  mFieldTextLength),
                                *aBoundNode, options,
                                /* aCoerceToString = */ false,
-                               result);
+                               &result);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
 
   // Define the evaluated result as a JS property
   nsDependentString name(mName);
   if (!::JS_DefineUCProperty(cx, aBoundNode,
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -9748,17 +9748,17 @@ nsGlobalWindow::RunTimeoutHandler(nsTime
     uint32_t lineNo = 0;
     handler->GetLocation(&filename, &lineNo);
 
     JS::CompileOptions options(aScx->GetNativeContext());
     options.setFileAndLine(filename, lineNo)
            .setVersion(JSVERSION_DEFAULT);
     JS::Value ignored;
     aScx->EvaluateString(nsDependentString(script), *FastGetGlobalJSObject(),
-                         options, /*aCoerceToString = */ false, ignored);
+                         options, /*aCoerceToString = */ false, &ignored);
   } else {
     nsCOMPtr<nsIVariant> dummy;
     nsCOMPtr<nsISupports> me(static_cast<nsIDOMWindow *>(this));
     aScx->CallEventHandler(me, FastGetGlobalJSObject(),
                            scriptObject, handler->GetArgv(),
                            // XXXmarkh - consider allowing CallEventHandler to
                            // accept nullptr?
                            getter_AddRefs(dummy));
--- a/dom/base/nsIScriptContext.h
+++ b/dom/base/nsIScriptContext.h
@@ -72,17 +72,17 @@ public:
    * @param aCoerceToString if the return value is not JSVAL_VOID, convert it
    *                        to a string before returning.
    * @param aRetValue the result of executing the script.
    **/
   virtual nsresult EvaluateString(const nsAString& aScript,
                                   JSObject& aScopeObject,
                                   JS::CompileOptions& aOptions,
                                   bool aCoerceToString,
-                                  JS::Value& aRetValue) = 0;
+                                  JS::Value* aRetValue) = 0;
 
   /**
    * Compile a script.
    *
    * @param aText a PRUnichar buffer containing script source
    * @param aTextLength number of characters in aText
    * @param aPrincipal the principal that produced the script
    * @param aURL the URL or filename for error messages
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -1228,22 +1228,22 @@ nsJSContext::GetCCRefcnt()
   return refcnt;
 }
 
 nsresult
 nsJSContext::EvaluateString(const nsAString& aScript,
                             JSObject& aScopeObject,
                             JS::CompileOptions& aOptions,
                             bool aCoerceToString,
-                            JS::Value& aRetValue)
+                            JS::Value* aRetValue)
 {
   SAMPLE_LABEL("JS", "EvaluateString");
   MOZ_ASSERT_IF(aOptions.versionSet, aOptions.version != JSVERSION_UNKNOWN);
   NS_ENSURE_TRUE(mIsInitialized, NS_ERROR_NOT_INITIALIZED);
-  aRetValue = JSVAL_VOID;
+  *aRetValue = JSVAL_VOID;
 
   if (!mScriptsEnabled) {
     return NS_OK;
   }
 
   nsCxPusher pusher;
   if (!pusher.Push(mContext))
     return NS_ERROR_FAILURE;
@@ -1267,21 +1267,21 @@ nsJSContext::EvaluateString(const nsAStr
     XPCAutoRequest ar(mContext);
     JSAutoCompartment ac(mContext, &aScopeObject);
 
     ++mExecuteDepth;
 
     js::RootedObject rootedScope(mContext, &aScopeObject);
     ok = JS::Evaluate(mContext, rootedScope, aOptions,
                       PromiseFlatString(aScript).get(),
-                      aScript.Length(), &aRetValue);
-    if (ok && !JSVAL_IS_VOID(aRetValue) && aCoerceToString) {
-      JSString* str = JS_ValueToString(mContext, aRetValue);
+                      aScript.Length(), aRetValue);
+    if (ok && !JSVAL_IS_VOID(*aRetValue) && aCoerceToString) {
+      JSString* str = JS_ValueToString(mContext, *aRetValue);
       ok = !!str;
-      aRetValue = ok ? JS::StringValue(str) : JSVAL_VOID;
+      *aRetValue = ok ? JS::StringValue(str) : JSVAL_VOID;
     }
     --mExecuteDepth;
   }
 
   if (!ok) {
     // Tell XPConnect about any pending exceptions. This is needed
     // to avoid dropping JS exceptions in case we got here through
     // nested calls through XPConnect.
--- a/dom/base/nsJSEnvironment.h
+++ b/dom/base/nsJSEnvironment.h
@@ -43,17 +43,17 @@ public:
                                                          nsIScriptContext)
 
   virtual nsIScriptObjectPrincipal* GetObjectPrincipal();
 
   virtual nsresult EvaluateString(const nsAString& aScript,
                                   JSObject& aScopeObject,
                                   JS::CompileOptions &aOptions,
                                   bool aCoerceToString,
-                                  JS::Value& aRetValue);
+                                  JS::Value* aRetValue);
 
   virtual nsresult CompileScript(const PRUnichar* aText,
                                  int32_t aTextLength,
                                  nsIPrincipal *principal,
                                  const char *aURL,
                                  uint32_t aLineNo,
                                  uint32_t aVersion,
                                  nsScriptObjectHolder<JSScript>& aScriptObject,
--- a/dom/plugins/base/nsNPAPIPlugin.cpp
+++ b/dom/plugins/base/nsNPAPIPlugin.cpp
@@ -1592,17 +1592,17 @@ bool NP_CALLBACK
                  ("NPN_Evaluate(npp %p, npobj %p, script <<<%s>>>) called\n",
                   npp, npobj, script->UTF8Characters));
 
   JS::CompileOptions options(cx);
   options.setFileAndLine(spec, 0)
          .setVersion(JSVERSION_DEFAULT);
   nsresult rv = scx->EvaluateString(utf16script, *obj, options,
                                     /* aCoerceToString = */ false,
-                                    *rval);
+                                    rval);
 
   return NS_SUCCEEDED(rv) &&
          (!result || JSValToNPVariant(npp, cx, *rval, result));
 }
 
 bool NP_CALLBACK
 _getproperty(NPP npp, NPObject* npobj, NPIdentifier property,
              NPVariant *result)
--- a/dom/src/jsurl/nsJSProtocolHandler.cpp
+++ b/dom/src/jsurl/nsJSProtocolHandler.cpp
@@ -323,17 +323,17 @@ nsresult nsJSThunk::EvaluateScript(nsICh
     } else {
         // No need to use the sandbox, evaluate the script directly in
         // the given scope.
         JS::CompileOptions options(cx);
         options.setFileAndLine(mURL.get(), 1)
                .setVersion(JSVERSION_DEFAULT);
         rv = scriptContext->EvaluateString(NS_ConvertUTF8toUTF16(script),
                                            *globalJSObject, options,
-                                           /* aCoerceToString = */ true, v);
+                                           /* aCoerceToString = */ true, &v);
 
         // If there's an error on cx as a result of that call, report
         // it now -- either we're just running under the event loop,
         // so we shouldn't propagate JS exceptions out of here, or we
         // can't be sure that our caller is JS (and if it's not we'll
         // lose the error), or it might be JS that then proceeds to
         // cause an error of its own (which will also make us lose
         // this error).