Bug 1132149 - Handlify the proto arg for NewArray; r=sfink

--HG--
extra : rebase_source : debf452d21e075cf2cae296fc1579cd44221fd30
This commit is contained in:
Terrence Cole 2015-02-11 12:54:32 -08:00
Родитель f6e7bab9dc
Коммит 28c16a726b
12 изменённых файлов: 44 добавлений и 44 удалений

Просмотреть файл

@ -927,7 +927,7 @@ StructMetaTypeDescr::create(JSContext *cx,
{
RootedObject fieldNamesVec(cx);
fieldNamesVec = NewDenseCopiedArray(cx, fieldNames.length(),
fieldNames.begin(), nullptr,
fieldNames.begin(), NullPtr(),
TenuredObject);
if (!fieldNamesVec)
return nullptr;
@ -939,7 +939,7 @@ StructMetaTypeDescr::create(JSContext *cx,
{
RootedObject fieldTypeVec(cx);
fieldTypeVec = NewDenseCopiedArray(cx, fieldTypeObjs.length(),
fieldTypeObjs.begin(), nullptr,
fieldTypeObjs.begin(), NullPtr(),
TenuredObject);
if (!fieldTypeVec)
return nullptr;
@ -951,7 +951,7 @@ StructMetaTypeDescr::create(JSContext *cx,
{
RootedObject fieldOffsetsVec(cx);
fieldOffsetsVec = NewDenseCopiedArray(cx, fieldOffsets.length(),
fieldOffsets.begin(), nullptr,
fieldOffsets.begin(), NullPtr(),
TenuredObject);
if (!fieldOffsetsVec)
return nullptr;

Просмотреть файл

@ -4271,7 +4271,8 @@ ParseNode::getConstantValue(ExclusiveContext *cx, AllowConstantObjects allowObje
pn = pn_head;
}
RootedArrayObject obj(cx, NewDenseFullyAllocatedArray(cx, count, nullptr, MaybeSingletonObject));
RootedArrayObject obj(cx, NewDenseFullyAllocatedArray(cx, count, NullPtr(),
MaybeSingletonObject));
if (!obj)
return false;

Просмотреть файл

@ -1749,7 +1749,7 @@ BaselineCompiler::emit_JSOP_NEWARRAY()
masm.move32(Imm32(length), R0.scratchReg());
masm.movePtr(ImmGCPtr(group), R1.scratchReg());
ArrayObject *templateObject = NewDenseUnallocatedArray(cx, length, nullptr, TenuredObject);
ArrayObject *templateObject = NewDenseUnallocatedArray(cx, length, NullPtr(), TenuredObject);
if (!templateObject)
return false;
templateObject->setGroup(group);
@ -1876,7 +1876,7 @@ BaselineCompiler::emit_JSOP_NEWINIT()
masm.move32(Imm32(0), R0.scratchReg());
masm.movePtr(ImmGCPtr(group), R1.scratchReg());
ArrayObject *templateObject = NewDenseUnallocatedArray(cx, 0, nullptr, TenuredObject);
ArrayObject *templateObject = NewDenseUnallocatedArray(cx, 0, NullPtr(), TenuredObject);
if (!templateObject)
return false;
templateObject->setGroup(group);
@ -3378,7 +3378,7 @@ BaselineCompiler::emit_JSOP_REST()
{
frame.syncStack(0);
ArrayObject *templateObject = NewDenseUnallocatedArray(cx, 0, nullptr, TenuredObject);
ArrayObject *templateObject = NewDenseUnallocatedArray(cx, 0, NullPtr(), TenuredObject);
if (!templateObject)
return false;
ObjectGroup::fixRestArgumentsGroup(cx, templateObject);

Просмотреть файл

@ -9114,7 +9114,7 @@ GetTemplateObjectForNative(JSContext *cx, HandleScript script, jsbytecode *pc,
count = args.length();
else if (args.length() == 1 && args[0].isInt32() && args[0].toInt32() >= 0)
count = args[0].toInt32();
res.set(NewDenseUnallocatedArray(cx, count, nullptr, TenuredObject));
res.set(NewDenseUnallocatedArray(cx, count, NullPtr(), TenuredObject));
if (!res)
return false;
@ -9126,7 +9126,7 @@ GetTemplateObjectForNative(JSContext *cx, HandleScript script, jsbytecode *pc,
}
if (native == intrinsic_NewDenseArray) {
res.set(NewDenseUnallocatedArray(cx, 0, nullptr, TenuredObject));
res.set(NewDenseUnallocatedArray(cx, 0, NullPtr(), TenuredObject));
if (!res)
return false;
@ -9141,7 +9141,8 @@ GetTemplateObjectForNative(JSContext *cx, HandleScript script, jsbytecode *pc,
if (args.thisv().isObject() && args.thisv().toObject().is<ArrayObject>() &&
!args.thisv().toObject().isSingleton())
{
res.set(NewDenseEmptyArray(cx, args.thisv().toObject().getProto(), TenuredObject));
RootedObject proto(cx, args.thisv().toObject().getProto());
res.set(NewDenseEmptyArray(cx, proto, TenuredObject));
if (!res)
return false;
res->setGroup(args.thisv().toObject().group());
@ -9150,7 +9151,7 @@ GetTemplateObjectForNative(JSContext *cx, HandleScript script, jsbytecode *pc,
}
if (native == js::str_split && args.length() == 1 && args[0].isString()) {
res.set(NewDenseUnallocatedArray(cx, 0, nullptr, TenuredObject));
res.set(NewDenseUnallocatedArray(cx, 0, NullPtr(), TenuredObject));
if (!res)
return false;
@ -9460,7 +9461,7 @@ CopyArray(JSContext *cx, HandleArrayObject obj, MutableHandleValue result)
if (!group)
return false;
RootedArrayObject newObj(cx, NewDenseFullyAllocatedArray(cx, length, nullptr, TenuredObject));
RootedArrayObject newObj(cx, NewDenseFullyAllocatedArray(cx, length, NullPtr(), TenuredObject));
if (!newObj)
return false;
@ -12220,7 +12221,7 @@ static bool DoRestFallback(JSContext *cx, ICRest_Fallback *stub,
unsigned numRest = numActuals > numFormals ? numActuals - numFormals : 0;
Value *rest = frame->argv() + numFormals;
ArrayObject *obj = NewDenseCopiedArray(cx, numRest, rest, nullptr);
ArrayObject *obj = NewDenseCopiedArray(cx, numRest, rest, NullPtr());
if (!obj)
return false;
ObjectGroup::fixRestArgumentsGroup(cx, obj);

Просмотреть файл

@ -913,7 +913,7 @@ InitRestParameter(JSContext *cx, uint32_t length, Value *rest, HandleObject temp
NewObjectKind newKind = templateObj->group()->shouldPreTenure()
? TenuredObject
: GenericObject;
ArrayObject *arrRes = NewDenseCopiedArray(cx, length, rest, nullptr, newKind);
ArrayObject *arrRes = NewDenseCopiedArray(cx, length, rest, NullPtr(), newKind);
if (arrRes)
arrRes->setGroup(templateObj->group());
return arrRes;

Просмотреть файл

@ -3332,7 +3332,7 @@ EnsureNewArrayElements(ExclusiveContext *cx, ArrayObject *obj, uint32_t length)
template <uint32_t maxLength>
static MOZ_ALWAYS_INLINE ArrayObject *
NewArray(ExclusiveContext *cxArg, uint32_t length,
JSObject *protoArg, NewObjectKind newKind = GenericObject)
HandleObject protoArg, NewObjectKind newKind = GenericObject)
{
gc::AllocKind allocKind = GuessArrayGCKind(length);
MOZ_ASSERT(CanBeFinalizedInBackground(allocKind, &ArrayObject::class_));
@ -3361,10 +3361,8 @@ NewArray(ExclusiveContext *cxArg, uint32_t length,
}
return arr;
} else {
RootedObject proto(cxArg, protoArg);
obj = cache.newObjectFromHit<CanGC>(cx, entry, heap);
MOZ_ASSERT(!obj);
protoArg = proto;
}
} else {
gcNumber = rt->gc.gcNumber();
@ -3372,9 +3370,6 @@ NewArray(ExclusiveContext *cxArg, uint32_t length,
}
RootedObject proto(cxArg, protoArg);
if (protoArg)
JS::PoisonPtr(&protoArg);
if (!proto && !GetBuiltinPrototype(cxArg, JSProto_Array, &proto))
return nullptr;
@ -3428,7 +3423,7 @@ NewArray(ExclusiveContext *cxArg, uint32_t length,
}
ArrayObject * JS_FASTCALL
js::NewDenseEmptyArray(JSContext *cx, JSObject *proto /* = nullptr */,
js::NewDenseEmptyArray(JSContext *cx, HandleObject proto /* = NullPtr() */,
NewObjectKind newKind /* = GenericObject */)
{
return NewArray<0>(cx, 0, proto, newKind);
@ -3436,7 +3431,7 @@ js::NewDenseEmptyArray(JSContext *cx, JSObject *proto /* = nullptr */,
ArrayObject * JS_FASTCALL
js::NewDenseFullyAllocatedArray(ExclusiveContext *cx, uint32_t length,
JSObject *proto /* = nullptr */,
HandleObject proto /* = NullPtr() */,
NewObjectKind newKind /* = GenericObject */)
{
return NewArray<NativeObject::NELEMENTS_LIMIT>(cx, length, proto, newKind);
@ -3444,14 +3439,15 @@ js::NewDenseFullyAllocatedArray(ExclusiveContext *cx, uint32_t length,
ArrayObject * JS_FASTCALL
js::NewDensePartlyAllocatedArray(ExclusiveContext *cx, uint32_t length,
JSObject *proto /* = nullptr */,
HandleObject proto /* = NullPtr() */,
NewObjectKind newKind /* = GenericObject */)
{
return NewArray<ArrayObject::EagerAllocationMaxLength>(cx, length, proto, newKind);
}
ArrayObject * JS_FASTCALL
js::NewDenseUnallocatedArray(ExclusiveContext *cx, uint32_t length, JSObject *proto /* = nullptr */,
js::NewDenseUnallocatedArray(ExclusiveContext *cx, uint32_t length,
HandleObject proto /* = NullPtr() */,
NewObjectKind newKind /* = GenericObject */)
{
return NewArray<0>(cx, length, proto, newKind);
@ -3467,12 +3463,12 @@ js::NewDenseArray(ExclusiveContext *cx, uint32_t length, HandleObjectGroup group
ArrayObject *arr;
if (allocating == NewArray_Unallocating) {
arr = NewDenseUnallocatedArray(cx, length, nullptr, newKind);
arr = NewDenseUnallocatedArray(cx, length, NullPtr(), newKind);
} else if (allocating == NewArray_PartlyAllocating) {
arr = NewDensePartlyAllocatedArray(cx, length, nullptr, newKind);
arr = NewDensePartlyAllocatedArray(cx, length, NullPtr(), newKind);
} else {
MOZ_ASSERT(allocating == NewArray_FullyAllocating);
arr = NewDenseFullyAllocatedArray(cx, length, nullptr, newKind);
arr = NewDenseFullyAllocatedArray(cx, length, NullPtr(), newKind);
}
if (!arr)
return nullptr;
@ -3490,7 +3486,7 @@ js::NewDenseArray(ExclusiveContext *cx, uint32_t length, HandleObjectGroup group
ArrayObject *
js::NewDenseCopiedArray(JSContext *cx, uint32_t length, HandleArrayObject src,
uint32_t elementOffset, JSObject *proto /* = nullptr */)
uint32_t elementOffset, HandleObject proto /* = NullPtr() */)
{
MOZ_ASSERT(!src->isIndexed());
@ -3512,7 +3508,8 @@ js::NewDenseCopiedArray(JSContext *cx, uint32_t length, HandleArrayObject src,
// values must point at already-rooted Value objects
ArrayObject *
js::NewDenseCopiedArray(JSContext *cx, uint32_t length, const Value *values,
JSObject *proto /* = nullptr */, NewObjectKind newKind /* = GenericObject */)
HandleObject proto /* = NullPtr() */,
NewObjectKind newKind /* = GenericObject */)
{
ArrayObject *arr = NewArray<NativeObject::NELEMENTS_LIMIT>(cx, length, proto);
if (!arr)

Просмотреть файл

@ -45,7 +45,7 @@ class ArrayObject;
/* Create a dense array with no capacity allocated, length set to 0. */
extern ArrayObject * JS_FASTCALL
NewDenseEmptyArray(JSContext *cx, JSObject *proto = nullptr,
NewDenseEmptyArray(JSContext *cx, HandleObject proto = NullPtr(),
NewObjectKind newKind = GenericObject);
/*
@ -53,7 +53,7 @@ NewDenseEmptyArray(JSContext *cx, JSObject *proto = nullptr,
* contents. This is useful, e.g., when accepting length from the user.
*/
extern ArrayObject * JS_FASTCALL
NewDenseUnallocatedArray(ExclusiveContext *cx, uint32_t length, JSObject *proto = nullptr,
NewDenseUnallocatedArray(ExclusiveContext *cx, uint32_t length, HandleObject proto = NullPtr(),
NewObjectKind newKind = GenericObject);
/*
@ -61,12 +61,12 @@ NewDenseUnallocatedArray(ExclusiveContext *cx, uint32_t length, JSObject *proto
* but with only |EagerAllocationMaxLength| elements allocated.
*/
extern ArrayObject * JS_FASTCALL
NewDensePartlyAllocatedArray(ExclusiveContext *cx, uint32_t length, JSObject *proto = nullptr,
NewDensePartlyAllocatedArray(ExclusiveContext *cx, uint32_t length, HandleObject proto = NullPtr(),
NewObjectKind newKind = GenericObject);
/* Create a dense array with length and capacity == 'length', initialized length set to 0. */
extern ArrayObject * JS_FASTCALL
NewDenseFullyAllocatedArray(ExclusiveContext *cx, uint32_t length, JSObject *proto = nullptr,
NewDenseFullyAllocatedArray(ExclusiveContext *cx, uint32_t length, HandleObject proto = NullPtr(),
NewObjectKind newKind = GenericObject);
enum AllocatingBehaviour {
@ -86,12 +86,12 @@ NewDenseArray(ExclusiveContext *cx, uint32_t length, HandleObjectGroup group,
/* Create a dense array with a copy of the dense array elements in src. */
extern ArrayObject *
NewDenseCopiedArray(JSContext *cx, uint32_t length, HandleArrayObject src,
uint32_t elementOffset, JSObject *proto = nullptr);
uint32_t elementOffset, HandleObject proto = NullPtr());
/* Create a dense array from the given array values, which must be rooted */
extern ArrayObject *
NewDenseCopiedArray(JSContext *cx, uint32_t length, const Value *values, JSObject *proto = nullptr,
NewObjectKind newKind = GenericObject);
NewDenseCopiedArray(JSContext *cx, uint32_t length, const Value *values,
HandleObject proto = NullPtr(), NewObjectKind newKind = GenericObject);
/* Create a dense array based on templateObject with the given length. */
extern ArrayObject *

Просмотреть файл

@ -1821,7 +1821,7 @@ js::DeepCloneObjectLiteral(JSContext *cx, HandleNativeObject obj, NewObjectKind
RootedNativeObject deepObj(cx);
if (obj->is<ArrayObject>()) {
clone = NewDenseUnallocatedArray(cx, obj->as<ArrayObject>().length(), nullptr, newKind);
clone = NewDenseUnallocatedArray(cx, obj->as<ArrayObject>().length(), NullPtr(), newKind);
} else {
// Object literals are tenured by default as holded by the JSScript.
MOZ_ASSERT(obj->isTenured());
@ -1922,7 +1922,7 @@ js::XDRObjectLiteral(XDRState<mode> *xdr, MutableHandleNativeObject obj)
return false;
if (mode == XDR_DECODE)
obj.set(NewDenseUnallocatedArray(cx, length, NULL, js::MaybeSingletonObject));
obj.set(NewDenseUnallocatedArray(cx, length, NullPtr(), js::MaybeSingletonObject));
} else {
// Code the alloc kind of the object.
@ -2154,7 +2154,8 @@ js::CloneObjectLiteral(JSContext *cx, HandleObject parent, HandleObject srcObj)
MOZ_ASSERT(srcArray->getElementsHeader()->ownerObject() == srcObj);
size_t length = srcArray->as<ArrayObject>().length();
RootedArrayObject res(cx, NewDenseFullyAllocatedArray(cx, length, nullptr, MaybeSingletonObject));
RootedArrayObject res(cx, NewDenseFullyAllocatedArray(cx, length, NullPtr(),
MaybeSingletonObject));
if (!res)
return nullptr;

Просмотреть файл

@ -3072,7 +3072,7 @@ CASE(JSOP_NEWINIT)
if (i == JSProto_Array) {
if (ObjectGroup::useSingletonForAllocationSite(script, REGS.pc, &ArrayObject::class_))
newKind = SingletonObject;
obj = NewDenseEmptyArray(cx, nullptr, newKind);
obj = NewDenseEmptyArray(cx, NullPtr(), newKind);
} else {
gc::AllocKind allocKind = GuessObjectGCKind(0);
if (ObjectGroup::useSingletonForAllocationSite(script, REGS.pc, &PlainObject::class_))
@ -3096,7 +3096,7 @@ CASE(JSOP_NEWARRAY)
NewObjectKind newKind = GenericObject;
if (ObjectGroup::useSingletonForAllocationSite(script, REGS.pc, &ArrayObject::class_))
newKind = SingletonObject;
obj = NewDenseFullyAllocatedArray(cx, count, nullptr, newKind);
obj = NewDenseFullyAllocatedArray(cx, count, NullPtr(), newKind);
if (!obj || !ObjectGroup::setAllocationSiteObjectGroup(cx, script, REGS.pc, obj,
newKind == SingletonObject))
{

Просмотреть файл

@ -831,7 +831,7 @@ RegExpCompartment::createMatchResultTemplateObject(JSContext *cx)
MOZ_ASSERT(!matchResultTemplateObject_);
/* Create template array object */
RootedArrayObject templateObject(cx, NewDenseUnallocatedArray(cx, 0, nullptr, TenuredObject));
RootedArrayObject templateObject(cx, NewDenseUnallocatedArray(cx, 0, NullPtr(), TenuredObject));
if (!templateObject)
return matchResultTemplateObject_; // = nullptr

Просмотреть файл

@ -1254,7 +1254,7 @@ CloneObject(JSContext *cx, HandleNativeObject selfHostedObject)
return nullptr;
clone = StringObject::create(cx, str);
} else if (selfHostedObject->is<ArrayObject>()) {
clone = NewDenseEmptyArray(cx, nullptr, TenuredObject);
clone = NewDenseEmptyArray(cx, NullPtr(), TenuredObject);
} else {
MOZ_ASSERT(selfHostedObject->isNative());
clone = NewObjectWithGivenProto(cx, selfHostedObject->getClass(), NullPtr(), cx->global(),

Просмотреть файл

@ -132,7 +132,7 @@ InterpreterFrame::createRestParameter(JSContext *cx)
unsigned nformal = fun()->nargs() - 1, nactual = numActualArgs();
unsigned nrest = (nactual > nformal) ? nactual - nformal : 0;
Value *restvp = argv() + nformal;
ArrayObject *obj = NewDenseCopiedArray(cx, nrest, restvp, nullptr);
ArrayObject *obj = NewDenseCopiedArray(cx, nrest, restvp, NullPtr());
if (!obj)
return nullptr;
ObjectGroup::fixRestArgumentsGroup(cx, obj);