Bug 949220 - Make |js::CloneObject| take a |JSObject*| prototype argument, not a |TaggedProto|. r=jandem

Differential Revision: https://phabricator.services.mozilla.com/D71272
This commit is contained in:
Jeff Walden 2020-04-17 20:32:32 +00:00
Родитель e658c58c15
Коммит 3f3c9e2c10
3 изменённых файлов: 7 добавлений и 9 удалений

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

@ -572,10 +572,9 @@ JS_FRIEND_API void JS_SetSetUseCounterCallback(
} }
JS_FRIEND_API JSObject* JS_CloneObject(JSContext* cx, HandleObject obj, JS_FRIEND_API JSObject* JS_CloneObject(JSContext* cx, HandleObject obj,
HandleObject protoArg) { HandleObject proto) {
// |obj| might be in a different compartment. // |obj| might be in a different compartment.
cx->check(protoArg); cx->check(proto);
Rooted<TaggedProto> proto(cx, TaggedProto(protoArg.get()));
return CloneObject(cx, obj, proto); return CloneObject(cx, obj, proto);
} }

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

@ -1180,7 +1180,7 @@ static bool CopyProxyObject(JSContext* cx, Handle<ProxyObject*> from,
} }
JSObject* js::CloneObject(JSContext* cx, HandleObject obj, JSObject* js::CloneObject(JSContext* cx, HandleObject obj,
Handle<js::TaggedProto> proto) { Handle<JSObject*> proto) {
if (!obj->isNative() && !obj->is<ProxyObject>()) { if (!obj->isNative() && !obj->is<ProxyObject>()) {
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
JSMSG_CANT_CLONE_OBJECT); JSMSG_CANT_CLONE_OBJECT);
@ -1191,8 +1191,7 @@ JSObject* js::CloneObject(JSContext* cx, HandleObject obj,
if (obj->isNative()) { if (obj->isNative()) {
// CloneObject is used to create the target object for JSObject::swap() and // CloneObject is used to create the target object for JSObject::swap() and
// swap() requires its arguments are tenured, so ensure tenure allocation. // swap() requires its arguments are tenured, so ensure tenure allocation.
clone = NewObjectWithGivenTaggedProto(cx, obj->getClass(), proto, clone = NewTenuredObjectWithGivenProto(cx, obj->getClass(), proto);
NewObjectKind::TenuredObject);
if (!clone) { if (!clone) {
return nullptr; return nullptr;
} }
@ -1219,8 +1218,8 @@ JSObject* js::CloneObject(JSContext* cx, HandleObject obj,
return nullptr; return nullptr;
} }
clone = ProxyObject::New(cx, handler, JS::NullHandleValue, proto, clone = ProxyObject::New(cx, handler, JS::NullHandleValue,
obj->getClass()); AsTaggedProto(proto), obj->getClass());
if (!clone) { if (!clone) {
return nullptr; return nullptr;
} }

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

@ -870,7 +870,7 @@ extern JSObject* CreateThis(JSContext* cx, const JSClass* clasp,
js::HandleObject callee); js::HandleObject callee);
extern JSObject* CloneObject(JSContext* cx, HandleObject obj, extern JSObject* CloneObject(JSContext* cx, HandleObject obj,
Handle<js::TaggedProto> proto); Handle<JSObject*> proto);
extern JSObject* DeepCloneObjectLiteral(JSContext* cx, HandleObject obj); extern JSObject* DeepCloneObjectLiteral(JSContext* cx, HandleObject obj);