Bug 889714 - Reduce the number of places where we pull |env| off cx. r=mrbkap
☠☠ backed out by 659b0d61fbc6 ☠ ☠
authorBobby Holley <bobbyholley@gmail.com>
Thu, 25 Jul 2013 11:29:20 -0700
changeset 148049 efe2d89832cf9e71548e01928490ea3893aedc3a
parent 148048 a83ae579e3df2989661c3964c7315ee51219de53
child 148050 c9387ac33f08e22e83c212216d19598956fd50c4
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs889714
milestone24.0a2
Bug 889714 - Reduce the number of places where we pull |env| off cx. r=mrbkap
ipc/testshell/XPCShellEnvironment.cpp
ipc/testshell/XPCShellEnvironment.h
--- a/ipc/testshell/XPCShellEnvironment.cpp
+++ b/ipc/testshell/XPCShellEnvironment.cpp
@@ -482,24 +482,26 @@ typedef enum JSShellErrNum
 #define MSG_DEF(name, number, count, exception, format) \
     name = number,
 #include "jsshell.msg"
 #undef MSG_DEF
     JSShellErr_Limit
 #undef MSGDEF
 } JSShellErrNum;
 
-static void
-ProcessFile(JSContext *cx,
-            JS::Handle<JSObject*> obj,
-            const char *filename,
-            FILE *file,
-            JSBool forceTTY)
+} /* anonymous namespace */
+
+void
+XPCShellEnvironment::ProcessFile(JSContext *cx,
+                                 JS::Handle<JSObject*> obj,
+                                 const char *filename,
+                                 FILE *file,
+                                 JSBool forceTTY)
 {
-    XPCShellEnvironment* env = Environment(cx);
+    XPCShellEnvironment* env = this;
     nsCxPusher pusher;
     pusher.Push(env->GetContext());
 
     JSScript *script;
     JS::Rooted<JS::Value> result(cx);
     int lineno, startline;
     JSBool ok, hitEOF;
     char *bufp, buffer[4096];
@@ -594,18 +596,16 @@ ProcessFile(JSContext *cx,
                     ok = JS_FALSE;
             }
         }
     } while (!hitEOF && !env->IsQuitting());
 
     fprintf(stdout, "\n");
 }
 
-} /* anonymous namespace */
-
 NS_IMETHODIMP_(nsrefcnt)
 XPCShellDirProvider::AddRef()
 {
     return 2;
 }
 
 NS_IMETHODIMP_(nsrefcnt)
 XPCShellDirProvider::Release()
@@ -806,17 +806,17 @@ XPCShellEnvironment::Init()
 
     return true;
 }
 
 bool
 XPCShellEnvironment::EvaluateString(const nsString& aString,
                                     nsString* aResult)
 {
-  XPCShellEnvironment* env = Environment(mCx);
+  XPCShellEnvironment* env = this;
   nsCxPusher pusher;
   pusher.Push(env->GetContext());
 
   JSAutoRequest ar(mCx);
 
   JS_ClearPendingException(mCx);
 
   JS::Rooted<JSObject*> global(mCx, GetGlobalObject());
--- a/ipc/testshell/XPCShellEnvironment.h
+++ b/ipc/testshell/XPCShellEnvironment.h
@@ -23,16 +23,18 @@ namespace mozilla {
 namespace ipc {
 
 class XPCShellEnvironment
 {
 public:
     static XPCShellEnvironment* CreateEnvironment();
     ~XPCShellEnvironment();
 
+    void ProcessFile(JSContext *cx, JS::Handle<JSObject*> obj,
+                     const char *filename, FILE *file, JSBool forceTTY);
     bool EvaluateString(const nsString& aString,
                         nsString* aResult = nullptr);
 
     JSPrincipals* GetPrincipal() {
         return mJSPrincipals;
     }
 
     JSObject* GetGlobalObject() {