Bug 1081268 - TypeArrayObject: Always use UseNewTypeForInitializer. r=bhackett

This commit is contained in:
Nicolas B. Pierron 2014-10-22 18:42:15 +02:00
parent 05127a3b4e
commit 7c76a784e5

View File

@ -308,18 +308,13 @@ class TypedArrayObjectTemplate : public TypedArrayObject
makeTypedInstance(JSContext *cx, uint32_t len, gc::AllocKind allocKind)
{
const Class *clasp = instanceClass();
if (len * sizeof(NativeType) >= TypedArrayObject::SINGLETON_TYPE_BYTE_LENGTH) {
JSObject *obj = NewBuiltinClassInstance(cx, clasp, allocKind, SingletonObject);
if (!obj)
return nullptr;
return &obj->as<TypedArrayObject>();
}
bool largeAllocation = len * sizeof(NativeType) >= TypedArrayObject::SINGLETON_TYPE_BYTE_LENGTH;
jsbytecode *pc;
RootedScript script(cx, cx->currentScript(&pc));
NewObjectKind newKind = script
? UseNewTypeForInitializer(script, pc, clasp)
: GenericObject;
: (largeAllocation ? SingletonObject : GenericObject);
RootedObject obj(cx, NewBuiltinClassInstance(cx, clasp, allocKind, newKind));
if (!obj)
return nullptr;