Remove JSObject::isNewborn, refactor object creation code, bug 684507.

This commit is contained in:
Brian Hackett
2011-11-02 13:34:19 -07:00
parent 9185686123
commit 28a34056ac
27 changed files with 432 additions and 692 deletions

View File

@@ -409,18 +409,6 @@ static inline JSObject *
NewIteratorObject(JSContext *cx, uintN flags)
{
if (flags & JSITER_ENUMERATE) {
/*
* Non-escaping native enumerator objects do not need map, proto, or
* parent. However, code in jstracer.cpp and elsewhere may find such a
* native enumerator object via the stack and (as for all objects that
* are not stillborn, with the exception of "NoSuchMethod" internal
* helper objects) expect it to have a non-null map pointer, so we
* share an empty Enumerator scope in the runtime.
*/
JSObject *obj = js_NewGCObject(cx, FINALIZE_OBJECT2);
if (!obj)
return NULL;
types::TypeObject *type = cx->compartment->getEmptyType(cx);
if (!type)
return NULL;
@@ -430,8 +418,11 @@ NewIteratorObject(JSContext *cx, uintN flags)
if (!emptyEnumeratorShape)
return NULL;
obj->init(cx, type);
obj->setInitialPropertyInfallible(emptyEnumeratorShape);
JSObject *obj = js_NewGCObject(cx, FINALIZE_OBJECT2);
if (!obj)
return NULL;
obj->initialize(emptyEnumeratorShape, type, NULL);
JS_ASSERT(obj->numFixedSlots() == JSObject::ITER_CLASS_NFIXED_SLOTS);
return obj;
@@ -1194,7 +1185,7 @@ js_NewGenerator(JSContext *cx)
JSObject *proto = global->getOrCreateGeneratorPrototype(cx);
if (!proto)
return NULL;
JSObject *obj = NewNonFunction<WithProto::Given>(cx, &GeneratorClass, proto, global);
JSObject *obj = NewObjectWithGivenProto(cx, &GeneratorClass, proto, global);
if (!obj)
return NULL;