Bug 1442587 - Part 1: Avoid Vector<Value> in JSObject::swap. r=Waldo
☠☠ backed out by ea523d724c71 ☠ ☠
authorJason Orendorff <jorendorff@mozilla.com>
Thu, 30 Aug 2018 12:54:56 -0500
changeset 435223 f88b838fa1b42b7f8a13817afdf08d080d9ca307
parent 435222 a5b2607fc1885b4f86cc7421fda89a19737788e4
child 435224 60a28b2e2493b1109d2274a57aa273f14c433d49
push id107603
push userapavel@mozilla.com
push dateFri, 07 Sep 2018 21:41:00 +0000
treeherdermozilla-inbound@7e7d80003930 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs1442587
milestone64.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 1442587 - Part 1: Avoid Vector<Value> in JSObject::swap. r=Waldo
js/src/vm/JSObject.cpp
js/src/vm/NativeObject.h
js/src/vm/ProxyObject.h
--- a/js/src/vm/JSObject.cpp
+++ b/js/src/vm/JSObject.cpp
@@ -1552,17 +1552,17 @@ js::XDRObjectLiteral(XDRState<mode>* xdr
 template XDRResult
 js::XDRObjectLiteral(XDRState<XDR_ENCODE>* xdr, MutableHandleObject obj);
 
 template XDRResult
 js::XDRObjectLiteral(XDRState<XDR_DECODE>* xdr, MutableHandleObject obj);
 
 /* static */ bool
 NativeObject::fillInAfterSwap(JSContext* cx, HandleNativeObject obj,
-                              const Vector<Value>& values, void* priv)
+                              const AutoValueVector& values, void* priv)
 {
     // This object has just been swapped with some other object, and its shape
     // no longer reflects its allocated size. Correct this information and
     // fill the slots in with the specified values.
     MOZ_ASSERT(obj->slotSpan() == values.length());
 
     // Make sure the shape's numFixedSlots() is correct.
     size_t nfixed = gc::GetGCKindSlots(obj->asTenured().getAllocKind(), obj->getClass());
@@ -1598,17 +1598,17 @@ JSObject::fixDictionaryShapeAfterSwap()
 {
     // Dictionary shapes can point back to their containing objects, so after
     // swapping the guts of those objects fix the pointers up.
     if (isNative() && as<NativeObject>().inDictionaryMode())
         as<NativeObject>().shape()->listp = as<NativeObject>().shapePtr();
 }
 
 static MOZ_MUST_USE bool
-CopyProxyValuesBeforeSwap(JSContext* cx, ProxyObject* proxy, Vector<Value>& values)
+CopyProxyValuesBeforeSwap(JSContext* cx, ProxyObject* proxy, AutoValueVector& values)
 {
     MOZ_ASSERT(values.empty());
 
     // Remove the GCPtrValues we're about to swap from the store buffer, to
     // ensure we don't trace bogus values.
     StoreBuffer& sb = cx->runtime()->gc.storeBuffer();
 
     // Reserve space for the private slot and the reserved slots.
@@ -1623,17 +1623,17 @@ CopyProxyValuesBeforeSwap(JSContext* cx,
         sb.unputValue(&valArray->reservedSlots.slots[i]);
         values.infallibleAppend(valArray->reservedSlots.slots[i]);
     }
 
     return true;
 }
 
 bool
-ProxyObject::initExternalValueArrayAfterSwap(JSContext* cx, const Vector<Value>& values)
+ProxyObject::initExternalValueArrayAfterSwap(JSContext* cx, const AutoValueVector& values)
 {
     MOZ_ASSERT(getClass()->isProxy());
 
     size_t nreserved = numReservedSlots();
 
     // |values| contains the private slot and the reserved slots.
     MOZ_ASSERT(values.length() == 1 + nreserved);
 
@@ -1738,26 +1738,26 @@ JSObject::swap(JSContext* cx, HandleObje
 
         // When the objects have different sizes, they will have different
         // numbers of fixed slots before and after the swap, so the slots for
         // native objects will need to be rearranged.
         NativeObject* na = a->isNative() ? &a->as<NativeObject>() : nullptr;
         NativeObject* nb = b->isNative() ? &b->as<NativeObject>() : nullptr;
 
         // Remember the original values from the objects.
-        Vector<Value> avals(cx);
+        AutoValueVector avals(cx);
         void* apriv = nullptr;
         if (na) {
             apriv = na->hasPrivate() ? na->getPrivate() : nullptr;
             for (size_t i = 0; i < na->slotSpan(); i++) {
                 if (!avals.append(na->getSlot(i)))
                     oomUnsafe.crash("JSObject::swap");
             }
         }
-        Vector<Value> bvals(cx);
+        AutoValueVector bvals(cx);
         void* bpriv = nullptr;
         if (nb) {
             bpriv = nb->hasPrivate() ? nb->getPrivate() : nullptr;
             for (size_t i = 0; i < nb->slotSpan(); i++) {
                 if (!bvals.append(nb->getSlot(i)))
                     oomUnsafe.crash("JSObject::swap");
             }
         }
--- a/js/src/vm/NativeObject.h
+++ b/js/src/vm/NativeObject.h
@@ -961,17 +961,17 @@ class NativeObject : public ShapedObject
 
     static Shape*
     addAccessorPropertyInternal(JSContext* cx, HandleNativeObject obj, HandleId id,
                                 JSGetterOp getter, JSSetterOp setter, unsigned attrs,
                                 ShapeTable* table, ShapeTable::Entry* entry,
                                 const AutoKeepShapeTables& keep);
 
     static MOZ_MUST_USE bool fillInAfterSwap(JSContext* cx, HandleNativeObject obj,
-                                             const Vector<Value>& values, void* priv);
+                                             const AutoValueVector& values, void* priv);
 
   public:
     // Return true if this object has been converted from shared-immutable
     // prototype-rooted shape storage to dictionary-shapes in a doubly-linked
     // list.
     bool inDictionaryMode() const {
         return lastProperty()->inDictionary();
     }
--- a/js/src/vm/ProxyObject.h
+++ b/js/src/vm/ProxyObject.h
@@ -52,17 +52,18 @@ class ProxyObject : public ShapedObject
         return (void*)(uintptr_t(this) + sizeof(ProxyObject));
     }
     bool usingInlineValueArray() const {
         return data.values() == inlineDataStart();
     }
     void setInlineValueArray() {
         data.reservedSlots = &reinterpret_cast<detail::ProxyValueArray*>(inlineDataStart())->reservedSlots;
     }
-    MOZ_MUST_USE bool initExternalValueArrayAfterSwap(JSContext* cx, const Vector<Value>& values);
+    MOZ_MUST_USE bool initExternalValueArrayAfterSwap(JSContext* cx,
+                                                      const AutoValueVector& values);
 
     const Value& private_() const {
         return GetProxyPrivate(this);
     }
 
     void setCrossCompartmentPrivate(const Value& priv);
     void setSameCompartmentPrivate(const Value& priv);