зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1245316 - Use Rooted<GCVector> to implement AutoVector; r=sfink
--HG-- extra : rebase_source : 24a7c4e21ea94820d94a4e8454044e4f1988365e
This commit is contained in:
Родитель
aa1716839f
Коммит
02f5e80db6
|
@ -22,9 +22,7 @@ class nsICycleCollectorListener;
|
|||
class nsScriptNameSpaceManager;
|
||||
|
||||
namespace JS {
|
||||
template <typename T>
|
||||
class AutoVectorRooter;
|
||||
typedef AutoVectorRooter<Value> AutoValueVector;
|
||||
class AutoValueVector;
|
||||
} // namespace JS
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
@ -40,9 +40,7 @@ extern JS_FRIEND_DATA(const js::Class* const) FunctionClassPtr;
|
|||
|
||||
namespace JS {
|
||||
|
||||
template <typename T>
|
||||
class AutoVectorRooter;
|
||||
typedef AutoVectorRooter<jsid> AutoIdVector;
|
||||
class AutoIdVector;
|
||||
|
||||
/**
|
||||
* The answer to a successful query as to whether an object is an Array per
|
||||
|
|
|
@ -98,6 +98,11 @@ class GCVector
|
|||
return vector.infallibleAppend(aBegin, aLength);
|
||||
}
|
||||
|
||||
template<typename U, size_t O, class BP>
|
||||
bool appendAll(const mozilla::Vector<U, O, BP>& aU) { return vector.appendAll(aU); }
|
||||
template<typename U, size_t O, class BP>
|
||||
bool appendAll(const GCVector<U, O, BP>& aU) { return vector.append(aU.begin(), aU.length()); }
|
||||
|
||||
bool appendN(const T& val, size_t count) { return vector.appendN(val, count); }
|
||||
|
||||
template<typename U> bool append(const U* aBegin, const U* aEnd) {
|
||||
|
@ -191,6 +196,8 @@ class MutableGCVectorOperations
|
|||
}
|
||||
template<typename U, size_t O, class BP>
|
||||
bool appendAll(const mozilla::Vector<U, O, BP>& aU) { return vec().appendAll(aU); }
|
||||
template<typename U, size_t O, class BP>
|
||||
bool appendAll(const JS::GCVector<U, O, BP>& aU) { return vec().appendAll(aU); }
|
||||
bool appendN(const T& aT, size_t aN) { return vec().appendN(aT, aN); }
|
||||
template<typename U> bool append(const U* aBegin, const U* aEnd) {
|
||||
return vec().append(aBegin, aEnd);
|
||||
|
|
|
@ -30,18 +30,14 @@ class TwoByteCharsZ;
|
|||
class UTF8Chars;
|
||||
class UTF8CharsZ;
|
||||
|
||||
template <typename T>
|
||||
class AutoVectorRooter;
|
||||
typedef AutoVectorRooter<Value> AutoValueVector;
|
||||
typedef AutoVectorRooter<jsid> AutoIdVector;
|
||||
typedef AutoVectorRooter<JSObject*> AutoObjectVector;
|
||||
typedef AutoVectorRooter<JSScript*> AutoVector;
|
||||
class AutoValueVector;
|
||||
class AutoIdVector;
|
||||
class AutoObjectVector;
|
||||
|
||||
using ValueVector = JS::GCVector<JS::Value>;
|
||||
using IdVector = JS::GCVector<jsid>;
|
||||
using ScriptVector = JS::GCVector<JSScript*>;
|
||||
|
||||
template <typename T> class AutoVectorRooter;
|
||||
template<typename K, typename V> class AutoHashMapRooter;
|
||||
template<typename T> class AutoHashSetRooter;
|
||||
|
||||
|
@ -84,10 +80,9 @@ using JS::UTF8CharsZ;
|
|||
using JS::UniqueChars;
|
||||
using JS::UniqueTwoByteChars;
|
||||
|
||||
using JS::AutoVectorRooter;
|
||||
typedef AutoVectorRooter<Value> AutoValueVector;
|
||||
typedef AutoVectorRooter<jsid> AutoIdVector;
|
||||
typedef AutoVectorRooter<JSObject*> AutoObjectVector;
|
||||
using JS::AutoValueVector;
|
||||
using JS::AutoIdVector;
|
||||
using JS::AutoObjectVector;
|
||||
|
||||
using JS::ValueVector;
|
||||
using JS::IdVector;
|
||||
|
|
|
@ -154,24 +154,6 @@ AutoGCRooter::trace(JSTracer* trc)
|
|||
frontend::MarkParser(trc, this);
|
||||
return;
|
||||
|
||||
case VALVECTOR: {
|
||||
AutoValueVector::VectorImpl& vector = static_cast<AutoValueVector*>(this)->vector;
|
||||
TraceRootRange(trc, vector.length(), vector.begin(), "JS::AutoValueVector.vector");
|
||||
return;
|
||||
}
|
||||
|
||||
case IDVECTOR: {
|
||||
AutoIdVector::VectorImpl& vector = static_cast<AutoIdVector*>(this)->vector;
|
||||
TraceRootRange(trc, vector.length(), vector.begin(), "JS::AutoIdVector.vector");
|
||||
return;
|
||||
}
|
||||
|
||||
case OBJVECTOR: {
|
||||
AutoObjectVector::VectorImpl& vector = static_cast<AutoObjectVector*>(this)->vector;
|
||||
TraceRootRange(trc, vector.length(), vector.begin(), "JS::AutoObjectVector.vector");
|
||||
return;
|
||||
}
|
||||
|
||||
case VALARRAY: {
|
||||
/*
|
||||
* We don't know the template size parameter, but we can safely treat it
|
||||
|
|
|
@ -218,9 +218,31 @@ class MOZ_RAII AutoVectorRooter : public AutoVectorRooterBase<T>
|
|||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
typedef AutoVectorRooter<Value> AutoValueVector;
|
||||
typedef AutoVectorRooter<jsid> AutoIdVector;
|
||||
typedef AutoVectorRooter<JSObject*> AutoObjectVector;
|
||||
class AutoValueVector : public Rooted<GCVector<Value, 8>> {
|
||||
using Vec = GCVector<Value, 8>;
|
||||
using Base = Rooted<Vec>;
|
||||
public:
|
||||
explicit AutoValueVector(JSContext* cx) : Base(cx, Vec(cx)) {}
|
||||
explicit AutoValueVector(js::ContextFriendFields* cx) : Base(cx, Vec(cx)) {}
|
||||
};
|
||||
|
||||
class AutoIdVector : public Rooted<GCVector<jsid, 8>> {
|
||||
using Vec = GCVector<jsid, 8>;
|
||||
using Base = Rooted<Vec>;
|
||||
public:
|
||||
explicit AutoIdVector(JSContext* cx) : Base(cx, Vec(cx)) {}
|
||||
explicit AutoIdVector(js::ContextFriendFields* cx) : Base(cx, Vec(cx)) {}
|
||||
|
||||
bool appendAll(const AutoIdVector& other) { return this->Base::appendAll(other.get()); }
|
||||
};
|
||||
|
||||
class AutoObjectVector : public Rooted<GCVector<JSObject*, 8>> {
|
||||
using Vec = GCVector<JSObject*, 8>;
|
||||
using Base = Rooted<Vec>;
|
||||
public:
|
||||
explicit AutoObjectVector(JSContext* cx) : Base(cx, Vec(cx)) {}
|
||||
explicit AutoObjectVector(js::ContextFriendFields* cx) : Base(cx, Vec(cx)) {}
|
||||
};
|
||||
|
||||
using ValueVector = JS::GCVector<JS::Value>;
|
||||
using IdVector = JS::GCVector<jsid>;
|
||||
|
|
|
@ -28,9 +28,7 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
template <typename T>
|
||||
class AutoVectorRooter;
|
||||
typedef AutoVectorRooter<jsid> AutoIdVector;
|
||||
class AutoIdVector;
|
||||
class CallArgs;
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -13,9 +13,7 @@
|
|||
#include "js/CallNonGenericMethod.h"
|
||||
|
||||
namespace JS {
|
||||
template <typename T>
|
||||
class AutoVectorRooter;
|
||||
typedef AutoVectorRooter<jsid> AutoIdVector;
|
||||
class AutoIdVector;
|
||||
} // namespace JS
|
||||
|
||||
namespace xpc {
|
||||
|
|
Загрузка…
Ссылка в новой задаче