Index: Source/heap/Handle.h |
diff --git a/Source/heap/Handle.h b/Source/heap/Handle.h |
index 4025e95e89f2779d2529fd4a925d7d9bb3799fca..f0e312a4b21a8992ca4cbe91976e3d8b7fc42f5d 100644 |
--- a/Source/heap/Handle.h |
+++ b/Source/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(raw) |
+#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) |
@@ -353,6 +364,8 @@ private: |
friend class CrossThreadPersistent<T>; |
}; |
+#undef ASSERT_IS_VALID_PERSISTENT_POINTER |
+ |
// Unlike Persistent, we can destruct a CrossThreadPersistent in a thread |
// different from the construction thread. |
template<typename T> |
@@ -432,6 +445,11 @@ public: |
COMPILE_ASSERT_IS_GARBAGE_COLLECTED(T, NonGarbageCollectedObjectInMember); |
} |
+ explicit Member(T& raw) : m_raw(&raw) |
+ { |
+ COMPILE_ASSERT_IS_GARBAGE_COLLECTED(T, NonGarbageCollectedObjectInMember); |
haraken
2014/04/02 07:49:41
Can we implement ASSERT_IS_VALID_MEMBER_POINTER as
sof
2014/04/02 08:05:50
Catching out cross-heap references would be useful
haraken
2014/04/02 08:09:29
Oh, sorry. Cross-heap references are allowed, so w
sof
2014/04/02 08:12:54
Interesting, what code relies on creating such cro
haraken
2014/04/02 08:15:41
I think some classes in webdatabase/ are using cro
Mads Ager (chromium)
2014/04/02 08:22:04
That is correct, we have cross thread pointers in
|
+ } |
+ |
Member(WTF::HashTableDeletedValueType) : m_raw(reinterpret_cast<T*>(-1)) |
{ |
COMPILE_ASSERT_IS_GARBAGE_COLLECTED(T, NonGarbageCollectedObjectInMember); |