зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1142304
. Remove the parent argument from NewObjectWithGivenTaggedProto. r=waldo
This commit is contained in:
Родитель
657942d7d3
Коммит
04bd6d2255
|
@ -1159,27 +1159,25 @@ NewObjectCache::fillProto(EntryIndex entry, const Class *clasp, js::TaggedProto
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
NewObjectWithTaggedProtoIsCachable(ExclusiveContext *cxArg, Handle<TaggedProto> proto,
|
NewObjectWithTaggedProtoIsCachable(ExclusiveContext *cxArg, Handle<TaggedProto> proto,
|
||||||
NewObjectKind newKind, const Class *clasp,
|
NewObjectKind newKind, const Class *clasp)
|
||||||
HandleObject parentArg)
|
|
||||||
{
|
{
|
||||||
return cxArg->isJSContext() &&
|
return cxArg->isJSContext() &&
|
||||||
proto.isObject() &&
|
proto.isObject() &&
|
||||||
newKind == GenericObject &&
|
newKind == GenericObject &&
|
||||||
clasp->isNative() &&
|
clasp->isNative() &&
|
||||||
!cxArg->asJSContext()->compartment()->hasObjectMetadataCallback() &&
|
!cxArg->asJSContext()->compartment()->hasObjectMetadataCallback() &&
|
||||||
(!parentArg || parentArg == proto.toObject()->getParent()) &&
|
|
||||||
!proto.toObject()->is<GlobalObject>();
|
!proto.toObject()->is<GlobalObject>();
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject *
|
JSObject *
|
||||||
js::NewObjectWithGivenTaggedProto(ExclusiveContext *cxArg, const Class *clasp,
|
js::NewObjectWithGivenTaggedProto(ExclusiveContext *cxArg, const Class *clasp,
|
||||||
Handle<TaggedProto> proto, HandleObject parentArg,
|
Handle<TaggedProto> proto,
|
||||||
gc::AllocKind allocKind, NewObjectKind newKind)
|
gc::AllocKind allocKind, NewObjectKind newKind)
|
||||||
{
|
{
|
||||||
if (CanBeFinalizedInBackground(allocKind, clasp))
|
if (CanBeFinalizedInBackground(allocKind, clasp))
|
||||||
allocKind = GetBackgroundAllocKind(allocKind);
|
allocKind = GetBackgroundAllocKind(allocKind);
|
||||||
|
|
||||||
bool isCachable = NewObjectWithTaggedProtoIsCachable(cxArg, proto, newKind, clasp, parentArg);
|
bool isCachable = NewObjectWithTaggedProtoIsCachable(cxArg, proto, newKind, clasp);
|
||||||
if (isCachable) {
|
if (isCachable) {
|
||||||
JSContext *cx = cxArg->asJSContext();
|
JSContext *cx = cxArg->asJSContext();
|
||||||
JSRuntime *rt = cx->runtime();
|
JSRuntime *rt = cx->runtime();
|
||||||
|
@ -1197,9 +1195,7 @@ js::NewObjectWithGivenTaggedProto(ExclusiveContext *cxArg, const Class *clasp,
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
// Default parent to the global.
|
// Default parent to the global.
|
||||||
RootedObject parent(cxArg, parentArg);
|
RootedObject parent(cxArg, cxArg->global());
|
||||||
if (!parent)
|
|
||||||
parent = cxArg->global();
|
|
||||||
|
|
||||||
RootedObject obj(cxArg, NewObject(cxArg, group, parent, allocKind, newKind));
|
RootedObject obj(cxArg, NewObject(cxArg, group, parent, allocKind, newKind));
|
||||||
if (!obj)
|
if (!obj)
|
||||||
|
@ -1326,7 +1322,7 @@ js::NewObjectWithClassProtoCommon(ExclusiveContext *cxArg, const Class *clasp,
|
||||||
gc::AllocKind allocKind, NewObjectKind newKind)
|
gc::AllocKind allocKind, NewObjectKind newKind)
|
||||||
{
|
{
|
||||||
if (protoArg) {
|
if (protoArg) {
|
||||||
return NewObjectWithGivenTaggedProto(cxArg, clasp, AsTaggedProto(protoArg), NullPtr(),
|
return NewObjectWithGivenTaggedProto(cxArg, clasp, AsTaggedProto(protoArg),
|
||||||
allocKind, newKind);
|
allocKind, newKind);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1523,8 +1519,7 @@ CreateThisForFunctionWithGroup(JSContext *cx, HandleObjectGroup group,
|
||||||
|
|
||||||
if (newKind == SingletonObject) {
|
if (newKind == SingletonObject) {
|
||||||
Rooted<TaggedProto> protoRoot(cx, group->proto());
|
Rooted<TaggedProto> protoRoot(cx, group->proto());
|
||||||
return NewObjectWithGivenTaggedProto(cx, &PlainObject::class_, protoRoot, cx->global(),
|
return NewObjectWithGivenTaggedProto(cx, &PlainObject::class_, protoRoot, allocKind, newKind);
|
||||||
allocKind, newKind);
|
|
||||||
}
|
}
|
||||||
return NewObjectWithGroup<PlainObject>(cx, group, cx->global(), 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);
|
RootedObject clone(cx);
|
||||||
if (obj->isNative()) {
|
if (obj->isNative()) {
|
||||||
clone = NewObjectWithGivenTaggedProto(cx, obj->getClass(), proto, NullPtr());
|
clone = NewObjectWithGivenTaggedProto(cx, obj->getClass(), proto);
|
||||||
if (!clone)
|
if (!clone)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
|
|
@ -577,22 +577,22 @@ class AutoPropertyDescriptorVector : public AutoVectorRooter<PropertyDescriptor>
|
||||||
*/
|
*/
|
||||||
JSObject *
|
JSObject *
|
||||||
NewObjectWithGivenTaggedProto(ExclusiveContext *cx, const Class *clasp, Handle<TaggedProto> proto,
|
NewObjectWithGivenTaggedProto(ExclusiveContext *cx, const Class *clasp, Handle<TaggedProto> proto,
|
||||||
HandleObject parent, gc::AllocKind allocKind, NewObjectKind newKind);
|
gc::AllocKind allocKind, NewObjectKind newKind);
|
||||||
|
|
||||||
inline JSObject *
|
inline JSObject *
|
||||||
NewObjectWithGivenTaggedProto(ExclusiveContext *cx, const Class *clasp, Handle<TaggedProto> proto,
|
NewObjectWithGivenTaggedProto(ExclusiveContext *cx, const Class *clasp, Handle<TaggedProto> proto,
|
||||||
HandleObject parent, NewObjectKind newKind = GenericObject)
|
NewObjectKind newKind = GenericObject)
|
||||||
{
|
{
|
||||||
gc::AllocKind allocKind = gc::GetGCObjectKind(clasp);
|
gc::AllocKind allocKind = gc::GetGCObjectKind(clasp);
|
||||||
return NewObjectWithGivenTaggedProto(cx, clasp, proto, parent, allocKind, newKind);
|
return NewObjectWithGivenTaggedProto(cx, clasp, proto, allocKind, newKind);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline T *
|
inline T *
|
||||||
NewObjectWithGivenTaggedProto(ExclusiveContext *cx, Handle<TaggedProto> proto, HandleObject parent,
|
NewObjectWithGivenTaggedProto(ExclusiveContext *cx, Handle<TaggedProto> proto,
|
||||||
NewObjectKind newKind = GenericObject)
|
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;
|
return obj ? &obj->as<T>() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -600,7 +600,7 @@ inline JSObject *
|
||||||
NewObjectWithGivenProto(ExclusiveContext *cx, const Class *clasp, HandleObject proto,
|
NewObjectWithGivenProto(ExclusiveContext *cx, const Class *clasp, HandleObject proto,
|
||||||
gc::AllocKind allocKind, NewObjectKind newKind)
|
gc::AllocKind allocKind, NewObjectKind newKind)
|
||||||
{
|
{
|
||||||
return NewObjectWithGivenTaggedProto(cx, clasp, AsTaggedProto(proto), NullPtr(), allocKind,
|
return NewObjectWithGivenTaggedProto(cx, clasp, AsTaggedProto(proto), allocKind,
|
||||||
newKind);
|
newKind);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -608,7 +608,7 @@ inline JSObject *
|
||||||
NewObjectWithGivenProto(ExclusiveContext *cx, const Class *clasp, HandleObject proto,
|
NewObjectWithGivenProto(ExclusiveContext *cx, const Class *clasp, HandleObject proto,
|
||||||
NewObjectKind newKind = GenericObject)
|
NewObjectKind newKind = GenericObject)
|
||||||
{
|
{
|
||||||
return NewObjectWithGivenTaggedProto(cx, clasp, AsTaggedProto(proto), NullPtr(), newKind);
|
return NewObjectWithGivenTaggedProto(cx, clasp, AsTaggedProto(proto), newKind);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -616,7 +616,7 @@ inline T *
|
||||||
NewObjectWithGivenProto(ExclusiveContext *cx, HandleObject proto,
|
NewObjectWithGivenProto(ExclusiveContext *cx, HandleObject proto,
|
||||||
NewObjectKind newKind = GenericObject)
|
NewObjectKind newKind = GenericObject)
|
||||||
{
|
{
|
||||||
return NewObjectWithGivenTaggedProto<T>(cx, AsTaggedProto(proto), NullPtr(), newKind);
|
return NewObjectWithGivenTaggedProto<T>(cx, AsTaggedProto(proto), newKind);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -624,7 +624,7 @@ inline T *
|
||||||
NewObjectWithGivenProto(ExclusiveContext *cx, HandleObject proto,
|
NewObjectWithGivenProto(ExclusiveContext *cx, HandleObject proto,
|
||||||
gc::AllocKind allocKind, NewObjectKind newKind = GenericObject)
|
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);
|
allocKind, newKind);
|
||||||
return obj ? &obj->as<T>() : nullptr;
|
return obj ? &obj->as<T>() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -346,7 +346,7 @@ NewNativeObjectWithGivenTaggedProto(ExclusiveContext *cx, const Class *clasp,
|
||||||
Handle<TaggedProto> proto,
|
Handle<TaggedProto> proto,
|
||||||
gc::AllocKind allocKind, NewObjectKind newKind)
|
gc::AllocKind allocKind, NewObjectKind newKind)
|
||||||
{
|
{
|
||||||
return MaybeNativeObject(NewObjectWithGivenTaggedProto(cx, clasp, proto, NullPtr(), allocKind,
|
return MaybeNativeObject(NewObjectWithGivenTaggedProto(cx, clasp, proto, allocKind,
|
||||||
newKind));
|
newKind));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,7 +355,7 @@ NewNativeObjectWithGivenTaggedProto(ExclusiveContext *cx, const Class *clasp,
|
||||||
Handle<TaggedProto> proto,
|
Handle<TaggedProto> proto,
|
||||||
NewObjectKind newKind = GenericObject)
|
NewObjectKind newKind = GenericObject)
|
||||||
{
|
{
|
||||||
return MaybeNativeObject(NewObjectWithGivenTaggedProto(cx, clasp, proto, NullPtr(), newKind));
|
return MaybeNativeObject(NewObjectWithGivenTaggedProto(cx, clasp, proto, newKind));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline NativeObject *
|
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
|
// Note: this will initialize the object's |data| to strange values, but we
|
||||||
// will immediately overwrite those below.
|
// will immediately overwrite those below.
|
||||||
RootedObject obj(cx, NewObjectWithGivenTaggedProto(cx, clasp, proto, NullPtr(), allocKind,
|
RootedObject obj(cx, NewObjectWithGivenTaggedProto(cx, clasp, proto, allocKind,
|
||||||
newKind));
|
newKind));
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
js_free(values);
|
js_free(values);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче