Eliminate JSClass::reserveSlots and streamline new-object paths (535416, r=gal).
This commit is contained in:
@@ -388,12 +388,27 @@ Compare(T *a, T *b, size_t c)
|
||||
return true;
|
||||
}
|
||||
|
||||
static JSObject *
|
||||
static inline JSObject *
|
||||
NewIteratorObject(JSContext *cx, uintN flags)
|
||||
{
|
||||
return !(flags & JSITER_ENUMERATE)
|
||||
? NewObject(cx, &js_IteratorClass.base, NULL, NULL)
|
||||
: NewObjectWithGivenProto(cx, &js_IteratorClass.base, NULL, NULL);
|
||||
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);
|
||||
if (!obj)
|
||||
return false;
|
||||
obj->map = cx->runtime->emptyEnumeratorScope->hold();
|
||||
obj->init(&js_IteratorClass.base, NULL, NULL, JSVAL_NULL);
|
||||
return obj;
|
||||
}
|
||||
|
||||
return NewBuiltinClassInstance(cx, &js_IteratorClass.base);
|
||||
}
|
||||
|
||||
static inline void
|
||||
@@ -912,7 +927,7 @@ JSExtendedClass js_GeneratorClass = {
|
||||
JS_REQUIRES_STACK JSObject *
|
||||
js_NewGenerator(JSContext *cx)
|
||||
{
|
||||
JSObject *obj = NewObject(cx, &js_GeneratorClass.base, NULL, NULL);
|
||||
JSObject *obj = NewBuiltinClassInstance(cx, &js_GeneratorClass.base);
|
||||
if (!obj)
|
||||
return NULL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user