Bug 895395 - Support NameFunctions when compiling scripts off the main thread Bug 895395 - Support NameFunctions when compiling scripts off the main thread (r=bhackett)

This commit is contained in:
Bill McCloskey 2013-11-19 13:20:33 -08:00
Родитель 5ae04a9cf8
Коммит c4942592ad
3 изменённых файлов: 8 добавлений и 7 удалений

Просмотреть файл

@ -355,9 +355,7 @@ frontend::CompileScript(ExclusiveContext *cx, LifoAlloc *alloc, HandleObject sco
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))

Просмотреть файл

@ -23,7 +23,7 @@ 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 */
@ -262,7 +262,7 @@ class NameResolver
}
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
@ -331,7 +331,7 @@ class NameResolver
} /* anonymous namespace */
bool
frontend::NameFunctions(JSContext *cx, ParseNode *pn)
frontend::NameFunctions(ExclusiveContext *cx, ParseNode *pn)
{
NameResolver nr(cx);
nr.resolve(pn);

Просмотреть файл

@ -10,12 +10,15 @@
#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 */