Bug 1306701 - Part 0.2: Remove no longer needed destructuring helper method from BytecodeEmitter. r=Waldo
authorAndré Bargull <andre.bargull@gmail.com>
Mon, 10 Oct 2016 10:29:17 -0700
changeset 360358 d4c1417d3155cc3bc69ae984698470ea61af78b9
parent 360357 9d4004121f9c884ff6425cb746c32b3596b5bdae
child 360359 86e17a8b40d0daaa968613960860b62690d31790
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-beta@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs1306701
milestone52.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 1306701 - Part 0.2: Remove no longer needed destructuring helper method from BytecodeEmitter. r=Waldo
js/src/frontend/BytecodeEmitter.cpp
js/src/frontend/BytecodeEmitter.h
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -4330,19 +4330,19 @@ BytecodeEmitter::emitDestructuringLHS(Pa
     // destructuring initialiser-form, call ourselves to handle it, then pop
     // the matched value. Otherwise emit an lvalue bytecode sequence followed
     // by an assignment op.
     if (target->isKind(PNK_SPREAD))
         target = target->pn_kid;
     else if (target->isKind(PNK_ASSIGN))
         target = target->pn_left;
     if (target->isKind(PNK_ARRAY) || target->isKind(PNK_OBJECT)) {
-        if (!emitDestructuringOpsHelper(target, flav))
-            return false;
-        // Per its post-condition, emitDestructuringOpsHelper has left the
+        if (!emitDestructuringOps(target, flav))
+            return false;
+        // Per its post-condition, emitDestructuringOps has left the
         // to-be-destructured value on top of the stack.
         if (!emit1(JSOP_POP))
             return false;
     } else {
         switch (target->getKind()) {
           case PNK_NAME: {
             auto emitSwapScopeAndRhs = [](BytecodeEmitter* bce, const NameLocation&,
                                           bool emittedBindOp)
@@ -4509,17 +4509,17 @@ BytecodeEmitter::emitDefault(ParseNode* 
     if (!emitConditionallyExecutedTree(defaultExpr))      // DEFAULTVALUE
         return false;
     if (!emitJumpTargetAndPatch(jump))
         return false;
     return true;
 }
 
 bool
-BytecodeEmitter::emitDestructuringOpsArrayHelper(ParseNode* pattern, DestructuringFlavor flav)
+BytecodeEmitter::emitDestructuringOpsArray(ParseNode* pattern, DestructuringFlavor flav)
 {
     MOZ_ASSERT(pattern->isKind(PNK_ARRAY));
     MOZ_ASSERT(pattern->isArity(PN_LIST));
     MOZ_ASSERT(this->stackDepth != 0);
 
     // Here's pseudo code for |let [a, b, , c=y, ...d] = x;|
     //
     //   let x, y;
@@ -4776,17 +4776,17 @@ BytecodeEmitter::emitDestructuringOpsArr
 bool
 BytecodeEmitter::emitComputedPropertyName(ParseNode* computedPropName)
 {
     MOZ_ASSERT(computedPropName->isKind(PNK_COMPUTED_NAME));
     return emitTree(computedPropName->pn_kid) && emit1(JSOP_TOID);
 }
 
 bool
-BytecodeEmitter::emitDestructuringOpsObjectHelper(ParseNode* pattern, DestructuringFlavor flav)
+BytecodeEmitter::emitDestructuringOpsObject(ParseNode* pattern, DestructuringFlavor flav)
 {
     MOZ_ASSERT(pattern->isKind(PNK_OBJECT));
     MOZ_ASSERT(pattern->isArity(PN_LIST));
 
     MOZ_ASSERT(this->stackDepth > 0);                             // ... RHS
 
     if (!emitRequireObjectCoercible())                            // ... RHS
         return false;
@@ -4850,38 +4850,22 @@ BytecodeEmitter::emitDestructuringOpsObj
         // Destructure PROP per this member's subpattern.
         if (!emitDestructuringLHS(subpattern, flav))
             return false;
     }
 
     return true;
 }
 
-/*
- * Recursive helper for emitDestructuringOps.
- * EmitDestructuringOpsHelper assumes the to-be-destructured value has been
- * pushed on the stack and emits code to destructure each part of a [] or {}
- * lhs expression.
- */
-bool
-BytecodeEmitter::emitDestructuringOpsHelper(ParseNode* pattern, DestructuringFlavor flav)
+bool
+BytecodeEmitter::emitDestructuringOps(ParseNode* pattern, DestructuringFlavor flav)
 {
     if (pattern->isKind(PNK_ARRAY))
-        return emitDestructuringOpsArrayHelper(pattern, flav);
-    return emitDestructuringOpsObjectHelper(pattern, flav);
-}
-
-bool
-BytecodeEmitter::emitDestructuringOps(ParseNode* pattern, DestructuringFlavor flav)
-{
-    /*
-     * Call our recursive helper to emit the destructuring assignments and
-     * related stack manipulations.
-     */
-    return emitDestructuringOpsHelper(pattern, flav);
+        return emitDestructuringOpsArray(pattern, flav);
+    return emitDestructuringOpsObject(pattern, flav);
 }
 
 bool
 BytecodeEmitter::emitTemplateString(ParseNode* pn)
 {
     MOZ_ASSERT(pn->isArity(PN_LIST));
 
     bool pushedString = false;
@@ -4944,17 +4928,17 @@ BytecodeEmitter::emitDeclarationList(Par
             MOZ_ASSERT(decl->isOp(JSOP_NOP));
 
             ParseNode* pattern = decl->pn_left;
             MOZ_ASSERT(pattern->isKind(PNK_ARRAY) || pattern->isKind(PNK_OBJECT));
 
             if (!emitTree(decl->pn_right))
                 return false;
 
-            if (!emitDestructuringOpsHelper(pattern, DestructuringDeclaration))
+            if (!emitDestructuringOps(pattern, DestructuringDeclaration))
                 return false;
 
             if (!emit1(JSOP_POP))
                 return false;
         } else {
             if (!emitSingleDeclaration(declList, decl, decl->expr()))
                 return false;
         }
--- a/js/src/frontend/BytecodeEmitter.h
+++ b/js/src/frontend/BytecodeEmitter.h
@@ -636,27 +636,29 @@ struct MOZ_STACK_CLASS BytecodeEmitter
         // contains the function body's vars, but into its enclosing scope for
         // parameter expressions.
         DestructuringFormalParameterInVarScope,
 
         // Destructuring as part of an AssignmentExpression.
         DestructuringAssignment
     };
 
-    // EmitDestructuringLHS assumes the to-be-destructured value has been pushed on
+    // emitDestructuringLHS assumes the to-be-destructured value has been pushed on
     // the stack and emits code to destructure a single lhs expression (either a
     // name or a compound []/{} expression).
     MOZ_MUST_USE bool emitDestructuringLHS(ParseNode* target, DestructuringFlavor flav);
     MOZ_MUST_USE bool emitConditionallyExecutedDestructuringLHS(ParseNode* target,
                                                                 DestructuringFlavor flav);
 
+    // emitDestructuringOps assumes the to-be-destructured value has been
+    // pushed on the stack and emits code to destructure each part of a [] or
+    // {} lhs expression.
     MOZ_MUST_USE bool emitDestructuringOps(ParseNode* pattern, DestructuringFlavor flav);
-    MOZ_MUST_USE bool emitDestructuringOpsHelper(ParseNode* pattern, DestructuringFlavor flav);
-    MOZ_MUST_USE bool emitDestructuringOpsArrayHelper(ParseNode* pattern, DestructuringFlavor flav);
-    MOZ_MUST_USE bool emitDestructuringOpsObjectHelper(ParseNode* pattern, DestructuringFlavor flav);
+    MOZ_MUST_USE bool emitDestructuringOpsArray(ParseNode* pattern, DestructuringFlavor flav);
+    MOZ_MUST_USE bool emitDestructuringOpsObject(ParseNode* pattern, DestructuringFlavor flav);
 
     typedef bool
     (*DestructuringDeclEmitter)(BytecodeEmitter* bce, ParseNode* pn);
 
     template <typename NameEmitter>
     MOZ_MUST_USE bool emitDestructuringDeclsWithEmitter(ParseNode* pattern, NameEmitter emitName);
 
     // Throw a TypeError if the value atop the stack isn't convertible to an