From a29b6396bb42f72a90748acf268236f72ae8efd0 Mon Sep 17 00:00:00 2001 From: Jason Orendorff Date: Thu, 27 Oct 2011 17:00:48 -0500 Subject: [PATCH] Move GlobalScope from BytecodeCompiler to BytecodeEmitter. Bug 696953, part 2 of 4. r=Waldo. --HG-- rename : js/src/frontend/Parser.cpp => js/src/frontend/SemanticAnalysis.cpp extra : rebase_source : d07f9e50246b46d9704c3a45ae0fa368c88319be --- js/src/frontend/BytecodeCompiler.cpp | 4 ++-- js/src/frontend/BytecodeCompiler.h | 1 - js/src/frontend/BytecodeEmitter.cpp | 6 ++++-- js/src/frontend/BytecodeEmitter.h | 4 ++-- js/src/frontend/Parser.cpp | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/js/src/frontend/BytecodeCompiler.cpp b/js/src/frontend/BytecodeCompiler.cpp index fb08f9b110c..29d53678982 100644 --- a/js/src/frontend/BytecodeCompiler.cpp +++ b/js/src/frontend/BytecodeCompiler.cpp @@ -55,7 +55,7 @@ using namespace js::frontend; * Compile a top-level script. */ BytecodeCompiler::BytecodeCompiler(JSContext *cx, JSPrincipals *prin, StackFrame *cfp) - : parser(cx, prin, cfp), globalScope(NULL) + : parser(cx, prin, cfp) {} JSScript * @@ -110,7 +110,7 @@ BytecodeCompiler::compileScript(JSContext *cx, JSObject *scopeChain, StackFrame GlobalScope globalScope(cx, globalObj, &bce); bce.flags |= tcflags; bce.setScopeChain(scopeChain); - compiler.globalScope = &globalScope; + bce.globalScope = &globalScope; if (!SetStaticLevel(&bce, staticLevel)) goto out; diff --git a/js/src/frontend/BytecodeCompiler.h b/js/src/frontend/BytecodeCompiler.h index ca7c51836de..62ae990ad0a 100644 --- a/js/src/frontend/BytecodeCompiler.h +++ b/js/src/frontend/BytecodeCompiler.h @@ -48,7 +48,6 @@ namespace js { struct BytecodeCompiler { Parser parser; - GlobalScope *globalScope; BytecodeCompiler(JSContext *cx, JSPrincipals *prin = NULL, StackFrame *cfp = NULL); diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitter.cpp index c6b6aa72c39..15b8cc035f7 100644 --- a/js/src/frontend/BytecodeEmitter.cpp +++ b/js/src/frontend/BytecodeEmitter.cpp @@ -125,6 +125,7 @@ BytecodeEmitter::BytecodeEmitter(Parser *parser, uintN lineno) constList(parser->context), upvarIndices(parser->context), upvarMap(parser->context), + globalScope(NULL), globalUses(parser->context), globalMap(parser->context), closedArgs(parser->context), @@ -2076,7 +2077,7 @@ static bool TryConvertToGname(BytecodeEmitter *bce, ParseNode *pn, JSOp *op) { if (bce->compileAndGo() && - bce->compiler()->globalScope->globalObj && + bce->globalScope->globalObj && !bce->mightAliasLocals() && !pn->isDeoptimized() && !(bce->flags & TCF_STRICT_MODE_CODE)) { @@ -2110,7 +2111,7 @@ BindKnownGlobal(JSContext *cx, BytecodeEmitter *bce, ParseNode *dn, ParseNode *p if (bce->mightAliasLocals()) return true; - GlobalScope *globalScope = bce->compiler()->globalScope; + GlobalScope *globalScope = bce->globalScope; jsatomid index; if (dn->pn_cookie.isFree()) { @@ -5923,6 +5924,7 @@ frontend::EmitTree(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn) bce2->setFunction(fun); bce2->funbox = pn->pn_funbox; bce2->parent = bce; + bce2->globalScope = bce->globalScope; /* * js::frontend::SetStaticLevel limited static nesting depth to fit in diff --git a/js/src/frontend/BytecodeEmitter.h b/js/src/frontend/BytecodeEmitter.h index dcd6f87b474..d4cb4ba7816 100644 --- a/js/src/frontend/BytecodeEmitter.h +++ b/js/src/frontend/BytecodeEmitter.h @@ -435,8 +435,6 @@ struct TreeContext { /* tree context for semantic checks */ int sharpSlotBase; bool ensureSharpSlots(); - BytecodeCompiler *compiler() { return (BytecodeCompiler *) parser; } - // Return true there is a generator function within |skip| lexical scopes // (going upward) from this context's lexical scope. Always return true if // this context is itself a generator. @@ -657,6 +655,8 @@ struct BytecodeEmitter : public TreeContext UpvarCookies upvarMap; /* indexed upvar slot locations */ + GlobalScope *globalScope; /* frontend::CompileScript global scope, or null */ + typedef Vector GlobalUseVector; GlobalUseVector globalUses; /* per-script global uses */ diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index 51a537637cc..9b4c0bfda89 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -2021,7 +2021,7 @@ OuterLet(TreeContext *tc, StmtInfo *stmt, JSAtom *atom) static bool DefineGlobal(ParseNode *pn, BytecodeEmitter *bce, PropertyName *name) { - GlobalScope *globalScope = bce->compiler()->globalScope; + GlobalScope *globalScope = bce->globalScope; JSObject *globalObj = globalScope->globalObj; if (!bce->compileAndGo() || !globalObj || bce->compilingForEval())