Make sure to call XML methods properly in property ICs, no bug. r=dvander

This commit is contained in:
Brian Hackett 2012-01-05 12:57:06 -08:00
parent 8fddf285b4
commit ec406a6cd9
2 changed files with 18 additions and 15 deletions

View File

@ -199,6 +199,21 @@ AssertValidPropertyCacheHit(JSContext *cx, JSObject *start, JSObject *found,
{} {}
#endif #endif
inline bool
GetPropertyGenericMaybeCallXML(JSContext *cx, JSOp op, JSObject *obj, jsid id, Value *vp)
{
/*
* Various XML properties behave differently when accessed in a
* call vs. normal context, and getGeneric will not work right.
*/
#if JS_HAS_XML_SUPPORT
if (op == JSOP_CALLPROP && obj->isXML())
return js_GetXMLMethod(cx, obj, id, vp);
#endif
return obj->getGeneric(cx, id, vp);
}
inline bool inline bool
GetPropertyOperation(JSContext *cx, jsbytecode *pc, const Value &lval, Value *vp) GetPropertyOperation(JSContext *cx, jsbytecode *pc, const Value &lval, Value *vp)
{ {
@ -264,20 +279,8 @@ GetPropertyOperation(JSContext *cx, jsbytecode *pc, const Value &lval, Value *vp
jsid id = ATOM_TO_JSID(name); jsid id = ATOM_TO_JSID(name);
if (obj->getOps()->getProperty) { if (obj->getOps()->getProperty) {
#if JS_HAS_XML_SUPPORT if (!GetPropertyGenericMaybeCallXML(cx, op, obj, id, vp))
if (op == JSOP_CALLPROP && obj->isXML()) {
/*
* Various XML properties behave differently when accessed in a
* call vs. normal context, and getGeneric will not work right.
*/
if (!js_GetXMLMethod(cx, obj, id, vp))
return false; return false;
} else
#endif
{
if (!obj->getGeneric(cx, id, vp))
return false;
}
} else { } else {
if (!GetPropertyHelper(cx, obj, id, flags, vp)) if (!GetPropertyHelper(cx, obj, id, flags, vp))
return false; return false;

View File

@ -1907,7 +1907,7 @@ GetPropWithStub(VMFrame &f, ic::PICInfo *pic, VoidStubPIC stub)
} }
Value v; Value v;
if (!obj->getProperty(f.cx, name, &v)) if (!GetPropertyGenericMaybeCallXML(f.cx, JSOp(*f.pc()), obj, ATOM_TO_JSID(name), &v))
THROW(); THROW();
f.regs.sp[-1] = v; f.regs.sp[-1] = v;