Bug 556830. Fill the propcache even if we start the lookup on a Call whose parent is the global the property is on. r=jorendorff

This commit is contained in:
Boris Zbarsky 2010-04-06 15:42:39 -04:00
parent cb5afb060e
commit 1289dee978

View File

@ -4837,8 +4837,13 @@ js_FindIdentifierBase(JSContext *cx, JSObject *scopeChain, jsid id)
* property. We also stop when we reach the global object skipping any
* farther checks or lookups. For details see the JSOP_BINDNAME case of
* js_Interpret.
*
* The test order here matters because js_IsCacheableNonGlobalScope
* must not be passed a global object (i.e. one with null parent).
*/
for (int scopeIndex = 0; js_IsCacheableNonGlobalScope(obj); scopeIndex++) {
for (int scopeIndex = 0;
!obj->getParent() || js_IsCacheableNonGlobalScope(obj);
scopeIndex++) {
JSObject *pobj;
JSProperty *prop;
int protoIndex = js_LookupPropertyWithFlags(cx, obj, id,
@ -4848,7 +4853,8 @@ js_FindIdentifierBase(JSContext *cx, JSObject *scopeChain, jsid id)
return NULL;
if (prop) {
JS_ASSERT(pobj->isNative());
JS_ASSERT(OBJ_GET_CLASS(cx, pobj) == OBJ_GET_CLASS(cx, obj));
JS_ASSERT(!obj->getParent() ||
OBJ_GET_CLASS(cx, pobj) == OBJ_GET_CLASS(cx, obj));
#ifdef DEBUG
PropertyCacheEntry *entry =
#endif
@ -4859,10 +4865,10 @@ js_FindIdentifierBase(JSContext *cx, JSObject *scopeChain, jsid id)
return obj;
}
/* Call and other cacheable objects always have a parent. */
obj = obj->getParent();
if (!obj->getParent())
JSObject *parent = obj->getParent();
if (!parent)
return obj;
obj = parent;
}
/* Loop until we find a property or reach the global object. */