mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-01 05:48:26 +00:00
Bug 1142304. Remove the parent argument from NewObjectWithGivenTaggedProto. r=waldo
This commit is contained in:
parent
657942d7d3
commit
04bd6d2255
@ -1159,27 +1159,25 @@ NewObjectCache::fillProto(EntryIndex entry, const Class *clasp, js::TaggedProto
|
||||
|
||||
static bool
|
||||
NewObjectWithTaggedProtoIsCachable(ExclusiveContext *cxArg, Handle<TaggedProto> proto,
|
||||
NewObjectKind newKind, const Class *clasp,
|
||||
HandleObject parentArg)
|
||||
NewObjectKind newKind, const Class *clasp)
|
||||
{
|
||||
return cxArg->isJSContext() &&
|
||||
proto.isObject() &&
|
||||
newKind == GenericObject &&
|
||||
clasp->isNative() &&
|
||||
!cxArg->asJSContext()->compartment()->hasObjectMetadataCallback() &&
|
||||
(!parentArg || parentArg == proto.toObject()->getParent()) &&
|
||||
!proto.toObject()->is<GlobalObject>();
|
||||
}
|
||||
|
||||
JSObject *
|
||||
js::NewObjectWithGivenTaggedProto(ExclusiveContext *cxArg, const Class *clasp,
|
||||
Handle<TaggedProto> proto, HandleObject parentArg,
|
||||
Handle<TaggedProto> proto,
|
||||
gc::AllocKind allocKind, NewObjectKind newKind)
|
||||
{
|
||||
if (CanBeFinalizedInBackground(allocKind, clasp))
|
||||
allocKind = GetBackgroundAllocKind(allocKind);
|
||||
|
||||
bool isCachable = NewObjectWithTaggedProtoIsCachable(cxArg, proto, newKind, clasp, parentArg);
|
||||
bool isCachable = NewObjectWithTaggedProtoIsCachable(cxArg, proto, newKind, clasp);
|
||||
if (isCachable) {
|
||||
JSContext *cx = cxArg->asJSContext();
|
||||
JSRuntime *rt = cx->runtime();
|
||||
@ -1197,9 +1195,7 @@ js::NewObjectWithGivenTaggedProto(ExclusiveContext *cxArg, const Class *clasp,
|
||||
return nullptr;
|
||||
|
||||
// Default parent to the global.
|
||||
RootedObject parent(cxArg, parentArg);
|
||||
if (!parent)
|
||||
parent = cxArg->global();
|
||||
RootedObject parent(cxArg, cxArg->global());
|
||||
|
||||
RootedObject obj(cxArg, NewObject(cxArg, group, parent, allocKind, newKind));
|
||||
if (!obj)
|
||||
@ -1326,7 +1322,7 @@ js::NewObjectWithClassProtoCommon(ExclusiveContext *cxArg, const Class *clasp,
|
||||
gc::AllocKind allocKind, NewObjectKind newKind)
|
||||
{
|
||||
if (protoArg) {
|
||||
return NewObjectWithGivenTaggedProto(cxArg, clasp, AsTaggedProto(protoArg), NullPtr(),
|
||||
return NewObjectWithGivenTaggedProto(cxArg, clasp, AsTaggedProto(protoArg),
|
||||
allocKind, newKind);
|
||||
}
|
||||
|
||||
@ -1523,8 +1519,7 @@ CreateThisForFunctionWithGroup(JSContext *cx, HandleObjectGroup group,
|
||||
|
||||
if (newKind == SingletonObject) {
|
||||
Rooted<TaggedProto> protoRoot(cx, group->proto());
|
||||
return NewObjectWithGivenTaggedProto(cx, &PlainObject::class_, protoRoot, cx->global(),
|
||||
allocKind, newKind);
|
||||
return NewObjectWithGivenTaggedProto(cx, &PlainObject::class_, protoRoot, allocKind, newKind);
|
||||
}
|
||||
return NewObjectWithGroup<PlainObject>(cx, group, cx->global(), allocKind, newKind);
|
||||
}
|
||||
@ -1705,7 +1700,7 @@ js::CloneObject(JSContext *cx, HandleObject obj, Handle<js::TaggedProto> proto)
|
||||
|
||||
RootedObject clone(cx);
|
||||
if (obj->isNative()) {
|
||||
clone = NewObjectWithGivenTaggedProto(cx, obj->getClass(), proto, NullPtr());
|
||||
clone = NewObjectWithGivenTaggedProto(cx, obj->getClass(), proto);
|
||||
if (!clone)
|
||||
return nullptr;
|
||||
|
||||
|
@ -577,22 +577,22 @@ class AutoPropertyDescriptorVector : public AutoVectorRooter<PropertyDescriptor>
|
||||
*/
|
||||
JSObject *
|
||||
NewObjectWithGivenTaggedProto(ExclusiveContext *cx, const Class *clasp, Handle<TaggedProto> proto,
|
||||
HandleObject parent, gc::AllocKind allocKind, NewObjectKind newKind);
|
||||
gc::AllocKind allocKind, NewObjectKind newKind);
|
||||
|
||||
inline JSObject *
|
||||
NewObjectWithGivenTaggedProto(ExclusiveContext *cx, const Class *clasp, Handle<TaggedProto> proto,
|
||||
HandleObject parent, NewObjectKind newKind = GenericObject)
|
||||
NewObjectKind newKind = GenericObject)
|
||||
{
|
||||
gc::AllocKind allocKind = gc::GetGCObjectKind(clasp);
|
||||
return NewObjectWithGivenTaggedProto(cx, clasp, proto, parent, allocKind, newKind);
|
||||
return NewObjectWithGivenTaggedProto(cx, clasp, proto, allocKind, newKind);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T *
|
||||
NewObjectWithGivenTaggedProto(ExclusiveContext *cx, Handle<TaggedProto> proto, HandleObject parent,
|
||||
NewObjectWithGivenTaggedProto(ExclusiveContext *cx, Handle<TaggedProto> proto,
|
||||
NewObjectKind newKind = GenericObject)
|
||||
{
|
||||
JSObject *obj = NewObjectWithGivenTaggedProto(cx, &T::class_, proto, parent, newKind);
|
||||
JSObject *obj = NewObjectWithGivenTaggedProto(cx, &T::class_, proto, newKind);
|
||||
return obj ? &obj->as<T>() : nullptr;
|
||||
}
|
||||
|
||||
@ -600,7 +600,7 @@ inline JSObject *
|
||||
NewObjectWithGivenProto(ExclusiveContext *cx, const Class *clasp, HandleObject proto,
|
||||
gc::AllocKind allocKind, NewObjectKind newKind)
|
||||
{
|
||||
return NewObjectWithGivenTaggedProto(cx, clasp, AsTaggedProto(proto), NullPtr(), allocKind,
|
||||
return NewObjectWithGivenTaggedProto(cx, clasp, AsTaggedProto(proto), allocKind,
|
||||
newKind);
|
||||
}
|
||||
|
||||
@ -608,7 +608,7 @@ inline JSObject *
|
||||
NewObjectWithGivenProto(ExclusiveContext *cx, const Class *clasp, HandleObject proto,
|
||||
NewObjectKind newKind = GenericObject)
|
||||
{
|
||||
return NewObjectWithGivenTaggedProto(cx, clasp, AsTaggedProto(proto), NullPtr(), newKind);
|
||||
return NewObjectWithGivenTaggedProto(cx, clasp, AsTaggedProto(proto), newKind);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -616,7 +616,7 @@ inline T *
|
||||
NewObjectWithGivenProto(ExclusiveContext *cx, HandleObject proto,
|
||||
NewObjectKind newKind = GenericObject)
|
||||
{
|
||||
return NewObjectWithGivenTaggedProto<T>(cx, AsTaggedProto(proto), NullPtr(), newKind);
|
||||
return NewObjectWithGivenTaggedProto<T>(cx, AsTaggedProto(proto), newKind);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -624,7 +624,7 @@ inline T *
|
||||
NewObjectWithGivenProto(ExclusiveContext *cx, HandleObject proto,
|
||||
gc::AllocKind allocKind, NewObjectKind newKind = GenericObject)
|
||||
{
|
||||
JSObject *obj = NewObjectWithGivenTaggedProto(cx, &T::class_, AsTaggedProto(proto), NullPtr(),
|
||||
JSObject *obj = NewObjectWithGivenTaggedProto(cx, &T::class_, AsTaggedProto(proto),
|
||||
allocKind, newKind);
|
||||
return obj ? &obj->as<T>() : nullptr;
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ NewNativeObjectWithGivenTaggedProto(ExclusiveContext *cx, const Class *clasp,
|
||||
Handle<TaggedProto> proto,
|
||||
gc::AllocKind allocKind, NewObjectKind newKind)
|
||||
{
|
||||
return MaybeNativeObject(NewObjectWithGivenTaggedProto(cx, clasp, proto, NullPtr(), allocKind,
|
||||
return MaybeNativeObject(NewObjectWithGivenTaggedProto(cx, clasp, proto, allocKind,
|
||||
newKind));
|
||||
}
|
||||
|
||||
@ -355,7 +355,7 @@ NewNativeObjectWithGivenTaggedProto(ExclusiveContext *cx, const Class *clasp,
|
||||
Handle<TaggedProto> proto,
|
||||
NewObjectKind newKind = GenericObject)
|
||||
{
|
||||
return MaybeNativeObject(NewObjectWithGivenTaggedProto(cx, clasp, proto, NullPtr(), newKind));
|
||||
return MaybeNativeObject(NewObjectWithGivenTaggedProto(cx, clasp, proto, newKind));
|
||||
}
|
||||
|
||||
inline NativeObject *
|
||||
|
@ -47,7 +47,7 @@ ProxyObject::New(JSContext *cx, const BaseProxyHandler *handler, HandleValue pri
|
||||
|
||||
// Note: this will initialize the object's |data| to strange values, but we
|
||||
// will immediately overwrite those below.
|
||||
RootedObject obj(cx, NewObjectWithGivenTaggedProto(cx, clasp, proto, NullPtr(), allocKind,
|
||||
RootedObject obj(cx, NewObjectWithGivenTaggedProto(cx, clasp, proto, allocKind,
|
||||
newKind));
|
||||
if (!obj) {
|
||||
js_free(values);
|
||||
|
Loading…
x
Reference in New Issue
Block a user