Bug 822442. Keep track of DOM proxies in TI, like other DOM objects, so we can do the same call/get/set optimizaations with them. r=efaust

This commit is contained in:
Boris Zbarsky 2014-04-15 22:58:45 -04:00
parent db51046224
commit 3ee63c971e
4 changed files with 18 additions and 7 deletions

View File

@ -479,6 +479,10 @@ struct Class
return flags & JSCLASS_IS_PROXY;
}
bool isDOMClass() const {
return flags & JSCLASS_IS_DOMJSCLASS;
}
static size_t offsetOfFlags() { return offsetof(Class, flags); }
};

View File

@ -3096,9 +3096,14 @@ PropertyReadNeedsTypeBarrier(types::CompilerConstraintList *constraints,
// a barrier is needed. Note that this only covers reads from properties
// which are accounted for by type information, i.e. native data properties
// and elements.
if (object->unknownProperties() || observed->empty())
//
// We also need a barrier if the object is a proxy, because then all bets
// are off, just as if it has unknown properties.
if (object->unknownProperties() || observed->empty() ||
object->clasp()->isProxy())
{
return true;
}
jsid id = name ? NameToId(name) : JSID_VOID;
types::HeapTypeSetKey property = object->property(id);

View File

@ -1763,7 +1763,7 @@ TemporaryTypeSet::isDOMClass()
unsigned count = getObjectCount();
for (unsigned i = 0; i < count; i++) {
const Class *clasp = getObjectClass(i);
if (clasp && (!(clasp->flags & JSCLASS_IS_DOMJSCLASS) || clasp->isProxy()))
if (clasp && !clasp->isDOMClass())
return false;
}

View File

@ -29,9 +29,11 @@ ProxyObject::New(JSContext *cx, BaseProxyHandler *handler, HandleValue priv, Tag
/*
* Eagerly mark properties unknown for proxies, so we don't try to track
* their properties and so that we don't need to walk the compartment if
* their prototype changes later.
* their prototype changes later. But don't do this for DOM proxies,
* because we want to be able to keep track of them in typesets in useful
* ways.
*/
if (proto.isObject() && !options.singleton()) {
if (proto.isObject() && !options.singleton() && !clasp->isDOMClass()) {
RootedObject protoObj(cx, proto.toObject());
if (!JSObject::setNewTypeUnknown(cx, clasp, protoObj))
return nullptr;
@ -49,8 +51,8 @@ ProxyObject::New(JSContext *cx, BaseProxyHandler *handler, HandleValue priv, Tag
proxy->initHandler(handler);
proxy->initCrossCompartmentPrivate(priv);
/* Don't track types of properties of proxies. */
if (newKind != SingletonObject)
/* Don't track types of properties of non-DOM and non-singleton proxies. */
if (newKind != SingletonObject && !clasp->isDOMClass())
MarkTypeObjectUnknownProperties(cx, proxy->type());
return proxy;