mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 744192 - Assert that Vectors do not contain implicitly postbarriered types; r=luke
Since vectors move their memory around outside the control of the GC, it is not valid to store an implicitly post-barriered item in a Vector. --HG-- extra : rebase_source : 2cef4d855cc4e926cea872cda18e5cf29230f0a7
This commit is contained in:
parent
57a990453d
commit
1cf21563aa
@ -174,6 +174,11 @@ template <typename T> struct IsPodType<T *> { static const bool result =
|
||||
template <bool cond, typename T, T v1, T v2> struct If { static const T result = v1; };
|
||||
template <typename T, T v1, T v2> struct If<false, T, v1, v2> { static const T result = v2; };
|
||||
|
||||
/*
|
||||
* Traits class for identifying types that are implicitly barriered.
|
||||
*/
|
||||
template <class T> struct IsPostBarrieredType { static const bool result = false; };
|
||||
|
||||
} /* namespace tl */
|
||||
} /* namespace js */
|
||||
|
||||
|
@ -213,6 +213,8 @@ struct VectorImpl<T, N, AP, true>
|
||||
template <class T, size_t N, class AllocPolicy>
|
||||
class Vector : private AllocPolicy
|
||||
{
|
||||
typedef typename tl::StaticAssert<!tl::IsPostBarrieredType<T>::result>::result _;
|
||||
|
||||
/* utilities */
|
||||
|
||||
static const bool sElemIsPod = tl::IsPodType<T>::result;
|
||||
@ -505,7 +507,7 @@ class Vector : private AllocPolicy
|
||||
*/
|
||||
size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const;
|
||||
|
||||
/*
|
||||
/*
|
||||
* Like sizeOfExcludingThis, but also measures the size of the Vector
|
||||
* object (which must be heap-allocated) itself.
|
||||
*/
|
||||
|
@ -509,6 +509,15 @@ class ReadBarrieredValue
|
||||
inline JSObject &toObject() const;
|
||||
};
|
||||
|
||||
}
|
||||
namespace tl {
|
||||
|
||||
template <class T> struct IsPostBarrieredType<HeapPtr<T> > {
|
||||
static const bool result = true; };
|
||||
template <> struct IsPostBarrieredType<HeapSlot> { static const bool result = true; };
|
||||
template <> struct IsPostBarrieredType<HeapValue> { static const bool result = true; };
|
||||
template <> struct IsPostBarrieredType<HeapId> { static const bool result = true; };
|
||||
|
||||
} /* namespace tl */
|
||||
} /* namespace js */
|
||||
|
||||
#endif /* jsgc_barrier_h___ */
|
||||
|
Loading…
Reference in New Issue
Block a user