Bug 1190636 - Replace AutoStringVector with Rooted usage; r=njn
authorTerrence Cole <terrence@mozilla.com>
Mon, 03 Aug 2015 17:39:03 -0700
changeset 287900 a220d2e6b9047a8c004b4a93c656ec862d4ee0f3
parent 287899 7cbb4de9b9c621f6cf1bf805cfa4376432b63e67
child 287901 d18e3a6d5149099a25c54f51a8b3972b395dee6b
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)
reviewersnjn
bugs1190636
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 1190636 - Replace AutoStringVector with Rooted usage; r=njn
js/public/TraceableVector.h
js/src/gc/RootMarking.cpp
js/src/jscntxt.h
js/src/jspubtd.h
js/src/jsstr.cpp
--- a/js/public/TraceableVector.h
+++ b/js/public/TraceableVector.h
@@ -128,17 +128,17 @@ class MutableTraceableVectorOperations
     void infallibleAppendN(const T& aT, size_t aN) { vec().infallibleAppendN(aT, aN); }
     template<typename U> void infallibleAppend(const U* aBegin, const U* aEnd) {
         vec().infallibleAppend(aBegin, aEnd);
     }
     template<typename U> void infallibleAppend(const U* aBegin, size_t aLength) {
         vec().infallibleAppend(aBegin, aLength);
     }
     void popBack() { vec().popBack(); }
-    T popCopy() { return vec().podCopy(); }
+    T popCopy() { return vec().popCopy(); }
     template<typename U> T* insert(T* aP, U&& aVal) {
         return vec().insert(aP, mozilla::Forward<U>(aVal));
     }
     void erase(T* aT) { vec().erase(aT); }
     void erase(T* aBegin, T* aEnd) { vec().erase(aBegin, aEnd); }
 };
 
 template <typename T, size_t N, typename AP, typename TP>
--- a/js/src/gc/RootMarking.cpp
+++ b/js/src/gc/RootMarking.cpp
@@ -125,22 +125,16 @@ AutoGCRooter::trace(JSTracer* trc)
       }
 
       case OBJVECTOR: {
         AutoObjectVector::VectorImpl& vector = static_cast<AutoObjectVector*>(this)->vector;
         TraceRootRange(trc, vector.length(), vector.begin(), "JS::AutoObjectVector.vector");
         return;
       }
 
-      case STRINGVECTOR: {
-        AutoStringVector::VectorImpl& vector = static_cast<AutoStringVector*>(this)->vector;
-        TraceRootRange(trc, vector.length(), vector.begin(), "js::AutoStringVector.vector");
-        return;
-      }
-
       case NAMEVECTOR: {
         AutoNameVector::VectorImpl& vector = static_cast<AutoNameVector*>(this)->vector;
         TraceRootRange(trc, vector.length(), vector.begin(), "js::AutoNameVector.vector");
         return;
       }
 
       case VALARRAY: {
         /*
--- a/js/src/jscntxt.h
+++ b/js/src/jscntxt.h
@@ -658,20 +658,20 @@ CheckForInterrupt(JSContext* cx)
     JSRuntime* rt = cx->runtime();
     if (MOZ_UNLIKELY(rt->hasPendingInterrupt()))
         return rt->handleInterrupt(cx);
     return true;
 }
 
 /************************************************************************/
 
-typedef JS::AutoVectorRooter<JSString*> AutoStringVector;
 typedef JS::AutoVectorRooter<PropertyName*> AutoPropertyNameVector;
 
 using ShapeVector = js::TraceableVector<Shape*>;
+using StringVector = js::TraceableVector<JSString*>;
 
 /* AutoArrayRooter roots an external array of Values. */
 class AutoArrayRooter : private JS::AutoGCRooter
 {
   public:
     AutoArrayRooter(JSContext* cx, size_t len, Value* vec
                     MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : JS::AutoGCRooter(cx, len), array(vec)
--- a/js/src/jspubtd.h
+++ b/js/src/jspubtd.h
@@ -219,32 +219,30 @@ class JS_PUBLIC_API(AutoGCRooter)
     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 */
-        STRINGVECTOR =-15, /* js::AutoStringVector */
         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 */
         CUSTOM =      -26  /* js::CustomAutoRooter */
     };
 
     static ptrdiff_t GetTag(const Value& value) { return VALVECTOR; }
     static ptrdiff_t GetTag(const jsid& id) { return IDVECTOR; }
     static ptrdiff_t GetTag(JSObject* obj) { return OBJVECTOR; }
     static ptrdiff_t GetTag(JSScript* script) { return SCRIPTVECTOR; }
-    static ptrdiff_t GetTag(JSString* string) { return STRINGVECTOR; }
 
   private:
     AutoGCRooter ** const stackTop;
 
     /* No copy or assignment semantics. */
     AutoGCRooter(AutoGCRooter& ida) = delete;
     void operator=(AutoGCRooter& ida) = delete;
 };
--- a/js/src/jsstr.cpp
+++ b/js/src/jsstr.cpp
@@ -1343,33 +1343,33 @@ js::StringFindPattern(JSLinearString* te
 
 // When an algorithm does not need a string represented as a single linear
 // array of characters, this range utility may be used to traverse the string a
 // sequence of linear arrays of characters. This avoids flattening ropes.
 class StringSegmentRange
 {
     // If malloc() shows up in any profiles from this vector, we can add a new
     // StackAllocPolicy which stashes a reusable freed-at-gc buffer in the cx.
-    AutoStringVector stack;
+    Rooted<StringVector> stack;
     RootedLinearString cur;
 
     bool settle(JSString* str) {
         while (str->isRope()) {
             JSRope& rope = str->asRope();
             if (!stack.append(rope.rightChild()))
                 return false;
             str = rope.leftChild();
         }
         cur = &str->asLinear();
         return true;
     }
 
   public:
     explicit StringSegmentRange(JSContext* cx)
-      : stack(cx), cur(cx)
+      : stack(cx, StringVector(cx)), cur(cx)
     {}
 
     MOZ_WARN_UNUSED_RESULT bool init(JSString* str) {
         MOZ_ASSERT(stack.empty());
         return settle(str);
     }
 
     bool empty() const {