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

Unified Diff: third_party/WebKit/Source/platform/heap/Persistent.h

Issue 2007283002: Allow CrossThreadPersistent in collections (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
Index: third_party/WebKit/Source/platform/heap/Persistent.h
diff --git a/third_party/WebKit/Source/platform/heap/Persistent.h b/third_party/WebKit/Source/platform/heap/Persistent.h
index 8aa3708af2df13521feaaa734413965cde3ac299..62ae0943988b600eeec328b449920b31dc98c31e 100644
--- a/third_party/WebKit/Source/platform/heap/Persistent.h
+++ b/third_party/WebKit/Source/platform/heap/Persistent.h
@@ -77,12 +77,20 @@ public:
checkPointer();
}
+ PersistentBase(WTF::HashTableDeletedValueType) : m_raw(reinterpret_cast<T*>(-1))
+ {
+ initialize();
+ checkPointer();
+ }
+
~PersistentBase()
{
uninitialize();
m_raw = nullptr;
}
+ bool isHashTableDeletedValue() const { return m_raw == reinterpret_cast<T*>(-1); }
+
template<typename VisitorDispatcher>
void trace(VisitorDispatcher visitor)
{
@@ -184,7 +192,7 @@ private:
void initialize()
{
ASSERT(!m_persistentNode);
- if (!m_raw)
+ if (!m_raw || isHashTableDeletedValue())
return;
TraceCallback traceCallback = TraceMethodDelegate<PersistentBase<T, weaknessConfiguration, crossThreadnessConfiguration>, &PersistentBase<T, weaknessConfiguration, crossThreadnessConfiguration>::trace>::trampoline;
@@ -221,7 +229,7 @@ private:
void checkPointer()
{
#if ENABLE(ASSERT) && defined(ADDRESS_SANITIZER)
- if (!m_raw)
+ if (!m_raw || isHashTableDeletedValue())
return;
// ThreadHeap::isHeapObjectAlive(m_raw) checks that m_raw is a traceable
@@ -263,6 +271,7 @@ public:
Persistent(const Persistent<U>& other) : Parent(other) { }
template<typename U>
Persistent(const Member<U>& other) : Parent(other) { }
+ Persistent(WTF::HashTableDeletedValueType x) : Parent(x) { }
template<typename U>
Persistent& operator=(U* other)
@@ -372,6 +381,7 @@ public:
CrossThreadPersistent(const CrossThreadPersistent<U>& other) : Parent(other) { }
template<typename U>
CrossThreadPersistent(const Member<U>& other) : Parent(other) { }
+ CrossThreadPersistent(WTF::HashTableDeletedValueType x) : Parent(x) { }
T* atomicGet() { return Parent::atomicGet(); }
@@ -682,6 +692,28 @@ template<typename T, typename U> inline bool operator!=(const Persistent<T>& a,
namespace WTF {
+template <typename T>
+struct PersistentHash : MemberHash<T> {
+ STATIC_ONLY(PersistentHash);
+};
+
+template <typename T>
+struct CrossThreadPersistentHash : MemberHash<T> {
+ STATIC_ONLY(CrossThreadPersistentHash);
+};
+
+template <typename T>
+struct DefaultHash<blink::Persistent<T>> {
+ STATIC_ONLY(DefaultHash);
+ using Hash = PersistentHash<T>;
+};
+
+template <typename T>
+struct DefaultHash<blink::CrossThreadPersistent<T>> {
+ STATIC_ONLY(DefaultHash);
+ using Hash = CrossThreadPersistentHash<T>;
+};
+
template<typename T>
struct ParamStorageTraits<blink::WeakPersistentThisPointer<T>> {
STATIC_ONLY(ParamStorageTraits);
« no previous file with comments | « third_party/WebKit/Source/platform/heap/HeapTest.cpp ('k') | third_party/WebKit/Source/platform/heap/PersistentNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698