From 955aba9d18251e91123f91224664b6391c9d1413 Mon Sep 17 00:00:00 2001 From: Jan de Mooij <jdemooij@mozilla.com> Date: Thu, 9 Sep 2021 13:04:14 +0000 Subject: [PATCH] Bug 1729867 part 3 - Share more code in NewObject, inline NewObject. r=jonco Depends on D125043 Differential Revision: https://phabricator.services.mozilla.com/D125044 --- js/src/vm/JSObject.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/js/src/vm/JSObject.cpp b/js/src/vm/JSObject.cpp index e091e049cc957..357f6736c23a4 100644 --- a/js/src/vm/JSObject.cpp +++ b/js/src/vm/JSObject.cpp @@ -727,10 +727,9 @@ bool js::TestIntegrityLevel(JSContext* cx, HandleObject obj, /* * */ -static inline NativeObject* NewObject(JSContext* cx, Handle<TaggedProto> proto, - const JSClass* clasp, gc::AllocKind kind, - NewObjectKind newKind, - ObjectFlags objectFlags = {}) { +static MOZ_ALWAYS_INLINE NativeObject* NewObject( + JSContext* cx, Handle<TaggedProto> proto, const JSClass* clasp, + gc::AllocKind kind, NewObjectKind newKind, ObjectFlags objectFlags = {}) { MOZ_ASSERT(clasp->isNativeObject()); // Some classes have specialized allocation functions and shouldn't end up @@ -743,8 +742,12 @@ static inline NativeObject* NewObject(JSContext* cx, Handle<TaggedProto> proto, // store fixed data inline (TypedArrays and ArrayBuffers) so for simplicity // and performance reasons we don't support such objects here. MOZ_ASSERT(!ClassCanHaveFixedData(clasp)); - size_t nfixed = GetGCKindSlots(kind); + + if (CanChangeToBackgroundAllocKind(kind, clasp)) { + kind = ForegroundToBackgroundAllocKind(kind); + } + RootedShape shape( cx, SharedShape::getInitialShape(cx, clasp, cx->realm(), proto, nfixed, objectFlags)); @@ -765,10 +768,6 @@ static inline NativeObject* NewObject(JSContext* cx, Handle<TaggedProto> proto, NativeObject* js::NewObjectWithGivenTaggedProto( JSContext* cx, const JSClass* clasp, Handle<TaggedProto> proto, gc::AllocKind allocKind, NewObjectKind newKind, ObjectFlags objectFlags) { - if (CanChangeToBackgroundAllocKind(allocKind, clasp)) { - allocKind = ForegroundToBackgroundAllocKind(allocKind); - } - return NewObject(cx, proto, clasp, allocKind, newKind, objectFlags); } @@ -781,10 +780,6 @@ NativeObject* js::NewObjectWithClassProto(JSContext* cx, const JSClass* clasp, allocKind, newKind); } - if (CanChangeToBackgroundAllocKind(allocKind, clasp)) { - allocKind = ForegroundToBackgroundAllocKind(allocKind); - } - // Find the appropriate proto for clasp. Built-in classes have a cached // proto on cx->global(); all others get %ObjectPrototype%. JSProtoKey protoKey = JSCLASS_CACHED_PROTO_KEY(clasp); -- GitLab