Bug 852667 - Permit passing #fixed slots to getInitialShape (r=bhackett)
authorBill McCloskey <wmccloskey@mozilla.com>
Mon, 18 Mar 2013 17:27:09 -0700
changeset 125937 c4a29b7a2ead0b062b1f1c7c8846fc3e74cdbd09
parent 125936 7f4e825f7c04326a114f304afb09d288975daeb5
child 125938 5a97d33c3a071db58dd6b1d1f24d531e103bdb03
push id25180
push userwmccloskey@mozilla.com
push dateFri, 22 Mar 2013 18:01:41 +0000
treeherdermozilla-inbound@4b3ba25df1af [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs852667
milestone22.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 852667 - Permit passing #fixed slots to getInitialShape (r=bhackett)
js/src/jsobj.cpp
js/src/vm/Shape.cpp
js/src/vm/Shape.h
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -1070,17 +1070,17 @@ JSObject::sealOrFreeze(JSContext *cx, Ha
          * hierarchy mirroring the original one, which can be shared if many
          * objects with the same structure are sealed/frozen. If we use the
          * generic path below then any non-empty object will be converted to
          * dictionary mode.
          */
         RootedShape last(cx, EmptyShape::getInitialShape(cx, obj->getClass(),
                                                          obj->getTaggedProto(),
                                                          obj->getParent(),
-                                                         obj->getAllocKind(),
+                                                         obj->numFixedSlots(),
                                                          obj->lastProperty()->getObjectFlags()));
         if (!last)
             return false;
 
         /* Get an in order list of the shapes in this object. */
         AutoShapeVector shapes(cx);
         for (Shape::Range<NoGC> r(obj->lastProperty()); !r.empty(); r.popFront()) {
             if (!shapes.append(&r.front()))
@@ -1803,26 +1803,26 @@ JSObject::ReserveForTradeGuts(JSContext 
      * inline slots. The fixed slots will be updated in place during TradeGuts.
      * Non-native objects need to be reshaped according to the new count.
      */
     if (a->isNative()) {
         if (!a->generateOwnShape(cx))
             return false;
     } else {
         reserved.newbshape = EmptyShape::getInitialShape(cx, aClass, aProto, a->getParent(),
-                                                         b->getAllocKind());
+                                                         b->numFixedSlots());
         if (!reserved.newbshape)
             return false;
     }
     if (b->isNative()) {
         if (!b->generateOwnShape(cx))
             return false;
     } else {
         reserved.newashape = EmptyShape::getInitialShape(cx, bClass, bProto, b->getParent(),
-                                                         a->getAllocKind());
+                                                         a->numFixedSlots());
         if (!reserved.newashape)
             return false;
     }
 
     /* The avals/bvals vectors hold all original values from the objects. */
 
     if (!reserved.avals.reserve(a->slotSpan()))
         return false;
--- a/js/src/vm/Shape.cpp
+++ b/js/src/vm/Shape.cpp
@@ -1225,27 +1225,26 @@ InitialShapeEntry::match(const InitialSh
         && lookup.proto.toWord() == key.proto.toWord()
         && lookup.parent == shape->getObjectParent()
         && lookup.nfixed == shape->numFixedSlots()
         && lookup.baseFlags == shape->getObjectFlags();
 }
 
 /* static */ Shape *
 EmptyShape::getInitialShape(JSContext *cx, Class *clasp, TaggedProto proto, JSObject *parent,
-                            AllocKind kind, uint32_t objectFlags)
+                            size_t nfixed, uint32_t objectFlags)
 {
     JS_ASSERT_IF(proto.isObject(), cx->compartment == proto.toObject()->compartment());
     JS_ASSERT_IF(parent, cx->compartment == parent->compartment());
 
     InitialShapeSet &table = cx->compartment->initialShapes;
 
     if (!table.initialized() && !table.init())
         return NULL;
 
-    size_t nfixed = GetGCKindSlots(kind, clasp);
     InitialShapeEntry::Lookup lookup(clasp, proto, parent, nfixed, objectFlags);
 
     InitialShapeSet::AddPtr p = table.lookupForAdd(lookup);
 
     if (p)
         return p->shape;
 
     Rooted<TaggedProto> protoRoot(cx, lookup.proto);
@@ -1265,16 +1264,23 @@ EmptyShape::getInitialShape(JSContext *c
     lookup.parent = parentRoot;
 
     if (!table.relookupOrAdd(p, lookup, InitialShapeEntry(shape, lookup.proto)))
         return NULL;
 
     return shape;
 }
 
+/* static */ Shape *
+EmptyShape::getInitialShape(JSContext *cx, Class *clasp, TaggedProto proto, JSObject *parent,
+                            AllocKind kind, uint32_t objectFlags)
+{
+    return getInitialShape(cx, clasp, proto, parent, GetGCKindSlots(kind, clasp), objectFlags);
+}
+
 void
 NewObjectCache::invalidateEntriesForShape(JSContext *cx, HandleShape shape, HandleObject proto)
 {
     Class *clasp = shape->getObjectClass();
 
     gc::AllocKind kind = gc::GetGCObjectKind(shape->numFixedSlots());
     if (CanBeFinalizedInBackground(kind, clasp))
         kind = GetBackgroundAllocKind(kind);
--- a/js/src/vm/Shape.h
+++ b/js/src/vm/Shape.h
@@ -894,16 +894,18 @@ struct EmptyShape : public js::Shape
 {
     EmptyShape(RawUnownedBaseShape base, uint32_t nfixed);
 
     /*
      * Lookup an initial shape matching the given parameters, creating an empty
      * shape if none was found.
      */
     static Shape *getInitialShape(JSContext *cx, Class *clasp, TaggedProto proto,
+                                  JSObject *parent, size_t nfixed, uint32_t objectFlags = 0);
+    static Shape *getInitialShape(JSContext *cx, Class *clasp, TaggedProto proto,
                                   JSObject *parent, gc::AllocKind kind, uint32_t objectFlags = 0);
 
     /*
      * Reinsert an alternate initial shape, to be returned by future
      * getInitialShape calls, until the new shape becomes unreachable in a GC
      * and the table entry is purged.
      */
     static void insertInitialShape(JSContext *cx, HandleShape shape, HandleObject proto);