Bug 1132282 - Part 1: Handlify more parent args to NewObject; r=sfink
authorTerrence Cole <terrence@mozilla.com>
Fri, 13 Feb 2015 11:36:40 -0800
changeset 229195 7e497c0b0bad04f76d43d94e469b5a350c0a3598
parent 229194 ded390f05c90f01a05f8f924eaec5d24f530c42a
child 229196 78adb26a80b1d32f986ce49ed305c590ba067a6a
push id28282
push usercbook@mozilla.com
push dateMon, 16 Feb 2015 15:06:35 +0000
treeherdermozilla-central@09f4968d5f42 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1132282
milestone38.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 1132282 - Part 1: Handlify more parent args to NewObject; r=sfink
js/src/jsobj.cpp
js/src/jsobjinlines.h
js/src/vm/RegExpObject.cpp
js/src/vm/Shape.cpp
js/src/vm/TypeInference.cpp
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -1165,17 +1165,17 @@ NewObjectGCKind(const js::Class *clasp)
     if (clasp == &ArrayObject::class_)
         return gc::FINALIZE_OBJECT8;
     if (clasp == &JSFunction::class_)
         return gc::FINALIZE_OBJECT2;
     return gc::FINALIZE_OBJECT4;
 }
 
 static inline JSObject *
