Bug 1278583 part 4. Rip out the now-unused construct hook holder bits in bindings. r=peterv

This commit is contained in:
Boris Zbarsky 2016-08-03 18:32:06 -07:00
parent ab204ba73e
commit ba5962ed70
4 changed files with 31 additions and 71 deletions

View File

@ -712,7 +712,6 @@ static JSObject*
CreateInterfaceObject(JSContext* cx, JS::Handle<JSObject*> global,
JS::Handle<JSObject*> constructorProto,
const js::Class* constructorClass,
const JSNativeHolder* constructorNative,
unsigned ctorNargs, const NamedConstructor* namedConstructors,
JS::Handle<JSObject*> proto,
const NativeProperties* properties,
@ -720,37 +719,29 @@ CreateInterfaceObject(JSContext* cx, JS::Handle<JSObject*> global,
const char* name, bool defineOnGlobal)
{
JS::Rooted<JSObject*> constructor(cx);
if (constructorClass) {
MOZ_ASSERT(constructorProto);
constructor = JS_NewObjectWithGivenProto(cx, Jsvalify(constructorClass),
constructorProto);
} else {
MOZ_ASSERT(constructorNative);
MOZ_ASSERT(constructorProto == JS_GetFunctionPrototype(cx, global));
constructor = CreateConstructor(cx, global, name, constructorNative,
ctorNargs);
}
MOZ_ASSERT(constructorProto);
MOZ_ASSERT(constructorClass);
constructor = JS_NewObjectWithGivenProto(cx, Jsvalify(constructorClass),
constructorProto);
if (!constructor) {
return nullptr;
}
if (constructorClass) {
if (!JS_DefineProperty(cx, constructor, "length", ctorNargs,
JSPROP_READONLY)) {
return nullptr;
}
if (!JS_DefineProperty(cx, constructor, "length", ctorNargs,
JSPROP_READONLY)) {
return nullptr;
}
// Might as well intern, since we're going to need an atomized
// version of name anyway when we stick our constructor on the
// global.
JS::Rooted<JSString*> nameStr(cx, JS_AtomizeAndPinString(cx, name));
if (!nameStr) {
return nullptr;
}
// Might as well intern, since we're going to need an atomized
// version of name anyway when we stick our constructor on the
// global.
JS::Rooted<JSString*> nameStr(cx, JS_AtomizeAndPinString(cx, name));
if (!nameStr) {
return nullptr;
}
if (!JS_DefineProperty(cx, constructor, "name", nameStr, JSPROP_READONLY)) {
return nullptr;
}
if (!JS_DefineProperty(cx, constructor, "name", nameStr, JSPROP_READONLY)) {
return nullptr;
}
if (properties) {
@ -914,7 +905,7 @@ CreateInterfaceObjects(JSContext* cx, JS::Handle<JSObject*> global,
JS::Handle<JSObject*> protoProto,
const js::Class* protoClass, JS::Heap<JSObject*>* protoCache,
JS::Handle<JSObject*> constructorProto,
const js::Class* constructorClass, const JSNativeHolder* constructor,
const js::Class* constructorClass,
unsigned ctorNargs, const NamedConstructor* namedConstructors,
JS::Heap<JSObject*>* constructorCache,
const NativeProperties* properties,
@ -923,8 +914,8 @@ CreateInterfaceObjects(JSContext* cx, JS::Handle<JSObject*> global,
const char* const* unscopableNames,
bool isGlobal)
{
MOZ_ASSERT(protoClass || constructorClass || constructor,
"Need at least one class or a constructor!");
MOZ_ASSERT(protoClass || constructorClass,
"Need at least one class!");
MOZ_ASSERT(!((properties &&
(properties->HasMethods() || properties->HasAttributes())) ||
(chromeOnlyProperties &&
@ -937,18 +928,17 @@ CreateInterfaceObjects(JSContext* cx, JS::Handle<JSObject*> global,
(chromeOnlyProperties &&
(chromeOnlyProperties->HasStaticMethods() ||
chromeOnlyProperties->HasStaticAttributes()))) ||
constructorClass || constructor,
"Static methods but no constructorClass or constructor!");
MOZ_ASSERT(bool(name) == bool(constructorClass || constructor),
constructorClass,
"Static methods but no constructorClass!");
MOZ_ASSERT(bool(name) == bool(constructorClass),
"Must have name precisely when we have an interface object");
MOZ_ASSERT(!constructorClass || !constructor);
MOZ_ASSERT(!protoClass == !protoCache,
"If, and only if, there is an interface prototype object we need "
"to cache it");
MOZ_ASSERT(!(constructorClass || constructor) == !constructorCache,
MOZ_ASSERT(bool(constructorClass) == bool(constructorCache),
"If, and only if, there is an interface object we need to cache "
"it");
MOZ_ASSERT(constructorProto || (!constructorClass && !constructor),
MOZ_ASSERT(constructorProto || !constructorClass,
"Must have a constructor proto if we plan to create a constructor "
"object");
@ -969,11 +959,11 @@ CreateInterfaceObjects(JSContext* cx, JS::Handle<JSObject*> global,
}
JSObject* interface;
if (constructorClass || constructor) {
if (constructorClass) {
interface = CreateInterfaceObject(cx, global, constructorProto,
constructorClass, constructor,
ctorNargs, namedConstructors, proto,
properties, chromeOnlyProperties, name,
constructorClass, ctorNargs,
namedConstructors, proto, properties,
chromeOnlyProperties, name,
defineOnGlobal);
if (!interface) {
if (protoCache) {

View File

@ -613,7 +613,7 @@ CreateInterfaceObjects(JSContext* cx, JS::Handle<JSObject*> global,
JS::Handle<JSObject*> protoProto,
const js::Class* protoClass, JS::Heap<JSObject*>* protoCache,
JS::Handle<JSObject*> interfaceProto,
const js::Class* constructorClass, const JSNativeHolder* constructor,
const js::Class* constructorClass,
unsigned ctorNargs, const NamedConstructor* namedConstructors,
JS::Heap<JSObject*>* constructorCache,
const NativeProperties* regularProperties,

View File

@ -1716,24 +1716,6 @@ class CGConstructNavigatorObject(CGAbstractMethod):
""") + genConstructorBody(self.descriptor)
class CGClassConstructHookHolder(CGGeneric):
def __init__(self, descriptor):
if descriptor.interface.ctor():
constructHook = CONSTRUCT_HOOK_NAME
else:
constructHook = "ThrowingConstructor"
CGGeneric.__init__(self, fill(
"""
static const JSNativeHolder ${CONSTRUCT_HOOK_NAME}_holder = {
${constructHook},
${hooks}
};
""",
CONSTRUCT_HOOK_NAME=CONSTRUCT_HOOK_NAME,
constructHook=constructHook,
hooks=NativePropertyHooks(descriptor)))
def NamedConstructorName(m):
return '_' + m.identifier.name
@ -2792,11 +2774,6 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
else:
prefCache = None
if (needInterfaceObject and
self.descriptor.needsConstructHookHolder()):
constructHookHolder = "&" + CONSTRUCT_HOOK_NAME + "_holder"
else:
constructHookHolder = "nullptr"
if self.descriptor.interface.ctor():
constructArgs = methodLength(self.descriptor.interface.ctor())
else:
@ -2846,7 +2823,7 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
JS::Heap<JSObject*>* interfaceCache = ${interfaceCache};
dom::CreateInterfaceObjects(aCx, aGlobal, ${parentProto},
${protoClass}, protoCache,
${constructorProto}, ${interfaceClass}, ${constructHookHolder}, ${constructArgs}, ${namedConstructors},
${constructorProto}, ${interfaceClass}, ${constructArgs}, ${namedConstructors},
interfaceCache,
${properties},
${chromeProperties},
@ -2859,7 +2836,6 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
protoCache=protoCache,
constructorProto=constructorProto,
interfaceClass=interfaceClass,
constructHookHolder=constructHookHolder,
constructArgs=constructArgs,
namedConstructors=namedConstructors,
interfaceCache=interfaceCache,
@ -12000,8 +11976,6 @@ class CGDescriptor(CGThing):
descriptor.interface.ctor()))
cgThings.append(CGClassHasInstanceHook(descriptor))
cgThings.append(CGInterfaceObjectJSClass(descriptor, properties))
if descriptor.needsConstructHookHolder():
cgThings.append(CGClassConstructHookHolder(descriptor))
cgThings.append(CGNamedConstructors(descriptor))
cgThings.append(CGLegacyCallHook(descriptor))

View File

@ -602,10 +602,6 @@ class Descriptor(DescriptorProvider):
def hasNonOrdinaryGetPrototypeOf(self):
return self.interface.getExtendedAttribute("NonOrdinaryGetPrototypeOf")
def needsConstructHookHolder(self):
assert self.interface.hasInterfaceObject()
return False
def needsHeaderInclude(self):
"""
An interface doesn't need a header file if it is not concrete, not