Bug 1339395 - Part 7: Remove no longer needed check for jsid strings which are indices from frontend. r=shu

This commit is contained in:
André Bargull 2017-04-27 09:54:03 -07:00
Родитель 9898505928
Коммит 7d957d79e2
2 изменённых файлов: 4 добавлений и 42 удалений

Просмотреть файл

@ -5919,20 +5919,9 @@ BytecodeEmitter::emitDestructuringOpsObject(ParseNode* pattern, DestructuringFla
if (!emitNumberOp(key->pn_dval)) // ... *SET RHS *LREF RHS KEY if (!emitNumberOp(key->pn_dval)) // ... *SET RHS *LREF RHS KEY
return false; return false;
} else if (key->isKind(PNK_OBJECT_PROPERTY_NAME) || key->isKind(PNK_STRING)) { } else if (key->isKind(PNK_OBJECT_PROPERTY_NAME) || key->isKind(PNK_STRING)) {
PropertyName* name = key->pn_atom->asPropertyName(); if (!emitAtomOp(key->pn_atom, JSOP_GETPROP)) // ... *SET RHS *LREF PROP
return false;
// The parser already checked for atoms representing indexes and needsGetElem = false;
// 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;
}
} else { } else {
if (!emitComputedPropertyName(key)) // ... *SET RHS *LREF RHS KEY if (!emitComputedPropertyName(key)) // ... *SET RHS *LREF RHS KEY
return false; return false;
@ -6009,17 +5998,7 @@ BytecodeEmitter::emitDestructuringObjRestExclusionSet(ParseNode* pattern)
return false; return false;
isIndex = true; isIndex = true;
} else if (key->isKind(PNK_OBJECT_PROPERTY_NAME) || key->isKind(PNK_STRING)) { } else if (key->isKind(PNK_OBJECT_PROPERTY_NAME) || key->isKind(PNK_STRING)) {
// The parser already checked for atoms representing indexes and pnatom.set(key->pn_atom);
// 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);
}
} else { } else {
// Otherwise this is a computed property name which needs to // Otherwise this is a computed property name which needs to
// be added dynamically. // be added dynamically.
@ -9906,16 +9885,6 @@ BytecodeEmitter::emitPropertyList(ParseNode* pn, MutableHandlePlainObject objp,
{ {
continue; 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 { } else {
if (!emitComputedPropertyName(key)) if (!emitComputedPropertyName(key))
return false; return false;

Просмотреть файл

@ -1348,15 +1348,8 @@ FoldElement(JSContext* cx, ParseNode** nodePtr, Parser<FullParseHandler, char16_
if (!name) if (!name)
return true; 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 // Optimization 3: We have expr["foo"] where foo is not an index. Convert
// to a property access (like expr.foo) that optimizes better downstream. // 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); ParseNode* dottedAccess = parser.handler.newPropertyAccess(expr, name, node->pn_pos.end);
if (!dottedAccess) if (!dottedAccess)
return false; return false;