Bug 1140670 part 2. Just use the global as the parent in js::CreateThis and js::CreateThisForFunctionWithProto. r=waldo
This commit is contained in:
@@ -1510,13 +1510,12 @@ js::CreateThis(JSContext *cx, const Class *newclasp, HandleObject callee)
|
||||
return nullptr;
|
||||
|
||||
RootedObject proto(cx, protov.isObjectOrNull() ? protov.toObjectOrNull() : nullptr);
|
||||
RootedObject parent(cx, callee->getParent());
|
||||
gc::AllocKind kind = NewObjectGCKind(newclasp);
|
||||
return NewObjectWithClassProto(cx, newclasp, proto, parent, kind);
|
||||
return NewObjectWithClassProto(cx, newclasp, proto, NullPtr(), kind);
|
||||
}
|
||||
|
||||
static inline JSObject *
|
||||
CreateThisForFunctionWithGroup(JSContext *cx, HandleObjectGroup group, HandleObject parent,
|
||||
CreateThisForFunctionWithGroup(JSContext *cx, HandleObjectGroup group,
|
||||
NewObjectKind newKind)
|
||||
{
|
||||
if (group->maybeUnboxedLayout() && newKind != SingletonObject)
|
||||
@@ -1553,7 +1552,7 @@ CreateThisForFunctionWithGroup(JSContext *cx, HandleObjectGroup group, HandleObj
|
||||
// plain object and register it with the group. Use the maximum number
|
||||
// of fixed slots, as is also required by the TypeNewScript.
|
||||
gc::AllocKind allocKind = GuessObjectGCKind(NativeObject::MAX_FIXED_SLOTS);
|
||||
PlainObject *res = NewObjectWithGroup<PlainObject>(cx, group, parent, allocKind, newKind);
|
||||
PlainObject *res = NewObjectWithGroup<PlainObject>(cx, group, cx->global(), allocKind, newKind);
|
||||
if (!res)
|
||||
return nullptr;
|
||||
|
||||
@@ -1567,11 +1566,10 @@ CreateThisForFunctionWithGroup(JSContext *cx, HandleObjectGroup group, HandleObj
|
||||
|
||||
if (newKind == SingletonObject) {
|
||||
Rooted<TaggedProto> protoRoot(cx, group->proto());
|
||||
RootedObject parentRoot(cx, parent);
|
||||
return NewObjectWithGivenTaggedProto(cx, &PlainObject::class_, protoRoot, parentRoot,
|
||||
return NewObjectWithGivenTaggedProto(cx, &PlainObject::class_, protoRoot, cx->global(),
|
||||
allocKind, newKind);
|
||||
}
|
||||
return NewObjectWithGroup<PlainObject>(cx, group, parent, allocKind, newKind);
|
||||
return NewObjectWithGroup<PlainObject>(cx, group, cx->global(), allocKind, newKind);
|
||||
}
|
||||
|
||||
JSObject *
|
||||
@@ -1599,12 +1597,11 @@ js::CreateThisForFunctionWithProto(JSContext *cx, HandleObject callee, HandleObj
|
||||
}
|
||||
}
|
||||
|
||||
RootedObject parent(cx, callee->getParent());
|
||||
res = CreateThisForFunctionWithGroup(cx, group, parent, newKind);
|
||||
res = CreateThisForFunctionWithGroup(cx, group, newKind);
|
||||
} else {
|
||||
RootedObject parent(cx, callee->getParent());
|
||||
gc::AllocKind allocKind = NewObjectGCKind(&PlainObject::class_);
|
||||
res = NewObjectWithProto<PlainObject>(cx, proto, parent, allocKind, newKind);
|
||||
res = NewObjectWithProto<PlainObject>(cx, proto, cx->global(),
|
||||
allocKind, newKind);
|
||||
}
|
||||
|
||||
if (res) {
|
||||
|
||||
Reference in New Issue
Block a user