Bug 1339395 - Part 7: Remove no longer needed check for jsid strings which are indices from frontend. r=shu
authorAndré Bargull <andre.bargull@gmail.com>
Thu, 04 May 2017 05:05:42 -0700
changeset 572829 81097689944acad771e652f4724925b978c77657
parent 572828 cf1b369f61b87128cd484c1e0c46d1adfecbb053
child 572830 9af2b54dc7bd9b519f71671345b630b22d429d0e
push id57195
push userbmo:rbarker@mozilla.com
push dateThu, 04 May 2017 20:08:56 +0000
reviewersshu
bugs1339395
milestone55.0a1
Bug 1339395 - Part 7: Remove no longer needed check for jsid strings which are indices from frontend. r=shu
js/src/frontend/BytecodeEmitter.cpp
js/src/frontend/FoldConstants.cpp
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -5968,30 +5968,19 @@ BytecodeEmitter::emitDestructuringOpsObj
         } else {
             MOZ_ASSERT(member->isKind(PNK_COLON) || member->isKind(PNK_SHORTHAND));
 
             ParseNode* key = member->pn_left;
             if (key->isKind(PNK_NUMBER)) {
                 if (!emitNumberOp(key->pn_dval))                  // ... *SET RHS *LREF RHS KEY
                     return false;
             } else if (key->isKind(PNK_OBJECT_PROPERTY_NAME) || key->isKind(PNK_STRING)) {
-                PropertyName* name = key->pn_atom->asPropertyName();
-
-                // The parser already checked for atoms representing indexes and
-                // used PNK_NUMBER instead, but also watch for ids which TI treats
-                // as indexes for simplification of downstream analysis.
-                jsid id = NameToId(name);
-                if (id != IdToTypeId(id)) {
-                    if (!emitTree(key))                           // ... *SET RHS *LREF RHS KEY
-                        return false;
-                } else {
-                    if (!emitAtomOp(name, JSOP_GETPROP))          // ... *SET RHS *LREF PROP
-                        return false;
-                    needsGetElem = false;
-                }
+                if (!emitAtomOp(key->pn_atom, JSOP_GETPROP))      // ... *SET RHS *LREF PROP
+                    return false;
+                needsGetElem = false;
             } else {
                 if (!emitComputedPropertyName(key))               // ... *SET RHS *LREF RHS KEY
                     return false;
 
                 // Add the computed property key to the exclusion set.
                 if (needsRestPropertyExcludedSet) {
                     if (!emitDupAt(emitted + 3))                  // ... SET RHS *LREF RHS KEY SET
                         return false;
@@ -6058,27 +6047,17 @@ BytecodeEmitter::emitDestructuringObjRes
             pnatom.set(cx->names().proto);
         } else {
             ParseNode* key = member->pn_left;
             if (key->isKind(PNK_NUMBER)) {
                 if (!emitNumberOp(key->pn_dval))
                     return false;
                 isIndex = true;
             } else if (key->isKind(PNK_OBJECT_PROPERTY_NAME) || key->isKind(PNK_STRING)) {
-                // The parser already checked for atoms representing indexes and
-                // used PNK_NUMBER instead, but also watch for ids which TI treats
-                // as indexes for simplification of downstream analysis.
-                jsid id = NameToId(key->pn_atom->asPropertyName());
-                if (id != IdToTypeId(id)) {
-                    if (!emitTree(key))
-                        return false;
-                    isIndex = true;
-                } else {
-                    pnatom.set(key->pn_atom);
-                }
+                pnatom.set(key->pn_atom);
             } else {
                 // Otherwise this is a computed property name which needs to
                 // be added dynamically.
                 obj.set(nullptr);
                 continue;
             }
         }
 
@@ -9955,26 +9934,16 @@ BytecodeEmitter::emitPropertyList(ParseN
             isIndex = true;
         } else if (key->isKind(PNK_OBJECT_PROPERTY_NAME) || key->isKind(PNK_STRING)) {
             // EmitClass took care of constructor already.
             if (type == ClassBody && key->pn_atom == cx->names().constructor &&
                 !propdef->as<ClassMethod>().isStatic())
             {
                 continue;
             }
-
-            // The parser already checked for atoms representing indexes and
-            // used PNK_NUMBER instead, but also watch for ids which TI treats
-            // as indexes for simplification of downstream analysis.
-            jsid id = NameToId(key->pn_atom->asPropertyName());
-            if (id != IdToTypeId(id)) {
-                if (!emitTree(key))
-                    return false;
-                isIndex = true;
-            }
         } else {
             if (!emitComputedPropertyName(key))
                 return false;
             isIndex = true;
         }
 
         /* Emit code for the property initializer. */
         if (!emitTree(propdef->pn_right))
--- a/js/src/frontend/FoldConstants.cpp
+++ b/js/src/frontend/FoldConstants.cpp
@@ -1343,25 +1343,18 @@ FoldElement(JSContext* cx, ParseNode** n
             name = atom->asPropertyName();
         }
     }
 
     // If we don't have a name, we can't optimize to getprop.
     if (!name)
         return true;
 
-    // Also don't optimize if the name doesn't map directly to its id for TI's
-    // purposes.
-    if (NameToId(name) != IdToTypeId(NameToId(name)))
-        return true;
-
     // Optimization 3: We have expr["foo"] where foo is not an index.  Convert
     // to a property access (like expr.foo) that optimizes better downstream.
-    // Don't bother with this for names that TI considers to be indexes, to
-    // simplify downstream analysis.
     ParseNode* dottedAccess = parser.handler.newPropertyAccess(expr, name, node->pn_pos.end);
     if (!dottedAccess)
         return false;
     dottedAccess->setInParens(node->isInParens());
     ReplaceNode(nodePtr, dottedAccess);
 
     // If we've replaced |expr["prop"]| with |expr.prop|, we can now free the
     // |"prop"| and |expr["prop"]| nodes -- but not the |expr| node that we're