Skip to content

Commit 2bded32

Browse files
committed
Do not reuse by resetting the JavascriptStaticEnumerator in the ForInObjectEnumerator
Even if the type match, the object may have change to have array index, producing wrong result. Since we now have an instance of the DynamicObjectPropertyEnumerator in the JavascriptStaticEnumerator already, reset doesn't really gain us much. So just remove it.
1 parent abd6d13 commit 2bded32

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

lib/Runtime/Library/ForInObjectEnumerator.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,16 @@ namespace Js
3737
enumerator.Clear();
3838
this->object = nullptr;
3939
this->baseObject = nullptr;
40-
this->baseObjectType = nullptr;
4140
this->firstPrototype = nullptr;
4241
return;
4342
}
4443

4544
Assert(JavascriptOperators::GetTypeId(currentObject) != TypeIds_Null
4645
&& JavascriptOperators::GetTypeId(currentObject) != TypeIds_Undefined);
4746

48-
if (this->object == currentObject &&
49-
this->baseObjectType == currentObject->GetType())
50-
{
51-
// We can re-use the enumerator, only if the 'object' and type from the previous enumeration
52-
// remains the same. If the previous enumeration involved prototype enumeration
53-
// 'object' and 'currentEnumerator' would represent the prototype. Hence,
54-
// we cannot re-use it. Null objects are always equal, therefore, the enumerator cannot
55-
// be re-used.
56-
enumerator.Reset();
57-
}
58-
else
59-
{
60-
this->baseObjectType = currentObject->GetType();
61-
this->object = currentObject;
47+
this->object = currentObject;
6248

63-
InitializeCurrentEnumerator();
64-
}
49+
InitializeCurrentEnumerator();
6550

6651
this->baseObject = currentObject;
6752
firstPrototype = GetFirstPrototypeWithEnumerableProperties(object);

lib/Runtime/Library/ForInObjectEnumerator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ namespace Js
1515
BVSparse<Recycler>* propertyIds;
1616
RecyclableObject *firstPrototype;
1717
Var currentIndex;
18-
Type* baseObjectType;
1918
SListBase<Js::PropertyRecord const *> newPropertyStrings;
2019
ScriptContext * scriptContext;
2120
bool enumSymbols;

0 commit comments

Comments
 (0)