| Index: Source/platform/heap/Handle.h
|
| diff --git a/Source/platform/heap/Handle.h b/Source/platform/heap/Handle.h
|
| index 8f735d2e32605fe5c51228205b0b0656b17ea9e1..99e61dd12ff8e8015bec8e0343b89ec3f1d6efd8 100644
|
| --- a/Source/platform/heap/Handle.h
|
| +++ b/Source/platform/heap/Handle.h
|
| @@ -216,6 +216,17 @@ private:
|
| friend class ThreadState;
|
| };
|
|
|
| +#ifndef NDEBUG
|
| + // For global persistent handles we cannot check that the
|
| + // pointer is in the heap because that would involve
|
| + // inspecting the heap of running threads.
|
| +#define ASSERT_IS_VALID_PERSISTENT_POINTER(pointer) \
|
| + bool isGlobalPersistent = WTF::IsSubclass<RootsAccessor, GlobalPersistents>::value; \
|
| + ASSERT(!pointer || isGlobalPersistent || ThreadStateFor<ThreadingTrait<T>::Affinity>::state()->contains(pointer))
|
| +#else
|
| +#define ASSERT_IS_VALID_PERSISTENT_POINTER(pointer)
|
| +#endif
|
| +
|
| template<typename T>
|
| class CrossThreadPersistent;
|
|
|
| @@ -251,13 +262,13 @@ public:
|
| Persistent(T* raw) : m_raw(raw)
|
| {
|
| COMPILE_ASSERT_IS_GARBAGE_COLLECTED(T, NonGarbageCollectedObjectInPersistent);
|
| -#ifndef NDEBUG
|
| - // For global persistent handles we cannot check that the
|
| - // pointer is in the heap because that would involve
|
| - // inspecting the heap of running threads.
|
| - bool isGlobalPersistent = WTF::IsSubclass<RootsAccessor, GlobalPersistents>::value;
|
| - ASSERT(!raw || isGlobalPersistent || ThreadStateFor<ThreadingTrait<T>::Affinity>::state()->contains(raw));
|
| -#endif
|
| + ASSERT_IS_VALID_PERSISTENT_POINTER(m_raw);
|
| + }
|
| +
|
| + explicit Persistent(T& raw) : m_raw(&raw)
|
| + {
|
| + COMPILE_ASSERT_IS_GARBAGE_COLLECTED(T, NonGarbageCollectedObjectInPersistent);
|
| + ASSERT_IS_VALID_PERSISTENT_POINTER(m_raw);
|
| }
|
|
|
| Persistent(const Persistent& other) : m_raw(other)
|
| @@ -432,6 +443,11 @@ public:
|
| COMPILE_ASSERT_IS_GARBAGE_COLLECTED(T, NonGarbageCollectedObjectInMember);
|
| }
|
|
|
| + explicit Member(T& raw) : m_raw(&raw)
|
| + {
|
| + COMPILE_ASSERT_IS_GARBAGE_COLLECTED(T, NonGarbageCollectedObjectInMember);
|
| + }
|
| +
|
| Member(WTF::HashTableDeletedValueType) : m_raw(reinterpret_cast<T*>(-1))
|
| {
|
| COMPILE_ASSERT_IS_GARBAGE_COLLECTED(T, NonGarbageCollectedObjectInMember);
|
|
|