Bug 1190911 - Replace AutoIdValueVector with normal Rooted usage; r=jonco
authorTerrence Cole <terrence@mozilla.com>
Tue, 04 Aug 2015 08:50:12 -0700
changeset 288095 fe4520e7fc27fea9b7555efb5befcfa23ea82df0
parent 288094 a7860794b00e186b56dff097c1727c5d0ab3474e
child 288096 21c28216e5e7255fa072ceefe2f31b1930758f34
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1190911
milestone42.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 1190911 - Replace AutoIdValueVector with normal Rooted usage; r=jonco
js/src/ds/IdValuePair.h
js/src/frontend/BytecodeEmitter.cpp
js/src/gc/RootMarking.cpp
js/src/jscntxt.h
js/src/jsobj.cpp
js/src/jspubtd.h
--- a/js/src/ds/IdValuePair.h
+++ b/js/src/ds/IdValuePair.h
@@ -5,44 +5,40 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef ds_IdValuePair_h
 #define ds_IdValuePair_h
 
 #include "jsapi.h"
 
 #include "NamespaceImports.h"
+#include "gc/Tracer.h"
 #include "js/Id.h"
+#include "js/TraceableVector.h"
 
 namespace js {
 
 struct IdValuePair
 {
+    Value value;
     jsid id;
-    Value value;
 
     IdValuePair()
-      : id(JSID_EMPTY), value(UndefinedValue())
+      : value(UndefinedValue()), id(JSID_EMPTY)
     {}
     explicit IdValuePair(jsid idArg)
-      : id(idArg), value(UndefinedValue())
+      : value(UndefinedValue()), id(idArg)
     {}
     IdValuePair(jsid idArg, Value valueArg)
-      : id(idArg), value(valueArg)
+      : value(valueArg), id(idArg)
     {}
+
+    void trace(JSTracer* trc) {
+        TraceRoot(trc, &value, "IdValuePair::value");
+        TraceRoot(trc, &id, "IdValuePair::id");
+    }
 };
 
-class MOZ_STACK_CLASS AutoIdValueVector : public JS::AutoVectorRooterBase<IdValuePair>
-{
-  public:
-    explicit AutoIdValueVector(ContextFriendFields* cx
-                               MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
-        : AutoVectorRooterBase<IdValuePair>(cx, IDVALVECTOR)
-    {
-        MOZ_GUARD_OBJECT_NOTIFIER_INIT;
-    }
-
-    MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
-};
+using IdValueVector = TraceableVector<IdValuePair>;
 
 } /* namespace js */
 
 #endif /* ds_IdValuePair_h */
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -4654,17 +4654,17 @@ ParseNode::getConstantValue(ExclusiveCon
         MOZ_ASSERT(!(pn_xflags & PNX_NONCONST));
 
         if (allowObjects == DontAllowObjects) {
             vp.setMagic(JS_GENERIC_MAGIC);
             return true;
         }
         MOZ_ASSERT(allowObjects == AllowObjects);
 
-        AutoIdValueVector properties(cx);
+        Rooted<IdValueVector> properties(cx, IdValueVector(cx));
 
         RootedValue value(cx), idvalue(cx);
         for (ParseNode* pn = pn_head; pn; pn = pn->pn_next) {
             if (!pn->pn_right->getConstantValue(cx, allowObjects, &value))
                 return false;
             if (value.isMagic(JS_GENERIC_MAGIC)) {
                 vp.setMagic(JS_GENERIC_MAGIC);
                 return true;
--- a/js/src/gc/RootMarking.cpp
+++ b/js/src/gc/RootMarking.cpp
@@ -110,25 +110,16 @@ AutoGCRooter::trace(JSTracer* trc)
       }
 
       case IDVECTOR: {
         AutoIdVector::VectorImpl& vector = static_cast<AutoIdVector*>(this)->vector;
         TraceRootRange(trc, vector.length(), vector.begin(), "JS::AutoIdVector.vector");
         return;
       }
 
-      case IDVALVECTOR: {
-        AutoIdValueVector::VectorImpl& vector = static_cast<AutoIdValueVector*>(this)->vector;
-        for (size_t i = 0; i < vector.length(); i++) {
-            TraceRoot(trc, &vector[i].id, "js::AutoIdValueVector id");
-            TraceRoot(trc, &vector[i].value, "js::AutoIdValueVector value");
-        }
-        return;
-      }
-
       case OBJVECTOR: {
         AutoObjectVector::VectorImpl& vector = static_cast<AutoObjectVector*>(this)->vector;
         TraceRootRange(trc, vector.length(), vector.begin(), "JS::AutoObjectVector.vector");
         return;
       }
 
       case NAMEVECTOR: {
         AutoNameVector::VectorImpl& vector = static_cast<AutoNameVector*>(this)->vector;
--- a/js/src/jscntxt.h
+++ b/js/src/jscntxt.h
@@ -500,20 +500,21 @@ struct AutoResolving {
     Kind                const kind;
     AutoResolving*      const link;
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
 /*
  * Enumerate all contexts in a runtime.
  */
-class ContextIter {
+class ContextIter
+{
     JSContext* iter;
 
-public:
+  public:
     explicit ContextIter(JSRuntime* rt) {
         iter = rt->contextList.getFirst();
     }
 
     bool done() const {
         return !iter;
     }
 
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -1211,17 +1211,18 @@ GetScriptArrayObjectElements(JSContext* 
             values[index].set(aobj->getSlot(shape.slot()));
         }
     }
 
     return true;
 }
 
 static bool
-GetScriptPlainObjectProperties(JSContext* cx, HandleObject obj, AutoIdValueVector& properties)
+GetScriptPlainObjectProperties(JSContext* cx, HandleObject obj,
+                               MutableHandle<IdValueVector> properties)
 {
     if (obj->is<PlainObject>()) {
         PlainObject* nobj = &obj->as<PlainObject>();
 
         if (!properties.appendN(IdValuePair(), nobj->slotSpan()))
             return false;
 
         for (Shape::Range<NoGC> r(nobj->lastProperty()); !r.empty(); r.popFront()) {
@@ -1297,18 +1298,18 @@ js::DeepCloneObjectLiteral(JSContext* cx
         ObjectGroup::NewArrayKind arrayKind = ObjectGroup::NewArrayKind::Normal;
         if (obj->is<ArrayObject>() && obj->as<ArrayObject>().denseElementsAreCopyOnWrite())
             arrayKind = ObjectGroup::NewArrayKind::CopyOnWrite;
 
         return ObjectGroup::newArrayObject(cx, values.begin(), values.length(), newKind,
                                            arrayKind);
     }
 
-    AutoIdValueVector properties(cx);
-    if (!GetScriptPlainObjectProperties(cx, obj, properties))
+    Rooted<IdValueVector> properties(cx, IdValueVector(cx));
+    if (!GetScriptPlainObjectProperties(cx, obj, &properties))
         return nullptr;
 
     for (size_t i = 0; i < properties.length(); i++) {
         if (!DeepCloneValue(cx, &properties[i].get().value, newKind))
             return nullptr;
     }
 
     if (obj->isSingleton())
@@ -1448,18 +1449,18 @@ js::XDRObjectLiteral(XDRState<mode>* xdr
             if (!obj)
                 return false;
         }
 
         return true;
     }
 
     // Code the properties in the object.
-    AutoIdValueVector properties(cx);
-    if (mode == XDR_ENCODE && !GetScriptPlainObjectProperties(cx, obj, properties))
+    Rooted<IdValueVector> properties(cx, IdValueVector(cx));
+    if (mode == XDR_ENCODE && !GetScriptPlainObjectProperties(cx, obj, &properties))
         return false;
 
     uint32_t nproperties = properties.length();
     if (!xdr->codeUint32(&nproperties))
         return false;
 
     if (mode == XDR_DECODE && !properties.appendN(IdValuePair(), nproperties))
         return false;
--- a/js/src/jspubtd.h
+++ b/js/src/jspubtd.h
@@ -217,17 +217,16 @@ class JS_PUBLIC_API(AutoGCRooter)
     ptrdiff_t tag_;
 
     enum {
         VALARRAY =     -2, /* js::AutoValueArray */
         PARSER =       -3, /* js::frontend::Parser */
         IDARRAY =      -6, /* js::AutoIdArray */
         VALVECTOR =   -10, /* js::AutoValueVector */
         IDVECTOR =    -11, /* js::AutoIdVector */
-        IDVALVECTOR = -12, /* js::AutoIdValueVector */
         OBJVECTOR =   -14, /* js::AutoObjectVector */
         SCRIPTVECTOR =-16, /* js::AutoScriptVector */
         NAMEVECTOR =  -17, /* js::AutoNameVector */
         HASHABLEVALUE=-18, /* js::HashableValue */
         IONMASM =     -19, /* js::jit::MacroAssembler */
         WRAPVECTOR =  -20, /* js::AutoWrapperVector */
         WRAPPER =     -21, /* js::AutoWrapperRooter */
         JSONPARSER =  -25, /* js::JSONParser */