mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07: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.
This commit is contained in:
parent
da8eb0d095
commit
431a41bf56
@ -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 */
|
||||
|
||||
|
@ -283,6 +283,10 @@ class Vector : private AllocPolicy
|
||||
Vector(const Vector &) MOZ_DELETE;
|
||||
Vector &operator=(const Vector &) MOZ_DELETE;
|
||||
|
||||
void checkStaticInvarients() {
|
||||
JS_STATIC_ASSERT(!tl::IsPostBarrieredType<T>::result);
|
||||
}
|
||||
|
||||
/* private accessors */
|
||||
|
||||
bool usingInlineStorage() const {
|
||||
@ -505,7 +509,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.
|
||||
*/
|
||||
@ -530,7 +534,9 @@ Vector<T,N,AllocPolicy>::Vector(AllocPolicy ap)
|
||||
#ifdef DEBUG
|
||||
, mReserved(0), entered(false)
|
||||
#endif
|
||||
{}
|
||||
{
|
||||
checkStaticInvarients();
|
||||
}
|
||||
|
||||
/* Move constructor. */
|
||||
template <class T, size_t N, class AllocPolicy>
|
||||
@ -538,6 +544,8 @@ JS_ALWAYS_INLINE
|
||||
Vector<T, N, AllocPolicy>::Vector(MoveRef<Vector> rhs)
|
||||
: AllocPolicy(rhs)
|
||||
{
|
||||
checkStaticInvarients();
|
||||
|
||||
mLength = rhs->mLength;
|
||||
mCapacity = rhs->mCapacity;
|
||||
#ifdef DEBUG
|
||||
|
@ -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