Index: third_party/WebKit/Source/platform/heap/Handle.h |
diff --git a/third_party/WebKit/Source/platform/heap/Handle.h b/third_party/WebKit/Source/platform/heap/Handle.h |
index fd9415a02382af0ad0f35457dd7285cb41c122fa..66350b7a732810e4f1f9024e9541ff9566ec4338 100644 |
--- a/third_party/WebKit/Source/platform/heap/Handle.h |
+++ b/third_party/WebKit/Source/platform/heap/Handle.h |
@@ -48,6 +48,9 @@ |
namespace blink { |
+template<typename T> class Member; |
+template<typename T> class UntracedMember; |
+ |
enum WeaknessPersistentConfiguration { |
NonWeakPersistentConfiguration, |
WeakPersistentConfiguration |
@@ -101,6 +104,14 @@ public: |
} |
template<typename U> |
+ PersistentBase(const UntracedMember<U>& other) : m_raw(other) |
haraken
2015/10/15 03:55:39
Now that UntracedMember inherits from Member, this
peria
2015/10/15 05:11:58
Done.
|
+ { |
+ initialize(); |
+ checkPointer(); |
+ recordBacktrace(); |
+ } |
+ |
+ template<typename U> |
PersistentBase(const Member<U>& other) : m_raw(other) |
{ |
initialize(); |
@@ -176,6 +187,13 @@ public: |
} |
template<typename U> |
+ PersistentBase& operator=(const UntracedMember<U>& other) |
+ { |
+ assign(other); |
+ return *this; |
+ } |
+ |
+ template<typename U> |
PersistentBase& operator=(const Member<U>& other) |
{ |
assign(other); |
@@ -298,6 +316,8 @@ public: |
template<typename U> |
Persistent(const Persistent<U>& other) : Parent(other) { } |
template<typename U> |
+ Persistent(const UntracedMember<U>& other) : Parent(other) { } |
+ template<typename U> |
Persistent(const Member<U>& other) : Parent(other) { } |
template<typename U> |
Persistent(const RawPtr<U>& other) : Parent(other.get()) { } |
@@ -329,6 +349,13 @@ public: |
} |
template<typename U> |
+ Persistent& operator=(const UntracedMember<U>& other) |
+ { |
+ Parent::operator=(other); |
+ return *this; |
+ } |
+ |
+ template<typename U> |
Persistent& operator=(const Member<U>& other) |
{ |
Parent::operator=(other); |
@@ -425,6 +452,8 @@ public: |
template<typename U> |
CrossThreadPersistent(const CrossThreadPersistent<U>& other) : Parent(other) { } |
template<typename U> |
+ CrossThreadPersistent(const UntracedMember<U>& other) : Parent(other) { } |
+ template<typename U> |
CrossThreadPersistent(const Member<U>& other) : Parent(other) { } |
template<typename U> |
CrossThreadPersistent(const RawPtr<U>& other) : Parent(other.get()) { } |
@@ -456,6 +485,13 @@ public: |
} |
template<typename U> |
+ CrossThreadPersistent& operator=(const UntracedMember<U>& other) |
+ { |
+ Parent::operator=(other); |
+ return *this; |
+ } |
+ |
+ template<typename U> |
CrossThreadPersistent& operator=(const Member<U>& other) |
{ |
Parent::operator=(other); |
@@ -483,6 +519,8 @@ public: |
template<typename U> |
CrossThreadWeakPersistent(const CrossThreadWeakPersistent<U>& other) : Parent(other) { } |
template<typename U> |
+ CrossThreadWeakPersistent(const UntracedMember<U>& other) : Parent(other) { } |
+ template<typename U> |
CrossThreadWeakPersistent(const Member<U>& other) : Parent(other) { } |
template<typename U> |
CrossThreadWeakPersistent(const RawPtr<U>& other) : Parent(other.get()) { } |
@@ -514,6 +552,13 @@ public: |
} |
template<typename U> |
+ CrossThreadWeakPersistent& operator=(const UntracedMember<U>& other) |
+ { |
+ Parent::operator=(other); |
+ return *this; |
+ } |
+ |
+ template<typename U> |
CrossThreadWeakPersistent& operator=(const Member<U>& other) |
{ |
Parent::operator=(other); |
@@ -691,6 +736,12 @@ public: |
checkPointer(); |
} |
+ template<typename U> |
+ Member(const UntracedMember<U>& other) : m_raw(other) |
+ { |
+ checkPointer(); |
+ } |
+ |
Member(const Member& other) : m_raw(other) |
{ |
checkPointer(); |
@@ -735,6 +786,14 @@ public: |
} |
template<typename U> |
+ Member& operator=(const UntracedMember<U>& other) |
+ { |
+ m_raw = other; |
+ checkPointer(); |
+ return *this; |
+ } |
+ |
+ template<typename U> |
Member& operator=(U* other) |
{ |
m_raw = other; |
@@ -823,6 +882,9 @@ public: |
WeakMember(const Persistent<U>& other) : Member<T>(other) { } |
template<typename U> |
+ WeakMember(const UntracedMember<U>& other) : Member<T>(other) { } |
+ |
+ template<typename U> |
WeakMember(const Member<U>& other) : Member<T>(other) { } |
template<typename U> |
@@ -842,6 +904,14 @@ public: |
} |
template<typename U> |
+ WeakMember& operator=(const UntracedMember<U>& other) |
+ { |
+ this->m_raw = other; |
+ this->checkPointer(); |
+ return *this; |
+ } |
+ |
+ template<typename U> |
WeakMember& operator=(U* other) |
{ |
this->m_raw = other; |
@@ -869,15 +939,58 @@ private: |
template<typename Derived> friend class VisitorHelper; |
}; |
-// Comparison operators between (Weak)Members and Persistents |
+// UntracedMember is actually a raw pointer. |
+// It is allowed to store a pointer to an object on oilpan heap, |
+// and it is also allowed to store UntracedMember in off heap collections. |
+// UntracedMember does not keep the pointee object alive, so if you use |
+// UntracedMember, you must guarantee that the pointee object is alive in |
+// some reason. |
+template<typename T> |
+class UntracedMember : public Member<T> { |
+public: |
+ UntracedMember() : Member<T>() { } |
+ |
+ UntracedMember(std::nullptr_t) : Member<T>(nullptr) { } |
+ |
+ UntracedMember(const UntracedMember& other) : Member<T>(other) { } |
+ |
+ template<typename U> |
+ UntracedMember(const UntracedMember<U>& other) : Member<T>(other) { } |
+ |
+ UntracedMember(T* raw) : Member<T>(raw) { } |
+ |
+ template<typename U> |
+ UntracedMember(const RawPtr<U>& other) : Member<T>(other) { } |
+ |
+ template<typename U> |
+ UntracedMember(const Persistent<U>& other) : Member<T>(other) { } |
+ |
+ template<typename U> |
+ UntracedMember(const Member<U>& other) : Member<T>(other) { } |
+ |
+ UntracedMember(WTF::HashTableDeletedValueType x) : Member<T>(x) { } |
+}; |
+ |
+// Comparison operators between (Weak)Members, Persistents, and UntracedMembers. |
template<typename T, typename U> inline bool operator==(const Member<T>& a, const Member<U>& b) { return a.get() == b.get(); } |
template<typename T, typename U> inline bool operator!=(const Member<T>& a, const Member<U>& b) { return a.get() != b.get(); } |
+template<typename T, typename U> inline bool operator==(const UntracedMember<T>& a, const UntracedMember<U>& b) { return a.get() == b.get(); } |
+template<typename T, typename U> inline bool operator!=(const UntracedMember<T>& a, const UntracedMember<U>& b) { return a.get() != b.get(); } |
+template<typename T, typename U> inline bool operator==(const Persistent<T>& a, const Persistent<U>& b) { return a.get() == b.get(); } |
+template<typename T, typename U> inline bool operator!=(const Persistent<T>& a, const Persistent<U>& b) { return a.get() != b.get(); } |
+ |
template<typename T, typename U> inline bool operator==(const Member<T>& a, const Persistent<U>& b) { return a.get() == b.get(); } |
template<typename T, typename U> inline bool operator!=(const Member<T>& a, const Persistent<U>& b) { return a.get() != b.get(); } |
template<typename T, typename U> inline bool operator==(const Persistent<T>& a, const Member<U>& b) { return a.get() == b.get(); } |
template<typename T, typename U> inline bool operator!=(const Persistent<T>& a, const Member<U>& b) { return a.get() != b.get(); } |
-template<typename T, typename U> inline bool operator==(const Persistent<T>& a, const Persistent<U>& b) { return a.get() == b.get(); } |
-template<typename T, typename U> inline bool operator!=(const Persistent<T>& a, const Persistent<U>& b) { return a.get() != b.get(); } |
+template<typename T, typename U> inline bool operator==(const Member<T>& a, const UntracedMember<U>& b) { return a.get() == b.get(); } |
+template<typename T, typename U> inline bool operator!=(const Member<T>& a, const UntracedMember<U>& b) { return a.get() != b.get(); } |
+template<typename T, typename U> inline bool operator==(const UntracedMember<T>& a, const Member<U>& b) { return a.get() == b.get(); } |
+template<typename T, typename U> inline bool operator!=(const UntracedMember<T>& a, const Member<U>& b) { return a.get() != b.get(); } |
+template<typename T, typename U> inline bool operator==(const UntracedMember<T>& a, const Persistent<U>& b) { return a.get() == b.get(); } |
+template<typename T, typename U> inline bool operator!=(const UntracedMember<T>& a, const Persistent<U>& b) { return a.get() != b.get(); } |
+template<typename T, typename U> inline bool operator==(const Persistent<T>& a, const UntracedMember<U>& b) { return a.get() == b.get(); } |
+template<typename T, typename U> inline bool operator!=(const Persistent<T>& a, const UntracedMember<U>& b) { return a.get() != b.get(); } |
template<typename T> |
class DummyBase { |
@@ -925,6 +1038,7 @@ public: |
#define RawPtrWillBePersistent blink::Persistent |
#define RawPtrWillBeWeakMember blink::WeakMember |
#define RawPtrWillBeWeakPersistent blink::WeakPersistent |
+#define RawPtrWillBeUntracedMember blink::UntracedMember |
#define OwnPtrWillBeCrossThreadPersistent blink::CrossThreadPersistent |
#define OwnPtrWillBeMember blink::Member |
#define OwnPtrWillBePersistent blink::Persistent |
@@ -1008,6 +1122,7 @@ template<typename T> T* adoptPtrWillBeNoop(T* ptr) |
#define RawPtrWillBePersistent WTF::RawPtr |
#define RawPtrWillBeWeakMember WTF::RawPtr |
#define RawPtrWillBeWeakPersistent WTF::RawPtr |
+#define RawPtrWillBeUntracedMember WTF::RawPtr |
#define OwnPtrWillBeCrossThreadPersistent WTF::OwnPtr |
#define OwnPtrWillBeMember WTF::OwnPtr |
#define OwnPtrWillBePersistent WTF::OwnPtr |
@@ -1198,6 +1313,13 @@ template <typename T> struct VectorTraits<blink::WeakMember<T>> : VectorTraitsBa |
static const bool canMoveWithMemcpy = true; |
}; |
+template <typename T> struct VectorTraits<blink::UntracedMember<T>> : VectorTraitsBase<blink::UntracedMember<T>> { |
+ static const bool needsDestruction = false; |
+ static const bool canInitializeWithMemset = true; |
+ static const bool canClearUnusedSlotsWithMemset = true; |
+ static const bool canMoveWithMemcpy = true; |
+}; |
+ |
template <typename T> struct VectorTraits<blink::HeapVector<T, 0>> : VectorTraitsBase<blink::HeapVector<T, 0>> { |
static const bool needsDestruction = false; |
static const bool canInitializeWithMemset = true; |
@@ -1289,6 +1411,32 @@ template<typename T> struct HashTraits<blink::WeakMember<T>> : SimpleClassHashTr |
} |
}; |
+template<typename T> struct HashTraits<blink::UntracedMember<T>> : SimpleClassHashTraits<blink::UntracedMember<T>> { |
+ static const bool needsDestruction = false; |
+ // FIXME: The distinction between PeekInType and PassInType is there for |
+ // the sake of the reference counting handles. When they are gone the two |
+ // types can be merged into PassInType. |
+ // FIXME: Implement proper const'ness for iterator types. |
+ using PeekInType = RawPtr<T>; |
+ using PassInType = RawPtr<T>; |
+ using IteratorGetType = blink::UntracedMember<T>*; |
+ using IteratorConstGetType = const blink::UntracedMember<T>*; |
+ using IteratorReferenceType = blink::UntracedMember<T>&; |
+ using IteratorConstReferenceType = const blink::UntracedMember<T>&; |
+ static IteratorReferenceType getToReferenceConversion(IteratorGetType x) { return *x; } |
+ static IteratorConstReferenceType getToReferenceConstConversion(IteratorConstGetType x) { return *x; } |
+ // FIXME: Similarly, there is no need for a distinction between PeekOutType |
+ // and PassOutType without reference counting. |
+ using PeekOutType = T*; |
+ using PassOutType = T*; |
+ |
+ template<typename U> |
+ static void store(const U& value, blink::UntracedMember<T>& storage) { storage = value; } |
+ |
+ static PeekOutType peek(const blink::UntracedMember<T>& value) { return value; } |
+ static PassOutType passOut(const blink::UntracedMember<T>& value) { return value; } |
+}; |
+ |
template<typename T> struct PtrHash<blink::Member<T>> : PtrHash<T*> { |
template<typename U> |
static unsigned hash(const U& key) { return PtrHash<T*>::hash(key); } |
@@ -1301,6 +1449,9 @@ template<typename T> struct PtrHash<blink::Member<T>> : PtrHash<T*> { |
template<typename T> struct PtrHash<blink::WeakMember<T>> : PtrHash<blink::Member<T>> { |
}; |
+template<typename T> struct PtrHash<blink::UntracedMember<T>> : PtrHash<blink::Member<T>> { |
+}; |
+ |
// PtrHash is the default hash for hash tables with members. |
template<typename T> struct DefaultHash<blink::Member<T>> { |
using Hash = PtrHash<blink::Member<T>>; |
@@ -1310,6 +1461,10 @@ template<typename T> struct DefaultHash<blink::WeakMember<T>> { |
using Hash = PtrHash<blink::WeakMember<T>>; |
}; |
+template<typename T> struct DefaultHash<blink::UntracedMember<T>> { |
+ using Hash = PtrHash<blink::UntracedMember<T>>; |
+}; |
+ |
template<typename T> |
struct NeedsTracing<blink::Member<T>> { |
static const bool value = true; |