Bug 1130811 - Make addArrayElement infallible, 'cause it is. r=efaust
authorJeff Walden <jwalden@mit.edu>
Tue, 10 Feb 2015 01:00:01 -0800
changeset 256871 5c7e45daf893d5a7de008ef0195c2c208794f7a6
parent 256870 688f46924277905d06c9576a80d1b04fcc1798e7
child 256872 a382317116055ef03ca9f288b6da836a441a1144
push id4610
push userjlund@mozilla.com
push dateMon, 30 Mar 2015 18:32:55 +0000
treeherdermozilla-beta@4df54044d9ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersefaust
bugs1130811
milestone38.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 1130811 - Make addArrayElement infallible, 'cause it is. r=efaust
js/src/frontend/FullParseHandler.h
js/src/frontend/Parser.cpp
js/src/frontend/SyntaxParseHandler.h
--- a/js/src/frontend/FullParseHandler.h
+++ b/js/src/frontend/FullParseHandler.h
@@ -132,29 +132,26 @@ class FullParseHandler
         ParseNode *callSite = new_<CallSiteNode>(begin);
         if (!callSite)
             return null();
 
         Node propExpr = newArrayLiteral(getPosition(callSite).begin, blockidGen);
         if (!propExpr)
             return null();
 
-        if (!addArrayElement(callSite, propExpr))
-            return null();
+        addArrayElement(callSite, propExpr);
 
         return callSite;
     }
 
     bool addToCallSiteObject(ParseNode *callSiteObj, ParseNode *rawNode, ParseNode *cookedNode) {
         MOZ_ASSERT(callSiteObj->isKind(PNK_CALLSITEOBJ));
 
-        if (!addArrayElement(callSiteObj, cookedNode))
-            return false;
-        if (!addArrayElement(callSiteObj->pn_head, rawNode))
-            return false;
+        addArrayElement(callSiteObj, cookedNode);
+        addArrayElement(callSiteObj->pn_head, rawNode);
 
         /*
          * We don't know when the last noSubstTemplate will come in, and we
          * don't want to deal with this outside this method
          */
         setEndPosition(callSiteObj, callSiteObj->pn_head);
         return true;
     }
@@ -265,21 +262,20 @@ class FullParseHandler
         ParseNode *spread = new_<UnaryNode>(PNK_SPREAD, JSOP_NOP, pos, inner);
         if (!spread)
             return null();
         literal->append(spread);
         literal->pn_xflags |= PNX_SPECIALARRAYINIT | PNX_NONCONST;
         return true;
     }
 
-    bool addArrayElement(ParseNode *literal, ParseNode *element) {
+    void addArrayElement(ParseNode *literal, ParseNode *element) {
         if (!element->isConstant())
             literal->pn_xflags |= PNX_NONCONST;
         literal->append(element);
-        return true;
     }
 
     ParseNode *newObjectLiteral(uint32_t begin) {
         ParseNode *literal = new_<ListNode>(PNK_OBJECT, TokenPos(begin, begin + 1));
         // Later in this stack: remove dependency on this opcode.
         if (literal)
             literal->setOp(JSOP_NEWINIT);
         return literal;
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -7765,18 +7765,17 @@ Parser<ParseHandler>::arrayInitializer()
                 if (!handler.addSpreadElement(literal, begin, inner))
                     return null();
             } else {
                 Node element = assignExpr();
                 if (!element)
                     return null();
                 if (foldConstants && !FoldConstants(context, &element, this))
                     return null();
-                if (!handler.addArrayElement(literal, element))
-                    return null();
+                handler.addArrayElement(literal, element);
             }
 
             if (tt != TOK_COMMA) {
                 /* If we didn't already match TOK_COMMA in above case. */
                 bool matched;
                 if (!tokenStream.matchToken(&matched, TOK_COMMA))
                     return null();
                 if (!matched) {
--- a/js/src/frontend/SyntaxParseHandler.h
+++ b/js/src/frontend/SyntaxParseHandler.h
@@ -175,17 +175,17 @@ class SyntaxParseHandler
     // Expressions
 
     Node newArrayComprehension(Node body, unsigned blockid, const TokenPos &pos) {
         return NodeGeneric;
     }
     Node newArrayLiteral(uint32_t begin, unsigned blockid) { return NodeGeneric; }
     bool addElision(Node literal, const TokenPos &pos) { return true; }
     bool addSpreadElement(Node literal, uint32_t begin, Node inner) { return true; }
-    bool addArrayElement(Node literal, Node element) { return true; }
+    void addArrayElement(Node literal, Node element) { }
 
     Node newObjectLiteral(uint32_t begin) { return NodeGeneric; }
     bool addPrototypeMutation(Node literal, uint32_t begin, Node expr) { return true; }
     bool addPropertyDefinition(Node literal, Node name, Node expr, bool isShorthand = false) { return true; }
     bool addMethodDefinition(Node literal, Node name, Node fn, JSOp op) { return true; }
     Node newYieldExpression(uint32_t begin, Node value, Node gen) { return NodeUnparenthesizedYieldExpr; }
     Node newYieldStarExpression(uint32_t begin, Node value, Node gen) { return NodeGeneric; }