From 8c4f98a44a69934986089e44c3f81738771b819c Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 14 May 2012 21:38:37 -0700 Subject: [PATCH] Bug 753249 (part 3) - Remove TCF_IN_WITH from TreeContextFlags. r=luke. --HG-- extra : rebase_source : c88cc07d9a3868ec756daa1da0a0cbe875d3c144 --- js/src/frontend/BytecodeEmitter.cpp | 2 +- js/src/frontend/ParseNode.cpp | 2 +- js/src/frontend/ParseNode.h | 2 ++ js/src/frontend/Parser.cpp | 5 ++--- js/src/frontend/TreeContext.h | 9 +++------ 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitter.cpp index b559b3a70f96..a28d3a5ead95 100644 --- a/js/src/frontend/BytecodeEmitter.cpp +++ b/js/src/frontend/BytecodeEmitter.cpp @@ -1605,7 +1605,7 @@ BytecodeEmitter::needsImplicitThis() } } for (const FunctionBox *funbox = this->sc->funbox; funbox; funbox = funbox->parent) { - if (funbox->tcflags & TCF_IN_WITH) + if (funbox->inWith) return true; } for (StmtInfo *stmt = sc->topStmt; stmt; stmt = stmt->down) { diff --git a/js/src/frontend/ParseNode.cpp b/js/src/frontend/ParseNode.cpp index 4d51f40f45b6..307eee4d411c 100644 --- a/js/src/frontend/ParseNode.cpp +++ b/js/src/frontend/ParseNode.cpp @@ -112,7 +112,7 @@ bool FunctionBox::inAnyDynamicScope() const { for (const FunctionBox *funbox = this; funbox; funbox = funbox->parent) { - if (funbox->tcflags & (TCF_IN_WITH | TCF_FUN_EXTENSIBLE_SCOPE)) + if (funbox->inWith || (funbox->tcflags & TCF_FUN_EXTENSIBLE_SCOPE)) return true; } return false; diff --git a/js/src/frontend/ParseNode.h b/js/src/frontend/ParseNode.h index f9e6f90943f6..597bb3bc3b4d 100644 --- a/js/src/frontend/ParseNode.h +++ b/js/src/frontend/ParseNode.h @@ -1543,6 +1543,8 @@ struct FunctionBox : public ObjectBox inLoop:1, /* in a loop in parent function */ level:JSFB_LEVEL_BITS; uint32_t tcflags; + bool inWith:1; /* some enclosing scope is a with-statement + or E4X filter-expression */ JSFunction *function() const { return (JSFunction *) object; } diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index bce4304c2cf0..34be3c8f3885 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -237,13 +237,12 @@ Parser::newFunctionBox(JSObject *obj, ParseNode *fn, TreeContext *tc) } funbox->level = tc->sc->staticLevel; funbox->tcflags = tc->sc->flags & TCF_STRICT_MODE_CODE; - if (tc->innermostWith) - funbox->tcflags |= TCF_IN_WITH; + funbox->inWith = !!tc->innermostWith; if (!tc->sc->inFunction) { JSObject *scope = tc->sc->scopeChain(); while (scope) { if (scope->isWith()) - funbox->tcflags |= TCF_IN_WITH; + funbox->inWith = true; scope = scope->enclosingScope(); } } diff --git a/js/src/frontend/TreeContext.h b/js/src/frontend/TreeContext.h index 6e3638540c8d..56feeb082c88 100644 --- a/js/src/frontend/TreeContext.h +++ b/js/src/frontend/TreeContext.h @@ -103,9 +103,6 @@ JS_ENUM_HEADER(TreeContextFlags, uint32_t) // The script contains singleton initialiser JSOP_OBJECT. TCF_HAS_SINGLETONS = 0x40, - // Some enclosing scope is a with-statement or E4X filter-expression. - TCF_IN_WITH = 0x80, - // This function does something that can extend the set of bindings in its // call objects --- it does a direct eval in non-strict code, or includes a // function statement (as opposed to a function definition). @@ -113,7 +110,7 @@ JS_ENUM_HEADER(TreeContextFlags, uint32_t) // This flag is *not* inherited by enclosed or enclosing functions; it // applies only to the function in whose flags it appears. // - TCF_FUN_EXTENSIBLE_SCOPE = 0x100, + TCF_FUN_EXTENSIBLE_SCOPE = 0x80, // Technically, every function has a binding named 'arguments'. Internally, // this binding is only added when 'arguments' is mentioned by the function @@ -136,7 +133,7 @@ JS_ENUM_HEADER(TreeContextFlags, uint32_t) // have no special semantics: the initial value is unconditionally the // actual argument (or undefined if nactual < nformal). // - TCF_ARGUMENTS_HAS_LOCAL_BINDING = 0x200, + TCF_ARGUMENTS_HAS_LOCAL_BINDING = 0x100, // In many cases where 'arguments' has a local binding (as described above) // we do not need to actually create an arguments object in the function @@ -147,7 +144,7 @@ JS_ENUM_HEADER(TreeContextFlags, uint32_t) // be unsound in several cases. The frontend filters out such cases by // setting this flag which eagerly sets script->needsArgsObj to true. // - TCF_DEFINITELY_NEEDS_ARGS_OBJ = 0x400 + TCF_DEFINITELY_NEEDS_ARGS_OBJ = 0x200 } JS_ENUM_FOOTER(TreeContextFlags);