Bug 895395 - Support NameFunctions when compiling scripts off the main thread Bug 895395 - Support NameFunctions when compiling scripts off the main thread (r=bhackett)
☠☠ backed out by 7e9be570d4b8 ☠ ☠
authorBill McCloskey <wmccloskey@mozilla.com>
Tue, 19 Nov 2013 13:20:33 -0800
changeset 171037 b92529577644a37517e87fe053ba29ab9e3f4c90
parent 171036 998d2d5e743d261785ae87017f160f2f5af59baf
child 171038 4f993fa378ebe15621a7e03114ae99552db757f5
child 171102 6a0e4afd52ab064aca0f1cd5424f9fa4a1e42903
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs895395
milestone28.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 895395 - Support NameFunctions when compiling scripts off the main thread Bug 895395 - Support NameFunctions when compiling scripts off the main thread (r=bhackett)
js/src/frontend/BytecodeCompiler.cpp
js/src/frontend/NameFunctions.cpp
js/src/frontend/NameFunctions.h
--- a/js/src/frontend/BytecodeCompiler.cpp
+++ b/js/src/frontend/BytecodeCompiler.cpp
@@ -350,19 +350,17 @@ frontend::CompileScript(ExclusiveContext
         if (canHaveDirectives) {
             if (!parser.maybeParseDirective(/* stmtList = */ nullptr, pn, &canHaveDirectives))
                 return nullptr;
         }
 
         if (!FoldConstants(cx, &pn, &parser))
             return nullptr;
 
-        // Inferring names for functions in compiled scripts is currently only
-        // supported while on the main thread. See bug 895395.
-        if (cx->isJSContext() && !NameFunctions(cx->asJSContext(), pn))
+        if (!NameFunctions(cx, pn))
             return nullptr;
 
         if (!EmitTree(cx, &bce, pn))
             return nullptr;
 
         parser.handler.freeTree(pn);
     }
 
--- a/js/src/frontend/NameFunctions.cpp
+++ b/js/src/frontend/NameFunctions.cpp
@@ -18,17 +18,17 @@ using namespace js;
 using namespace js::frontend;
 
 namespace {
 
 class NameResolver
 {
     static const size_t MaxParents = 100;
 
-    JSContext *cx;
+    ExclusiveContext *cx;
     size_t nparents;                /* number of parents in the parents array */
     ParseNode *parents[MaxParents]; /* history of ParseNodes we've been looking at */
     StringBuffer *buf;              /* when resolving, buffer to append to */
 
     /* Test whether a ParseNode represents a function invocation */
     bool call(ParseNode *pn) {
         return pn && pn->isKind(PNK_CALL);
     }
@@ -257,17 +257,17 @@ class NameResolver
      * This is the case for functions which do things like simply create a scope
      * for new variables and then return an anonymous function using this scope.
      */
     bool isDirectCall(int pos, ParseNode *cur) {
         return pos >= 0 && call(parents[pos]) && parents[pos]->pn_head == cur;
     }
 
   public:
-    explicit NameResolver(JSContext *cx) : cx(cx), nparents(0), buf(nullptr) {}
+    explicit NameResolver(ExclusiveContext *cx) : cx(cx), nparents(0), buf(nullptr) {}
 
     /*
      * Resolve all names for anonymous functions recursively within the
      * ParseNode instance given. The prefix is for each subsequent name, and
      * should initially be nullptr.
      */
     void resolve(ParseNode *cur, HandleAtom prefixArg = NullPtr()) {
         RootedAtom prefix(cx, prefixArg);
@@ -326,14 +326,14 @@ class NameResolver
         }
         nparents--;
     }
 };
 
 } /* anonymous namespace */
 
 bool
-frontend::NameFunctions(JSContext *cx, ParseNode *pn)
+frontend::NameFunctions(ExclusiveContext *cx, ParseNode *pn)
 {
     NameResolver nr(cx);
     nr.resolve(pn);
     return true;
 }
--- a/js/src/frontend/NameFunctions.h
+++ b/js/src/frontend/NameFunctions.h
@@ -5,19 +5,22 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef frontend_NameFunctions_h
 #define frontend_NameFunctions_h
 
 #include "js/TypeDecls.h"
 
 namespace js {
+
+class ExclusiveContext;
+
 namespace frontend {
 
 class ParseNode;
 
 bool
-NameFunctions(JSContext *cx, ParseNode *pn);
+NameFunctions(ExclusiveContext *cx, ParseNode *pn);
 
 } /* namespace frontend */
 } /* namespace js */
 
 #endif /* frontend_NameFunctions_h */