Bug 753657 (part 2): Simplify the setting of FunctionBox::tcflags. r=luke.
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 14 May 2012 23:17:50 -0700
changeset 94178 e1acc0dd12a8ff094fb06af7304f087242c73aca
parent 94177 d5a02a324330fe44c39c32e2b32221685c32eb5a
child 94179 2cde430809e3383047ee47cf723ccacf43050d8f
push id22701
push useremorley@mozilla.com
push dateThu, 17 May 2012 10:00:02 +0000
treeherdermozilla-central@f2b2b99108a2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs753657
milestone15.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 753657 (part 2): Simplify the setting of FunctionBox::tcflags. r=luke.
js/src/frontend/Parser.cpp
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -231,17 +231,17 @@ Parser::newFunctionBox(JSObject *obj, Pa
     funbox->inLoop = false;
     for (StmtInfo *stmt = tc->sc->topStmt; stmt; stmt = stmt->down) {
         if (STMT_IS_LOOP(stmt)) {
             funbox->inLoop = true;
             break;
         }
     }
     funbox->level = tc->sc->staticLevel;
-    funbox->tcflags = tc->sc->flags & TCF_STRICT_MODE_CODE;
+    funbox->tcflags = 0;    // this is set in LeaveFunction
     funbox->inWith = !!tc->innermostWith;
     if (!tc->sc->inFunction) {
         JSObject *scope = tc->sc->scopeChain();
         while (scope) {
             if (scope->isWith())
                 funbox->inWith = true;
             scope = scope->enclosingScope();
         }
@@ -1089,17 +1089,18 @@ EnterFunction(ParseNode *fn, Parser *par
         return NULL;
 
     /* Create box for fun->object early to protect against last-ditch GC. */
     FunctionBox *funbox = parser->newFunctionBox(fun, fn, tc);
     if (!funbox)
         return NULL;
 
     /* Initialize non-default members of funtc. */
-    funtc->sc->flags |= funbox->tcflags;
+    JS_ASSERT(!funtc->sc->flags);
+    funtc->sc->flags = tc->sc->flags & TCF_STRICT_MODE_CODE;  // inherit strict mode from parent
     funtc->sc->blockidGen = tc->sc->blockidGen;
     if (!GenerateBlockId(funtc->sc, funtc->sc->bodyid))
         return NULL;
     funtc->sc->setFunction(fun);
     funtc->sc->funbox = funbox;
     if (!SetStaticLevel(funtc->sc, tc->sc->staticLevel + 1))
         return NULL;
 
@@ -1133,17 +1134,18 @@ static bool
 LeaveFunction(ParseNode *fn, Parser *parser, PropertyName *funName = NULL,
               FunctionSyntaxKind kind = Expression)
 {
     TreeContext *funtc = parser->tc;
     TreeContext *tc = funtc->parent;
     tc->sc->blockidGen = funtc->sc->blockidGen;
 
     FunctionBox *funbox = fn->pn_funbox;
-    funbox->tcflags |= funtc->sc->flags;
+    JS_ASSERT(!funbox->tcflags);    // we don't set any of these flags until now
+    funbox->tcflags = funtc->sc->flags;
 
     fn->pn_dflags |= PND_INITIALIZED;
     if (!tc->sc->topStmt || tc->sc->topStmt->type == STMT_BLOCK)
         fn->pn_dflags |= PND_BLOCKCHILD;
 
     /*
      * Propagate unresolved lexical names up to tc->lexdeps, and save a copy
      * of funtc->lexdeps in a TOK_UPVARS node wrapping the function's formal
@@ -5455,23 +5457,22 @@ Parser::generatorExpr(ParseNode *kid)
         if (!gentc.init(context))
             return NULL;
 
         FunctionBox *funbox = EnterFunction(genfn, this);
         if (!funbox)
             return NULL;
 
         /*
-         * We assume conservatively that any deoptimization flag in tc->sc->flags
+         * We assume conservatively that any deoptimization flags in tc->sc->flags
          * come from the kid. So we propagate these flags into genfn. For code
          * simplicity we also do not detect if the flags were only set in the
          * kid and could be removed from tc->sc->flags.
          */
         gensc.flags |= TCF_FUN_IS_GENERATOR | outertc->sc->flags;
-        funbox->tcflags |= gensc.flags;
         funbox->inGenexpLambda = true;
         genfn->pn_funbox = funbox;
         genfn->pn_blockid = gensc.bodyid;
 
         ParseNode *body = comprehensionTail(pn, outertc->sc->blockid(), true);
         if (!body)
             return NULL;
         JS_ASSERT(!genfn->pn_body);