Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Unified Diff: Source/platform/heap/Handle.h

Issue 221823002: Oilpan: add explicit Persistent<T>(T&) and Member<T>(T&) constructors. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased and moved into platform/heap/Handle.h Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/websockets/WorkerThreadableWebSocketChannel.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « Source/modules/websockets/WorkerThreadableWebSocketChannel.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698