Bug 1179063 - Cleanup: remove superfluous StmtInfoBase::isNestedScope. (r=efaust)
authorShu-yu Guo <shu@rfrn.org>
Thu, 30 Jul 2015 22:17:04 -0700
changeset 287239 dbfb0313280303f2c03cdae7d8e67c0b00cf8e7e
parent 287238 52758787f3249f4e9c7331f8056ec139750070c9
child 287240 d5d0d7a18180663ea71040f6a32c342fce584c17
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersefaust
bugs1179063
milestone42.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 1179063 - Cleanup: remove superfluous StmtInfoBase::isNestedScope. (r=efaust)
js/src/frontend/BytecodeEmitter.cpp
js/src/frontend/Parser.cpp
js/src/frontend/SharedContext.h
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -568,17 +568,17 @@ class NonLocalExitScope {
       : bce(bce_),
         savedScopeIndex(bce->blockScopeList.length()),
         savedDepth(bce->stackDepth),
         openScopeIndex(UINT32_MAX) {
         if (bce->staticScope) {
             StmtInfoBCE* stmt = bce->topStmt;
             while (1) {
                 MOZ_ASSERT(stmt);
-                if (stmt->isNestedScope) {
+                if (stmt->linksScope()) {
                     openScopeIndex = stmt->blockScopeIndex;
                     break;
                 }
                 stmt = stmt->down;
             }
         }
     }
 
@@ -617,17 +617,17 @@ NonLocalExitScope::prepareForNonLocalJum
             FLUSH_POPS();
             if (!bce->emitBackPatchOp(&stmt->gosubs()))
                 return false;
             break;
 
           case StmtType::WITH:
             if (!bce->emit1(JSOP_LEAVEWITH))
                 return false;
-            MOZ_ASSERT(stmt->isNestedScope);
+            MOZ_ASSERT(stmt->linksScope());
             if (!popScopeForNonLocalExit(stmt->blockScopeIndex))
                 return false;
             break;
 
           case StmtType::FOR_OF_LOOP:
             npops += 2;
             break;
 
@@ -650,17 +650,16 @@ NonLocalExitScope::prepareForNonLocalJum
              */
             npops += 2;
             break;
 
           default:;
         }
 
         if (stmt->isBlockScope) {
-            MOZ_ASSERT(stmt->isNestedScope);
             StaticBlockObject& blockObj = stmt->staticBlock();
             if (blockObj.needsClone()) {
                 if (!bce->emit1(JSOP_POPBLOCKSCOPE))
                     return false;
             } else {
                 if (!bce->emit1(JSOP_DEBUGLEAVEBLOCK))
                     return false;
             }
@@ -936,17 +935,17 @@ BytecodeEmitter::enterNestedScope(StmtIn
 
     stmt->blockScopeIndex = blockScopeList.length();
     if (!blockScopeList.append(scopeObjectIndex, offset(), parent))
         return false;
 
     pushStatement(stmt, stmtType, offset());
     scopeObj->initEnclosingNestedScope(enclosingStaticScope());
     FinishPushNestedScope(this, stmt, *scopeObj);
-    MOZ_ASSERT(stmt->isNestedScope);
+    MOZ_ASSERT(stmt->linksScope());
     stmt->isBlockScope = (stmtType == StmtType::BLOCK);
 
     return true;
 }
 
 // Patches |breaks| and |continues| unless the top statement info record
 // represents a try-catch-finally suite.
 void
@@ -959,17 +958,17 @@ BytecodeEmitter::popStatement()
 
     FinishPopStatement(this);
 }
 
 bool
 BytecodeEmitter::leaveNestedScope(StmtInfoBCE* stmt)
 {
     MOZ_ASSERT(stmt == topStmt);
-    MOZ_ASSERT(stmt->isNestedScope);
+    MOZ_ASSERT(stmt->linksScope());
     MOZ_ASSERT(stmt->isBlockScope == !(stmt->type == StmtType::WITH));
     uint32_t blockScopeIndex = stmt->blockScopeIndex;
 
 #ifdef DEBUG
     MOZ_ASSERT(blockScopeList.list[blockScopeIndex].length == 0);
     uint32_t blockObjIndex = blockScopeList.list[blockScopeIndex].index;
     ObjectBox* blockObjBox = objectList.find(blockObjIndex);
     NestedScopeObject* staticScope = &blockObjBox->object->as<NestedScopeObject>();
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -3125,17 +3125,16 @@ AccumulateBlockScopeDepth(ParseContext<P
     }
 }
 
 template <typename ParseHandler>
 static void
 PopStatementPC(TokenStream& ts, ParseContext<ParseHandler>* pc)
 {
     RootedNestedScopeObject scopeObj(ts.context(), pc->topStmt->staticScope);
-    MOZ_ASSERT(!!scopeObj == pc->topStmt->isNestedScope);
 
     AccumulateBlockScopeDepth(pc);
     FinishPopStatement(pc);
 
     if (scopeObj) {
         if (scopeObj->is<StaticBlockObject>()) {
             RootedStaticBlockObject blockObj(ts.context(), &scopeObj->as<StaticBlockObject>());
             MOZ_ASSERT(!blockObj->inDictionaryMode());
@@ -4095,17 +4094,17 @@ Parser<FullParseHandler>::checkAndPrepar
             return false;
 
         /*
          * Insert stmt on the pc->topScopeStmt/stmtInfo.downScope linked
          * list stack, if it isn't already there.  If it is there, but it
          * lacks the SIF_SCOPE flag, it must be a try, catch, or finally
          * block.
          */
-        stmt->isBlockScope = stmt->isNestedScope = true;
+        stmt->isBlockScope = true;
         stmt->downScope = pc->topScopeStmt;
         pc->topScopeStmt = stmt;
 
         blockObj->initEnclosingNestedScopeFromParser(pc->staticScope);
         pc->staticScope = blockObj;
         stmt->staticScope = blockObj;
 
 #ifdef DEBUG
--- a/js/src/frontend/SharedContext.h
+++ b/js/src/frontend/SharedContext.h
@@ -500,45 +500,41 @@ struct StmtInfoBase {
     // Statement type (StmtType).
     StmtType type;
 
     // True if type is StmtType::BLOCK, StmtType::TRY, StmtType::SWITCH, or
     // StmtType::FINALLY and the block contains at least one let-declaration,
     // or if type is StmtType::CATCH.
     bool isBlockScope:1;
 
-    // True if isBlockScope or type == StmtType::WITH.
-    bool isNestedScope:1;
-
     // for (let ...) induced block scope
     bool isForLetBlock:1;
 
     // Block label.
     RootedAtom      label;
 
-    // Compile-time scope chain node for this scope.  Only set if
-    // isNestedScope.
+    // Compile-time scope chain node for this scope.
     Rooted<NestedScopeObject*> staticScope;
 
     explicit StmtInfoBase(ExclusiveContext* cx)
-        : isBlockScope(false), isNestedScope(false), isForLetBlock(false),
+        : isBlockScope(false), isForLetBlock(false),
           label(cx), staticScope(cx)
     {}
 
     bool maybeScope() const {
         return StmtType::BLOCK <= type && type <= StmtType::SUBROUTINE &&
                type != StmtType::WITH;
     }
 
     bool linksScope() const {
-        return isNestedScope;
+        return !!staticScope;
     }
 
     StaticBlockObject& staticBlock() const {
-        MOZ_ASSERT(isNestedScope);
+        MOZ_ASSERT(staticScope);
         MOZ_ASSERT(isBlockScope);
         return staticScope->as<StaticBlockObject>();
     }
 
     bool isLoop() const {
         return type >= StmtType::DO_LOOP;
     }
 
@@ -549,35 +545,28 @@ struct StmtInfoBase {
 
 // Push the C-stack-allocated struct at stmt onto the StmtInfoPC stack.
 template <class ContextT>
 void
 PushStatement(ContextT* ct, typename ContextT::StmtInfo* stmt, StmtType type)
 {
     stmt->type = type;
     stmt->isBlockScope = false;
-    stmt->isNestedScope = false;
     stmt->isForLetBlock = false;
     stmt->label = nullptr;
     stmt->staticScope = nullptr;
     stmt->down = ct->topStmt;
     ct->topStmt = stmt;
-    if (stmt->linksScope()) {
-        stmt->downScope = ct->topScopeStmt;
-        ct->topScopeStmt = stmt;
-    } else {
-        stmt->downScope = nullptr;
-    }
+    stmt->downScope = nullptr;
 }
 
 template <class ContextT>
 void
 FinishPushNestedScope(ContextT* ct, typename ContextT::StmtInfo* stmt, NestedScopeObject& staticScope)
 {
-    stmt->isNestedScope = true;
     stmt->downScope = ct->topScopeStmt;
     ct->topScopeStmt = stmt;
     ct->staticScope = &staticScope;
     stmt->staticScope = &staticScope;
 }
 
 // Pop pc->topStmt. If the top StmtInfoPC struct is not stack-allocated, it
 // is up to the caller to free it.  The dummy argument is just to make the
@@ -585,20 +574,18 @@ FinishPushNestedScope(ContextT* ct, type
 template <class ContextT>
 void
 FinishPopStatement(ContextT* ct)
 {
     typename ContextT::StmtInfo* stmt = ct->topStmt;
     ct->topStmt = stmt->down;
     if (stmt->linksScope()) {
         ct->topScopeStmt = stmt->downScope;
-        if (stmt->isNestedScope) {
-            MOZ_ASSERT(stmt->staticScope);
+        if (stmt->staticScope)
             ct->staticScope = stmt->staticScope->enclosingNestedScope();
-        }
     }
 }
 
 /*
  * Find a lexically scoped variable (one declared by let, catch, or an array
  * comprehension) named by atom, looking in ct's compile-time scopes.
  *
  * If a WITH statement is reached along the scope stack, return its statement