Bug 1142865. Remove the parent argument from NewObjectWithGroup. r=waldo
authorBoris Zbarsky <bzbarsky@mit.edu>
Sat, 14 Mar 2015 01:36:17 -0400
changeset 233672 7128e4104f942a3fa9e5588bea567e138620ecdd
parent 233671 74e1b16ef4e3777618699aa7be4fce30e6a7c535
child 233673 1340e686a3ded8c96e1cd36700368a51417e4d33
push id56907
push userbzbarsky@mozilla.com
push dateSat, 14 Mar 2015 05:37:23 +0000
treeherdermozilla-inbound@c0a7bfc8dfae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswaldo
bugs1142865
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1142865. Remove the parent argument from NewObjectWithGroup. r=waldo
js/src/builtin/Object.cpp
js/src/builtin/TypedObject.cpp
js/src/jsobj.cpp
js/src/jsobj.h
js/src/jsobjinlines.h
js/src/jsscript.cpp
js/src/vm/ObjectGroup.cpp
js/src/vm/RegExpObject.cpp
js/src/vm/TypeInference.cpp
js/src/vm/UnboxedObject.cpp
--- a/js/src/builtin/Object.cpp
+++ b/js/src/builtin/Object.cpp
@@ -626,18 +626,17 @@ js::ObjectCreateImpl(JSContext *cx, Hand
         if (!ngroup) {
             ngroup = ObjectGroup::callingAllocationSiteGroup(cx, JSProto_Null);
             if (!ngroup)
                 return nullptr;
         }
 
         MOZ_ASSERT(!ngroup->proto().toObjectOrNull());
 
-        return NewObjectWithGroup<PlainObject>(cx, ngroup, cx->global(), allocKind,
-                                               newKind);
+        return NewObjectWithGroup<PlainObject>(cx, ngroup, allocKind, newKind);
     }
 
     return NewObjectWithGivenProto<PlainObject>(cx, proto, allocKind, newKind);
 }
 
 PlainObject *
 js::ObjectCreateWithTemplate(JSContext *cx, HandlePlainObject templateObj)
 {
--- a/js/src/builtin/TypedObject.cpp
+++ b/js/src/builtin/TypedObject.cpp
@@ -1481,17 +1481,17 @@ OutlineTypedObject::createUnattachedWith
 
     RootedObjectGroup group(cx, ObjectGroup::defaultNewGroup(cx, clasp,
                                                              TaggedProto(&descr->typedProto()),
                                                              descr));
     if (!group)
         return nullptr;
 
     NewObjectKind newKind = (heap == gc::TenuredHeap) ? MaybeSingletonObject : GenericObject;
-    OutlineTypedObject *obj = NewObjectWithGroup<OutlineTypedObject>(cx, group, cx->global(),
+    OutlineTypedObject *obj = NewObjectWithGroup<OutlineTypedObject>(cx, group,
                                                                      gc::AllocKind::OBJECT0,
                                                                      newKind);
     if (!obj)
         return nullptr;
 
     obj->setOwnerAndData(nullptr, nullptr);
     return obj;
 }
@@ -2130,17 +2130,17 @@ InlineTypedObject::create(JSContext *cx,
 
     RootedObjectGroup group(cx, ObjectGroup::defaultNewGroup(cx, clasp,
                                                              TaggedProto(&descr->typedProto()),
                                                              descr));
     if (!group)
         return nullptr;
 
     NewObjectKind newKind = (heap == gc::TenuredHeap) ? MaybeSingletonObject : GenericObject;
-    return NewObjectWithGroup<InlineTypedObject>(cx, group, cx->global(), allocKind, newKind);
+    return NewObjectWithGroup<InlineTypedObject>(cx, group, allocKind, newKind);
 }
 
 /* static */ InlineTypedObject *
 InlineTypedObject::createCopy(JSContext *cx, Handle<InlineTypedObject *> templateObject,
                               gc::InitialHeap heap)
 {
     Rooted<TypeDescr *> descr(cx, &templateObject->typeDescr());
     InlineTypedObject *res = create(cx, descr, heap);
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -1375,55 +1375,52 @@ js::NewObjectWithClassProtoCommon(Exclus
         cache.fillGlobal(entry, clasp, global, allocKind,
                          &obj->as<NativeObject>());
     }
 
     return obj;
 }
 
 static bool
-NewObjectWithGroupIsCachable(ExclusiveContext *cx, HandleObjectGroup group, HandleObject parent,
+NewObjectWithGroupIsCachable(ExclusiveContext *cx, HandleObjectGroup group,
                              NewObjectKind newKind)
 {
     return group->proto().isObject() &&
-           parent == group->proto().toObject()->getParent() &&
            newKind == GenericObject &&
            group->clasp()->isNative() &&
            (!group->newScript() || group->newScript()->analyzed()) &&
            !cx->compartment()->hasObjectMetadataCallback() &&
            cx->isJSContext();
 }
 
 /*
  * Create a plain object with the specified group. This bypasses getNewGroup to
  * avoid losing creation site information for objects made by scripted 'new'.
  */
 JSObject *
-js::NewObjectWithGroupCommon(ExclusiveContext *cx, HandleObjectGroup group, HandleObject parent,
+js::NewObjectWithGroupCommon(ExclusiveContext *cx, HandleObjectGroup group,
                              gc::AllocKind allocKind, NewObjectKind newKind)
 {
-    MOZ_ASSERT(parent);
-
     MOZ_ASSERT(allocKind <= gc::AllocKind::OBJECT_LAST);
     if (CanBeFinalizedInBackground(allocKind, group->clasp()))
         allocKind = GetBackgroundAllocKind(allocKind);
 
-    bool isCachable = NewObjectWithGroupIsCachable(cx, group, parent, newKind);
+    bool isCachable = NewObjectWithGroupIsCachable(cx, group, newKind);
     if (isCachable) {
         NewObjectCache &cache = cx->asJSContext()->runtime()->newObjectCache;
         NewObjectCache::EntryIndex entry = -1;
         if (cache.lookupGroup(group, allocKind, &entry)) {
             JSObject *obj = cache.newObjectFromHit(cx->asJSContext(), entry,
                                                    GetInitialHeap(newKind, group->clasp()));
             if (obj)
                 return obj;
         }
     }
 
-    JSObject *obj = NewObject(cx, group, parent, allocKind, newKind);
+    JSObject *obj = NewObject(cx, group, cx->global(), allocKind, newKind);
     if (!obj)
         return nullptr;
 
     if (isCachable && !obj->as<NativeObject>().hasDynamicSlots()) {
         NewObjectCache &cache = cx->asJSContext()->runtime()->newObjectCache;
         NewObjectCache::EntryIndex entry = -1;
         cache.lookupGroup(group, allocKind, &entry);
         cache.fillGroup(entry, group, allocKind, &obj->as<NativeObject>());
@@ -1500,33 +1497,33 @@ CreateThisForFunctionWithGroup(JSContext
         // nursery.
         if (newKind == GenericObject)
             newKind = MaybeSingletonObject;
 
         // Not enough objects with this group have been created yet, so make a
         // 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, cx->global(), allocKind, newKind);
+        PlainObject *res = NewObjectWithGroup<PlainObject>(cx, group, allocKind, newKind);
         if (!res)
             return nullptr;
 
         if (newKind != SingletonObject)
             newScript->registerNewObject(res);
 
         return res;
     }
 
     gc::AllocKind allocKind = NewObjectGCKind(&PlainObject::class_);
 
     if (newKind == SingletonObject) {
         Rooted<TaggedProto> protoRoot(cx, group->proto());
         return NewObjectWithGivenTaggedProto(cx, &PlainObject::class_, protoRoot, allocKind, newKind);
     }
-    return NewObjectWithGroup<PlainObject>(cx, group, cx->global(), allocKind, newKind);
+    return NewObjectWithGroup<PlainObject>(cx, group, allocKind, newKind);
 }
 
 JSObject *
 js::CreateThisForFunctionWithProto(JSContext *cx, HandleObject callee, HandleObject proto,
                                    NewObjectKind newKind /* = GenericObject */)
 {
     RootedObject res(cx);
 
@@ -2081,37 +2078,37 @@ js::XDRObjectLiteral(XDRState<mode> *xdr
 
 template bool
 js::XDRObjectLiteral(XDRState<XDR_ENCODE> *xdr, MutableHandleObject obj);
 
 template bool
 js::XDRObjectLiteral(XDRState<XDR_DECODE> *xdr, MutableHandleObject obj);
 
 JSObject *
-js::CloneObjectLiteral(JSContext *cx, HandleObject parent, HandleObject srcObj)
+js::CloneObjectLiteral(JSContext *cx, HandleObject srcObj)
 {
     if (srcObj->is<PlainObject>()) {
         AllocKind kind = GetBackgroundAllocKind(GuessObjectGCKind(srcObj->as<PlainObject>().numFixedSlots()));
         MOZ_ASSERT_IF(srcObj->isTenured(), kind == srcObj->asTenured().getAllocKind());
 
         RootedObject proto(cx, cx->global()->getOrCreateObjectPrototype(cx));
         if (!proto)
             return nullptr;
         RootedObjectGroup group(cx, ObjectGroup::defaultNewGroup(cx, &PlainObject::class_,
                                                                  TaggedProto(proto)));
         if (!group)
             return nullptr;
 
-        RootedPlainObject res(cx, NewObjectWithGroup<PlainObject>(cx, group, parent, kind,
+        RootedPlainObject res(cx, NewObjectWithGroup<PlainObject>(cx, group, kind,
                                                                   MaybeSingletonObject));
         if (!res)
             return nullptr;
 
         RootedShape newShape(cx, ReshapeForParentAndAllocKind(cx, srcObj->as<PlainObject>().lastProperty(),
-                                                              TaggedProto(proto), parent, kind));
+                                                              TaggedProto(proto), cx->global(), kind));
         if (!newShape || !res->setLastProperty(cx, newShape))
             return nullptr;
 
         return res;
     }
 
     RootedArrayObject srcArray(cx, &srcObj->as<ArrayObject>());
     MOZ_ASSERT(srcArray->denseElementsAreCopyOnWrite());
--- a/js/src/jsobj.h
+++ b/js/src/jsobj.h
@@ -1259,17 +1259,17 @@ ToObjectFromStack(JSContext *cx, HandleV
     return js::ToObjectSlow(cx, vp, true);
 }
 
 template<XDRMode mode>
 bool
 XDRObjectLiteral(XDRState<mode> *xdr, MutableHandleObject obj);
 
 extern JSObject *
-CloneObjectLiteral(JSContext *cx, HandleObject parent, HandleObject srcObj);
+CloneObjectLiteral(JSContext *cx, HandleObject srcObj);
 
 extern void
 GetObjectSlotName(JSTracer *trc, char *buf, size_t bufsize);
 
 extern bool
 ReportGetterOnlyAssignment(JSContext *cx, bool strict);
 
 extern JSObject *
--- a/js/src/jsobjinlines.h
+++ b/js/src/jsobjinlines.h
@@ -717,35 +717,35 @@ NewBuiltinClassInstance(ExclusiveContext
     return obj ? &obj->as<T>() : nullptr;
 }
 
 // Used to optimize calls to (new Object())
 bool
 NewObjectScriptedCall(JSContext *cx, MutableHandleObject obj);
 
 JSObject *
-NewObjectWithGroupCommon(ExclusiveContext *cx, HandleObjectGroup group, HandleObject parent,
+NewObjectWithGroupCommon(ExclusiveContext *cx, HandleObjectGroup group,
                          gc::AllocKind allocKind, NewObjectKind newKind);
 
 template <typename T>
 inline T *
-NewObjectWithGroup(ExclusiveContext *cx, HandleObjectGroup group, HandleObject parent,
+NewObjectWithGroup(ExclusiveContext *cx, HandleObjectGroup group,
                    gc::AllocKind allocKind, NewObjectKind newKind = GenericObject)
 {
-    JSObject *obj = NewObjectWithGroupCommon(cx, group, parent, allocKind, newKind);
+    JSObject *obj = NewObjectWithGroupCommon(cx, group, allocKind, newKind);
     return obj ? &obj->as<T>() : nullptr;
 }
 
 template <typename T>
 inline T *
-NewObjectWithGroup(ExclusiveContext *cx, HandleObjectGroup group, HandleObject parent,
+NewObjectWithGroup(ExclusiveContext *cx, HandleObjectGroup group,
                    NewObjectKind newKind = GenericObject)
 {
     gc::AllocKind allocKind = gc::GetGCObjectKind(group->clasp());
-    return NewObjectWithGroup<T>(cx, group, parent, allocKind, newKind);
+    return NewObjectWithGroup<T>(cx, group, allocKind, newKind);
 }
 
 /*
  * As for gc::GetGCObjectKind, where numSlots is a guess at the final size of
  * the object, zero if the final size is unknown. This should only be used for
  * objects that do not require any fixed slots.
  */
 static inline gc::AllocKind
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -3024,17 +3024,17 @@ js::CloneScript(JSContext *cx, HandleObj
                 }
             } else {
                 /*
                  * Clone object literals emitted for the JSOP_NEWOBJECT opcode. We only emit that
                  * instead of the less-optimized JSOP_NEWINIT for self-hosted code or code compiled
                  * with JSOPTION_COMPILE_N_GO set. As we don't clone the latter type of code, this
                  * case should only ever be hit when cloning objects from self-hosted code.
                  */
-                clone = CloneObjectLiteral(cx, cx->global(), obj);
+                clone = CloneObjectLiteral(cx, obj);
             }
             if (!clone || !objects.append(clone))
                 return nullptr;
         }
     }
 
     /* RegExps */
 
--- a/js/src/vm/ObjectGroup.cpp
+++ b/js/src/vm/ObjectGroup.cpp
@@ -959,17 +959,17 @@ ObjectGroup::newPlainObject(ExclusiveCon
 
         Rooted<TaggedProto> tagged(cx, TaggedProto(proto));
         RootedObjectGroup group(cx, ObjectGroupCompartment::makeGroup(cx, &PlainObject::class_,
                                                                       tagged));
         if (!group)
             return nullptr;
 
         gc::AllocKind allocKind = gc::GetGCObjectKind(nproperties);
-        RootedPlainObject obj(cx, NewObjectWithGroup<PlainObject>(cx, group, cx->global(),
+        RootedPlainObject obj(cx, NewObjectWithGroup<PlainObject>(cx, group,
                                                                   allocKind, TenuredObject));
         if (!obj || !AddPlainObjectProperties(cx, obj, properties, nproperties))
             return nullptr;
 
         // Don't make entries with duplicate property names, which will show up
         // here as objects with fewer properties than we thought we were
         // adding to the object. In this case, reset the object's group to the
         // default (which will have unknown properties) so that the group we
@@ -1061,17 +1061,17 @@ ObjectGroup::newPlainObject(ExclusiveCon
     }
 
     RootedShape shape(cx, p->value().shape);
 
     if (group->maybePreliminaryObjects())
         newKind = TenuredObject;
 
     gc::AllocKind allocKind = gc::GetGCObjectKind(nproperties);
-    RootedPlainObject obj(cx, NewObjectWithGroup<PlainObject>(cx, group, cx->global(), allocKind,
+    RootedPlainObject obj(cx, NewObjectWithGroup<PlainObject>(cx, group, allocKind,
                                                               newKind));
 
     if (!obj->setLastProperty(cx, shape))
         return nullptr;
 
     for (size_t i = 0; i < nproperties; i++)
         obj->setSlot(i, properties[i].value);
 
--- a/js/src/vm/RegExpObject.cpp
+++ b/js/src/vm/RegExpObject.cpp
@@ -61,22 +61,20 @@ RegExpObjectBuilder::getOrCreate()
     return true;
 }
 
 bool
 RegExpObjectBuilder::getOrCreateClone(HandleObjectGroup group)
 {
     MOZ_ASSERT(!reobj_);
     MOZ_ASSERT(group->clasp() == &RegExpObject::class_);
-    group->proto().toObject()->assertParentIs(&group->proto().toObject()->global());
-    RootedObject parent(cx, &group->proto().toObject()->global());
 
     // Note: RegExp objects are always allocated in the tenured heap. This is
     // not strictly required, but simplifies embedding them in jitcode.
-    reobj_ = NewObjectWithGroup<RegExpObject>(cx->asJSContext(), group, parent, TenuredObject);
+    reobj_ = NewObjectWithGroup<RegExpObject>(cx->asJSContext(), group, TenuredObject);
     if (!reobj_)
         return false;
     reobj_->initPrivate(nullptr);
 
     return true;
 }
 
 RegExpObject *
--- a/js/src/vm/TypeInference.cpp
+++ b/js/src/vm/TypeInference.cpp
@@ -3612,17 +3612,17 @@ TypeNewScript::maybeAnalyze(JSContext *c
                 while (newPrefixShape->slotSpan() > prefixShape->slotSpan())
                     newPrefixShape = newPrefixShape->previous();
             }
         }
         prefixShape = newPrefixShape;
     }
 
     RootedObjectGroup groupRoot(cx, group);
-    templateObject_ = NewObjectWithGroup<PlainObject>(cx, groupRoot, cx->global(), kind,
+    templateObject_ = NewObjectWithGroup<PlainObject>(cx, groupRoot, kind,
                                                       MaybeSingletonObject);
     if (!templateObject_)
         return false;
 
     Vector<Initializer> initializerVector(cx);
 
     RootedPlainObject templateRoot(cx, templateObject());
     if (!jit::AnalyzeNewScriptDefiniteProperties(cx, function(), group, templateRoot, &initializerVector))
--- a/js/src/vm/UnboxedObject.cpp
+++ b/js/src/vm/UnboxedObject.cpp
@@ -387,17 +387,17 @@ UnboxedLayout::makeNativeGroup(JSContext
     // group and objects that were allocated using the replacement new group.
     RootedObjectGroup replacementNewGroup(cx);
     if (layout.newScript()) {
         replacementNewGroup = ObjectGroupCompartment::makeGroup(cx, &PlainObject::class_, proto);
         if (!replacementNewGroup)
             return false;
 
         PlainObject *templateObject = NewObjectWithGroup<PlainObject>(cx, replacementNewGroup,
-                                                                      cx->global(), layout.getAllocKind(),
+                                                                      layout.getAllocKind(),
                                                                       MaybeSingletonObject);
         if (!templateObject)
             return false;
 
         for (size_t i = 0; i < layout.properties().length(); i++) {
             const UnboxedLayout::Property &property = layout.properties()[i];
             if (!templateObject->addDataProperty(cx, NameToId(property.name), i, JSPROP_ENUMERATE))
                 return false;
@@ -498,18 +498,18 @@ UnboxedPlainObject::convertToNative(JSCo
 
 /* static */
 UnboxedPlainObject *
 UnboxedPlainObject::create(ExclusiveContext *cx, HandleObjectGroup group, NewObjectKind newKind)
 {
     MOZ_ASSERT(group->clasp() == &class_);
     gc::AllocKind allocKind = group->unboxedLayout().getAllocKind();
 
-    UnboxedPlainObject *res = NewObjectWithGroup<UnboxedPlainObject>(cx, group, cx->global(),
-                                                                     allocKind, newKind);
+    UnboxedPlainObject *res =
+        NewObjectWithGroup<UnboxedPlainObject>(cx, group, allocKind, newKind);
     if (!res)
         return nullptr;
 
     // Avoid spurious shape guard hits.
     res->dummy_ = nullptr;
 
     // Initialize reference fields of the object. All fields in the object will
     // be overwritten shortly, but references need to be safe for the GC.