diff --git a/js/src/vm/GlobalObject.cpp b/js/src/vm/GlobalObject.cpp index 8fdb1f7226e0..ba89099eac2a 100644 --- a/js/src/vm/GlobalObject.cpp +++ b/js/src/vm/GlobalObject.cpp @@ -456,8 +456,8 @@ const JSClass GlobalObject::OffThreadPlaceholderObject::class_ = { /* static */ GlobalObject::OffThreadPlaceholderObject* GlobalObject::OffThreadPlaceholderObject::New(JSContext* cx, unsigned slot) { Rooted placeholder(cx); - placeholder = NewObjectWithGivenTaggedProto( - cx, AsTaggedProto(nullptr)); + placeholder = + NewObjectWithGivenProto(cx, nullptr); if (!placeholder) { return nullptr; } diff --git a/js/src/vm/JSObject-inl.h b/js/src/vm/JSObject-inl.h index a66c86d77f83..2390d6f25fe5 100644 --- a/js/src/vm/JSObject-inl.h +++ b/js/src/vm/JSObject-inl.h @@ -416,13 +416,23 @@ inline JSObject* NewObjectWithGivenTaggedProto( initialShapeFlags); } +namespace detail { + +template +inline T* NewObjectWithGivenTaggedProtoForKind(JSContext* cx, + Handle proto) { + JSObject* obj = + NewObjectWithGivenTaggedProto(cx, &T::class_, proto, NewKind, 0); + return obj ? &obj->as() : nullptr; +} + +} // namespace detail + template inline T* NewObjectWithGivenTaggedProto(JSContext* cx, - Handle proto, - NewObjectKind newKind = GenericObject, - uint32_t initialShapeFlags = 0) { - JSObject* obj = NewObjectWithGivenTaggedProto(cx, &T::class_, proto, newKind, - initialShapeFlags); + Handle proto) { + JSObject* obj = + NewObjectWithGivenTaggedProto(cx, &T::class_, proto, GenericObject, 0); return obj ? &obj->as() : nullptr; } @@ -466,20 +476,20 @@ inline JSObject* NewSingletonObjectWithGivenProto(JSContext* cx, template inline T* NewObjectWithGivenProto(JSContext* cx, HandleObject proto) { - return NewObjectWithGivenTaggedProto(cx, AsTaggedProto(proto), - GenericObject); + return detail::NewObjectWithGivenTaggedProtoForKind( + cx, AsTaggedProto(proto)); } template inline T* NewSingletonObjectWithGivenProto(JSContext* cx, HandleObject proto) { - return NewObjectWithGivenTaggedProto(cx, AsTaggedProto(proto), - SingletonObject); + return detail::NewObjectWithGivenTaggedProtoForKind( + cx, AsTaggedProto(proto)); } template inline T* NewTenuredObjectWithGivenProto(JSContext* cx, HandleObject proto) { - return NewObjectWithGivenTaggedProto(cx, AsTaggedProto(proto), - TenuredObject); + return detail::NewObjectWithGivenTaggedProtoForKind( + cx, AsTaggedProto(proto)); } template