-NewObject(ExclusiveContext *cx, ObjectGroup *groupArg, JSObject *parent, gc::AllocKind kind,
+NewObject(ExclusiveContext *cx, ObjectGroup *groupArg, HandleObject parent, gc::AllocKind kind,
           NewObjectKind newKind)
 {
     const Class *clasp = groupArg->clasp();
 
     MOZ_ASSERT(clasp != &ArrayObject::class_);
     MOZ_ASSERT_IF(clasp == &JSFunction::class_,
                   kind == JSFunction::FinalizeKind || kind == JSFunction::ExtendedFinalizeKind);
     MOZ_ASSERT_IF(parent, &parent->global() == cx->global());
@@ -1459,17 +1459,17 @@ js::NewObjectWithClassProtoCommon(Exclus
     return obj;
 }
 
 /*
  * 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(JSContext *cx, HandleObjectGroup group, JSObject *parent,
+js::NewObjectWithGroupCommon(JSContext *cx, HandleObjectGroup group, HandleObject parent,
                              gc::AllocKind allocKind, NewObjectKind newKind)
 {
     MOZ_ASSERT(parent);
 
     MOZ_ASSERT(allocKind <= gc::FINALIZE_OBJECT_LAST);
     if (CanBeFinalizedInBackground(allocKind, group->clasp()))
         allocKind = GetBackgroundAllocKind(allocKind);
 
@@ -1483,17 +1483,17 @@ js::NewObjectWithGroupCommon(JSContext *
         !cx->compartment()->hasObjectMetadataCallback())
     {
         if (cache.lookupGroup(group, allocKind, &entry)) {
             JSObject *obj = cache.newObjectFromHit<NoGC>(cx, entry, GetInitialHeap(newKind, group->clasp()));
             if (obj) {
                 return obj;
             } else {
                 obj = cache.newObjectFromHit<CanGC>(cx, entry, GetInitialHeap(newKind, group->clasp()));
-                parent = group->proto().toObject()->getParent();
+                MOZ_ASSERT(!obj);
             }
         }
     }
 
     JSObject *obj = NewObject(cx, group, parent, allocKind, newKind);
     if (!obj)
         return nullptr;
 
@@ -1535,17 +1535,17 @@ js::CreateThis(JSContext *cx, const Clas
 
     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);
 }
 
 static inline JSObject *
-CreateThisForFunctionWithGroup(JSContext *cx, HandleObjectGroup group, JSObject *parent,
+CreateThisForFunctionWithGroup(JSContext *cx, HandleObjectGroup group, HandleObject parent,
                                NewObjectKind newKind)
 {
     if (group->maybeUnboxedLayout() && newKind != SingletonObject)
         return UnboxedPlainObject::create(cx, group, newKind);
 
     if (TypeNewScript *newScript = group->newScript()) {
         if (newScript->analyzed()) {
             // The definite properties analysis has been performed for this
@@ -1618,17 +1618,18 @@ js::CreateThisForFunctionWithProto(JSCon
                 // The script was analyzed successfully and may have changed
                 // the new type table, so refetch the group.
                 group = ObjectGroup::defaultNewGroup(cx, nullptr, TaggedProto(proto),
                                                      &callee->as<JSFunction>());
                 MOZ_ASSERT(group && group->newScript());
             }
         }
 
-        res = CreateThisForFunctionWithGroup(cx, group, callee->getParent(), newKind);
+        RootedObject parent(cx, callee->getParent());
+        res = CreateThisForFunctionWithGroup(cx, group, parent, newKind);
     } else {
         RootedObject parent(cx, callee->getParent());
         gc::AllocKind allocKind = NewObjectGCKind(&PlainObject::class_);
         res = NewObjectWithProto<PlainObject>(cx, proto, parent, allocKind, newKind);
     }
 
     if (res) {
         JSScript *script = callee->as<JSFunction>().getOrCreateScript(cx);
--- a/js/src/jsobjinlines.h
+++ b/js/src/jsobjinlines.h
@@ -617,39 +617,39 @@ NewBuiltinClassInstance(ExclusiveContext
     return obj ? &obj->as<T>() : nullptr;
 }
 
 // Used to optimize calls to (new Object())
 bool
 NewObjectScriptedCall(JSContext *cx, MutableHandleObject obj);
 
 JSObject *
-NewObjectWithGroupCommon(JSContext *cx, HandleObjectGroup group, JSObject *parent,
+NewObjectWithGroupCommon(JSContext *cx, HandleObjectGroup group, HandleObject parent,
                          gc::AllocKind allocKind, NewObjectKind newKind);
 
 template <typename T>
 inline T *
-NewObjectWithGroup(JSContext *cx, HandleObjectGroup group, JSObject *parent,
+NewObjectWithGroup(JSContext *cx, HandleObjectGroup group, HandleObject parent,
                    gc::AllocKind allocKind, NewObjectKind newKind = GenericObject)
 {
     JSObject *obj = NewObjectWithGroupCommon(cx, group, parent, allocKind, newKind);
     return obj ? &obj->as<T>() : nullptr;
 }
 
 template <typename T>
 inline T *
-NewObjectWithGroup(JSContext *cx, HandleObjectGroup group, JSObject *parent,
+NewObjectWithGroup(JSContext *cx, HandleObjectGroup group, HandleObject parent,
                    NewObjectKind newKind = GenericObject)
 {
     gc::AllocKind allocKind = gc::GetGCObjectKind(group->clasp());
     return NewObjectWithGroup<T>(cx, group, parent, allocKind, newKind);
 }
 
 JSObject *
-NewReshapedObject(JSContext *cx, HandleObjectGroup group, JSObject *parent,
+NewReshapedObject(JSContext *cx, HandleObjectGroup group, HandleObject parent,
                   gc::AllocKind allocKind, HandleShape shape,
                   NewObjectKind newKind = GenericObject);
 
 /*
  * 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.
  */
--- a/js/src/vm/RegExpObject.cpp
+++ b/js/src/vm/RegExpObject.cpp
@@ -62,17 +62,17 @@ RegExpObjectBuilder::getOrCreate()
 }
 
 bool
 RegExpObjectBuilder::getOrCreateClone(HandleObjectGroup group)
 {
     MOZ_ASSERT(!reobj_);
     MOZ_ASSERT(group->clasp() == &RegExpObject::class_);
 
-    JSObject *parent = group->proto().toObject()->getParent();
+    RootedObject parent(cx, group->proto().toObject()->getParent());
 
     // 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);
     if (!reobj_)
         return false;
     reobj_->initPrivate(nullptr);
 
--- a/js/src/vm/Shape.cpp
+++ b/js/src/vm/Shape.cpp
@@ -597,17 +597,17 @@ NativeObject::addPropertyInternal(Exclus
         return shape;
     }
 
     obj->checkShapeConsistency();
     return nullptr;
 }
 
 JSObject *
-js::NewReshapedObject(JSContext *cx, HandleObjectGroup group, JSObject *parent,
+js::NewReshapedObject(JSContext *cx, HandleObjectGroup group, HandleObject parent,
                       gc::AllocKind allocKind, HandleShape shape, NewObjectKind newKind)
 {
     RootedPlainObject res(cx, NewObjectWithGroup<PlainObject>(cx, group, parent, allocKind, newKind));
     if (!res)
         return nullptr;
 
     if (shape->isEmptyShape())
         return res;
--- a/js/src/vm/TypeInference.cpp
+++ b/js/src/vm/TypeInference.cpp
@@ -3292,17 +3292,18 @@ CommonPrefix(Shape *first, Shape *second
 static bool
 ChangeObjectFixedSlotCount(JSContext *cx, PlainObject *obj, gc::AllocKind allocKind)
 {
     MOZ_ASSERT(OnlyHasDataProperties(obj->lastProperty()));
 
     // Make a clone of the object, with the new allocation kind.
     RootedShape oldShape(cx, obj->lastProperty());
     RootedObjectGroup group(cx, obj->group());
-    JSObject *clone = NewReshapedObject(cx, group, obj->getParent(), allocKind, oldShape);
+    RootedObject parent(cx, obj->getParent());
+    JSObject *clone = NewReshapedObject(cx, group, parent, allocKind, oldShape);
     if (!clone)
         return false;
 
     obj->setLastPropertyShrinkFixedSlots(clone->lastProperty());
     return true;
 }
 
 namespace {