Bug 1217001 - Part 8: Eliminate all uses of PNX_POPVAR. r=shu.
authorJason Orendorff <jorendorff@mozilla.com>
Wed, 14 Oct 2015 18:47:02 -0500
changeset 305301 1e0dcdea04ffe410ee31a565b80de1e1ab4c9093
parent 305300 b5e96d501788e41f3d7d305dd3cff384e8dd3ae7
child 305302 f7d59de65bcd8300135a7abbd1aef8fb4a526592
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshu
bugs1217001
milestone44.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 1217001 - Part 8: Eliminate all uses of PNX_POPVAR. r=shu.
js/src/frontend/BytecodeEmitter.cpp
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -4249,22 +4249,24 @@ BytecodeEmitter::emitVariables(ParseNode
                     return false;
             } else {
                 // We're emitting destructuring let binding initialization
                 // for a legacy comprehension expression. See
                 // emitForInOrOfVariables.
 
                 // Lexical bindings cannot be used before they are
                 // initialized. Similar to the JSOP_INITLEXICAL case below.
-                MOZ_ASSERT(emitOption != DefineVars);
-                MOZ_ASSERT_IF(emitOption == InitializeVars, pn->pn_xflags & PNX_POPVAR);
+                MOZ_ASSERT(emitOption == InitializeVars);
+                MOZ_ASSERT(pn->pn_xflags & PNX_POPVAR);
                 if (!emit1(JSOP_UNDEFINED))
                     return false;
                 if (!emitInitializeDestructuringDecls(pn->getOp(), binding))
                     return false;
+                if (!emit1(JSOP_POP))
+                    return false;
             }
         } else if (binding->isKind(PNK_ASSIGN)) {
             /*
              * A destructuring initialiser assignment preceded by var will
              * never occur to the left of 'in' in a for-in loop.  As with 'for
              * (var x = i in o)...', this will cause the entire 'var [a, b] =
              * i' to be hoisted out of the loop.
              */
@@ -4286,16 +4288,23 @@ BytecodeEmitter::emitVariables(ParseNode
             if (!emitDestructuringDecls(pn->getOp(), initializer))
                 return false;
 
             if (!emitTree(binding->pn_right))
                 return false;
 
             if (!emitDestructuringOps(initializer, isLetExpr))
                 return false;
+
+            MOZ_ASSERT_IF(emitOption == InitializeVars, pn->pn_xflags & PNX_POPVAR);
+            MOZ_ASSERT_IF(pn->pn_xflags & PNX_POPVAR, emitOption == InitializeVars);
+            if (emitOption == InitializeVars) {
+                if (!emit1(JSOP_POP))
+                    return false;
+            }
         } else {
             /*
              * Load initializer early to share code above that jumps to
              * do_name. NB: if this var redeclares an existing binding, then
              * `binding` is linked on its definition's use-chain and pn_expr
              * has been overlayed with pn_lexdef.
              */
             initializer = binding->maybeExpr();
@@ -4345,40 +4354,32 @@ BytecodeEmitter::emitVariables(ParseNode
                 MOZ_ASSERT(emitOption != DefineVars);
                 MOZ_ASSERT_IF(emitOption == InitializeVars, pn->pn_xflags & PNX_POPVAR);
                 if (!emit1(JSOP_UNDEFINED))
                     return false;
             }
 
             // If we are not initializing, nothing to pop. If we are initializing
             // lets, we must emit the pops.
+            MOZ_ASSERT_IF(emitOption == InitializeVars, (pn->pn_xflags & PNX_POPVAR) != 0);
+            MOZ_ASSERT_IF((pn->pn_xflags & PNX_POPVAR) != 0, emitOption == InitializeVars);
             if (emitOption == InitializeVars) {
                 MOZ_ASSERT_IF(binding->isDefn(), initializer == binding->pn_expr);
                 if (!binding->pn_scopecoord.isFree()) {
                     if (!emitVarOp(binding, op))
                         return false;
                 } else {
                     if (!emitIndexOp(op, atomIndex))
                         return false;
                 }
+                if (!emit1(JSOP_POP))
+                    return false;
             }
         }
-
-        MOZ_ASSERT_IF(emitOption == InitializeVars, pn->pn_xflags & PNX_POPVAR);
-        if (next && emitOption == InitializeVars) {
-            if (!emit1(JSOP_POP))
-                return false;
-        }
-    }
-
-    if (pn->pn_xflags & PNX_POPVAR) {
-        if (!emit1(JSOP_POP))
-            return false;
-    }
-
+    }
     return true;
 }
 
 bool
 BytecodeEmitter::emitAssignment(ParseNode* lhs, JSOp op, ParseNode* rhs)
 {
     /*
      * Check left operand type and generate specialized code for it.