Bug 1265770. Don't try to get a prototype for the interface object for an interface that's [NoInterfaceObject], since it's just unnecessary work that can't even be done at all in some cases (e.g. when the parent interface is also [NoInterfaceObject]). r=peterv

This commit is contained in:
Boris Zbarsky 2016-04-20 18:04:56 -04:00
parent f0c4762155
commit 2f533f506d
3 changed files with 13 additions and 3 deletions

View File

@ -882,6 +882,9 @@ CreateInterfaceObjects(JSContext* cx, JS::Handle<JSObject*> global,
MOZ_ASSERT(!(constructorClass || constructor) == !constructorCache,
"If, and only if, there is an interface object we need to cache "
"it");
MOZ_ASSERT(constructorProto || (!constructorClass && !constructor),
"Must have a constructor proto if we plan to create a constructor "
"object");
JS::Rooted<JSObject*> proto(cx);
if (protoClass) {

View File

@ -568,7 +568,9 @@ struct NamedConstructor
* global is used as the parent of the interface object and the interface
* prototype object
* protoProto is the prototype to use for the interface prototype object.
* interfaceProto is the prototype to use for the interface object.
* interfaceProto is the prototype to use for the interface object. This can be
* null if both constructorClass and constructor are null (as in,
* if we're not creating an interface object at all).
* protoClass is the JSClass to use for the interface prototype object.
* This is null if we should not create an interface prototype
* object.

View File

@ -2860,11 +2860,15 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
if needInterfaceObject:
interfaceClass = "&sInterfaceObjectClass.mBase"
interfaceCache = "&aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::%s)" % self.descriptor.name
getConstructorProto = CGGeneric(getConstructorProto)
constructorProto = "constructorProto"
else:
# We don't have slots to store the named constructors.
assert len(self.descriptor.interface.namedConstructors) == 0
interfaceClass = "nullptr"
interfaceCache = "nullptr"
getConstructorProto = None
constructorProto = "nullptr"
isGlobal = self.descriptor.isGlobal() is not None
if not isGlobal and self.properties.hasNonChromeOnly():
@ -2882,7 +2886,7 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
JS::Heap<JSObject*>* interfaceCache = ${interfaceCache};
dom::CreateInterfaceObjects(aCx, aGlobal, ${parentProto},
${protoClass}, protoCache,
constructorProto, ${interfaceClass}, ${constructHookHolder}, ${constructArgs}, ${namedConstructors},
${constructorProto}, ${interfaceClass}, ${constructHookHolder}, ${constructArgs}, ${namedConstructors},
interfaceCache,
${properties},
${chromeProperties},
@ -2892,6 +2896,7 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
protoClass=protoClass,
parentProto=parentProto,
protoCache=protoCache,
constructorProto=constructorProto,
interfaceClass=interfaceClass,
constructHookHolder=constructHookHolder,
constructArgs=constructArgs,
@ -3068,7 +3073,7 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
makeProtoPrototypeImmutable = None
return CGList(
[getParentProto, CGGeneric(getConstructorProto), initIds,
[getParentProto, getConstructorProto, initIds,
prefCache, CGGeneric(call), defineAliases, unforgeableHolderSetup,
speciesSetup, makeProtoPrototypeImmutable],
"\n").define()