Bug 1398113 - Use NameToId for known property names to avoid the indexed property check in AtomToId. r=jandem

--HG--
extra : rebase_source : 1f475f02d98d6696c85207cdafb9e713743984ab
extra : histedit_source : 99612f2c6174d4d76914ea0f0fd76b9f6299fe5e
This commit is contained in:
André Bargull 2017-09-08 16:18:25 +02:00
parent 0e71aaaadf
commit aa75b0997a
5 changed files with 12 additions and 8 deletions

View File

@ -3694,8 +3694,8 @@ BytecodeEmitter::iteratorResultShape(unsigned* shape)
if (!obj)
return false;
Rooted<jsid> value_id(cx, AtomToId(cx->names().value));
Rooted<jsid> done_id(cx, AtomToId(cx->names().done));
Rooted<jsid> value_id(cx, NameToId(cx->names().value));
Rooted<jsid> done_id(cx, NameToId(cx->names().done));
if (!NativeDefineProperty(cx, obj, value_id, UndefinedHandleValue, nullptr, nullptr,
JSPROP_ENUMERATE))
{

View File

@ -47,6 +47,10 @@ AtomToId(JSAtom* atom)
return JSID_FROM_BITS(size_t(atom));
}
// Use the NameToId method instead!
inline jsid
AtomToId(PropertyName* name) = delete;
inline bool
ValueToIdPure(const Value& v, jsid* id)
{

View File

@ -1409,7 +1409,7 @@ js::proxy_revocable(JSContext* cx, unsigned argc, Value* vp)
MOZ_ASSERT(proxyVal.toObject().is<ProxyObject>());
RootedObject revoker(cx, NewFunctionByIdWithReserved(cx, RevokeProxy, 0, 0,
AtomToId(cx->names().revoke)));
NameToId(cx->names().revoke)));
if (!revoker)
return false;

View File

@ -6761,10 +6761,10 @@ DebuggerScript_getOffsetsCoverage(JSContext* cx, unsigned argc, Value* vp)
if (!result)
return false;
RootedId offsetId(cx, AtomToId(cx->names().offset));
RootedId lineNumberId(cx, AtomToId(cx->names().lineNumber));
RootedId columnNumberId(cx, AtomToId(cx->names().columnNumber));
RootedId countId(cx, AtomToId(cx->names().count));
RootedId offsetId(cx, NameToId(cx->names().offset));
RootedId lineNumberId(cx, NameToId(cx->names().lineNumber));
RootedId columnNumberId(cx, NameToId(cx->names().columnNumber));
RootedId countId(cx, NameToId(cx->names().count));
RootedObject item(cx);
RootedValue offsetValue(cx);

View File

@ -1765,7 +1765,7 @@ static bool
CombineArrayObjectElements(JSContext* cx, ArrayObject* obj, JSValueType* elementType)
{
if (obj->inDictionaryMode() ||
obj->lastProperty()->propid() != AtomToId(cx->names().length) ||
obj->lastProperty()->propid() != NameToId(cx->names().length) ||
!obj->lastProperty()->previous()->isEmptyShape())
{
// Only use an unboxed representation if the object has no properties.